From 676fdcfd966c2cce03a21db1389d02b968ec2e31 Mon Sep 17 00:00:00 2001 From: Rafael Bradley Date: Mon, 25 Aug 2025 20:03:21 -0300 Subject: [PATCH] Run cargo fmt --all --- src/framework/commands/mod.rs | 12 ++++++++---- src/framework/commands/permissions.rs | 2 +- src/framework/interactions/registry.rs | 4 +--- src/groups/about/commands.rs | 20 ++++++++++++++------ src/groups/leveling/events.rs | 4 +++- src/utils.rs | 12 ++++++++---- 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/framework/commands/mod.rs b/src/framework/commands/mod.rs index eb10fc4..3311332 100644 --- a/src/framework/commands/mod.rs +++ b/src/framework/commands/mod.rs @@ -5,9 +5,13 @@ use deadpool_redis::{cluster::PoolError, redis::RedisError}; use thiserror::Error; use twilight_http::response::DeserializeBodyError; -use crate::{database::models::{DatabaseError, DatabaseOrDiscordError}, framework::{commands::{ - arguments::Argument, context::CommandContext, permissions::Permission, -}, runtime::Runtime}}; +use crate::{ + database::models::{DatabaseError, DatabaseOrDiscordError}, + framework::{ + commands::{arguments::Argument, context::CommandContext, permissions::Permission}, + runtime::Runtime, + }, +}; pub mod arguments; pub mod context; @@ -40,7 +44,7 @@ pub enum CommandError { RedisFailed(#[from] RedisError), #[error(transparent)] - DatabaseOrDiscordError(#[from] DatabaseOrDiscordError) + DatabaseOrDiscordError(#[from] DatabaseOrDiscordError), } #[async_trait] diff --git a/src/framework/commands/permissions.rs b/src/framework/commands/permissions.rs index 02735da..d823328 100644 --- a/src/framework/commands/permissions.rs +++ b/src/framework/commands/permissions.rs @@ -7,7 +7,7 @@ use crate::framework::commands::{CommandError, context::CommandContext}; #[async_trait] pub trait Permission: Debug { async fn check(&self, ctx: &CommandContext) -> Result; - + async fn on_handle_denied(&self, _ctx: &CommandContext) -> Result<(), CommandError> { Ok(()) } diff --git a/src/framework/interactions/registry.rs b/src/framework/interactions/registry.rs index c401c06..39eddb4 100644 --- a/src/framework/interactions/registry.rs +++ b/src/framework/interactions/registry.rs @@ -81,9 +81,7 @@ where )) .await .inspect(|_| log::debug!("Executed component interaction")) - .inspect_err(|e| { - log::error!("Interaction execution failed: {e:?}") - }) + .inspect_err(|e| log::error!("Interaction execution failed: {e:?}")) } else { Err(InteractionError::InteractionNotFound) } diff --git a/src/groups/about/commands.rs b/src/groups/about/commands.rs index 2edba35..87e08a2 100644 --- a/src/groups/about/commands.rs +++ b/src/groups/about/commands.rs @@ -3,14 +3,22 @@ use async_trait::async_trait; use crate::{ extras::Extras, framework::commands::{ - arguments::{Arg, Argument, NeedyString, ParseArguments}, context::CommandContext, Command, CommandError + Command, CommandError, + arguments::{Arg, Argument, NeedyString, ParseArguments}, + context::CommandContext, }, - groups::{about::{ - components::{ - HelpDonateLinkButton, HelpGoBackButton, HelpSupportLinkButton, HelpWebsiteLinkButton, + groups::{ + about::{ + components::{ + HelpDonateLinkButton, HelpGoBackButton, HelpSupportLinkButton, + HelpWebsiteLinkButton, + }, + embeds::{ + get_all_command_help_embed, get_command_help_embed, get_command_not_found_embed, + }, }, - embeds::{get_all_command_help_embed, get_command_help_embed, get_command_not_found_embed}, - }, calls::components::CodeOfConductButton}, + calls::components::CodeOfConductButton, + }, state::State, }; diff --git a/src/groups/leveling/events.rs b/src/groups/leveling/events.rs index 897abf9..bf1b617 100644 --- a/src/groups/leveling/events.rs +++ b/src/groups/leveling/events.rs @@ -11,7 +11,9 @@ use crate::{ database::models::Channel, extras::Extras, framework::{ - commands::extras::ExtrasGetter, events::traits::{EventResult, OnMessageHandler}, runtime::Runtime + commands::extras::ExtrasGetter, + events::traits::{EventResult, OnMessageHandler}, + runtime::Runtime, }, groups::leveling::constants::KEY_LEADERBOARD_MONTHLY, state::State, diff --git a/src/utils.rs b/src/utils.rs index 139305b..2eea93e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -102,16 +102,20 @@ pub fn u64_to_i64(u: u64) -> i64 { } /// Splits at the `n`th occurrence of `pattern` counting from the end of the string. -/// +/// /// Arguments: /// * `s` - The string to split. /// * `pattern` - The pattern to split at. /// * `n` - The occurrence to split at (counting from the end). -/// +/// /// Returns: /// [`Option<(&str, &str)>`] - The splitted parts of the string, or [`None`] if no occurrences of /// `pattern` were found in `s`. -pub fn split_at_nth_from_end<'a, 'b>(s: &'a str, pattern: &'b str, n: usize) -> Option<(&'a str, &'a str)> { +pub fn split_at_nth_from_end<'a, 'b>( + s: &'a str, + pattern: &'b str, + n: usize, +) -> Option<(&'a str, &'a str)> { let mut end = s.len(); let mut count = 0; @@ -128,4 +132,4 @@ pub fn split_at_nth_from_end<'a, 'b>(s: &'a str, pattern: &'b str, n: usize) -> } None -} \ No newline at end of file +}