""" Contained commands and views for record commands. """ import nextcord from nextcord.ext import commands class RecordCog(commands.Cog, name="Record Commands"): """ Class holds record commands. """ def __init__(self, bot) -> None: """ Default constructor for RecordCog class. Does nothing. """ super().__init__() self.bot: commands.Bot = bot @nextcord.slash_command(guild_ids=[1000247361639030804]) async def record(self, interaction: nextcord.Interaction): """ Parent slash command for record. Never called. """ @record.subcommand(description="Record an event and its participants.") 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 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())