feat: fix the command handler to reveal more data about the interaction

This commit is contained in:
2026-03-27 01:35:29 -04:00
parent d9e0801ec9
commit 3439bf9699
8 changed files with 70 additions and 55 deletions

View File

@@ -109,8 +109,8 @@ async fn main() -> Result<(), MainError> {
let intents = Intents::GUILD_VOICE_STATES;
let mut shard = Shard::new(shard_id, discord_token.expose_secret().to_owned(), intents);
let vc_event_types = EventTypeFlags::GUILD_VOICE_STATES;
let mut next_event = shard.next_event(vc_event_types);
let event_types = EventTypeFlags::GUILD_VOICE_STATES | EventTypeFlags::INTERACTION_CREATE;
let mut next_event = shard.next_event(event_types);
let discord_client = twilight_http::Client::new(discord_token.expose_secret().to_owned());
@@ -161,7 +161,7 @@ async fn main() -> Result<(), MainError> {
}
}
next_event = shard.next_event(vc_event_types);
next_event = shard.next_event(event_types);
}
Ok(())
@@ -176,13 +176,16 @@ async fn handle_event(command_router: &CommandRouter, vcs: Arc<VCs>, event: Even
Event::InteractionCreate(interaction_create) => {
let InteractionCreate(interaction) = *interaction_create;
match interaction.data {
match &interaction.data {
None => {
tracing::warn!("missing expected interaction data");
}
Some(InteractionData::ApplicationCommand(command_data)) => {
let command_name = &command_data.name.clone();
let state = State { vcs };
command_router.handle(state, *command_data).await;
command_router
.handle(state, command_name, interaction)
.await;
}
Some(InteractionData::MessageComponent(component_data)) => {