From 0837a65bf42614e3e6219b24aa08a08b22c772a1 Mon Sep 17 00:00:00 2001 From: toast Date: Tue, 5 Dec 2023 13:11:45 +1100 Subject: [PATCH] Refactor command registration to be global --- src/main.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1e21dac..6694ced 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,8 +4,6 @@ use poise::serenity_prelude::{self as serenity}; type Error = Box; -const GUILD_ID: serenity::GuildId = serenity::GuildId(865673694184996885); - async fn on_ready( ctx: &serenity::Context, ready: &serenity::Ready, @@ -14,12 +12,19 @@ async fn on_ready( println!("Connected to API as {}", ready.user.name); let builder = poise::builtins::create_application_commands(&framework.options().commands); - let commands = serenity::GuildId::set_application_commands(&GUILD_ID, &ctx.http, |commands| { - *commands = builder.clone(); - commands - }).await; - - println!("Registered the following commands: \n{:#?}", commands); + let commands = serenity::Command::set_global_application_commands(&ctx.http, |commands| { + *commands = builder.clone(); + commands + }).await; + + match commands { + Ok(cmdmap) => { + for command in cmdmap.iter() { + println!("Registered command globally: {}", command.name); + } + }, + Err(why) => println!("Error registering commands: {:?}", why) + } Ok(()) }