Add clear_cache command

This commit is contained in:
Natsu Kagami 2024-12-31 09:06:13 +01:00 committed by Natsu Kagami
parent ba74465ca7
commit 03e37fbebc

View file

@ -21,7 +21,8 @@ use serenity::all::User;
"beatmap",
"check",
"ranks",
"leaderboard"
"leaderboard",
"clear_cache"
)
)]
pub async fn osu<U: HasOsuEnv>(_ctx: CmdContext<'_, U>) -> Result<()> {
@ -642,6 +643,24 @@ async fn leaderboard<U: HasOsuEnv>(
Ok(())
}
/// Clear youmu's cache.
#[poise::command(slash_command, owners_only)]
pub async fn clear_cache<U: HasOsuEnv>(
ctx: CmdContext<'_, U>,
#[description = "Also clear oppai cache"] clear_oppai: bool,
) -> Result<()> {
let env = ctx.data().osu_env();
ctx.defer_ephemeral().await?;
env.beatmaps.clear().await?;
if clear_oppai {
env.oppai.clear().await?;
}
ctx.reply("Beatmap cache cleared!").await?;
Ok(())
}
fn arg_from_username_or_discord(
username: Option<String>,
discord_name: Option<User>,