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
Jupyter notebooks and AWS CloudFormation template to show how Hudi, Iceberg, and Delta Lake work

Modern Data Lake Storage Layers This repository contains supporting assets for my research in modern Data Lake storage layers like Apache Hudi, Apache

Damon P. Cortesi 25 Oct 31, 2022
Get random jokes bapack2 on telegram

Jokes Bapack2 Telegram Bot Get random jokes bapack2 from jokes-bapack2-api on telegram bot Screenshot Requirements python pip pipenv python-telegram-b

Miftah Afina 2 Nov 17, 2021
Solcast rooftop api for HA

Solcast Solar Home Assistant(https://www.home-assistant.io/) Component This custom component integrates the Solcast API into Home Assistant. Modified

Greg 1 Oct 11, 2021
This code is for a bot which will find a Twitter user's most tweeted word and tweet that word, tagging said user

max_tweeted_word This code is for a bot which will find a Twitter user's most tweeted word and tweet that word, tagging said user The program uses twe

Yasho Bapat 1 Nov 29, 2021
Please Do Not Throw Sausage Pizza Away - Side Scrolling Up The OSI Stack

Please Do Not Throw Sausage Pizza Away - Side Scrolling Up The OSI Stack

John Capobianco 2 Jan 25, 2022
Tracks how much money a profile has in their bank and graphs it, as long as they enable the bank api

Tracks how much money a profile has in their bank and graphs it, as long as they enable the bank api. (you could really use this to track anything from the hypixel api)

1 Feb 08, 2022
A simple object model for the Notion SDK.

A simplified object model for the Notion SDK. This is loosely modeled after concepts found in SQLAlchemy.

Jason Heddings 54 Jan 02, 2023
YouTube-Discord-Bot - Discord Bot to Search YouTube

YouTube Bot Info YouTube Bot is a discord bot where you can search for anything

Riceblades11 10 Mar 05, 2022
The Simple Google Colab Notebook to Download Files from Direct Link to Google Drive with custom name and bulk link support.

Direct Link to Google Drive (Advanced! 🔥 ) The Most Advanced yet Simple Google Colab Notebook to Download Files from Direct Link to Google Drive. 🆕

Dr.Caduceus 14 Jul 26, 2022
Simple script to extract useful informations from the combo BloodHound + Neo4j

bloodhound-quickwin Simple script to extract useful informations from the combo BloodHound + Neo4j. Can help to choose a target. Prerequisites python3

140 Dec 21, 2022
JAKYM, Just Another Konsole YouTube-Music. A command line based Youtube music player written in Python with spotify and youtube playlist support

Just Another Konsole YouTube-Music Overview I wanted to create this application so that I could use the command line to play music easily. I often pla

Mayank Jha 73 Jan 01, 2023
Autofill HZDR Zeitman entries

Zeitman_autofill Filling out Zeitman is boring. This script might make some of the pain go away. Requirements The selenium package and Chrome webdrive

Tim Callow 8 Mar 14, 2022
Get Notified about vaccine availability in your location on email & sms ✉️! Vaccinator Octocat tracks & sends personalised vaccine info everday. Go get your shot ! 💉

Vaccinater Get Notified about vaccine availability in your location on email & sms ✉️ ! Vaccinator Octocat tracks & sends personalised vaccine info ev

Mayukh Pankaj 6 Apr 28, 2022
Estudo de como criar uma api para o gerenciamento de livros usando a django restframework

Boa parte do projeto foi beaseado nesse vídeo e nesse artigo. Se assim como eu, você entrou agora no mundo BackEnd, recomendo fortemente tais materiai

Michel Ledig 14 Jun 28, 2022
Match-making API for OpenSanctions

OpenSanctions Match-making API This directory contains code and a Docker image for running an API to match data against OpenSanctions. It is intended

OpenSanctions.org 26 Dec 15, 2022
Simple Discord bot which logs several events in your server

logging-bot Simple Discord bot which logs several events in your server, including: Message Edits Message Deletes Role Adds Role Removes Member joins

1 Feb 14, 2022
DEPRECATED - Official Python Client for the Discogs API

⚠️ DEPRECATED This repository is no longer maintained. You can still use a REST client like Requests or other third-party Python library to access the

Discogs 483 Dec 31, 2022
⬇️ Telegram Bot to download TikTok videos without watermark in a snap with Inline mode support.

⬇️ Tokmate - Telegram Bot to download TikTok videos ⛲ Features Superfast and supports all type of TikTok links Download any TikTok videos without mate

Hemanta Pokharel 35 Jan 05, 2023
Twitter bot that finds new friends in Twitter.

PythonTwitterBot Twitter Bot Thats Find New Friends pip install textblob pip install tweepy pip install googletrans check requirements.txt file Env

IbukiYoshida 4 Aug 11, 2021
A file-based quote bot written in Python

Let's Write a Python Quote Bot! This repository will get you started with building a quote bot in Python. It's meant to be used along with the Learnin

Jyoti prakash Rout 1 Jan 08, 2022