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

@ -228,7 +228,7 @@ impl FromStr for Nth {
}
}
fn list_plays(plays: &[Score], mode: Mode, ctx: Context, m: &Message) -> CommandResult {
fn list_plays(plays: Vec<Score>, mode: Mode, ctx: Context, m: &Message) -> CommandResult {
let watcher = ctx.data.get_cloned::<ReactionWatcher>();
let osu = ctx.data.get_cloned::<BeatmapMetaCache>();
let beatmap_cache = ctx.data.get_cloned::<BeatmapCache>();
@ -245,7 +245,7 @@ fn list_plays(plays: &[Score], mode: Mode, ctx: Context, m: &Message) -> Command
watcher.paginate_fn(
ctx,
m.channel_id,
|page, e| {
move |page, e| {
let page = page as usize;
let start = page * ITEMS_PER_PAGE;
let end = plays.len().min(start + ITEMS_PER_PAGE);
@ -417,7 +417,7 @@ pub fn recent(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult
}
Nth::All => {
let plays = osu.user_recent(UserID::ID(user.id), |f| f.mode(mode).limit(50))?;
list_plays(&plays, mode, ctx.clone(), msg)?;
list_plays(plays, mode, ctx.clone(), msg)?;
}
}
Ok(())
@ -549,7 +549,7 @@ pub fn top(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
}
Nth::All => {
let plays = osu.user_best(UserID::ID(user.id), |f| f.mode(mode).limit(100))?;
list_plays(&plays, mode, ctx.clone(), msg)?;
list_plays(plays, mode, ctx.clone(), msg)?;
}
}
Ok(())