This commit is contained in:
kku 2024-12-27 20:16:30 +01:00
parent eed084cd91
commit 6060a3df83

View File

@ -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)