Skip to content

Commit

Permalink
chore: improve delete command function
Browse files Browse the repository at this point in the history
  • Loading branch information
Quozul committed Mar 15, 2024
1 parent d85732e commit c7e5259
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@ mod commands;
struct Handler;

#[allow(dead_code)]
async fn delete_all_commands(ctx: Context) -> Result<(), Box<dyn Error>> {
async fn delete_all_commands(ctx: &Context) -> Result<(), Box<dyn Error>> {
for command in Command::get_global_commands(&ctx.http).await? {
Command::delete_global_command(&ctx.http, command.id).await?
Command::delete_global_command(&ctx.http, command.id).await?;
info!("Deleted global command {} commands!", command.name);
}

let id: u64 = 533362856297496596;
let guild_id = GuildId::new(id);
let guild = Guild::get(ctx, guild_id).await.unwrap();
let commands = guild.get_commands(ctx).await.unwrap();
for command in commands {
let _ = guild.delete_command(ctx, command.id).await;
info!("Deleted guild command {} commands!", command.name);
}

Ok(())
Expand Down

0 comments on commit c7e5259

Please sign in to comment.