Skip to content

Commit

Permalink
Move check_filters to a separate trait
Browse files Browse the repository at this point in the history
  • Loading branch information
tapnisu committed Mar 17, 2024
1 parent e47b191 commit 3ad8961
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ pub struct Handler {
pub hide_usernames: bool,
}

#[async_trait]
impl EventHandler for Handler {
async fn message(&self, ctx: Context, msg: Message) {
if (!self
impl Handler {
fn check_filters(&self, msg: &Message) -> bool {
(!self
.allowed_guilds_ids
.contains(&msg.guild_id.unwrap_or_default().0)
&& !self.allowed_guilds_ids.is_empty())
Expand All @@ -39,7 +38,13 @@ impl EventHandler for Handler {
|| (!self.allowed_users_ids.contains(&msg.author.id.0)
&& !self.allowed_users_ids.is_empty())
|| (self.muted_users_ids.contains(&msg.author.id.0) && !self.muted_users_ids.is_empty())
{
}
}

#[async_trait]
impl EventHandler for Handler {
async fn message(&self, ctx: Context, msg: Message) {
if self.check_filters(&msg) {
return;
}

Expand Down

0 comments on commit 3ad8961

Please sign in to comment.