feat(events/ready): adding the Interaction handle autodetect

This commit is contained in:
Raphael 2026-02-12 20:10:48 +01:00
parent 4a832f75be
commit cd85236218
No known key found for this signature in database

View file

@ -1,18 +1,25 @@
use serenity::all::*;
use crate::commands::SlashCommand;
use crate::events::{BotEvent, EventEntry};
pub async fn handle(ctx: &Context, ready: &Ready, commands: &[Box<dyn SlashCommand>]) {
println!("TTY is now running as: '{}'\n", ready.user.name);
pub struct ReadyHandler;
println!("Starting command registration:");
let cmds: Vec<CreateCommand> = commands
.iter()
.map(|c| c.register())
.collect();
#[serenity::async_trait]
impl BotEvent for ReadyHandler {
fn event_type(&self) -> &'static str { "ready" }
Command::set_global_commands(&ctx.http, cmds)
.await
.expect("❌ | Cannot register commands");
async fn on_ready(&self, ctx: &Context, ready: &Ready, commands: &[Box<dyn SlashCommand>]) {
println!("TTY is now running as: '{}'", ready.user.name);
println!("\nTTY now running with {} commands loaded", commands.len());
let cmds: Vec<CreateCommand> = commands.iter().map(|c| c.register()).collect();
Command::set_global_commands(&ctx.http, cmds)
.await
.expect("❌ | Cannot register commands");
println!("TTY now running with {} commands loaded", commands.len());
}
}
inventory::submit! {
EventEntry { create: || Box::new(ReadyHandler) }
}