Easy to use reaction role Discord bot written in Python.

Overview

Reaction Light - Discord Role Bot

Reaction Light Discord Server Reaction Light 3.0.1 Python 3.8+ disnake 2.2.2+

Reaction Light Embed Example

Light yet powerful reaction role bot coded in Python.

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
    • No need to rely on developer mode and IDs
  • Optional update notifications and error reporting to your own Discord server
  • Multiple languages
  • Slash command ready

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

Contents

Requirements

This bot requires disnake and Python 3.8+.

You can get disnake via PyPI or GitHub:

python3 -m pip install -r requirements.txt

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) or edit it manually
  • Activate the message content intent for your bot (found at: https://discord.com/developers/applications/ under the bot section)
  • Invite the bot to your server(s) with enough permissions using the following link (need to replace CLIENT_ID with your bot's ID, visible under 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 (or your bot's name) 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 /admin add @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 /admin add (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.

  • /help shows this set of commands along with a link to the repository.
  • /message new starts the creation process for a new reaction role message. Check below for an example.
  • /message edit edits the text and embed of an existing reaction role message.
  • /message reaction adds or removes a reaction from an existing reaction role message.
  • /settings 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).
  • /settings colour changes the colour of the embeds of new and newly edited reaction role messages.
  • /settings activity adds or removes an activity for the bot to loop through and show as status.
  • /settings systemchannel updates the main or server system channel where the bot sends errors and update notifications.
  • /settings language sets a new language for the bot. Currently available languages are: en-gb (English), it-it (Italian).
  • /admin adds or removes the mentioned role or role id to/from the admin list. Requires administrator permissions on the server.
  • /bot kill shuts down the bot.
  • /bot restart restarts the bot.
  • /bot update updates the bot and restarts it. Only works on git clone installations. Check the setup section to learn how to install with git.
  • /bot version reports the bot's current version and the latest available one from GitHub.

Usage Example

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 /message new.

User: /message 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 /message 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 🔧 , the bot will remove the 🔧 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 /bot 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 /bot 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 /bot kill command
  • Start the bot again

Roadmap

Upcoming features can be found in the open issues and PRs tagged with new feature or enhancement. They can be found here.

Open a new issue if you would like to see a feature implemented, and/or open a pull request implementing it.

FAQ

When I click one of the reactions the bot does not give me a role!

Ensure that you moved the Reaction Light role to a position that is hierarchically higher than the role you are trying to assign.

The bot says I am not an admin, even though I own the server (or have admin rights for it)

Run /admin add @Role to give all users with that role permission to manage Reaction Light. This is done to have server staff use the bot without giving them unnecessary server rights. The only server admin command is /admin.

I have updated from v2 to v3 and I do not see any slash commands

Ensure that you followed the update steps as outlined in the changelog for v3.0.0. If this still doesn't fix the issue, try to shutdown the bot and re-inviting it to your server with the link provided in this readme or in the changelog.

Help

If you need help with the bot or need to report bugs, post an issue here. You can also join our Discord server.

Contribute

If you would like to contribute to this project, fork it and then create a pull request. Please ensure that you have thoroughly tested all your changes. Black formatting with a line length of 130 is preferred.

Even if you are not a Python programmer, you can contribute to this project by reporting bugs, requesting new features, or translating the bot in your language. To translate the bot simply copy the English file and replace the text inside the second quotes of each line. Do not replace the text within {}. Click here for an example.

License

MIT

Comments
  • Re-work message clean up, re-work of the admin system and cleaning up left guilds

    Re-work message clean up, re-work of the admin system and cleaning up left guilds

    Fixes #52 by deleting a guilds database entries after leaving the guild / if the guild gets deleted. In order to do this I added another database function (remove_guild) which just removes everything directly connected to the guild (message, reactionroles, systemchannels). Please note: This will NOT remove the admin role id from the database as admins table does not refer to which guild the admin role belongs to.

    opened by Edwinexd 14
  • Error when adding admin roles on fresh install

    Error when adding admin roles on fresh install

    Describe the bug

    When using /admin add @Rolecommand in Discord channel as server administrator, bot fails to write to database and produces trackback error in console. Files are all in home directory sub-folders and bot is being run as same user

    To Reproduce

    Fresh install and setup of bot, authenticated and added to server. Attempt to add admin role to bot.

    Expected behavior

    Admin role to be added successfully without errors

    Screenshots

    image

    Server:

    • OS: Ubuntu 20.04
    • Python version: 3.8
    • disnake version: 2.4.0

    Traceback

    Ignoring exception in slash command 'admin':
    Traceback (most recent call last):
      File "/home/jon/.local/lib/python3.8/site-packages/disnake/ext/commands/slash_core.py", line 597, in invoke
        await call_param_func(self.callback, inter, self.cog, **kwargs)
      File "/home/jon/.local/lib/python3.8/site-packages/disnake/ext/commands/params.py", line 778, in call_param_func
        return await maybe_coroutine(safe_call, function, **kwargs)
      File "/home/jon/.local/lib/python3.8/site-packages/disnake/utils.py", line 561, in maybe_coroutine
        return await value
      File "/home/jon/reaction-light-etf/cogs/admin.py", line 43, in admin
        await inter.response.defer()
      File "/home/jon/.local/lib/python3.8/site-packages/disnake/interactions/base.py", line 666, in defer
        await adapter.create_interaction_response(
      File "/home/jon/.local/lib/python3.8/site-packages/disnake/webhook/async_.py", line 214, in request
        raise NotFound(response, data)
    disnake.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/home/jon/.local/lib/python3.8/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1332, in process_application_commands
        await app_command.invoke(interaction)
      File "/home/jon/.local/lib/python3.8/site-packages/disnake/ext/commands/slash_core.py", line 606, in invoke
        raise CommandInvokeError(exc) from exc
    disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction
    
    bug 
    opened by BlackOutJon 8
  • [IMP] Make `embeds` optionnal as those can be hidden clientside

    [IMP] Make `embeds` optionnal as those can be hidden clientside

    If the users have hidden the embed messages in their settings,they only see the reactions attached to an empty message.

    This commit aims to make the embed messages 'optionnal' and rely on a normal message. Here's the changes on the commands:

    {prefix}new - message formatting (step == 3) :

    • some text: Set only a message
    • some text // some embed title: Set a message with an embed that only has a title
    • some text // some embed title // some embed content: Set a message with an embed that has a title and some contents

    {prefix}edit:

    • {prefix}edit #channelname // MESSAGE_NUMBER // New Message: Change the message's body
    • {prefix}edit #channelname // MESSAGE_NUMBER // New Message // New Embed Title (Optionnal):
      • If the reaction-role message already had an embed, it keeps its existing description, changes its title and the message's body.
      • If the reaction-role message didn't had an embed, it sets one with only a title and the message's body
    • {prefix}edit #channelname // MESSAGE_NUMBER // New Message // New Embed Title (Optionnal) // New Embed Description (Optionnal)t:
      • If the reaction-role message already had an embed, it changes its title, its description and the message's body
      • If the reaction-role message didn't had an embed, it sets one with the new title, the new description and the new message body.

    {prefix}rm-embed:

    • {prefix}edit #channelname // MESSAGE_NUMBER: Remove the embed set on the selected reaction-role message
    opened by arbaes 8
  • Refactor bot.py (add cogs, cleaner code)

    Refactor bot.py (add cogs, cleaner code)

    Even though the bot works flawlessly in its current state (except for the currently open enhancement-related issues), the code could use a lot of improvements.

    Refactoring with better functions, classes, cogs, and general usage of discord.py is ideal.

    ~~We could also consider using SQLite instead of CSV files. Though this will add an extra dependency to the bot (and a complete remake of the bot's file manager (rlightfm)).~~

    ~~EDIT: Additionally, another hurdle of adopting SQLite is creating a script to transfer the data of CSV files in currently existing installations to the database so to minimise downtime to a simple bot restart.~~

    EDIT: Striked parts done in #20

    enhancement help wanted refactoring 
    opened by eibex 7
  • Click on USE existing text in new installation ends in loop

    Click on USE existing text in new installation ends in loop

    I just installed the bot added with the new command my first reactions

    at the point use existing text or make new one i choose the icon to use and existing, believing there is some default

    now i cant proceed further, so i restarted the bot and tried the edit command i have to enter a channel and always get the information

    There are no reaction-role messages in that channel.

    bug 
    opened by ChaosEmpire 6
  • add notification toggles and checks

    add notification toggles and checks

    Describe the PR changes

    • Adds a new table called guild_settings: I would like to use this for anything guild related in the future, I tried to merge systemchannels into this but I couldn't find an elegant way yet. I will figure it out before merging... Most likely going to copy the contents into a new column and then delete the old table in the one_to_two function
    • Moved the admin migration introduced by @Edwinexd from core.database to core.schema (I believe everything should still be working correctly)
    • Adds a toggle command rl!notify
    • Guilds are inserted into the table when either rl!notify is first used or when the bot checks for it (a user adds or removes a reaction from themselves). In the first case, the bot toggles the notification on, in the latter, the bot sets notifications to off (the "default")

    I still need to test this properly, but comments are welcome

    Closes #50

    opened by eibex 6
  • The bot deletes reactionroles although the message still exists.

    The bot deletes reactionroles although the message still exists.

    Bot deletes Reactionroles though the messages still exist

    What happens is, that the bot starts deleting stored Reactionroles for messages that still exists, with the reason, that the message got deleted. In fact, the message didnt get deleted. Its still existing.

    To Reproduce

    This happened to me when restarting the bot multiple times, each restart made it delete 1 reactionrole. This happened locally, but when running on my Windows VPS 2019, it just did the same thing without any restarts.

    Expected behavior

    The Bot will delete the Rectionrole

    Screenshots

    None

    Server:

    • OS: Windows 10 20H2 / Windows 10 2019 Server
    • Python version: 3.8.9
    • discord.py version: 1.6

    Traceback

    Theres no traceback since there isnt any error that came up in console.
    
    bug needs info 
    opened by Shmalle 5
  • Multiple (2) roles per reaction?

    Multiple (2) roles per reaction?

    Is there an easy way to allow the bot to give multiple roles for each reaction?

    I will try to explain the reason for this;

    By default a Discord server allows each user to all categories and channels. Perhaps there is too many, so they allow users to react for roles that hide categories/channels. Which is a better method than reacting to see them.

    For these roles that hide (or restrict) access to categories/channels, there could be numerous of them. To keep these roles organized, there is 1 main role above all these roles, like a header. For example it might be called ----HIDDEN---- and every role below this header means that role is hiding/restricting view permissions for the corresponding category/channel.

    There is also an issue I can see with this- when users un-react to get access back to categ/chan the bot doesn't know better to not take away this header (---HIDDEN---) role. So it would need to know not to touch that header role unless all reactions from the user have been removed/un-reacted.

    Hope this makes sense.

    One might say "Why not just give that role on join?" which is a fair point. But heres 2 reasons- the first being your bot that gives auto role on join might only be capable of giving 1 role. The other reason is that the whole point of these roles are for channel organization, so users having the header (---HIDDEN---) role without having any roles under it, would look out of place.

    enhancement wontfix new feature 
    opened by rich1488 4
  • missing brackets in database.py

    missing brackets in database.py

    Describe the bug

    I was running this on my server, it was going smooth until I noticed this error in code.

    rec

    I would not like trespass here but to contribute, I would like to make the small change needed :)

    bug 
    opened by starlightknown 4
  • Check daily for removed messages and clean the database

    Check daily for removed messages and clean the database

    Fixes #3

    A daily task is registered and the bot removes messages that return a discord.NotFound when they are fetched.

    Also added message ID reporting of messages that return a 403 if the system channel is set for this feature and also for edit and rm-embed.

    opened by eibex 4
  • option for inverting reaction role function

    option for inverting reaction role function

    Is your feature request related to a problem? Please describe.

    Not related to a problem.

    Describe the solution you'd like

    When users click on a reaction, they lose a role, instead of getting it assigned. unclicking regains them the role.

    Describe alternatives you've considered

    Haven't been able to come up with any.

    enhancement wontfix new feature 
    opened by traxell1 3
  • Refactor `message.py`

    Refactor `message.py`

    Refactor message.py:

    • Full rewrite /message new (better code and no more usage of //)
    • More functions to avoid repeated code between edit, reaction, and new (e.g. preparation of embeds to send)
    enhancement refactoring 
    opened by eibex 0
Releases(v3.1.1a)
Owner
eibex
Coding in Python during my free time as a hobby.
eibex
A Python Client to View F1TV Content the right way

F1Hub is a terminal application running directly on your computer -- no connection to the website needed* *In theory. As of now, the F1TV website is needed for some content

kodos 3 Jun 14, 2022
52pojie 吾爱破解论坛 签到 支持云函数/服务器等Py3环境运行

52pojie-Checkin 52pojie 吾爱破解论坛 签到 Py3单程序 支持云函数/服务器等Py3环境运行 只需要Cookie即可运行 新版说明 依赖包请用项目 https://github.com/BlueSkyXN/requirements-serverless 需要填写的参数有 co

BlueSkyXN 22 Sep 15, 2022
A QQ(Tencent) robot created by go-cqhttp & nonebot2

绘梨花(胶布)Bot|ErikaBot ✨ 基于NoneBot2的绘梨花多功能 Bot ,自用 ✨ 快速开始 参考go-cqhttp项目文档,配置好机器人的相关设置,以及反向ws客户端 参考nonebot2项目文档,添加必要的.env相关设置 安装本项目相关的依赖库(依赖清单) git clone本

10 Aug 09, 2022
Twitter feed of newly published articles in Limnology

limnopapers Code to monitor limnology RSS feeds and tweet new articles. Scope The keywords and journal choices herein aim to focus on limnology (the s

7 Dec 20, 2022
A Discord bot to play bluffing games like Dobbins or Bobbins

Usage: pip install -r requirements.txt python3 bot.py DISCORD_BOT_TOKEN Gameplay: All commands are case-insensitive, with trailing punctuation and spa

4 May 27, 2022
Powerful Telegram Maintained UserBot in Telethon

Fire-X UserBot The Awaited Bot Fire-X userbot The Most Powerful Telegram Userbot. This Userbot is Safe to use in Your Telegram Account. It is not like

22 Oct 21, 2022
Utility for downloading fanfiction in bulk from the Archive of Our Own

What is this? This is a program intended to help you download fanfiction from the Archive of Our Own in bulk. This program is primarily intended to wo

73 Dec 30, 2022
The Best Multipurpose Discord Bot!

Polsu The Best Multipurpose Discord Bot! • Introduction • Screenshots • Setup • License Introduction Polsu is a Multipurpose Discord Bot. Polsu has a

Polsulpicien 1 Nov 09, 2021
Una herramienta para transmitir mensajes automáticamente a múltiples grupos de chat

chat-broadcast Una herramienta para transmitir mensajes automáticamente a múltiples grupos de chat Setup Librerías Necesitas Python 3 con la librería

Seguimos 2 Jan 09, 2022
Definitive Guide to Creating a SQL Database on Cloud with AWS and Python

Definitive Guide to Creating a SQL Database on Cloud with AWS and Python An easy-to-follow comprehensive guide on integrating Amazon RDS, MySQL Workbe

Kenneth Leung 6 Aug 17, 2022
Mventory is an API-driven solution for Makerspaces, Tinkerers, and Hackers.

Mventory is an API-driven inventory solution for Makers, Makerspaces, Hackspaces, and just about anyone else who needs to keep track of "stuff".

Make Monmouth 107 Dec 21, 2022
A light wrapper around FedEx's SOAP API.

Python FedEx SOAP API Module Author: Greg Taylor, Radek Wojcik Maintainer: Python FedEx Developers License: BSD Status: Stable What is it? A light wra

155 Dec 16, 2022
OSINT tool to get information from a Github and Gitlab profile and find user's email addresses leaked on commits.

gitrecon OSINT tool to get information from a Github or Gitlab profile and find user's email addresses leaked on commits. 📚 How does this work? GitHu

GOΠZO 211 Dec 17, 2022
DIAL(Did I Alert Lambda?) is a centralised security misconfiguration detection framework which completely runs on AWS Managed services like AWS API Gateway, AWS Event Bridge & AWS Lambda

DIAL(Did I Alert Lambda?) is a centralised security misconfiguration detection framework which completely runs on AWS Managed services like AWS API Gateway, AWS Event Bridge & AWS Lambda

CRED 71 Dec 29, 2022
A Python wrapper for the DeepL API

deepl.py A Python wrapper for the DeepL API installing Install and update using pip: pip install deepl.py A simple example. # Sync Sample import deep

grarich 18 Dec 12, 2022
A CLI tool to transfer, sync, and backup playlists on music streaming services

unitunes A command-line interface tool to manage playlists across music streaming services. Introduction unitunes manages playlists across streaming s

Victor Tao 50 Jan 07, 2023
A bot for Large Fry Larrys

GroupMe Bot Driver This driver is written entirely in Python, and with easy configuration in mind. Using this driver, you'll be able to monitor multip

1 Oct 25, 2021
TG-Streaming-bot - TG Simple Streaming bot

TG Simple Streaming bot telegram video straming bot 🎚️ Features Play youtube li

HyDrix 4 May 05, 2022
Advanced Number Validator Using telnyx api

Number Validator Python v1.0.0 Number Validator Using telnyx api DISCLAIMER This Tool is only for educational purposes You'll be responsible yourself

xBlackxCoder 3 Sep 24, 2022
Powerful Telegram Members Scraping and Adding Toolkit

🔥 Genisys V2.1 Powerful Telegram Members Scraping and Adding Toolkit 🔻 Features 🔺 ADDS IN BULK[by user id, not by username] Scrapes and adds to pub

The Cryptonian 16 Mar 01, 2022