Skip to content

Commit

Permalink
now registering commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Inspirateur committed Jan 7, 2023
1 parent b0eff0a commit 49bc70c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/handle_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
27 changes: 27 additions & 0 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,31 @@ impl Handler {
}
}
}

pub async fn register_commands(&self, http: Arc<Http>, 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);
};

}
}

0 comments on commit 49bc70c

Please sign in to comment.