Discord.py Buat tombol
We need the Libary: discord.py-message-components
You can download it so: py -m pip install -U git+https://github.com/mccoderpy/discord.py-message-components.git@developer
But first Uninstall discord.py
With this Libary you can make Selects, Buttons, Modals, Slash Commands or other stuff!
Docs: https://discordpy-message-components.readthedocs.io/en/latest/
And how to make a button?
With:
from discord import ActionRow, Button, ButtonStyle
@bot.command()
async def button(ctx):
components = [
ActionRow(
Button(label="Button", emoji="❤", custom_id="customid", style=ButtonStyle.green) # <= This is the Button
)
]
@bot.on_click() # <= This is the event if someone clicked on the button!
async def customid(i: discord.ComponentInteraction, button): # <= customid is the custom id of the button!
await i.respond(f'Thanks for clicking {i.author.mention}', hidden=True) # <= Its send a Ephermal Message with the Text: "Thanks for clicking User"
Hayoto Dev