mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
osu: small redundancy cleanups
This commit is contained in:
parent
2f49f09a27
commit
cc35c2e4e5
3 changed files with 25 additions and 42 deletions
|
@ -183,15 +183,7 @@ pub async fn save<U: HasOsuEnv>(
|
||||||
.clone()
|
.clone()
|
||||||
.send(
|
.send(
|
||||||
CreateReply::default()
|
CreateReply::default()
|
||||||
.content(format!(
|
.content(save_request_message(&u.username, score.beatmap_id, mode))
|
||||||
"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()
|
|
||||||
))
|
|
||||||
.embed(beatmap_embed(&beatmap, mode, Mods::NOMOD, &info))
|
.embed(beatmap_embed(&beatmap, mode, Mods::NOMOD, &info))
|
||||||
.components(vec![beatmap_components(mode, ctx.guild_id())]),
|
.components(vec![beatmap_components(mode, ctx.guild_id())]),
|
||||||
)
|
)
|
||||||
|
@ -349,10 +341,7 @@ async fn beatmap<U: HasOsuEnv>(
|
||||||
};
|
};
|
||||||
ctx.send(
|
ctx.send(
|
||||||
CreateReply::default()
|
CreateReply::default()
|
||||||
.content(format!(
|
.content(format!("Information for {}", beatmap.mention(mode, &mods)))
|
||||||
"Information for beatmap `{}`",
|
|
||||||
beatmap.short_link(mode, &mods)
|
|
||||||
))
|
|
||||||
.embed(beatmap_embed(
|
.embed(beatmap_embed(
|
||||||
&beatmap,
|
&beatmap,
|
||||||
mode.unwrap_or(beatmap.mode),
|
mode.unwrap_or(beatmap.mode),
|
||||||
|
@ -372,11 +361,7 @@ async fn beatmap<U: HasOsuEnv>(
|
||||||
let b0 = &vec[0];
|
let b0 = &vec[0];
|
||||||
let msg = ctx
|
let msg = ctx
|
||||||
.clone()
|
.clone()
|
||||||
.reply(format!(
|
.reply(format!("Information for {}", b0.beatmapset_mention()))
|
||||||
"Information for beatmapset [`/s/{}`](<{}>)",
|
|
||||||
b0.beatmapset_id,
|
|
||||||
b0.beatmapset_link()
|
|
||||||
))
|
|
||||||
.await?
|
.await?
|
||||||
.into_message()
|
.into_message()
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -475,17 +460,9 @@ async fn check<U: HasOsuEnv>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let display = if beatmaps.len() == 1 {
|
let display = if beatmaps.len() == 1 {
|
||||||
format!(
|
beatmaps[0].0.mention(None, Mods::NOMOD)
|
||||||
"[{}](<{}>)",
|
|
||||||
beatmaps[0].0.short_link(None, Mods::NOMOD),
|
|
||||||
beatmaps[0].0.link()
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
format!(
|
beatmaps[0].0.beatmapset_mention()
|
||||||
"[/s/{}](<{}>)",
|
|
||||||
beatmaps[0].0.beatmapset_id,
|
|
||||||
beatmaps[0].0.beatmapset_link()
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let ordering = sort.unwrap_or_default();
|
let ordering = sort.unwrap_or_default();
|
||||||
|
@ -602,10 +579,9 @@ async fn leaderboard<U: HasOsuEnv>(
|
||||||
let beatmap = &bm.0;
|
let beatmap = &bm.0;
|
||||||
if scores.is_empty() {
|
if scores.is_empty() {
|
||||||
ctx.reply(format!(
|
ctx.reply(format!(
|
||||||
"No scores have been recorded in **{}** on [`{}`]({}).",
|
"No scores have been recorded in **{}** on {}.",
|
||||||
guild.name,
|
guild.name,
|
||||||
beatmap.short_link(mode, Mods::NOMOD),
|
beatmap.mention(mode, Mods::NOMOD),
|
||||||
beatmap.link()
|
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
@ -257,15 +257,7 @@ pub async fn save(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
||||||
.send_message(
|
.send_message(
|
||||||
&ctx,
|
&ctx,
|
||||||
CreateMessage::new()
|
CreateMessage::new()
|
||||||
.content(format!(
|
.content(save_request_message(&u.username, score.beatmap_id, mode))
|
||||||
"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()
|
|
||||||
))
|
|
||||||
.embed(beatmap_embed(&beatmap, mode, Mods::NOMOD, &info))
|
.embed(beatmap_embed(&beatmap, mode, Mods::NOMOD, &info))
|
||||||
.components(vec![beatmap_components(mode, msg.guild_id)]),
|
.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(())
|
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(
|
pub(crate) async fn find_save_requirements(
|
||||||
env: &OsuEnv,
|
env: &OsuEnv,
|
||||||
username: String,
|
username: String,
|
||||||
|
@ -943,9 +947,9 @@ pub async fn check(ctx: &Context, msg: &Message, mut args: Args) -> CommandResul
|
||||||
.reply(
|
.reply(
|
||||||
&ctx,
|
&ctx,
|
||||||
format!(
|
format!(
|
||||||
"Here are the scores by `{}` on `{}`!",
|
"Here are the scores by `{}` on {}!",
|
||||||
&user.username,
|
&user.username,
|
||||||
bm.short_link(&mods)
|
bm.0.mention(Some(bm.1), &mods)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -457,6 +457,9 @@ impl Beatmap {
|
||||||
self.mode_link(override_mode),
|
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.
|
/// Link to the cover image of the beatmap.
|
||||||
pub fn cover_url(&self) -> String {
|
pub fn cover_url(&self) -> String {
|
||||||
|
|
Loading…
Add table
Reference in a new issue