mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-09 20:20:29 +00:00
osu: small redundancy cleanups
This commit is contained in:
parent
a5fd4f4eab
commit
c28cad0718
3 changed files with 25 additions and 42 deletions
|
@ -183,15 +183,7 @@ pub async fn save<U: HasOsuEnv>(
|
|||
.clone()
|
||||
.send(
|
||||
CreateReply::default()
|
||||
.content(format!(
|
||||
"To set your osu username to **{}**, please make your most recent play \
|
||||
be the following map: `/b/{}` in **{}** mode! \
|
||||
It does **not** have to be a pass, and **NF** can be used! \
|
||||
React to this message with 👌 within 5 minutes when you're done!",
|
||||
u.username,
|
||||
score.beatmap_id,
|
||||
mode.as_str_new_site()
|
||||
))
|
||||
.content(save_request_message(&u.username, score.beatmap_id, mode))
|
||||
.embed(beatmap_embed(&beatmap, mode, Mods::NOMOD, &info))
|
||||
.components(vec![beatmap_components(mode, ctx.guild_id())]),
|
||||
)
|
||||
|
@ -349,10 +341,7 @@ async fn beatmap<U: HasOsuEnv>(
|
|||
};
|
||||
ctx.send(
|
||||
CreateReply::default()
|
||||
.content(format!(
|
||||
"Information for beatmap `{}`",
|
||||
beatmap.short_link(mode, &mods)
|
||||
))
|
||||
.content(format!("Information for {}", beatmap.mention(mode, &mods)))
|
||||
.embed(beatmap_embed(
|
||||
&beatmap,
|
||||
mode.unwrap_or(beatmap.mode),
|
||||
|
@ -372,11 +361,7 @@ async fn beatmap<U: HasOsuEnv>(
|
|||
let b0 = &vec[0];
|
||||
let msg = ctx
|
||||
.clone()
|
||||
.reply(format!(
|
||||
"Information for beatmapset [`/s/{}`](<{}>)",
|
||||
b0.beatmapset_id,
|
||||
b0.beatmapset_link()
|
||||
))
|
||||
.reply(format!("Information for {}", b0.beatmapset_mention()))
|
||||
.await?
|
||||
.into_message()
|
||||
.await?;
|
||||
|
@ -475,17 +460,9 @@ async fn check<U: HasOsuEnv>(
|
|||
};
|
||||
|
||||
let display = if beatmaps.len() == 1 {
|
||||
format!(
|
||||
"[{}](<{}>)",
|
||||
beatmaps[0].0.short_link(None, Mods::NOMOD),
|
||||
beatmaps[0].0.link()
|
||||
)
|
||||
beatmaps[0].0.mention(None, Mods::NOMOD)
|
||||
} else {
|
||||
format!(
|
||||
"[/s/{}](<{}>)",
|
||||
beatmaps[0].0.beatmapset_id,
|
||||
beatmaps[0].0.beatmapset_link()
|
||||
)
|
||||
beatmaps[0].0.beatmapset_mention()
|
||||
};
|
||||
|
||||
let ordering = sort.unwrap_or_default();
|
||||
|
@ -602,10 +579,9 @@ async fn leaderboard<U: HasOsuEnv>(
|
|||
let beatmap = &bm.0;
|
||||
if scores.is_empty() {
|
||||
ctx.reply(format!(
|
||||
"No scores have been recorded in **{}** on [`{}`]({}).",
|
||||
"No scores have been recorded in **{}** on {}.",
|
||||
guild.name,
|
||||
beatmap.short_link(mode, Mods::NOMOD),
|
||||
beatmap.link()
|
||||
beatmap.mention(mode, Mods::NOMOD),
|
||||
))
|
||||
.await?;
|
||||
return Ok(());
|
||||
|
|
|
@ -257,15 +257,7 @@ pub async fn save(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
.send_message(
|
||||
&ctx,
|
||||
CreateMessage::new()
|
||||
.content(format!(
|
||||
"To set your osu username to **{}**, please make your most recent play \
|
||||
be the following map: `/b/{}` in **{}** mode! \
|
||||
It does **not** have to be a pass, and **NF** can be used! \
|
||||
React to this message with 👌 within 5 minutes when you're done!",
|
||||
u.username,
|
||||
score.beatmap_id,
|
||||
mode.as_str_new_site()
|
||||
))
|
||||
.content(save_request_message(&u.username, score.beatmap_id, mode))
|
||||
.embed(beatmap_embed(&beatmap, mode, Mods::NOMOD, &info))
|
||||
.components(vec![beatmap_components(mode, msg.guild_id)]),
|
||||
)
|
||||
|
@ -274,6 +266,18 @@ pub async fn save(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn save_request_message(username: &str, beatmap_id: u64, mode: Mode) -> String {
|
||||
format!(
|
||||
"To set your osu username to **{}**, please make your most recent play \
|
||||
be the following map: `/b/{}` in **{}** mode! \
|
||||
It does **not** have to be a pass, and **NF** can be used! \
|
||||
React to this message with 👌 within 5 minutes when you're done!",
|
||||
username,
|
||||
beatmap_id,
|
||||
mode.as_str_new_site()
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) async fn find_save_requirements(
|
||||
env: &OsuEnv,
|
||||
username: String,
|
||||
|
@ -943,9 +947,9 @@ pub async fn check(ctx: &Context, msg: &Message, mut args: Args) -> CommandResul
|
|||
.reply(
|
||||
&ctx,
|
||||
format!(
|
||||
"Here are the scores by `{}` on `{}`!",
|
||||
"Here are the scores by `{}` on {}!",
|
||||
&user.username,
|
||||
bm.short_link(&mods)
|
||||
bm.0.mention(Some(bm.1), &mods)
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -457,6 +457,9 @@ impl Beatmap {
|
|||
self.mode_link(override_mode),
|
||||
)
|
||||
}
|
||||
pub fn beatmapset_mention(&self) -> String {
|
||||
format!("[/s/{}](<{}>)", self.beatmapset_id, self.beatmapset_link())
|
||||
}
|
||||
|
||||
/// Link to the cover image of the beatmap.
|
||||
pub fn cover_url(&self) -> String {
|
||||
|
|
Loading…
Add table
Reference in a new issue