Create custom user select to edit the embed with selected people.

This commit is contained in:
2024-05-09 16:37:45 -04:00
parent bd3debf025
commit 905314cfb5
+19 -6
View File
@@ -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)