mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 09:10:49 +00:00
pagination: make editing generic over a CanEdit interface
This commit is contained in:
parent
5fde2f343a
commit
a35563801d
11 changed files with 233 additions and 207 deletions
|
@ -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),
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use serde::Deserialize;
|
||||
use serenity::builder::EditMessage;
|
||||
use serenity::framework::standard::CommandError as Error;
|
||||
use serenity::{
|
||||
framework::standard::{
|
||||
|
@ -66,7 +65,7 @@ async fn message_command(
|
|||
}
|
||||
let images = std::sync::Arc::new(images);
|
||||
paginate_reply(
|
||||
paginate_from_fn(|page, _, _, btns| {
|
||||
paginate_from_fn(|page, btns| {
|
||||
let images = images.clone();
|
||||
Box::pin(async move {
|
||||
let page = page as usize;
|
||||
|
@ -74,7 +73,7 @@ async fn message_command(
|
|||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(
|
||||
EditMessage::new()
|
||||
CreateReply::default()
|
||||
.content(format!(
|
||||
"[🖼️ **{}/{}**] Here's the image you requested!\n\n{}",
|
||||
page + 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue