Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- client = commands.Bot(command_prefix="!", intents=discord.Intents.default())
- tree = client.tree
- @client.event
- async def on_ready():
- print(f"Logged in as {client.user}")
- synced = await tree.sync()
- print(f"Synced {len(synced)} Command(s).")
- class Dropdown(discord.ui.Select):
- def __init__(self):
- options = [
- discord.SelectOption(label="Select 1", description="First Select Option"),
- discord.SelectOption(label="Select 2", description="Second Select Option"),
- discord.SelectOption(label="Select 3", description="Third Select Option"),
- discord.SelectOption(label="Select 4", description="Fourth Select Option"),
- discord.SelectOption(label="Select 5", description="Fifth Select Option"),
- ]
- super().__init__(placeholder="Select an element", min_values=2, max_values=3, options=options)
- async def callback(self, interaction: discord.Interaction):
- elements = ",".join(x for x in self.values)
- await interaction.response.send_message(f"You chose {elements}")
- class DropdownView(discord.ui.View):
- def __init__(self):
- super().__init__()
- self.add_item(Dropdown())
- @tree.command(name="select")
- async def _select(interaction: discord.Interaction):
- await interaction.response.send_message(view=DropdownView())
- client.run("TOKEN")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement