From 905314cfb5e6344d192e91af37a7e586c0dbaa3a Mon Sep 17 00:00:00 2001 From: imcompiling Date: Thu, 9 May 2024 16:37:45 -0400 Subject: [PATCH] Create custom user select to edit the embed with selected people. --- cogs/commands/record.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/cogs/commands/record.py b/cogs/commands/record.py index 42ca1dc..390b6a6 100644 --- a/cogs/commands/record.py +++ b/cogs/commands/record.py @@ -75,12 +75,7 @@ class EventView(nextcord.ui.View): self.name: str = name self.config: DakinyConfig = config - self.event_participants = nextcord.ui.UserSelect( - min_values=1, - max_values=25, - placeholder="Select all participants", - row=0, - ) + self.event_participants = ParticipantSelect() self.add_item(self.event_participants) @@ -153,3 +148,21 @@ class ParticipantModal(nextcord.ui.Modal): ) await interaction.response.edit_message(embed=self.embed) + + +class ParticipantSelect(nextcord.ui.UserSelect): + def __init__(self) -> None: + super().__init__( + min_values=1, + max_values=25, + placeholder="Select all participants", + row=0, + ) + + async def callback(self, interaction: nextcord.Interaction): + embed: nextcord.Embed = interaction.message.embeds[0] + participants: str = "\n".join( + [f"<@{participant.id}>" for participant in self.values.members] + ) + embed.set_field_at(0, name="Participants", value=participants) + await interaction.response.edit_message(embed=embed)