From 0cdbe63c553b5c9341053da28a6c792ab7a5d672 Mon Sep 17 00:00:00 2001 From: Rafael Bradley Date: Tue, 12 Aug 2025 23:01:55 -0300 Subject: [PATCH] Fix lint warnings --- src/database/models.rs | 1 + src/framework/bot.rs | 14 ++++++++++++++ src/framework/commands/messages.rs | 9 +++++---- src/framework/interactions/components.rs | 4 ---- src/framework/interactions/context.rs | 18 ------------------ src/groups/calls/moderation.rs | 4 +++- 6 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/database/models.rs b/src/database/models.rs index 5c3834b..f68937f 100644 --- a/src/database/models.rs +++ b/src/database/models.rs @@ -133,6 +133,7 @@ impl<'a> Object<'a> for User { } impl User { + #[allow(dead_code)] pub async fn get_by_id(id: u64, session: &Session) -> Result, DatabaseError> { let id = u64_to_i64(id); diff --git a/src/framework/bot.rs b/src/framework/bot.rs index ce2c01b..18e5b03 100644 --- a/src/framework/bot.rs +++ b/src/framework/bot.rs @@ -132,6 +132,7 @@ impl Bot { self } + #[allow(dead_code)] pub fn on_interaction(mut self, handler: impl OnInteractionHandler + 'static) -> Self { self.on_interaction_handlers.push(Arc::new(handler)); self @@ -142,11 +143,13 @@ impl Bot { self } + #[allow(dead_code)] pub fn on_message_edit(mut self, handler: impl OnMessageEditHandler + 'static) -> Self { self.on_message_edit_handlers.push(Arc::new(handler)); self } + #[allow(dead_code)] pub fn on_message_delete(mut self, handler: impl OnMessageDeleteHandler + 'static) -> Self { self.on_message_delete_handlers.push(Arc::new(handler)); self @@ -288,6 +291,17 @@ impl Bot { .bye(); } } + Event::GuildUpdate(guild) => { + for handler in &task_bot.on_server_update_handlers { + handler + .on_server_update(&guild, task_rt.clone()) + .await + .inspect_err( + |e| log::error!("An error occurred while handling on server update for {handler:?}! {e:?}") + ) + .bye(); + } + } Event::GuildDelete(guild) => { for handler in &task_bot.on_server_delete_handlers { handler diff --git a/src/framework/commands/messages.rs b/src/framework/commands/messages.rs index dcf286f..55c4d61 100644 --- a/src/framework/commands/messages.rs +++ b/src/framework/commands/messages.rs @@ -82,7 +82,7 @@ where for (index, component) in self.components { if index != current_index { - if current_row.len() > 0 { + if !current_row.is_empty() { rows.push(current_row.build()); current_row = ActionRow::new(&[]); } @@ -101,7 +101,7 @@ where current_row.add(custom_id.clone(), component.clone()); } - if current_row.len() > 0 { + if !current_row.is_empty() { rows.push(current_row.build()); } @@ -161,6 +161,7 @@ where } } + #[allow(dead_code)] pub fn content(mut self, content: impl ToString) -> Self { self.content = Some(content.to_string()); @@ -194,7 +195,7 @@ where for (index, component) in self.components { if index != current_index { - if current_row.len() > 0 { + if !current_row.is_empty() { rows.push(current_row.build()); current_row = ActionRow::new(&[]); } @@ -213,7 +214,7 @@ where current_row.add(custom_id.clone(), component.clone()); } - if current_row.len() > 0 { + if !current_row.is_empty() { rows.push(current_row.build()); } diff --git a/src/framework/interactions/components.rs b/src/framework/interactions/components.rs index faf0eed..8786547 100644 --- a/src/framework/interactions/components.rs +++ b/src/framework/interactions/components.rs @@ -25,10 +25,6 @@ impl ActionRow { self.components.push((id, component)); } - pub fn len(&self) -> usize { - self.components.len() - } - pub fn is_empty(&self) -> bool { self.components.is_empty() } diff --git a/src/framework/interactions/context.rs b/src/framework/interactions/context.rs index fa83e8d..0654e6b 100644 --- a/src/framework/interactions/context.rs +++ b/src/framework/interactions/context.rs @@ -39,24 +39,6 @@ impl InteractionContext { Ok(()) } - pub async fn think(&self) -> Result<(), InteractionError> { - self.rt - .http - .interaction(self.rt.app.id) - .create_response( - self.event.id, - &self.event.token, - &InteractionResponse { - data: None, - kind: InteractionResponseType::DeferredChannelMessageWithSource, - }, - ) - .await - .map_err(|_| InteractionError::DeferringFailed)?; - - Ok(()) - } - pub fn original_message(&self) -> Option> { self.event.message.as_ref().map(|_| OriginalMessage { interaction_id: self.event.id, diff --git a/src/groups/calls/moderation.rs b/src/groups/calls/moderation.rs index ca754f0..eb61dd9 100644 --- a/src/groups/calls/moderation.rs +++ b/src/groups/calls/moderation.rs @@ -62,7 +62,7 @@ pub fn escape_message(event: &MessageCreate) -> String { message = message.replace(url, &"\\#".repeat(url.len())); } - let (censored, rules) = moderate_message(&message); + let (censored, _) = moderate_message(&message); log::debug!("Escaped and normalized message: {censored:?}"); @@ -216,12 +216,14 @@ pub fn moderate_message(original: &str) -> (String, Vec>) { (censored, analysis.iter().map(|(_, r)| r.clone()).collect()) } +#[allow(dead_code)] #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum Action { BlockAndPenalty, SoftCensorAndWarn, } +#[allow(dead_code)] pub trait Rule: Send + Sync { fn name(&self) -> &'static str; fn action(&self) -> &'static Action;