fix(moderation): only mute on rejoin if previously muted

This commit is contained in:
oSumAtrIX 2022-10-07 11:03:12 +02:00
parent 7ea6f90ca0
commit 6e9f20df05
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -4,7 +4,7 @@ use std::sync::Arc;
use mongodb::options::FindOptions;
use poise::serenity_prelude::{ChannelId, Http, User};
use tokio::task::JoinHandle;
use tracing::{debug, error, trace};
use tracing::{debug, error};
use super::bot::get_data_lock;
use super::*;
@ -43,8 +43,10 @@ pub async fn mute_on_join(ctx: &serenity::Context, new_member: &mut serenity::Me
)
.await
{
if cursor.advance().await.is_ok() {
trace!("Muted member {} rejoined the server", new_member.user.tag());
if let Ok(found) = cursor.advance().await {
if found {
debug!("Muted member {} rejoined the server", new_member.user.tag());
if new_member
.add_role(&ctx.http, RoleId(data.configuration.general.mute.role))
.await
@ -61,6 +63,9 @@ pub async fn mute_on_join(ctx: &serenity::Context, new_member: &mut serenity::Me
);
}
}
} else {
error!("Failed to advance the cursor");
}
} else {
error!("Failed to query database for muted users");
}