From 49bc70c4732769211304e5ef580ef7acf153af5b Mon Sep 17 00:00:00 2001 From: Teo Date: Sat, 7 Jan 2023 14:27:40 +0100 Subject: [PATCH] now registering commands --- src/handle_events.rs | 1 + src/handler.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/handle_events.rs b/src/handle_events.rs index cac161c..7cff0a9 100644 --- a/src/handle_events.rs +++ b/src/handle_events.rs @@ -44,6 +44,7 @@ impl EventHandler for Handler { } async fn guild_create(&self, ctx: Context, guild: Guild, _is_new: bool) { + self.register_commands(ctx.http.clone(), guild.id).await; self.register_guild(ctx.http, guild).await; } diff --git a/src/handler.rs b/src/handler.rs index db4b93f..d8fc26e 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -125,4 +125,31 @@ impl Handler { } } } + + pub async fn register_commands(&self, http: Arc, guild_id: GuildId) { + println!("Registering slash commands for Guild {}", guild_id); + if let Err(why) = + GuildId::set_application_commands(&guild_id, http, |commands| { + commands + .create_application_command(|command| { + command.name("cloud").description( + "Discover the word cloud that defines you !", + ) + }) + .create_application_command(|command| { + command + .name("emojis") + .description("Display the most and least used emojis for this server.") + }).create_application_command(|command| { + command + .name("activity") + .description("Display stats about the activity of text channels over time.") + }) + }) + .await + { + println!("Couldn't register slash commmands: {}", why); + }; + + } }