import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
bot = commands.Bot(command_prefix="!", intents=intents)
DiscordComponents(bot)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user.name}")
@bot.command()
async def button_example(ctx):
button = Button(style=ButtonStyle.blue, label="Click Me!")
await ctx.send("This is an example of a button!", components=button)
@bot.event
async def on_button_click(ctx):
if ctx.component.id == "your_button_id":
await ctx.send(f"{ctx.author.mention} clicked the button!")
bot.run("your_discord_bot_token")