Untitled
unknown
plain_text
4 years ago
1.2 kB
5
Indexable
class MySelect(disnake.ui.Select): def __init__(self): options = [ disnake.SelectOption( label="Victorsitou", description="Victorsitou is player 1", value="player1" ), disnake.SelectOption( label="Victorsitou 2", description="Victorsitou 2 is not pro", value="player2" ), ] super().__init__(custom_id="room1", placeholder="Room players here.", options=options) def delete_option(self, option_value: str): for n, option in enumerate(self._underlying.options): if option.value == option_value: del self._underlying.options[n] async def callback(self, inter: disnake.MessageInteraction): self.delete_option(inter.values[0]) # self.add_option(label="Victorsitou 3", description="what", value="player3") # Note that if the value is already in the select menu, it'll raise a HTTPException error try: await inter.response.edit_message(view=self.view) except disnake.HTTPException: # This error will be raised if the select menu is empty pass
Editor is loading...