diff --git a/Cargo.toml b/Cargo.toml index 4734795..ca98266 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,6 @@ members = [ ] [workspace.lints.rust] deprecated = "allow" + +[workspace.lints.clippy] +too_many_arguments = "allow" diff --git a/youmubot-db-sql/src/models/osu_user.rs b/youmubot-db-sql/src/models/osu_user.rs index 7327086..aba6ac7 100644 --- a/youmubot-db-sql/src/models/osu_user.rs +++ b/youmubot-db-sql/src/models/osu_user.rs @@ -188,7 +188,7 @@ impl OsuUser { impl OsuUser { /// Stores the user. - pub async fn store<'a>(&self, conn: &mut Transaction<'a, Database>) -> Result { + pub async fn store(&self, conn: &mut Transaction<'_, Database>) -> Result { let old_user_id = { query!( r#"SELECT id as "id: i64" FROM osu_users WHERE user_id = ?"#, diff --git a/youmubot-osu/src/discord/commands.rs b/youmubot-osu/src/discord/commands.rs index f38f935..463c996 100644 --- a/youmubot-osu/src/discord/commands.rs +++ b/youmubot-osu/src/discord/commands.rs @@ -337,7 +337,7 @@ async fn beatmap( EmbedType::Beatmap(beatmap, bmode, info, bmmods) => { let (beatmap, info, mods) = if mods.is_none() && mode.is_none_or(|v| v == bmode.unwrap_or(beatmap.mode)) { - (*beatmap, info, bmmods) + (*beatmap, *info, bmmods) } else { let mode = bmode.unwrap_or(beatmap.mode); let mods = match mods { @@ -678,7 +678,7 @@ async fn parse_map_input( return Ok(EmbedType::Beatmap( Box::new(beatmap), None, - info, + Box::new(info), Mods::NOMOD.clone(), )); } diff --git a/youmubot-osu/src/discord/display.rs b/youmubot-osu/src/discord/display.rs index 088599a..cce970a 100644 --- a/youmubot-osu/src/discord/display.rs +++ b/youmubot-osu/src/discord/display.rs @@ -194,7 +194,7 @@ mod scores { header: header.clone(), scores, }; - let Some(content) = p.to_table(0, usize::max_value()).await? else { + let Some(content) = p.format_table(0, usize::MAX).await? else { on.apply_edit(CreateReply::default().content("No plays found")) .await?; return Ok(()); @@ -240,7 +240,7 @@ mod scores { } impl Paginate { - async fn to_table(&mut self, start: usize, end: usize) -> Result> { + async fn format_table(&mut self, start: usize, end: usize) -> Result> { let scores = self.scores.get_range(start..end).await?; if scores.is_empty() { return Ok(None); @@ -374,7 +374,7 @@ mod scores { let start = page * ITEMS_PER_PAGE; let end = start + ITEMS_PER_PAGE; - let Some(score_table) = self.to_table(start, end).await? else { + let Some(score_table) = self.format_table(start, end).await? else { return Ok(None); }; let mut content = serenity::utils::MessageBuilder::new(); diff --git a/youmubot-osu/src/discord/hook.rs b/youmubot-osu/src/discord/hook.rs index 3a0d568..bbf157a 100644 --- a/youmubot-osu/src/discord/hook.rs +++ b/youmubot-osu/src/discord/hook.rs @@ -254,7 +254,7 @@ pub fn hook<'a>( .then(|l| async move { match l.embed { EmbedType::Beatmap(b, mode, info, mods) => { - handle_beatmap(ctx, &b, info, l.link, mode, mods, msg) + handle_beatmap(ctx, &b, *info, l.link, mode, mods, msg) .await .pls_ok(); let bm = super::BeatmapWithMode(*b, mode); @@ -277,7 +277,7 @@ pub fn hook<'a>( }) } -async fn handle_beatmap<'a, 'b>( +async fn handle_beatmap( ctx: &Context, beatmap: &Beatmap, info: BeatmapInfoWithPP, @@ -316,7 +316,7 @@ async fn handle_beatmap<'a, 'b>( Ok(()) } -async fn handle_beatmapset<'a, 'b>( +async fn handle_beatmapset( ctx: &Context, beatmaps: Vec, link: &'_ str, diff --git a/youmubot-osu/src/discord/link_parser.rs b/youmubot-osu/src/discord/link_parser.rs index 3116b6d..5ffb9aa 100644 --- a/youmubot-osu/src/discord/link_parser.rs +++ b/youmubot-osu/src/discord/link_parser.rs @@ -11,7 +11,7 @@ use super::{oppai_cache::BeatmapInfoWithPP, OsuEnv}; #[derive(Debug, Clone)] pub enum EmbedType { - Beatmap(Box, Option, BeatmapInfoWithPP, Mods), + Beatmap(Box, Option, Box, Mods), Beatmapset(Vec, Option), } @@ -166,7 +166,7 @@ impl EmbedType { .await .map(|b| b.get_possible_pp_with(mode, &mods))? }; - Ok(Self::Beatmap(Box::new(bm), mode, info, mods)) + Ok(Self::Beatmap(Box::new(bm), mode, Box::new(info), mods)) } pub(crate) async fn from_beatmapset_id( diff --git a/youmubot-osu/src/discord/mod.rs b/youmubot-osu/src/discord/mod.rs index 34bd53f..b05999a 100644 --- a/youmubot-osu/src/discord/mod.rs +++ b/youmubot-osu/src/discord/mod.rs @@ -449,31 +449,28 @@ pub async fn forcesave(ctx: &Context, msg: &Message, mut args: Args) -> CommandR async fn add_user(target: serenity::model::id::UserId, user: &User, env: &OsuEnv) -> Result<()> { let modes = [Mode::Std, Mode::Taiko, Mode::Catch, Mode::Mania] .into_iter() - .map(|mode| { - let mode = mode; - async move { - let pp = async { - env.client - .user(&UserID::ID(user.id), |f| f.mode(mode)) - .await - .pls_ok() - .unwrap_or(None) - .and_then(|u| u.pp) - }; - let map_length_age = UserExtras::from_user(env, user, mode); - let (pp, ex) = join!(pp, map_length_age); - pp.zip(ex.ok()).map(|(pp, ex)| { - ( - mode, - OsuUserMode { - pp, - map_length: ex.map_length, - map_age: ex.map_age, - last_update: Utc::now(), - }, - ) - }) - } + .map(|mode| async move { + let pp = async { + env.client + .user(&UserID::ID(user.id), |f| f.mode(mode)) + .await + .pls_ok() + .unwrap_or(None) + .and_then(|u| u.pp) + }; + let map_length_age = UserExtras::from_user(env, user, mode); + let (pp, ex) = join!(pp, map_length_age); + pp.zip(ex.ok()).map(|(pp, ex)| { + ( + mode, + OsuUserMode { + pp, + map_length: ex.map_length, + map_age: ex.map_age, + last_update: Utc::now(), + }, + ) + }) }) .collect::>() .filter_map(future::ready) @@ -832,7 +829,7 @@ pub(crate) async fn load_beatmap_from_channel( Some(EmbedType::Beatmap( Box::new(b), m, - info, + Box::new(info), Mods::NOMOD.clone(), )) } diff --git a/youmubot-osu/src/request/scores.rs b/youmubot-osu/src/request/scores.rs index f113009..d08ff88 100644 --- a/youmubot-osu/src/request/scores.rs +++ b/youmubot-osu/src/request/scores.rs @@ -160,7 +160,7 @@ impl Scores for ScoresFetcher { /// Get all scores. async fn get_all(mut self) -> Result> { - let _ = self.get_range(0..usize::max_value()).await?; + let _ = self.get_range(0..usize::MAX).await?; Ok(self.scores) }