From a20449f7b24d40e8db185b723a7118ba4125ad71 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Tue, 19 Apr 2022 11:47:38 -0600 Subject: [PATCH] Fix star add issues with deleted channels --- jarvis/cogs/starboard.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/jarvis/cogs/starboard.py b/jarvis/cogs/starboard.py index b0bfccf..27681b1 100644 --- a/jarvis/cogs/starboard.py +++ b/jarvis/cogs/starboard.py @@ -2,7 +2,6 @@ import logging from dis_snek import InteractionContext, Permissions, Scale, Snake -from dis_snek.client.utils.misc_utils import find from dis_snek.models.discord.channel import GuildText from dis_snek.models.discord.components import ActionRow, Select, SelectOption from dis_snek.models.discord.message import Message @@ -130,8 +129,21 @@ class StarboardCog(Scale): return channel_list = [] + to_delete = [] for starboard in starboards: - channel_list.append(find(lambda x: x.id == starboard.channel, ctx.guild.channels)) + channel = await ctx.guild.fetch_channel(starboard.channel) + if channel: + channel_list.append(channel) + else: + to_delete.append(starboard) + + for starboard in to_delete: + await starboard.delete() + + select_channels = [] + for idx, x in enumerate(channel_list): + if x: + select_channels.append(SelectOption(label=x.name, value=str(idx))) select_channels = [ SelectOption(label=x.name, value=str(idx)) for idx, x in enumerate(channel_list)