mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 01:00:49 +00:00
pagination: Directly pass list of interactions to render
This commit is contained in:
parent
8c5135bfc9
commit
5fde2f343a
7 changed files with 59 additions and 47 deletions
|
@ -53,7 +53,7 @@ mod scores {
|
|||
|
||||
mod grid {
|
||||
use pagination::paginate_with_first_message;
|
||||
use serenity::all::GuildId;
|
||||
use serenity::all::{CreateActionRow, GuildId};
|
||||
use serenity::builder::EditMessage;
|
||||
use serenity::model::channel::Message;
|
||||
|
||||
|
@ -97,6 +97,7 @@ mod scores {
|
|||
page: u8,
|
||||
ctx: &Context,
|
||||
msg: &Message,
|
||||
btns: Vec<CreateActionRow>,
|
||||
) -> Result<Option<EditMessage>> {
|
||||
let env = ctx.data.read().await.get::<OsuEnv>().unwrap().clone();
|
||||
let page = page as usize;
|
||||
|
@ -127,7 +128,12 @@ mod scores {
|
|||
.footer(format!("Page {}/{}", page + 1, self.scores.len()))
|
||||
.build()
|
||||
})
|
||||
.components(vec![score_components(self.guild_id), self.pagination_row()]),
|
||||
.components(
|
||||
vec![score_components(self.guild_id)]
|
||||
.into_iter()
|
||||
.chain(btns)
|
||||
.collect(),
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -141,6 +147,7 @@ mod scores {
|
|||
use std::borrow::Cow;
|
||||
|
||||
use pagination::paginate_with_first_message;
|
||||
use serenity::all::CreateActionRow;
|
||||
use serenity::builder::EditMessage;
|
||||
use serenity::model::channel::Message;
|
||||
|
||||
|
@ -196,6 +203,7 @@ mod scores {
|
|||
page: u8,
|
||||
ctx: &Context,
|
||||
_: &Message,
|
||||
btns: Vec<CreateActionRow>,
|
||||
) -> Result<Option<EditMessage>> {
|
||||
let env = ctx.data.read().await.get::<OsuEnv>().unwrap().clone();
|
||||
|
||||
|
@ -323,11 +331,7 @@ mod scores {
|
|||
.push_line("[?] means pp was predicted by oppai-rs.")
|
||||
.build();
|
||||
|
||||
Ok(Some(
|
||||
EditMessage::new()
|
||||
.content(content)
|
||||
.components(vec![self.pagination_row()]),
|
||||
))
|
||||
Ok(Some(EditMessage::new().content(content).components(btns)))
|
||||
}
|
||||
|
||||
fn len(&self) -> Option<usize> {
|
||||
|
@ -339,7 +343,7 @@ mod scores {
|
|||
|
||||
mod beatmapset {
|
||||
use serenity::{
|
||||
all::{CreateButton, GuildId},
|
||||
all::{CreateActionRow, CreateButton, GuildId},
|
||||
builder::{CreateEmbedFooter, EditMessage},
|
||||
model::channel::{Message, ReactionType},
|
||||
};
|
||||
|
@ -433,6 +437,7 @@ mod beatmapset {
|
|||
page: u8,
|
||||
ctx: &Context,
|
||||
msg: &Message,
|
||||
btns: Vec<CreateActionRow>,
|
||||
) -> Result<Option<EditMessage>> {
|
||||
let page = page as usize;
|
||||
if page == self.maps.len() {
|
||||
|
@ -442,7 +447,7 @@ mod beatmapset {
|
|||
&self.maps[..],
|
||||
self.mode,
|
||||
))
|
||||
.components(vec![self.pagination_row()]),
|
||||
.components(btns),
|
||||
));
|
||||
}
|
||||
if page > self.maps.len() {
|
||||
|
@ -489,7 +494,7 @@ mod beatmapset {
|
|||
))
|
||||
})
|
||||
)
|
||||
.components(vec![beatmap_components(map.mode, self.guild_id), self.pagination_row()]),
|
||||
.components(std::iter::once(beatmap_components(map.mode, self.guild_id)).chain(btns).collect()),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ pub fn dot_osu_hook<'a>(
|
|||
let mut edit = EditMessage::new()
|
||||
.content(format!("Attached beatmaps ({}/{})", page + 1, embed_len))
|
||||
.embed(embed.clone())
|
||||
.components(vec![btns]);
|
||||
.components(btns);
|
||||
for att in attachments {
|
||||
edit = edit.new_attachment(att.clone());
|
||||
}
|
||||
|
|
|
@ -317,9 +317,7 @@ where
|
|||
last_update.format("<t:%s:R>"),
|
||||
))
|
||||
.build();
|
||||
Ok(Some(
|
||||
EditMessage::new().content(content).components(vec![btns]),
|
||||
))
|
||||
Ok(Some(EditMessage::new().content(content).components(btns)))
|
||||
})
|
||||
})
|
||||
.with_page_count(total_pages),
|
||||
|
@ -719,9 +717,7 @@ pub async fn display_rankings_table(
|
|||
))
|
||||
.build();
|
||||
|
||||
Ok(Some(
|
||||
EditMessage::new().content(content).components(vec![btns]),
|
||||
))
|
||||
Ok(Some(EditMessage::new().content(content).components(btns)))
|
||||
})
|
||||
})
|
||||
.with_page_count(total_pages),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue