Geocrack

select menus discord

Sep 18th, 2022
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. import discord
  2. from discord.ui import Select, View
  3. from discord.ext.commands.context import Context
  4. from discord.ext import commands
  5.  
  6.  
  7. intents = discord.Intents.all()
  8. bot = commands.Bot(intents=intents, command_prefix="*")
  9.  
  10. TOKEN = ""
  11.  
  12. @bot.event
  13. async def on_ready():
  14.     name_bot = bot.user.name
  15.     print(f"{'-'*45}\nDiscord Bot ist online als {name_bot}\n{'-'*45}")
  16.  
  17.  
  18. @bot.command(name="message")
  19. async def send_message(ctx: Context):
  20.     select = Select(
  21.         min_values=1,
  22.         max_values=4,
  23.         placeholder="Suche deine Rolle aus",
  24.         options=[
  25.         discord.SelectOption(label="Gamer", emoji="🎮",
  26.                              description="Eine Rolle für Gamer"),
  27.         discord.SelectOption(label="Student", emoji="👨‍🎓",
  28.                              description="Eine Rolle für Studenten"),
  29.         discord.SelectOption(label="Gamer_2", emoji="🎮",
  30.                              description="Eine Rolle für Gamer"),
  31.         discord.SelectOption(label="Student_2", emoji="👨‍🎓",
  32.                              description="Eine Rolle für Studenten")
  33.     ])
  34.     async def my_callback(interaction):
  35.         await interaction.response.send_message(f"Deine Auswahl ist: {select.values}")
  36.     select.callback = my_callback
  37.     view = View()
  38.     view.add_item(select)
  39.     await ctx.send("Suche eine Rolle aus", view=view)
  40.  
  41.  
  42. bot.run(TOKEN)
  43.  
Advertisement
Add Comment
Please, Sign In to add comment