feat: fix the command handler to reveal more data about the interaction
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -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)) => {
|
||||
|
||||
Reference in New Issue
Block a user