mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-20 01:08:55 +00:00
Prelude: pagination takes a &mut Message
This commit is contained in:
parent
e2024b991a
commit
b5424c0087
1 changed files with 5 additions and 5 deletions
|
@ -22,10 +22,10 @@ pub async fn paginate<'a, T, F>(
|
||||||
timeout: std::time::Duration,
|
timeout: std::time::Duration,
|
||||||
) -> Result<()>
|
) -> Result<()>
|
||||||
where
|
where
|
||||||
T: FnMut(u8, &Context, &Message) -> F,
|
T: for<'m> FnMut(u8, &'a Context, &'m mut Message) -> F,
|
||||||
F: Future<Output = Result<bool>>,
|
F: Future<Output = Result<bool>>,
|
||||||
{
|
{
|
||||||
let message = channel
|
let mut message = channel
|
||||||
.send_message(&ctx, |e| e.content("Youmu is loading the first page..."))
|
.send_message(&ctx, |e| e.content("Youmu is loading the first page..."))
|
||||||
.await?;
|
.await?;
|
||||||
// React to the message
|
// React to the message
|
||||||
|
@ -45,7 +45,7 @@ where
|
||||||
Err(_) => break Ok(()),
|
Err(_) => break Ok(()),
|
||||||
Ok(None) => break Ok(()),
|
Ok(None) => break Ok(()),
|
||||||
Ok(Some(reaction)) => {
|
Ok(Some(reaction)) => {
|
||||||
page = match handle_reaction(page, &mut pager, ctx, &message, &reaction).await {
|
page = match handle_reaction(page, &mut pager, ctx, &mut message, &reaction).await {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => break Err(e),
|
Err(e) => break Err(e),
|
||||||
};
|
};
|
||||||
|
@ -63,11 +63,11 @@ async fn handle_reaction<'a, T, F>(
|
||||||
page: u8,
|
page: u8,
|
||||||
pager: &mut T,
|
pager: &mut T,
|
||||||
ctx: &'a Context,
|
ctx: &'a Context,
|
||||||
message: &'_ Message,
|
message: &'_ mut Message,
|
||||||
reaction: &ReactionAction,
|
reaction: &ReactionAction,
|
||||||
) -> Result<u8>
|
) -> Result<u8>
|
||||||
where
|
where
|
||||||
T: for<'n, 'm> FnMut(u8, &'n Context, &'m Message) -> F,
|
T: for<'m> FnMut(u8, &'a Context, &'m mut Message) -> F,
|
||||||
F: Future<Output = Result<bool>>,
|
F: Future<Output = Result<bool>>,
|
||||||
{
|
{
|
||||||
let reaction = match reaction {
|
let reaction = match reaction {
|
||||||
|
|
Loading…
Add table
Reference in a new issue