Fix star add issues with deleted channels
This commit is contained in:
parent
785f67c9c4
commit
a20449f7b2
1 changed files with 14 additions and 2 deletions
|
@ -2,7 +2,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from dis_snek import InteractionContext, Permissions, Scale, Snake
|
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.channel import GuildText
|
||||||
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
|
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
|
||||||
from dis_snek.models.discord.message import Message
|
from dis_snek.models.discord.message import Message
|
||||||
|
@ -130,8 +129,21 @@ class StarboardCog(Scale):
|
||||||
return
|
return
|
||||||
|
|
||||||
channel_list = []
|
channel_list = []
|
||||||
|
to_delete = []
|
||||||
for starboard in starboards:
|
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 = [
|
select_channels = [
|
||||||
SelectOption(label=x.name, value=str(idx)) for idx, x in enumerate(channel_list)
|
SelectOption(label=x.name, value=str(idx)) for idx, x in enumerate(channel_list)
|
||||||
|
|
Loading…
Add table
Reference in a new issue