mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 17:20:49 +00:00
Change pagination to use interactions instead of reactions
This commit is contained in:
parent
460624c7fe
commit
d1f3aa5fa9
8 changed files with 281 additions and 227 deletions
|
@ -44,14 +44,14 @@ async fn list(ctx: &Context, m: &Message, _: Args) -> CommandResult {
|
|||
let pages = (roles.len() + ROLES_PER_PAGE - 1) / ROLES_PER_PAGE;
|
||||
|
||||
paginate_reply(
|
||||
paginate_from_fn(|page, ctx, msg| {
|
||||
paginate_from_fn(|page, _, _, btns| {
|
||||
let roles = roles.clone();
|
||||
Box::pin(async move {
|
||||
let page = page as usize;
|
||||
let start = page * ROLES_PER_PAGE;
|
||||
let end = roles.len().min(start + ROLES_PER_PAGE);
|
||||
if end <= start {
|
||||
return Ok(false);
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let roles = &roles[start..end];
|
||||
|
@ -77,8 +77,9 @@ async fn list(ctx: &Context, m: &Message, _: Args) -> CommandResult {
|
|||
.push_line(format!("Page **{}/{}**", page + 1, pages))
|
||||
.build();
|
||||
|
||||
msg.edit(ctx, EditMessage::new().content(content)).await?;
|
||||
Ok(true)
|
||||
Ok(Some(
|
||||
EditMessage::new().content(content).components(vec![btns]),
|
||||
))
|
||||
})
|
||||
})
|
||||
.with_page_count(pages),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue