From 1201e4431389a2776c4440eceaadd4e6e71303a3 Mon Sep 17 00:00:00 2001 From: DaXcess Date: Mon, 25 Sep 2023 16:37:12 +0200 Subject: [PATCH] Remove unnecessary impl and add dev changelog --- CHANGELOG.md | 9 +++++ src/bot/events.rs | 84 +++++++++++++++++++++++------------------------ 2 files changed, 50 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9175e13..e01de79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/src/bot/events.rs b/src/bot/events.rs index 3668150..f70639a 100644 --- a/src/bot/events.rs +++ b/src/bot/events.rs @@ -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::().expect("to contain a value"); + let data = ctx.data.read().await; + let command_manager = data.get::().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::().expect("to contain a value"); + let data = ctx.data.read().await; + let command_manager = data.get::().expect("to contain a value"); - command_manager.execute_component(&ctx, component).await; - } + command_manager.execute_component(&ctx, component).await; }