Skip to content

A Discord role bot (auto roles and role buttons), built from blocks

Two common jobs: give a role to everyone who joins, and let members choose their own roles with a button. Both use the *Add Role* and *Remove Role* blocks, with a different trigger.

How to build it

  1. Auto role. Create a command with an Event trigger on Guild Member Add and add Add Role with the user set to ((member.id)) and the ID of the role to give.
  2. Role button. In a command, send a message with Send Message (or Respond with Message) that carries a button with a custom ID such as role_news.
  3. Create an Event trigger on interactionCreate with the custom ID filter role_news. Add Add Role with the user set to ((interaction.userId)) and the role ID, then Respond with Message with a private reply to confirm.
  4. Add a second button and flow with Remove Role if members should be able to leave the role.

Blocks you will use

Block names are the ones of the app; each links to its entry in the dictionary.

What to know

  • The bot needs the Manage Roles permission, and its role must sit above every role it gives (Discord rule).
  • A button does one action. For a toggle, make two buttons (add and remove) or build the check yourself with an IF / ELSE Block.
  • Join events need the Server Members Intent, as in the welcome bot.

Go further

Other things you can build