mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
osu: Improve wording for interaction outputs
This commit is contained in:
parent
346f74e6c4
commit
dc02b4b7e2
2 changed files with 39 additions and 16 deletions
|
@ -61,23 +61,45 @@ pub fn handle_check_button<'a>(
|
||||||
}
|
}
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
let (msg, author) = (&*comp.message, comp.user.id);
|
let msg = &*comp.message;
|
||||||
|
|
||||||
let env = ctx.data.read().await.get::<OsuEnv>().unwrap().clone();
|
let env = ctx.data.read().await.get::<OsuEnv>().unwrap().clone();
|
||||||
let (bm, _) = super::load_beatmap(&env, comp.channel_id, Some(msg))
|
let (bm, _) = super::load_beatmap(&env, comp.channel_id, Some(msg))
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let user_id = super::to_user_id_query(None, &env, author).await?;
|
let user = match env.saved_users.by_user_id(comp.user.id).await? {
|
||||||
|
Some(u) => u,
|
||||||
|
None => {
|
||||||
|
comp.create_response(&ctx, CreateInteractionResponse::Message(CreateInteractionResponseMessage::new().content("You don't have a saved account yet! Save your osu! account by `y2!osu save <your-osu-username>`.").ephemeral(true))).await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let scores = super::do_check(&env, &bm, Mods::NOMOD, &user_id).await?;
|
let scores = super::do_check(&env, &bm, Mods::NOMOD, &crate::UserID::ID(user.id)).await?;
|
||||||
|
if scores.is_empty() {
|
||||||
|
comp.create_response(
|
||||||
|
&ctx,
|
||||||
|
CreateInteractionResponse::Message(
|
||||||
|
CreateInteractionResponseMessage::new().content(format!(
|
||||||
|
"No plays found for [`{}`](<https://osu.ppy.sh/users/{}>) on `{}`.",
|
||||||
|
user.username,
|
||||||
|
user.id,
|
||||||
|
bm.short_link(Mods::NOMOD)
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let reply = {
|
let reply = {
|
||||||
comp.create_response(
|
comp.create_response(
|
||||||
&ctx,
|
&ctx,
|
||||||
serenity::all::CreateInteractionResponse::Message(
|
serenity::all::CreateInteractionResponse::Message(
|
||||||
CreateInteractionResponseMessage::new().content(format!(
|
CreateInteractionResponseMessage::new().content(format!(
|
||||||
"Here are the scores by `{}` on `{}`!",
|
"Here are the scores by [`{}`](<https://osu.ppy.sh/users/{}>) on `{}`!",
|
||||||
&user_id,
|
user.username,
|
||||||
|
user.id,
|
||||||
bm.short_link(Mods::NOMOD)
|
bm.short_link(Mods::NOMOD)
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
|
@ -120,29 +142,29 @@ pub fn handle_last_button<'a>(
|
||||||
|
|
||||||
let env = ctx.data.read().await.get::<OsuEnv>().unwrap().clone();
|
let env = ctx.data.read().await.get::<OsuEnv>().unwrap().clone();
|
||||||
|
|
||||||
let (BeatmapWithMode(b, m), mods_def) =
|
let (bm, mods_def) = super::load_beatmap(&env, comp.channel_id, Some(msg))
|
||||||
super::load_beatmap(&env, comp.channel_id, Some(msg))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let BeatmapWithMode(b, m) = &bm;
|
||||||
|
|
||||||
let mods = mods_def.unwrap_or(Mods::NOMOD);
|
let mods = mods_def.unwrap_or(Mods::NOMOD);
|
||||||
let info = env
|
let info = env
|
||||||
.oppai
|
.oppai
|
||||||
.get_beatmap(b.beatmap_id)
|
.get_beatmap(b.beatmap_id)
|
||||||
.await?
|
.await?
|
||||||
.get_possible_pp_with(m, mods)?;
|
.get_possible_pp_with(*m, mods)?;
|
||||||
comp.create_response(
|
comp.create_response(
|
||||||
&ctx,
|
&ctx,
|
||||||
serenity::all::CreateInteractionResponse::Message(
|
serenity::all::CreateInteractionResponse::Message(
|
||||||
CreateInteractionResponseMessage::new()
|
CreateInteractionResponseMessage::new()
|
||||||
.content("Here is the beatmap you requested!")
|
.content(format!("Information for beatmap `{}`", bm.short_link(mods)))
|
||||||
.embed(beatmap_embed(&b, m, mods, info))
|
.embed(beatmap_embed(b, *m, mods, info))
|
||||||
.components(vec![beatmap_components(comp.guild_id)]),
|
.components(vec![beatmap_components(comp.guild_id)]),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
// Save the beatmap...
|
// Save the beatmap...
|
||||||
super::cache::save_beatmap(&env, msg.channel_id, &BeatmapWithMode(b, m)).await?;
|
super::cache::save_beatmap(&env, msg.channel_id, &bm).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
@ -191,8 +213,9 @@ pub fn handle_lb_button<'a>(
|
||||||
if scores.is_empty() {
|
if scores.is_empty() {
|
||||||
comp.create_followup(
|
comp.create_followup(
|
||||||
&ctx,
|
&ctx,
|
||||||
CreateInteractionResponseFollowup::new()
|
CreateInteractionResponseFollowup::new().content(
|
||||||
.content("No scores have been recorded for this beatmap."),
|
"No scores have been recorded for this beatmap from anyone in this server.",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
@ -450,7 +450,7 @@ async fn to_user_id_query(
|
||||||
env.saved_users
|
env.saved_users
|
||||||
.by_user_id(id)
|
.by_user_id(id)
|
||||||
.await?
|
.await?
|
||||||
.map(|u| UserID::ID(u.id))
|
.map(|u| UserID::Username(u.username.to_string()))
|
||||||
.ok_or_else(|| Error::msg("No saved account found"))
|
.ok_or_else(|| Error::msg("No saved account found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue