Skip to content
Eibe edited this page Feb 26, 2024 · 15 revisions

Reaction Light - Wiki

Easy to use self-hosted reaction role Discord bot written in Python.

Reaction Light Discord Server

Deployment

First, you need to create a bot user on Discord Developer Portal.

Once you created a bot, you will need to activate the message content intent under the bot section, as well as saving the bot token you generated for later use in this installation guide.

Before moving onto downloading and running the bot, invite the bot user you have just created to your server with the following link (ensuring to replace CLIENT_ID with the ID shown in the general information tab):

https://discord.com/oauth2/authorize?&client_id=CLIENT_ID&scope=bot%20applications.commands&permissions=2415978560

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.

Docker

Create a directory to store your configuration and database files in the location you prefer:

mkdir -p reaction-light/files
cd reaction-light

Inside the directory create a file named config.ini with the following contents:

[server]
token = INSERT_YOUR_TOKEN
name = Reaction Light
system_channel =
logo = https://cdn.discordapp.com/attachments/915013456749543525/915372094785716275/reactionlight.png
colour = 0xffff00
language = en-gb

Replace INSERT_YOUR_TOKEN with the token you generated beforehand. You can change the bot's name and embed's logo (not to be mistaken with the bot's avatar) by replacing the values accordingly.

You can pull the Docker image of Reaction Light from our GitHub Packages:

docker pull ghcr.io/eibex/reaction-light:latest

Once you pulled the last Docker image, you can run the container (replacing the /path/to/reaction-light strings with the location of your reaction-light directory):

docker run -d \
  --name reaction-light \
  --restart always \
  -v /path/to/reaction-light/files:/bot/files \
  -v /path/to/reaction-light/config.ini:/bot/config.ini \
  ghcr.io/eibex/reaction-light:latest

Now the bot should be up and running. 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.

Git

Clone the repository using:

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

git comes pre-installed on most Linux-based operating systems. On Windows, if you are not familiar with git, you can use GitHub Desktop

While inside the reaction-light directory, install requirements via pip using:

python3 -m pip install -r requirements.txt

Run setup.py and follow the instructions or create a config.ini file (example provided in config.ini.sample) or edit it manually.

python3 setup.py

Insert the token of your bot (found at: https://discord.com/developers/applications/). You can set most of the other values via commands later (set manually name and logo, which appear in the footer of each embed).

If you do not have or want to use tmux or screen, the bot can be run as a background task by using:

nohup python3 bot.py &

Now the bot should be up and running. 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.

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 /bot update to update the bot and restart it.

Note: If you update a docker installation with the /bot update command and you need to update a dependency (i.e. disnake, python), you will need to update the Docker container manually.

Updating a Docker installation

First, stop and delete the reaction-light container using:

docker stop reaction-light && docker rm reaction-light

Re-pull the Docker image using:

docker pull ghcr.io/eibex/reaction-light:latest

Create and start a new container using:

docker run -d \
  --name reaction-light \
  --restart always \
  -v /path/to/reaction-light/files:/bot/files \
  -v /path/to/reaction-light/config.ini:/bot/config.ini \
  ghcr.io/eibex/reaction-light:latest

Optionally, remove all orphaned images:

docker image prune -a

Manually updating a git install

  • Navigate to the reaction-light directory
  • Run git pull origin master
  • Shutdown the bot by using the /bot kill command. You can also use /bot restart on Linux-based systems.
  • Start the bot again