From d82999b1412b27c93681d58e9889f3dba1ce4422 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Thu, 20 Mar 2025 09:50:31 -0400 Subject: [PATCH] Check for channel being None. Allow groups to be posted in threads. --- agon/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/agon/utils.py b/agon/utils.py index bb4a74c..5fed6db 100644 --- a/agon/utils.py +++ b/agon/utils.py @@ -342,11 +342,13 @@ async def send_highscore_message(session: Session, guild: nextcord.Guild, group: group (CategoryGroup): group to post to the message. """ highscore_string = format_highscore_message(session, group) - channel = guild.get_channel(group.channel_id) + if (channel := guild.get_channel(group.channel_id)) is None: + agon_logger.error("Channel id %s in guild %s does not exist.", group.channel_id, guild.id) + return - if not isinstance(channel, nextcord.TextChannel): + if not isinstance(channel, nextcord.TextChannel) or not isinstance(channel, nextcord.Thread): agon_logger.error( - "Channel id %s in guild %s is does not correspond to a TextChannel.", channel.id, channel.guild.id + "Channel id %s in guild %s is does not correspond to a TextChannel or Thread.", channel.id, channel.guild.id ) return