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 small discord bot to interface with python-discord's snekbox.

A small discord bot to interface with python-discord's snekbox.

Hassan Abouelela 0 Oct 05, 2021
A Discord Bot that tracks and displays cryptocurrencies using the CoinMarketCap API

PyBo - A Crypto Inspired Discord Bot Pybo (paɪ boʊ) is a Discord bot that utilizes the discord.py API wrapper to run the bot. Pybo also integrates the

0 Nov 17, 2022
Cleaning Tiktok Hacks With Python

Cleaning Tiktok Hacks With Python

13 Jan 06, 2023
Simple Telegram webscrap bot

webscrap-bot Simple Telegram webscrap bot Configs TOKEN - Get bot token from @BotFather API_ID - From my.telegram.org API_HASH - From my.telegram.org

lokaman chendekar 10 Oct 21, 2022
Aplicação dos metodos de classificação em 3 diferentes banco de dados. Usando...

Machine Learning - Métodos de classificação Base de Dados utilizadas: Dados de crédito Dados do Census Métodos de classificação aplicados: Naive Bayes

1 Jan 18, 2022
可基于【腾讯云函数】/【GitHub Actions】/【Docker】的每日签到脚本(支持多账号使用)签到列表: |爱奇艺|全民K歌|腾讯视频|有道云笔记|网易云音乐|一加手机社区官方论坛|百度贴吧|Bilibili|V2EX|咔叽网单|什么值得买|AcFun|天翼云盘|WPS|吾爱破解|芒果TV|联通营业厅|Fa米家|小米运动|百度搜索资源平台|每日天气预报|每日一句|哔咔漫画|和彩云|智友邦|微博|CSDN|王者营地|

每日签到集合 基于【腾讯云函数】/【GitHub Actions】/【Docker】的每日签到脚本 支持多账号使用 特别声明: 本仓库发布的脚本及其中涉及的任何解锁和解密分析脚本,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。

87 Nov 12, 2022
Unlimited Filter Telegram Bot 2

Mother NAther Bot Features Auto Filter Manuel Filter IMDB Admin Commands Broadcast Index IMDB search Inline Search Random pics ids and User info Stats

LɪᴏɴKᴇᴛᴛʏUᴅ 1 Oct 30, 2021
A telegram bot written in Python to fetch random SFW & NSFW anime images

Tsuzumi A telegram bot written in python to fetch both random SFW & NSFW Anime images using nekos.life & waifu.pics API Commands SFW Commands : /

Nisarga Adhikary 3 Oct 12, 2022
A project that alerts me when there's a dog outside so I can go look at it.

Dog Detector A project that alerts me when there's a dog outside so I can go look at it. Tech Specs This script uses the YOLOv3 object detection model

rydercalmdown 58 Jul 29, 2022
Using AWS Batch jobs to bulk copy/sync files in S3

Using AWS Batch jobs to bulk copy/sync files in S3

AWS Samples 14 Sep 19, 2022
This is an implementation example of a bot that periodically sends predictions to the alphasea-agent.

alphasea-example-model alphasea-example-modelは、 alphasea-agent に対して毎ラウンド、予測を投稿するプログラムです。 Numeraiのexample modelに相当します。 準備 alphasea-example-modelの動作には、

AlphaSea 11 Jul 28, 2022
Track live sentiment for stocks from Reddit and Twitter and identify growing stocks

Market Sentiment About This repository can mainly be used for two things. a. Tracking the live sentiment of stocks from Reddit and Twitter b. Tracking

Market Sentiment 345 Dec 17, 2022
Add members to unlimited telegram channels and groups

Program Features 📌 Coded with Python version 10. 📌 without the need for a proxy. 📌 without the need for a Telegram ID. 📌 Ability to add infinite p

hack4lx 10 Nov 25, 2022
Python Wrapper for aztro - The Astrology API | Get Daily Horoscope 💫

PyAztro PyAztro is a client library for aztro written in Python. aztro provides horoscope info for sun signs such as Lucky Number, Lucky Color, Mood,

Sameer Kumar 30 Jan 08, 2023
WhatsApp Multi Device Client

WhatsApp Multi Device Client

23 Nov 18, 2022
pyDuinoCoin is a simple python integration for the DuinoCoin REST API, that allows developers to communicate with DuinoCoin Master Server

PyDuinoCoin PyDuinoCoin is a simple python integration for the DuinoCoin REST API, that allows developers to communicate with DuinoCoin Main Server. I

BackrndSource 6 Jul 14, 2022
search different Streaming Platforms for movie titles.

Install git clone and cd to directory install Selenium download chromedriver.exe to same directory First Run Use --setup True for the first run. Platf

34 Dec 25, 2022
Command-line program to download image galleries and collections from several image hosting sites

gallery-dl gallery-dl is a command-line program to download image galleries and collections from several image hosting sites (see Supported Sites). It

Mike Fährmann 6.4k Jan 06, 2023
Youtube Music Playlist Organizer

Youtube Music Playlist Organizer, a simple Python application that uses ytmusicapi to help user edit their playlists and organize in other playlists.

Bedir Tapkan 1 Oct 24, 2021