mirror of
https://github.com/revanced/revanced-discord-bot.git
synced 2025-04-30 22:44:26 +02:00
fix(moderation): only mute on rejoin if previously muted
This commit is contained in:
parent
7ea6f90ca0
commit
6e9f20df05
@ -4,7 +4,7 @@ use std::sync::Arc;
|
|||||||
use mongodb::options::FindOptions;
|
use mongodb::options::FindOptions;
|
||||||
use poise::serenity_prelude::{ChannelId, Http, User};
|
use poise::serenity_prelude::{ChannelId, Http, User};
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
use tracing::{debug, error, trace};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
use super::bot::get_data_lock;
|
use super::bot::get_data_lock;
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -43,8 +43,10 @@ pub async fn mute_on_join(ctx: &serenity::Context, new_member: &mut serenity::Me
|
|||||||
)
|
)
|
||||||
.await
|
.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
|
if new_member
|
||||||
.add_role(&ctx.http, RoleId(data.configuration.general.mute.role))
|
.add_role(&ctx.http, RoleId(data.configuration.general.mute.role))
|
||||||
.await
|
.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 {
|
} else {
|
||||||
error!("Failed to query database for muted users");
|
error!("Failed to query database for muted users");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user