From 61bbe3076560a352dfdfb70824f21ae2d739b930 Mon Sep 17 00:00:00 2001 From: Chiffa Date: Sat, 12 Apr 2025 17:27:18 +0300 Subject: [PATCH 1/3] fix: missing whitespace --- bathbot/src/commands/osu/relax/profile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bathbot/src/commands/osu/relax/profile.rs b/bathbot/src/commands/osu/relax/profile.rs index fff7706e..bbd4d54c 100644 --- a/bathbot/src/commands/osu/relax/profile.rs +++ b/bathbot/src/commands/osu/relax/profile.rs @@ -166,7 +166,7 @@ pub fn relax_profile_builder(args: RelaxProfileArgs) -> Result { let stats = &args.info; let mut description = "__**Relax user statistics".to_string(); if let Some(discord_id) = args.discord_id { - let _ = write!(description, "for <@{discord_id}>"); + let _ = write!(description, " for <@{discord_id}>"); }; description.push_str(":**__"); From 7cd117bb6b0f7414f4118911e6fd3b4472ef8187 Mon Sep 17 00:00:00 2001 From: Chiffa Date: Sat, 12 Apr 2025 18:29:11 +0300 Subject: [PATCH 2/3] fix: Adjust error messages on missing players --- bathbot/src/commands/osu/relax/profile.rs | 2 +- bathbot/src/commands/osu/relax/top.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bathbot/src/commands/osu/relax/profile.rs b/bathbot/src/commands/osu/relax/profile.rs index bbd4d54c..5ab6731c 100644 --- a/bathbot/src/commands/osu/relax/profile.rs +++ b/bathbot/src/commands/osu/relax/profile.rs @@ -106,7 +106,7 @@ pub(super) async fn relax_profile(orig: CommandOrigin<'_>, args: RelaxProfile<'_ Ok(Some(info_res)) => info_res, Ok(None) => { return orig - .error(format!("Relax user `{}` not found", user.username)) + .error(format!("Relax player `{}` not found", user.username)) .await; } Err(err) => { diff --git a/bathbot/src/commands/osu/relax/top.rs b/bathbot/src/commands/osu/relax/top.rs index a29ef7eb..5327023b 100644 --- a/bathbot/src/commands/osu/relax/top.rs +++ b/bathbot/src/commands/osu/relax/top.rs @@ -92,7 +92,9 @@ pub async fn top(orig: CommandOrigin<'_>, args: RelaxTop<'_>) -> Result<()> { }; let Some(player) = player else { - return orig.error("Relax player not found").await; + return orig + .error(format!("Relax player `{}` not found", user.username)) + .await; }; match args.sort.unwrap_or_default() { From c87f43d23c1e8371134a57ad285cde1a3df5c0f0 Mon Sep 17 00:00:00 2001 From: Chiffa Date: Mon, 14 Apr 2025 00:15:01 +0300 Subject: [PATCH 3/3] fix: Combine API result handling to avoid beatmap fetches --- bathbot/src/commands/osu/relax/top.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bathbot/src/commands/osu/relax/top.rs b/bathbot/src/commands/osu/relax/top.rs index 5327023b..489ad061 100644 --- a/bathbot/src/commands/osu/relax/top.rs +++ b/bathbot/src/commands/osu/relax/top.rs @@ -1,7 +1,7 @@ use std::{cmp::Ordering, collections::HashMap}; use bathbot_util::constants::GENERAL_ISSUE; -use eyre::Result; +use eyre::{Report, Result}; use rosu_v2::{error::OsuError, model::GameMode, request::UserId}; use super::RelaxTop; @@ -52,7 +52,7 @@ pub async fn top(orig: CommandOrigin<'_>, args: RelaxTop<'_>) -> Result<()> { } Err(err) => { let _ = orig.error(GENERAL_ISSUE).await; - let err = eyre::Report::new(err).wrap_err("Failed to get user"); + let err = Report::new(err).wrap_err("Failed to get user"); return Err(err); } @@ -66,7 +66,12 @@ pub async fn top(orig: CommandOrigin<'_>, args: RelaxTop<'_>) -> Result<()> { let relax_api_result = tokio::try_join!(scores_fut, player_fut); let (mut scores, player) = match relax_api_result { - Ok(v) => v, + Ok((scores, Some(player))) => (scores, player), + Ok((_, None)) => { + return orig + .error(format!("Relax user `{}` not found", user.username)) + .await; + } Err(e) => { let _ = orig.error("Failed to get a relax player").await; @@ -91,12 +96,6 @@ pub async fn top(orig: CommandOrigin<'_>, args: RelaxTop<'_>) -> Result<()> { } }; - let Some(player) = player else { - return orig - .error(format!("Relax player `{}` not found", user.username)) - .await; - }; - match args.sort.unwrap_or_default() { RelaxTopOrder::Acc => scores.sort_unstable_by(|lhs, rhs| { rhs.accuracy