mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 01:00:49 +00:00
Provide a way to give pagination functions a total page count
This commit is contained in:
parent
0b111d5b26
commit
64ff4b3ed8
7 changed files with 102 additions and 55 deletions
|
@ -43,8 +43,8 @@ async fn list(ctx: &Context, m: &Message, _: Args) -> CommandResult {
|
|||
const ROLES_PER_PAGE: usize = 8;
|
||||
let pages = (roles.len() + ROLES_PER_PAGE - 1) / ROLES_PER_PAGE;
|
||||
|
||||
paginate_reply_fn(
|
||||
|page, ctx, msg| {
|
||||
paginate_reply(
|
||||
paginate_from_fn(|page, ctx, msg| {
|
||||
let roles = roles.clone();
|
||||
Box::pin(async move {
|
||||
let page = page as usize;
|
||||
|
@ -80,7 +80,8 @@ async fn list(ctx: &Context, m: &Message, _: Args) -> CommandResult {
|
|||
msg.edit(ctx, EditMessage::new().content(content)).await?;
|
||||
Ok(true)
|
||||
})
|
||||
},
|
||||
})
|
||||
.with_page_count(pages),
|
||||
ctx,
|
||||
m,
|
||||
std::time::Duration::from_secs(60 * 10),
|
||||
|
|
|
@ -65,8 +65,8 @@ async fn message_command(
|
|||
return Ok(());
|
||||
}
|
||||
let images = std::sync::Arc::new(images);
|
||||
paginate_reply_fn(
|
||||
move |page, ctx, msg: &mut Message| {
|
||||
paginate_reply(
|
||||
paginate_from_fn(|page, ctx, msg: &mut Message| {
|
||||
let images = images.clone();
|
||||
Box::pin(async move {
|
||||
let page = page as usize;
|
||||
|
@ -87,7 +87,8 @@ async fn message_command(
|
|||
.map_err(|e| e.into())
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
.with_page_count(images.len()),
|
||||
ctx,
|
||||
msg,
|
||||
std::time::Duration::from_secs(120),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue