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
Discord Token Checker

Discord-Token-Checker Optimizations Asynchronous Fast & Efficient Multi Tasked Proxy support (socks4/socks5/http) Usage Put tasks depending on your PC

scripted 6 May 05, 2022
Python SCript to scrape members from a selected Telegram group.

A python script to scrape all the members in a telegram group anad save in a CSV file. REGESTRING Go to this link https://core.telegram.org/api/obtain

Gurjeet Singh 7 Dec 01, 2022
allow windows programs to call dssp/mkdssp command from wsl; rework biopython on windows (PDB -> dssp -> fasta)

dssp-wsl Converting PDB (Protein Data Bank) file format to DSSP file format is required for generating datasets of peptides and their secondary struct

Taine Zhao 1 Feb 23, 2022
The source code of the bot that displays erotic images on Discord

説明 このコードはDiscord.pyとNeko APIを使ったNsfw画像表示ボットのソースコードです。 成人向けコンテンツを含むボットなので、不快になる方はこのボットの作成中止をおすすめします。 使い方 まず、install.batを起動してください。 そのあとに、config.json を開き

はなくそ 1 Dec 28, 2021
MCNameBot is a fast discord bot that is used to check the availability of a Minecraft name with a simple command.

MCNameBot MCNameBot is a fast discord bot that is used to check the availability of a Minecraft name with a simple command. If you would like to just

Killin 2 Oct 11, 2022
Python API to interact with Uwazi

Python Uwazi API Quick Start To use the API install the requirements pip3 install -r requirements.txt and use it like this: uwazi_adapter = UwaziAdap

HURIDOCS 2 Dec 16, 2021
Implement backup and recovery with AWS Backup across your AWS Organizations using a CI/CD pipeline (AWS CodePipeline).

Backup and Recovery with AWS Backup This repository provides you with a management and deployment solution for implementing Backup and Recovery with A

AWS Samples 8 Nov 22, 2022
A Code that can make your Discord Account 24/7 on Voice Channels!

Voicecord Make your Discord Account Online 24/7 on Voice Channels! A Code written in Python that helps you to keep your account 24/7 on Voice Channels

Phantom 229 Jan 07, 2023
WhatsApp Api Python - This documentation aims to exemplify the use of Moorse Whatsapp API in Python

WhatsApp API Python ChatBot Este repositório contém uma aplicação que se utiliza

Moorse.io 3 Jan 08, 2022
A demo titiler for Sentinel 2 Digital Twin dataset

This is a DEMO custom api built on top of TiTiler to create Web Map Tiles from the Digital Twin Sentinel-2 COG created by Sinergise

Development Seed 26 May 21, 2022
An unofficial python wrapper for the comdirect API for private consumers.

An unofficial python wrapper for the comdirect API for private consumers.

Alexander Knittel 18 Nov 30, 2022
A telegram string extractor bot

Made with Python3 (C) @FayasNoushad Copyright permission under MIT License License - https://github.com/FayasNoushad/String-Extract-Bot/blob/main/LIC

Fayas Noushad 12 Jul 19, 2022
This Wrapper is a Discum Copy With Addons, original one is made by Merubokkusu

Remaded Discum Its not Official Discum Wrapper ! This Wrapper is a Discum Copy With Addons, original one is made by Merubokkusu Authors @merubokkusu (

discum-remaded 8 Aug 09, 2022
Automate and Manage Telegram Channels

Channel Automation Bot @ChannelAutomateBot A star ⭐ from you means a lot to us! Telegram bot to automate and manage channels. Usage Deploy to Heroku T

Stark Bots 61 Dec 29, 2022
“ HOLA HUMANS 👋 I'M DAISYX 2.0 ❤️ „ LATEST VERSION OF DAISYX.. Source Code of @Daisyxbot

❤️ DaisyX 2.0 ❤️ A Powerful, Smart And Simple Group Manager ... Written with AioGram , Pyrogram and Telethon... ⭐️ Thanks to everyone who starred Dais

TeamDaisyX 153 Dec 06, 2022
PyMed is a Python library that provides access to PubMed.

IMPORTANT NOTE: I don't have time to maintain this library (as some of you might have noticed). The PubMed API is a little chaotic, without a clear do

Gijs Wobben 143 Dec 21, 2022
A discord self-bot to automate shitposting for your everyday needs.

Shitpost Selfbot A discord self-bot to automate shitposting for your everyday needs. Caution: May be a little racist. I have no clue where we are taki

stormy 1 Mar 31, 2022
Super Fast Telegram UserBot Made With Python.

Description Super Fast Telegram UserBot Made With Python. LOGO Made With Support of All Userbots Dev's Dark-Venom is a Light-Weight Userbot. It's unde

2 Sep 14, 2021
Georeferencing large amounts of data for free.

Geolocate Georeferencing large amounts of data for free. Special thanks to @brunodepauloalmeida and the whole team for the contributions. How? It's us

Gabriel Gazola Milan 23 Dec 30, 2022
Discord Remote Administration Tool

Discord Remote Administration Tool

Rdimo 82 Aug 15, 2022