Create custom user select to edit the embed with selected people.
This commit is contained in:
+19
-6
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user