Remove reactions when youmu is no longer handling paginations

This commit is contained in:
Natsu Kagami 2024-02-11 17:34:46 +01:00
parent 30f186c604
commit b5e8a24919
Signed by: nki
GPG key ID: 55A032EB38B49ADB

View file

@ -3,7 +3,7 @@ use futures_util::{future::Future, StreamExt};
use serenity::{ use serenity::{
collector::ReactionAction, collector::ReactionAction,
model::{ model::{
channel::{Message, ReactionType}, channel::{Message, Reaction, ReactionType},
id::ChannelId, id::ChannelId,
}, },
}; };
@ -110,22 +110,32 @@ async fn paginate_with_first_message(
} }
// React to the message // React to the message
let large_count = pager.len().filter(|&p| p > 10).is_some(); let large_count = pager.len().filter(|&p| p > 10).is_some();
if large_count { let reactions = {
// add >> and << buttons let mut rs = Vec::<Reaction>::with_capacity(4);
message.react(&ctx, ReactionType::try_from(REWIND)?).await?; if large_count {
} // add >> and << buttons
message rs.push(message.react(&ctx, ReactionType::try_from(REWIND)?).await?);
.react(&ctx, ReactionType::try_from(ARROW_LEFT)?) }
.await?; rs.push(
message message
.react(&ctx, ReactionType::try_from(ARROW_RIGHT)?) .react(&ctx, ReactionType::try_from(ARROW_LEFT)?)
.await?; .await?,
if large_count { );
// add >> and << buttons rs.push(
message message
.react(&ctx, ReactionType::try_from(FAST_FORWARD)?) .react(&ctx, ReactionType::try_from(ARROW_RIGHT)?)
.await?; .await?,
} );
if large_count {
// add >> and << buttons
rs.push(
message
.react(&ctx, ReactionType::try_from(FAST_FORWARD)?)
.await?,
);
}
rs
};
// Build a reaction collector // Build a reaction collector
let mut reaction_collector = message.await_reactions(ctx).removed(true).build(); let mut reaction_collector = message.await_reactions(ctx).removed(true).build();
let mut page = 0; let mut page = 0;
@ -148,7 +158,9 @@ async fn paginate_with_first_message(
} }
}; };
message.react(&ctx, '🛑').await?; for reaction in reactions {
reaction.delete_all(&ctx).await?;
}
res res
} }