@bot.command()
async def ticket(ctx):
if ctx.author.guild_permissions.administrator == True:
if settings["ticket"] == True:
view = discord.ui.View(timeout=None)
ticketBtn = discord.ui.Button(label="click me", style=discord.ButtonStyle.green)
async def ticketBtn_callback(interaction):
await interaction.response.send_message("Wotking!")
ticketBtn.callback = ticketBtn_callback
view.add_item(item=ticketBtn)
embed = discord.Embed(title=" Помощь", description=f"У вас возник вопрос или потребовалась помощь? Воспользуйтесь кнопкой ниже!", color=settings['default_color'])
await ctx.send(embed=embed, view=view)
Как внедрить меню dropdown?Как написано в документации и примерах использования dropdown
(желательно ответьте куском кода )
import discord
from discord.ext import commands
class Dropdown(discord.ui.Select):
def __init__(self):
options = [
discord.SelectOption(label='Red', description='Your favourite colour is red', emoji=''),
discord.SelectOption(label='Green', description='Your favourite colour is green', emoji=''),
discord.SelectOption(label='Blue', description='Your favourite colour is blue', emoji=''),
]
super().__init__(placeholder='Choose your favourite colour...', min_values=1, max_values=1, options=options)
async def callback(self, interaction: discord.Interaction):
await interaction.response.send_message(f'Your favourite colour is {self.values[0]}')
class DropdownView(discord.ui.View):
def __init__(self):
super().__init__()
self.add_item(Dropdown())
class Bot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
super().__init__(command_prefix=commands.when_mentioned_or('$'), intents=intents)
async def on_ready(self):
print(f'Logged in as {self.user} (ID: {self.user.id})')
print('------')
bot = Bot()
@bot.command()
async def colour(ctx):
view = DropdownView()
await ctx.send('Pick your favourite colour:', view=view)
bot.run('token')