Remove unnecessary impl and add dev changelog

main
DaXcess 2023-09-25 16:37:12 +02:00
parent 2daed2f704
commit 1201e44313
No known key found for this signature in database
GPG Key ID: CF78CC72F0FD5EAD
2 changed files with 50 additions and 43 deletions

View File

@ -1,5 +1,14 @@
# Changelog
## Current dev branch
In this section of the change log all current changes that have been made since the last version will be documented. This list will grow as more changes are made, until the next release. Upon the next release the list will be cleared.
### Changes
* Removed OpenSSL dependency
* Added aarch64 support
* Added cross compilation to Github Actions
* Added `dev` branch to Github Actions
## 2.1.1 | September 23rd 2023
Reduced the amount of CPU that the bot uses from ~15%-25% per user to 1%-2% per user (percentage per core, benched on an AMD Ryzen 9 5950X).

View File

@ -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;
}