diff --git a/youmubot-osu/src/discord/commands.rs b/youmubot-osu/src/discord/commands.rs index 7e26cc7..e1233b3 100644 --- a/youmubot-osu/src/discord/commands.rs +++ b/youmubot-osu/src/discord/commands.rs @@ -21,7 +21,8 @@ use serenity::all::User; "beatmap", "check", "ranks", - "leaderboard" + "leaderboard", + "clear_cache" ) )] pub async fn osu(_ctx: CmdContext<'_, U>) -> Result<()> { @@ -642,6 +643,24 @@ async fn leaderboard( Ok(()) } +/// Clear youmu's cache. +#[poise::command(slash_command, owners_only)] +pub async fn clear_cache( + 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, discord_name: Option,