diff --git a/lenaverse_bot/core/bot.py b/lenaverse_bot/core/bot.py index 1f8b8e0..eec0146 100644 --- a/lenaverse_bot/core/bot.py +++ b/lenaverse_bot/core/bot.py @@ -11,7 +11,6 @@ _logger = logging.getLogger(__name__) class LenaverseBot(discord.Client): def __init__(self) -> None: intents = discord.Intents.default() - intents.message_content = True super().__init__(intents=intents) diff --git a/lenaverse_bot/core/config.py b/lenaverse_bot/core/config.py index ab4911b..2c32d46 100644 --- a/lenaverse_bot/core/config.py +++ b/lenaverse_bot/core/config.py @@ -1,4 +1,3 @@ -import logging import os import tomllib from typing import Self @@ -6,44 +5,23 @@ from typing import Self import discord from pydantic import BaseModel -_logger = logging.getLogger(__name__) +class Post(BaseModel): + channel: int + users: list[int] -class PostTarget(BaseModel): - server: str - channel: str - thread: str - - def get(self, client: discord.Client) -> discord.Thread: + def get_channel( + self, + client: discord.Client, + ) -> discord.Thread | discord.TextChannel: """ Zielkanal für Posts finden """ - guilds = [guild for guild in client.guilds if guild.name == self.server] - _logger.debug(f"Guilds: {[guild.name for guild in guilds]}") - assert len(guilds) == 1 + channel = client.get_channel(self.channel) + assert isinstance(channel, discord.Thread | discord.TextChannel) - channels = [ - channel - for channel in guilds[0].channels - if isinstance(channel, discord.TextChannel | discord.ForumChannel) - and channel.name == self.channel - ] - _logger.debug(f"channels: {[channel.name for channel in channels]}") - assert len(channels) == 1 - - threads = [ - thread for thread in channels[0].threads if thread.name == self.thread - ] - _logger.debug(f"threads: {[thread.name for thread in threads]}") - assert len(threads) == 1 - - return threads[0] - - -class Post(BaseModel): - target: PostTarget - users: list[int] + return channel class Config(BaseModel): diff --git a/lenaverse_bot/core/post.py b/lenaverse_bot/core/post.py index 6d7d9bf..be57659 100644 --- a/lenaverse_bot/core/post.py +++ b/lenaverse_bot/core/post.py @@ -75,7 +75,7 @@ class PostModal(ui.Modal, title="Post verfassen"): _logger.info( f"User {interaction.user.name}({interaction.user.id}) published a /post" ) - target = CONFIG.post.target.get(interaction.client) + target = CONFIG.post.get_channel(interaction.client) await target.send(post_content) elif view.action is Action.ABORT: