mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-24 17:20:49 +00:00
Add cache clear command
This commit is contained in:
parent
7d00b95a4f
commit
b5013b9899
4 changed files with 45 additions and 1 deletions
|
@ -122,7 +122,8 @@ pub async fn setup(
|
|||
check,
|
||||
top,
|
||||
server_rank,
|
||||
update_leaderboard
|
||||
update_leaderboard,
|
||||
clean_cache
|
||||
)]
|
||||
#[default_command(std)]
|
||||
struct Osu;
|
||||
|
@ -702,6 +703,23 @@ pub async fn top(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[command("cleancache")]
|
||||
#[owners_only]
|
||||
#[description = "Clean the beatmap cache."]
|
||||
#[usage = "[--oppai to clear oppai cache as well]"]
|
||||
#[max_args(1)]
|
||||
pub async fn clean_cache(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
||||
let data = ctx.data.read().await;
|
||||
let meta_cache = data.get::<BeatmapMetaCache>().unwrap();
|
||||
meta_cache.clear().await?;
|
||||
if args.remains() == Some("--oppai") {
|
||||
let oppai = data.get::<BeatmapCache>().unwrap();
|
||||
oppai.clear().await?;
|
||||
}
|
||||
msg.reply_ping(ctx, "Beatmap cache cleared!").await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_user(ctx: &Context, msg: &Message, mut args: Args, mode: Mode) -> CommandResult {
|
||||
let data = ctx.data.read().await;
|
||||
let user = to_user_id_query(args.single::<UsernameArg>().ok(), &data, msg).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue