From 153ec0ab1c014a4d35d3f1afe3ddf4cc5e470631 Mon Sep 17 00:00:00 2001 From: NTGNguyen <23521049@gm.uit.edu.vn> Date: Tue, 21 Jan 2025 13:42:29 +0700 Subject: [PATCH] fix: just send to sendable channel --- src/cpn_core/notifications/engines/discord.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cpn_core/notifications/engines/discord.py b/src/cpn_core/notifications/engines/discord.py index 0adb431..859edf5 100644 --- a/src/cpn_core/notifications/engines/discord.py +++ b/src/cpn_core/notifications/engines/discord.py @@ -2,15 +2,15 @@ from typing import override from discord import ( + CategoryChannel, Client, - DMChannel, Forbidden, - GroupChannel, + ForumChannel, HTTPException, Intents, - TextChannel, User, ) +from discord.abc import PrivateChannel from cpn_core.notifications.models.discord import DiscordNotificationEngineConfig @@ -19,7 +19,6 @@ logger = getLogger(__name__) -# FIXME: @NTGNguyen: fetch channel, id bla bla bla. The command_prefix seem bruh? not relate class _DiscordNotificationCoreEngine: def __init__( self, @@ -37,12 +36,12 @@ async def _send_channel(self) -> None: logger.error(f"Discord channel ID {self.discord.chat_id}: Not found") return if ( - not isinstance(channel, TextChannel) - or not isinstance(channel, GroupChannel) - or not isinstance(channel, DMChannel) + isinstance(channel, ForumChannel) + or isinstance(channel, CategoryChannel) + or isinstance(channel, PrivateChannel) ): logger.error( - f"Discord channel ID {self.discord.chat_id}: Must be text channel" + f"Discord channel ID {self.discord.chat_id} is not sendable channel" ) return for message in self._messages: