import discord
from discord_components import DiscordComponents, Button
client = discord.Client()
prefix = "!"
@client.event
async def on_ready():
DiscordComponents(client)
@client.event
async def on_message(message):
if message.content.startswith(prefix + "кнопки"):
await message.channel.send(
"Пример кнопок:",
components=[
Button(style=1, label="Кнопка 1"),
Button(style=2, label="Кнопка 2"),
Button(style=3, label="Кнопка 3"),
],
)
@client.event
async def on_button_click(interaction):
if interaction.component.label == "Кнопка 1":
await interaction.respond("Вы нажали на кнопку 1")
elif interaction.component.label == "Кнопка 2":
await interaction.respond("Вы нажали на кнопку 2")
elif interaction.component.label == "Кнопка 3":
await interaction.respond("Вы нажали на кнопку 3")
client.run("токен_бота")