Re-mute user on join if they are still muted
This commit is contained in:
parent
16a0a591b4
commit
d11916e5aa
1 changed files with 20 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
from pathlib import Path
|
||||
import pymongo
|
||||
from datetime import datetime, timedelta
|
||||
from discord import Intents
|
||||
from discord import Intents, Member
|
||||
from discord.ext import commands
|
||||
from discord.ext.tasks import loop
|
||||
from discord.utils import find, get
|
||||
|
@ -49,6 +49,25 @@ async def on_ready():
|
|||
restart_ctx = None
|
||||
|
||||
|
||||
@jarvis.event
|
||||
async def on_member_join(user: Member):
|
||||
guild = user.guild
|
||||
db = DBManager(get_config().mongo).mongo
|
||||
mutes = list(
|
||||
db.jarvis.mutes.find(
|
||||
{"active": True, "user": user.id, "guild": guild.id}
|
||||
)
|
||||
)
|
||||
if mutes and len(mutes) >= 1:
|
||||
mute_role = db.jarvis.settings.find_one(
|
||||
{"guild": guild.id, "setting": "mute"}
|
||||
)
|
||||
role = guild.get_role(mute_role["role"])
|
||||
user.add_roles(
|
||||
role, reason="User is muted still muted from prior mute"
|
||||
)
|
||||
|
||||
|
||||
@jarvis.event
|
||||
async def on_guild_join(guild):
|
||||
general = find(lambda x: x.name == "general", guild.channels)
|
||||
|
|
Loading…
Add table
Reference in a new issue