Overhaul reaction handler to a thread spawning model (#2)

* Overhaul reaction handler to a thread spawning model

* Remove limits for mods on voting and community buckets
This commit is contained in:
Natsu Kagami 2020-07-06 13:26:34 -04:00 committed by GitHub
parent 18ab9a3434
commit 10ba2dda1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 183 additions and 128 deletions

View file

@ -17,7 +17,7 @@ impl ReactionWatcher {
/// Takes a copy of Context (which you can `clone`), a pager (see "Pagination") and a target channel id.
/// Pagination will handle all events on adding/removing an "arrow" emoji (⬅️ and ➡️).
/// This is a blocking call - it will block the thread until duration is over.
pub fn paginate<T: Pagination>(
pub fn paginate<T: Pagination + Send + 'static>(
&self,
ctx: Context,
channel: ChannelId,
@ -25,7 +25,8 @@ impl ReactionWatcher {
duration: std::time::Duration,
) -> CommandResult {
let handler = PaginationHandler::new(pager, ctx, channel)?;
self.handle_reactions(handler, duration)
self.handle_reactions(handler, duration, |_| {});
Ok(())
}
/// A version of `paginate` that compiles for closures.
@ -39,7 +40,9 @@ impl ReactionWatcher {
duration: std::time::Duration,
) -> CommandResult
where
T: for<'a> FnMut(u8, &'a mut EditMessage) -> (&'a mut EditMessage, CommandResult),
T: for<'a> FnMut(u8, &'a mut EditMessage) -> (&'a mut EditMessage, CommandResult)
+ Send
+ 'static,
{
self.paginate(ctx, channel, pager, duration)
}