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
Discovery is an open-source Discord Bot with the main features Tickets, Moderation, Giveaways and Reaction roles.

Discovery is an open-source Discord Bot with the main features Tickets, Moderation, Giveaways and Reaction roles.

null 1 Dec 29, 2021
Role Discord Members (by username) from File

Role Discord Members (by username) from File Bot Setup Navigate to https://discord.com/developers/applications Create a new application Navigate to th

Dylan Orrell 3 Jan 6, 2022
How to add reaction on message discord.py

BA / HR / RS: Python (discord.py) skripta pomocu koje dodajete reakciju na vasu poruku putem komande !v ili da se dodaje samo u nekoj odredjenoj sobi.

Seekii 3 Dec 23, 2021
A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py)

Articuno (discord-interactions) A small and fun Discord Bot that is written in Python and discord-interactions (with discord.py) Get started If you wa

Blue 8 Dec 26, 2022
A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.

A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using async and await

Senpai Development 4 Nov 5, 2021
A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.

disfork A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. Key Features Modern Pythonic API using async a

null 2 Feb 9, 2022
Satoshi is a discord bot template in python using discord.py that allow you to track some live crypto prices with your own discord bot.

Satoshi ~ DiscordCryptoBot Satoshi is a simple python discord bot using discord.py that allow you to track your favorites cryptos prices with your own

Théo 2 Sep 15, 2022
An Open-Source Discord bot created to provide basic functionality which should be in every discord guild. We use this same bot with additional configurations for our guilds.

A Discord bot completely written to be taken from the source and built according to your own custom needs. This bot supports some core features and is

Tesseract Coding 14 Jan 11, 2022
Role Based Access Control for Slack-Bolt Applications

Role Based Access Control for Slack-Bolt Apps Role Based Access Control (RBAC) is a term applied to limiting the authorization for a specific operatio

Jeremy Schulman 7 Jan 6, 2022
Auto Liker, Auto Reaction, Auto Comment, Auto Follower Tool. RajeLiker Credit Hacker.

Auto Liker, Auto Reaction, Auto Comment, Auto Follower Tool. RajeLiker Credit Hacker. Unlimited RajeLiker Credit Hack. Thanks To RajeLiker.

Md. Mehedi Hasan 32 Dec 28, 2022
DeKrypt 24 Sep 21, 2022
MusicBot is the original Discord music bot written for Python 3.5+, using the discord.py library

The original MusicBot for Discord (formerly SexualRhinoceros/MusicBot)

Just Some Bots 2.9k Jan 2, 2023
Zero2 Discord bot is written with Discord.py using Python.

Zero2 Discord bot is written with Discord.py using Python.

Siva Avanish 4 Nov 8, 2021
A multipurpose, semi-modular Discord bot written in Python with the new discord.py module.

Discord.py Reaction Bot MIRAI KURIYAMA A multipurpose, semi-modular Discord bot written in Python with the new discord.py module. Installing dependenc

null 1 Dec 2, 2021
A Anything goes Discord bot written in python and uses the wrapper Discord.py

GerardTheWizard A Anything goes Discord bot written in python and uses the wrapper Discord.py What can he do? Allow users to level up through typing,

null 1 May 5, 2022
A self-bot for discord, written in Python, which will send you notifications to your desktop if it detects an intruder on your discord server

A self-bot for discord, written in Python, which will send you notifications to your desktop if it detects an intruder on your discord server

LevPrav 1 Jan 11, 2022
iso6.9 is a Discord bot written in Python and is used to make your Discord experience better

iso6.9-2.6stable (debloated) iso.bot is originally made by notsniped#4573. This is a remix of iso.bot by αrchιshα#5518. iso6.9 is a Discord bot writte

Kamilla Youver 2 Jun 10, 2022
Easy-apply-bot - A LinkedIn Easy Apply bot to help with my job search.

easy-apply-bot A LinkedIn Easy Apply bot to help with my job search. Getting Started First, clone the repository somewhere onto your computer, or down

Matthew Alunni 5 Dec 9, 2022
Discord bot written in discord.py

Orion Discord bot written in discord.py Installation Installation of code is supported for macOS only currently First open the terminal. If incase you

Zeus 3 May 19, 2022