From 0777b71578043982408c3012f2b3a07f88fa7da2 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Wed, 8 May 2024 17:13:32 -0400 Subject: [PATCH] More filling out of the record command. The UserSelect seems to work for what I want. --- cogs/commands/record.py | 42 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/cogs/commands/record.py b/cogs/commands/record.py index 381a53b..9e5a8d1 100644 --- a/cogs/commands/record.py +++ b/cogs/commands/record.py @@ -18,7 +18,7 @@ class RecordCog(commands.Cog, name="Record Commands"): super().__init__() self.bot: commands.Bot = bot - @nextcord.slash_command() + @nextcord.slash_command(guild_ids=[1000247361639030804]) async def record(self, interaction: nextcord.Interaction): """ Parent slash command for record. Never called. @@ -28,12 +28,50 @@ class RecordCog(commands.Cog, name="Record Commands"): async def event( self, interaction: nextcord.Interaction, + name: str = nextcord.SlashOption( + required=True, description="Name of the event that was hosted." + ), host: nextcord.Member = nextcord.SlashOption( required=False, description="An alternative host if you are recording event for someone else.", ), ): # check role + if ( + interaction.guild.get_role(self.bot.config.params.event_host_role_id) + not in interaction.user.roles + ): + await interaction.response.send_message( + f"You must have the <@&{self.bot.config.params.event_host_role_id}> role to record an event.", + ephemeral=True, + ) + return + + if host is None: + host = interaction.user + + msg: str = f"Event {name} was hosted by <@{host.id}>." + + await interaction.response.send_message(msg, ephemeral=True, view=EventView()) + # create view to add members # add points to table - pass + + +class EventParticipants(nextcord.ui.UserSelect): + def __init__(self) -> None: + super().__init__( + min_values=1, + max_values=25, + ) + + async def callback(self, interaction: nextcord.Interaction): + await interaction.response.send_message(f"members selected: {self.values}") + + +class EventView(nextcord.ui.View): + def __init__(self): + super().__init__() + + # Adds the dropdown to our view object. + self.add_item(EventParticipants())