pagination: make editing generic over a CanEdit interface

This commit is contained in:
Natsu Kagami 2025-02-20 22:54:38 +01:00
parent 5fde2f343a
commit a35563801d
Signed by: nki
GPG key ID: 55A032EB38B49ADB
11 changed files with 233 additions and 207 deletions

View file

@ -1,5 +1,4 @@
use serenity::{
builder::EditMessage,
framework::standard::{macros::command, Args, CommandResult},
model::{
channel::{Message, ReactionType},
@ -44,7 +43,7 @@ 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, _, _, btns| {
paginate_from_fn(|page, btns| {
let roles = roles.clone();
Box::pin(async move {
let page = page as usize;
@ -77,7 +76,9 @@ async fn list(ctx: &Context, m: &Message, _: Args) -> CommandResult {
.push_line(format!("Page **{}/{}**", page + 1, pages))
.build();
Ok(Some(EditMessage::new().content(content).components(btns)))
Ok(Some(
CreateReply::default().content(content).components(btns),
))
})
})
.with_page_count(pages),