From fde17edf0955449f7c095cadbad11fb58fdf9662 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Thu, 9 May 2024 20:53:48 -0400 Subject: [PATCH] Have to make sure things exist before making list of them. Don't delete the embed before done using it. --- cogs/commands/record.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cogs/commands/record.py b/cogs/commands/record.py index 6c2cf91..9b8df1a 100644 --- a/cogs/commands/record.py +++ b/cogs/commands/record.py @@ -76,8 +76,6 @@ class RecordCog(commands.Cog, name="Record Commands"): embed=embed, ) - # add points to table - class EventView(nextcord.ui.View): """ @@ -125,6 +123,19 @@ class EventView(nextcord.ui.View): Submits the event embed to the event channel. Removes view and embed from recording message. Sends point information to database. """ + + discord_users = self.event_participants.values.members + if discord_users: + discord_users_list: list[str] = [str(user.id) for user in discord_users] + record_event_participation(self.config, discord_users_list, True) + + non_discord_users = interaction.message.embeds[0].fields[1].value + if non_discord_users: + non_discord_users_list: list[str] = non_discord_users.split("\n") + record_event_participation(self.config, non_discord_users_list, False) + + record_event_host(self.config, self.host_id) + event_channel: nextcord.TextChannel = interaction.guild.get_channel( self.config.params.event_post_channel_id ) @@ -133,17 +144,6 @@ class EventView(nextcord.ui.View): content="Event has been submitted.", view=None, embed=None ) - discord_users: list[str] = [ - str(user.id) for user in self.event_participants.values.members - ] - non_discord_users: list[str] = ( - interaction.message.embeds[0].fields[1].value.split("\n") - ) - - record_event_participation(self.config, discord_users, True) - record_event_participation(self.config, non_discord_users, False) - record_event_host(self.config, self.host_id) - self.stop()