mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
Add clear_cache command
This commit is contained in:
parent
a5d34f4dc7
commit
07bea1544f
1 changed files with 20 additions and 1 deletions
|
@ -21,7 +21,8 @@ use serenity::all::User;
|
||||||
"beatmap",
|
"beatmap",
|
||||||
"check",
|
"check",
|
||||||
"ranks",
|
"ranks",
|
||||||
"leaderboard"
|
"leaderboard",
|
||||||
|
"clear_cache"
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
pub async fn osu<U: HasOsuEnv>(_ctx: CmdContext<'_, U>) -> Result<()> {
|
pub async fn osu<U: HasOsuEnv>(_ctx: CmdContext<'_, U>) -> Result<()> {
|
||||||
|
@ -642,6 +643,24 @@ async fn leaderboard<U: HasOsuEnv>(
|
||||||
Ok(())
|
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(
|
fn arg_from_username_or_discord(
|
||||||
username: Option<String>,
|
username: Option<String>,
|
||||||
discord_name: Option<User>,
|
discord_name: Option<User>,
|
||||||
|
|
Loading…
Add table
Reference in a new issue