Remove unnecessary impl and add dev changelog
This commit is contained in:
+41
-43
@@ -54,23 +54,22 @@ impl EventHandler for Handler {
|
||||
// INTERACTION_CREATE event, emitted when the bot receives an interaction (slash command, button, etc.)
|
||||
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
|
||||
match interaction {
|
||||
Interaction::ApplicationCommand(command) => self.handle_command(ctx, command).await,
|
||||
Interaction::MessageComponent(component) => self.handle_component(ctx, component).await,
|
||||
Interaction::ApplicationCommand(command) => handle_command(ctx, command).await,
|
||||
Interaction::MessageComponent(component) => handle_component(ctx, component).await,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
async fn handle_command(&self, ctx: Context, command: ApplicationCommandInteraction) {
|
||||
enforce_guild!(command);
|
||||
async fn handle_command(ctx: Context, command: ApplicationCommandInteraction) {
|
||||
enforce_guild!(command);
|
||||
|
||||
// Commands must only be executed inside of guilds
|
||||
// Commands must only be executed inside of guilds
|
||||
|
||||
let guild_id = match command.guild_id {
|
||||
Some(guild_id) => guild_id,
|
||||
None => {
|
||||
if let Err(why) = command
|
||||
let guild_id = match command.guild_id {
|
||||
Some(guild_id) => guild_id,
|
||||
None => {
|
||||
if let Err(why) = command
|
||||
.create_interaction_response(&ctx.http, |response| {
|
||||
response
|
||||
.kind(serenity::model::prelude::interaction::InteractionResponseType::ChannelMessageWithSource)
|
||||
@@ -82,32 +81,32 @@ impl Handler {
|
||||
error!("Failed to send run-in-guild-only error message: {}", why);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
trace!(
|
||||
"Received command interaction: command={} user={} guild={}",
|
||||
command.data.name,
|
||||
command.user.id,
|
||||
guild_id
|
||||
);
|
||||
trace!(
|
||||
"Received command interaction: command={} user={} guild={}",
|
||||
command.data.name,
|
||||
command.user.id,
|
||||
guild_id
|
||||
);
|
||||
|
||||
let data = ctx.data.read().await;
|
||||
let command_manager = data.get::<CommandManager>().expect("to contain a value");
|
||||
let data = ctx.data.read().await;
|
||||
let command_manager = data.get::<CommandManager>().expect("to contain a value");
|
||||
|
||||
command_manager.execute_command(&ctx, command).await;
|
||||
}
|
||||
command_manager.execute_command(&ctx, command).await;
|
||||
}
|
||||
|
||||
async fn handle_component(&self, ctx: Context, component: MessageComponentInteraction) {
|
||||
enforce_guild!(component);
|
||||
async fn handle_component(ctx: Context, component: MessageComponentInteraction) {
|
||||
enforce_guild!(component);
|
||||
|
||||
// Components can only be interacted with inside of guilds
|
||||
// Components can only be interacted with inside of guilds
|
||||
|
||||
let guild_id = match component.guild_id {
|
||||
Some(guild_id) => guild_id,
|
||||
None => {
|
||||
if let Err(why) = component
|
||||
let guild_id = match component.guild_id {
|
||||
Some(guild_id) => guild_id,
|
||||
None => {
|
||||
if let Err(why) = component
|
||||
.create_interaction_response(&ctx.http, |response| {
|
||||
response
|
||||
.kind(serenity::model::prelude::interaction::InteractionResponseType::ChannelMessageWithSource)
|
||||
@@ -119,20 +118,19 @@ impl Handler {
|
||||
error!("Failed to send run-in-guild-only error message: {}", why);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
trace!(
|
||||
"Received component interaction: command={} user={} guild={}",
|
||||
component.data.custom_id,
|
||||
component.user.id,
|
||||
guild_id
|
||||
);
|
||||
trace!(
|
||||
"Received component interaction: command={} user={} guild={}",
|
||||
component.data.custom_id,
|
||||
component.user.id,
|
||||
guild_id
|
||||
);
|
||||
|
||||
let data = ctx.data.read().await;
|
||||
let command_manager = data.get::<CommandManager>().expect("to contain a value");
|
||||
let data = ctx.data.read().await;
|
||||
let command_manager = data.get::<CommandManager>().expect("to contain a value");
|
||||
|
||||
command_manager.execute_component(&ctx, component).await;
|
||||
}
|
||||
command_manager.execute_component(&ctx, component).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user