Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs

Discord Buttons - A library for creating reaction buttons easily in



DiscordButtons is an extension to the discordpy framework that allows you to create cool reaction buttons more easily.

Before click:

After click:

Normally, writing this would be annoying. In the example below, I use DBtns to make the process a lot simpler.

from discordbuttons import DBtns @client.command() async def hello(ctx): msg = await ctx.send("Hello") # Save the message that we want the button to appear on in a variable. btns = DBtns(client, msg, # Create DBtns instance and provide a client object, message and author. client.add_cog(btns) # Add it as a cog (for permissions). await btns.add_button("✔", send_hi, { "name": name }) # Add the button with the check mark emoji, passing data to the callback. async def send_hi(message, user, allowed_user, data): if == # check if the right user clicked the button await"Hi, " + data["name"] + "!")

Creating a new bot with DiscordButtons

Fork the template at the bottom of this page to get started. It's easy!

Adding DiscordButtons to an existing discordpy bot

To add discordbuttons to an existing bot, go to the template at the bottom of the page. Click on "files" and select and copy all the code inside it. Then, go to your repl or a local bot and create a file named, then paste all the code you copied earlier in there. Finally, add from discordbuttons import DBtns. You now have access to all the features of DiscordButtons.

Note: I plan to upload this package to PyPi soon, but I will not do it yet.


class DBtns (extends commands.Cog)

You are meant to use this class as a cog.

  • __init__(bot, message, user = None, clear_buttons = True)

    • bot: Your commands.Bot or discord.Client instance. Usually client or bot.
    • user: The person that sent the command or triggered the buttons to appear. This user will be passed into events.
    • clear_buttons: Whether or not to remove all the reactions after the button has been clicked.
  • async add_button(emoji = '✅', on_click = print_hello_world, data = {}):

    • emoji: The emoji to add as a reaction.
    • on_click: Function to be called when the button is clicked. Arguments are passed:
      • message: Message that the button was created on.
      • user: User who clicked the button.
      • allowed_user: User who created the button (passed to __init__).
      • data: Data passed to add_button.
1 year ago
You are viewing a single comment. View All