From 6060a3df8323f22895a026e03100fb53426f6bc3 Mon Sep 17 00:00:00 2001 From: kku Date: Fri, 27 Dec 2024 20:16:30 +0100 Subject: [PATCH] Closes #18 --- cogs/logger.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cogs/logger.py b/cogs/logger.py index 8a7f08e..67b3bd1 100644 --- a/cogs/logger.py +++ b/cogs/logger.py @@ -1,6 +1,7 @@ +import logging from typing import Dict, Any -from discord import Member, Message, TextChannel +from discord import Member, Message, TextChannel, MessageType from discord import utils as ds_utils from discord.ext import commands from libbot.utils import config_get @@ -8,6 +9,8 @@ from libbot.utils import config_get from classes.holo_bot import HoloBot from modules.database import col_users +logger = logging.getLogger(__name__) + class Logger(commands.Cog): def __init__(self, client: HoloBot): @@ -31,6 +34,16 @@ class Logger(commands.Cog): await col_users.insert_one(document=user) + if ( + (message.type == MessageType.thread_created) + and (message.channel is not None) + and ( + await col_users.count_documents({"customchannel": message.channel.id}) + > 0 + ) + ): + await message.delete() + @commands.Cog.listener() async def on_member_join(self, member: Member) -> None: welcome_chan: TextChannel | None = ds_utils.get( @@ -42,6 +55,9 @@ class Logger(commands.Cog): id=await config_get("rules", "channels", "text"), ) + if welcome_chan is None: + logger.warning("Could not find a welcome channel by its id") + if ( (member != self.client.user) and (member.bot is False)