Reaction Light - Discord Role Bot

Easy to use reaction role Discord bot written in Python.

Light yet powerful reaction role bot coded in discord.py.

Key Features

  • Create multiple custom embedded messages with custom reactions and roles
  • Automatically assign/remove roles to users when they select/deselect a certain reaction
  • Optionally limit users to select one reaction (and role) at a time
  • Use the same instance of the bot on multiple servers
  • Easy installation, setup, and updating
  • Optional update notifications and error reporting to your own Discord server
  • No need to rely on developer mode and IDs
  • Multiple languages

You can host the bot yourself by configuring the config.ini file (manually or via setup.py).

Requirements

This bot requires discord.py and Python 3.6+.

You can get discord.py (and other dependencies) via PyPI:

python3 -m pip install -U discord.py

Setup

  • Clone the repository using git clone https://github.com/eibex/reaction-light.git (or download it as a *.zip file and extract it - it is recommended to use git instead of the zip archive)
    • git comes pre-installed on most Linux-based operating systems. On Windows, if you are not familiar with git, you can use GitHub Desktop
  • Run setup.py and follow the instructions or create a config.ini file (example provided in config.ini.sample) and edit it manually:
    • Insert the token of your bot (found at: https://discord.com/developers/applications/)
      • Make sure you enabled the server members intent on your bot developer page
    • Choose a prefix of your liking (default: rl!)
    • Set a name to appear in embed footers (default: Reaction Light)
    • URL of the footer logo (default: same as picture above)
    • Hexadecimal value of embeds (default: 0xffff00 (yellow))
  • Optional: Edit the activities.csv file (example provided in activities.csv.sample):
    • In each row (line), add the activity the bot will display (playing <activity>). The bot will loop through them every 30 seconds.
    • If you want a static activity just add one line.
    • Do not use commas ,.
  • Invite the bot to your server(s) with enough permissions (Manage Roles, Manage Channels, Send Messages, Manage Messages, Add Reactions)
  • On your Discord server, go to: Server Settings > Roles and move Reaction Light in a position that is above all roles that it needs to add/remove. The bot only has permission to manage the roles below its own role.
  • Run rl!admin @Role to give users with that role permission to create reaction-role messages (even administrators need it). You need to be a server administrator to use this command.

Running the bot

The bot can be run by using:

python3 bot.py

To run it as a background task (recommended unless debugging):

nohup python3 bot.py &

Commands

All commands require an admin role which you can set by using rl!admin (requires administrator permissions on the server). The bot will reply with missing permissions otherwise. Executing a command without any argument will prompt the bot to provide you with instructions on how to use the command effectively. In the following list the default prefix rl! is used, but it can be freely changed in the config.ini file.

  • rl!help shows this set of commands along with a link to the repository.
  • rl!new starts the creation process for a new reaction role message. Check below for an example.
  • rl!edit edits the text and embed of an existing reaction role message.
  • rl!reaction adds or removes a reaction from an existing reaction role message.
  • rl!notify toggles sending messages to users when they get/lose a role (default off) for the current server (the command affects only the server it was used in).
  • rl!colour changes the colour of the embeds of new and newly edited reaction role messages.
  • rl!activity adds an activity for the bot to loop through and show as status.
  • rl!rm-activity removes an activity from the bot's list.
  • rl!activitylist lists the current activities used by the bot as statuses.
  • rl!admin adds the mentioned role or role id to the admin list, allowing members with a certain role to use the bot commands. Requires administrator permissions on the server.
  • rl!rm-admin removes the mentioned role or role id from the admin list, preventing members with a certain role from using the bot commands. Requires administrator permissions on the server.
  • rl!adminlist lists the current admins on the server the command was run in by mentioning them and the current admins from other servers by printing out the role IDs. Requires administrator permissions on the server.
  • rl!kill shuts down the bot.
  • rl!systemchannel updates the main or server system channel where the bot sends errors and update notifications.
  • rl!restart restarts the bot.
  • rl!update updates the bot and restarts it. Only works on git clone installations. Check the setup section to learn how to install with git.
  • rl!version reports the bot's current version and the latest available one from GitHub.
  • rl!language sets a new language for the bot. Currently available languages are: en-gb (English), it-it (Italian).

Usage Example

In this example the prefix used is rl!. Once you initiate the process, be sure only to answer to the bots questions or the bot might record unwanted messages as instructions. You can still send messages to other channels, and others can send messages to the channel you initiated the process in.

Initiate the message creation process with rl!new.

User: rl!new

Next, you will be asked to attach emojis to roles. Only use standard emojis or those that are hosted on servers the bot has access to. Send a single message for each single combination and then type done when you have finished attaching emojis to their respective roles. Ensure that the roles are mentionable when you are doing this step. You can disable mentions after finishing this step.

Bot: Attach roles and emojis separated by a space (one combination per message).
When you are done type `done`. Example:
:smile: `@Role`
User: :rage: @AngryRole
User: :sob: @SadRole
User: :cry: @EvenSadderRole
User: :joy: @HappyRole
User: done

Next, you will be asked if you want to allow users to select multiple reactions (and role) at a time or not. Then, you will be asked to either create a new message or use an existing one. Using an existing message will prevent you from using rl!edit if the target message wasn't created by the bot. If you choose to use an already existing message simply react to it with ![wrench](https://github.githubassets.com/images/icons/emoji/unicode/1f527.png =20x20), the bot will remove the ![wrench](https://github.githubassets.com/images/icons/emoji/unicode/1f527.png =20x20) reaction and add the ones you chose.

Otherwise, you will have to customise the message that the bot is going to send with the roles attached to it. Enter a title and the content of your message by separating them with // (the space before and after // is important).

Bot: What would you like the message to say? Formatting is: `Message // Embed_title // Embed_content`. `Embed_title` and `Embed_content` are optional. You can type `none` in any of the argument fields above (e.g. `Embed_title`) to make the bot ignore it.
User: none // Select your roles // Click on the buttons below to give yourself some roles!

Finally, the bot will send the message to the channel specified and it will react with each reactions specified so that the buttons are ready to be used (or just add the reactions if you chose to use an existing message). The bot will remove any new reactions to the message to avoid clutter. For example, if you added an :eggplant: reaction to the message created in this example, the bot will remove it as it is not attached to any role.

Updating

You can view new features in the changelog.

If you set a system channel in config.ini, your bot will check for new versions from this repository. If updates are available a message is sent briefly outlining the update process. This process varies depending on how you installed the bot.

Update a git install with a command

Type rl!update to update the bot and restart it.

Manually updating a git install

  • Navigate to the reaction-light directory
  • Run git pull origin master
  • Shutdown the bot by using the rl!kill command
  • Start the bot again

Manually updating a zip install

This is not the recommended way to manage the bot files, consider moving to git. You can copy your files folder and the config.ini file to maintain the bot functionality with older reaction-role messages.

If you downloaded the bot as a zip archive:

  • Download the new zip
  • Extract it into the current reaction-light folder and replace old files with new ones if prompted to
  • Shutdown the bot by using the rl!kill command
  • Start the bot again

GitHub

https://github.com/eibex/reaction-light