Fix lint warnings

This commit is contained in:
2025-08-12 23:01:55 -03:00
parent ed717ef94b
commit 0cdbe63c55
6 changed files with 23 additions and 27 deletions
+1
View File
@@ -133,6 +133,7 @@ impl<'a> Object<'a> for User {
} }
impl User { impl User {
#[allow(dead_code)]
pub async fn get_by_id(id: u64, session: &Session) -> Result<Option<Self>, DatabaseError> { pub async fn get_by_id(id: u64, session: &Session) -> Result<Option<Self>, DatabaseError> {
let id = u64_to_i64(id); let id = u64_to_i64(id);
+14
View File
@@ -132,6 +132,7 @@ impl<T: 'static + Send + Sync> Bot<T> {
self self
} }
#[allow(dead_code)]
pub fn on_interaction(mut self, handler: impl OnInteractionHandler<T> + 'static) -> Self { pub fn on_interaction(mut self, handler: impl OnInteractionHandler<T> + 'static) -> Self {
self.on_interaction_handlers.push(Arc::new(handler)); self.on_interaction_handlers.push(Arc::new(handler));
self self
@@ -142,11 +143,13 @@ impl<T: 'static + Send + Sync> Bot<T> {
self self
} }
#[allow(dead_code)]
pub fn on_message_edit(mut self, handler: impl OnMessageEditHandler<T> + 'static) -> Self { pub fn on_message_edit(mut self, handler: impl OnMessageEditHandler<T> + 'static) -> Self {
self.on_message_edit_handlers.push(Arc::new(handler)); self.on_message_edit_handlers.push(Arc::new(handler));
self self
} }
#[allow(dead_code)]
pub fn on_message_delete(mut self, handler: impl OnMessageDeleteHandler<T> + 'static) -> Self { pub fn on_message_delete(mut self, handler: impl OnMessageDeleteHandler<T> + 'static) -> Self {
self.on_message_delete_handlers.push(Arc::new(handler)); self.on_message_delete_handlers.push(Arc::new(handler));
self self
@@ -288,6 +291,17 @@ impl<T: 'static + Send + Sync> Bot<T> {
.bye(); .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) => { Event::GuildDelete(guild) => {
for handler in &task_bot.on_server_delete_handlers { for handler in &task_bot.on_server_delete_handlers {
handler handler
+5 -4
View File
@@ -82,7 +82,7 @@ where
for (index, component) in self.components { for (index, component) in self.components {
if index != current_index { if index != current_index {
if current_row.len() > 0 { if !current_row.is_empty() {
rows.push(current_row.build()); rows.push(current_row.build());
current_row = ActionRow::new(&[]); current_row = ActionRow::new(&[]);
} }
@@ -101,7 +101,7 @@ where
current_row.add(custom_id.clone(), component.clone()); current_row.add(custom_id.clone(), component.clone());
} }
if current_row.len() > 0 { if !current_row.is_empty() {
rows.push(current_row.build()); rows.push(current_row.build());
} }
@@ -161,6 +161,7 @@ where
} }
} }
#[allow(dead_code)]
pub fn content(mut self, content: impl ToString) -> Self { pub fn content(mut self, content: impl ToString) -> Self {
self.content = Some(content.to_string()); self.content = Some(content.to_string());
@@ -194,7 +195,7 @@ where
for (index, component) in self.components { for (index, component) in self.components {
if index != current_index { if index != current_index {
if current_row.len() > 0 { if !current_row.is_empty() {
rows.push(current_row.build()); rows.push(current_row.build());
current_row = ActionRow::new(&[]); current_row = ActionRow::new(&[]);
} }
@@ -213,7 +214,7 @@ where
current_row.add(custom_id.clone(), component.clone()); current_row.add(custom_id.clone(), component.clone());
} }
if current_row.len() > 0 { if !current_row.is_empty() {
rows.push(current_row.build()); rows.push(current_row.build());
} }
-4
View File
@@ -25,10 +25,6 @@ impl<T> ActionRow<T> {
self.components.push((id, component)); self.components.push((id, component));
} }
pub fn len(&self) -> usize {
self.components.len()
}
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.components.is_empty() self.components.is_empty()
} }
-18
View File
@@ -39,24 +39,6 @@ impl<T> InteractionContext<T> {
Ok(()) 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<OriginalMessage<T>> { pub fn original_message(&self) -> Option<OriginalMessage<T>> {
self.event.message.as_ref().map(|_| OriginalMessage { self.event.message.as_ref().map(|_| OriginalMessage {
interaction_id: self.event.id, interaction_id: self.event.id,
+3 -1
View File
@@ -62,7 +62,7 @@ pub fn escape_message(event: &MessageCreate) -> String {
message = message.replace(url, &"\\#".repeat(url.len())); 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:?}"); log::debug!("Escaped and normalized message: {censored:?}");
@@ -216,12 +216,14 @@ pub fn moderate_message(original: &str) -> (String, Vec<Arc<dyn Rule>>) {
(censored, analysis.iter().map(|(_, r)| r.clone()).collect()) (censored, analysis.iter().map(|(_, r)| r.clone()).collect())
} }
#[allow(dead_code)]
#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Action { pub enum Action {
BlockAndPenalty, BlockAndPenalty,
SoftCensorAndWarn, SoftCensorAndWarn,
} }
#[allow(dead_code)]
pub trait Rule: Send + Sync { pub trait Rule: Send + Sync {
fn name(&self) -> &'static str; fn name(&self) -> &'static str;
fn action(&self) -> &'static Action; fn action(&self) -> &'static Action;