From 2146b50ab68f33b6ec94ffd61f9f72e31e25fee0 Mon Sep 17 00:00:00 2001 From: Victor Mignot Date: Sun, 20 Nov 2022 19:45:39 -0500 Subject: [PATCH] Declare create and delete commands for tags --- src/discord/event_handler.rs | 39 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/discord/event_handler.rs b/src/discord/event_handler.rs index 8423877..49bb252 100644 --- a/src/discord/event_handler.rs +++ b/src/discord/event_handler.rs @@ -17,29 +17,34 @@ impl EventHandler for Handler { async fn ready(&self, ctx: Context, ready: Ready) { println!("Successfully connected as {}", ready.user.name); - let _ = Command::create_global_application_command(&ctx.http, |command| { + match Command::create_global_application_command(&ctx.http, |command| { command - .name("tag new") + .name("create_tag") .description("Add a new tag") .create_option(|option| { option - .name("new_tag") - .description("The new tag to add") + .name("tag") + .description("The tag to create") .kind(CommandOptionType::String) .required(true) }) }) - .await; + .await + { + Ok(_) => println!("Successfully registered create_tag command"), + Err(e) => println!("Failed to register create_tag command : {e}"), + }; - let _ = Command::create_global_application_command(&ctx.http, |command| { + match Command::create_global_application_command(&ctx.http, |command| { let command = command - .name("tag bulk_new") + .name("bulk_create_tag") .description("Add multiples tags"); for i in 0..MAX_ARGS_NUMBER { command.create_option(|option| { option - .name("new_tag_{i+1}") + .name(format!("tag{}", i + 1)) + .description("A new tag to add") .kind(CommandOptionType::String) .required(i == 0) }); @@ -47,19 +52,29 @@ impl EventHandler for Handler { command }) - .await; + .await + { + Ok(_) => println!("Successfully registered bulk_create_tag command"), + Err(e) => println!("Failed to register bulk_create_tag command: {e}"), + }; - let _ = Command::create_global_application_command(&ctx.http, |command| { + match Command::create_global_application_command(&ctx.http, |command| { command - .name("tag delete") + .name("delete_tag") .description("Delete a tag") .create_option(|option| { option .name("tag") + .description("The tag to delete") .kind(CommandOptionType::String) .required(true) }) - }); + }) + .await + { + Ok(_) => println!("Successfully registered delete_tag command"), + Err(e) => println!("Failed to register delete_tag command: {e}"), + }; } async fn resume(&self, _: Context, _: ResumedEvent) {