mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-10 04:30:29 +00:00
Add clear_cache command
This commit is contained in:
parent
ba74465ca7
commit
03e37fbebc
1 changed files with 20 additions and 1 deletions
|
@ -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>,
|
||||
|
|
Loading…
Add table
Reference in a new issue