Coder Social home page Coder Social logo

peterthehan / discord-reaction-role-bot Goto Github PK

View Code? Open in Web Editor NEW
124.0 8.0 52.0 3.93 MB

A Discord bot that allows users to self-assign roles using reactions.

License: MIT License

TypeScript 100.00%
discord bot discord-bot emoji reactions roles reaction role reaction-role reaction-roles

discord-reaction-role-bot's Introduction

Discord Reaction Role Bot

Discord Twitter Follow

A Discord bot that allows users to self-assign roles using reactions.

demo

Setup

  1. Follow the instructions in create-discord-bot.

    Don't forget to give your bot the Manage Roles and Manage Messages permissions (only grant the latter if the bot should handle reactions)!

  2. Download this bot and move the src-discord-reaction-role-bot folder into the /src/bots folder from step 1.

  3. Open config.json to configure your own settings:

    [
      {
        "messageId": "858190737065902101",
        "channelId": "258314939998011393",
        "removeReaction": true,
        "policy": "any",
        "emojiRoleMap": {
          "🤖": ["858186589187735565"],
          "🎉": ["542138999511187486"],
          "🥤": ["785794153089990688"]
        }
      }
    ]

    Add as many rules as you want to configure for other servers.

    • messageId is the message you want the bot to react to for your reaction roles.

    • channelId is the text channel the message is in.

    • removeReaction determines whether the user reaction is removed (true) or not (false).

    • policy must be one of the following strings:

      • once: User is only allowed to react and claim roles once. Subsequent reactions are ignored.
      • any: User can react and claim as many roles as they want.
      • unique (default): User can react and claim only one emoji's set of roles at a time.
    • emojiRoleMap is a one-to-many key-value map between emoji and role ids. An emoji can be:

      • A unicode emoji. https://emojipedia.org is a good reference to copy and paste from.

          "emojiRoleMap": {
            "😳": ["ROLE_1_ID"],
            "🥺": ["ROLE_2_ID", "ROLE_3_ID", "ROLE_4_ID"]
          }
      • An emoji ID for custom emojis. You can get a custom emoji's ID by sending \:YourCustomEmoji: in chat (prefix a backslash \ character in front of your desired emoji).

        "emojiRoleMap": {
          "716344914706694165": ["ROLE_1_ID"],
          "622635442013208589": ["ROLE_2_ID", "ROLE_3_ID", "ROLE_4_ID"]
        }
  4. npm start to run the bot.

Visit for more help or information!

discord-reaction-role-bot's People

Contributors

peterthehan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-reaction-role-bot's Issues

Custom emojis documentation

The readme says we should use the 'emoji id' for custom emojis. Practically, it doesn't say how to get input that emoji id and report them as "unknown".
For example, I've a :cyan_ship: custom emoji, but the bot is errorring when I try use cyan_ship or :cyan_ship: as an id.
To get the actual id, ones need to escape the emoji. So in my case, I had to type \:cyan_ship: in discord to see the id to use.

Stopping it from removing users reactions?

I see in the .gif example, when a user reacts it gets reset back to 1 reaction. Not sure how this is even done (though I've seen it before) but is there an easy way to disable this or make it so it doesn't do that?

Just out of curiosity would be nice to see the quantity count of reactions.

Help

Where do I put my token?

Multiple (2) roles per reaction?

Is it possible to set 2 roles per reaction?

There might be a slight issue with this. When the user unreacts to get the role removed, the bot doesn't know better to leave the base role assigned unless users has unreacted to all reactions.

error

This is being so all people
npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/discord-reaction-role-bot/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/discord-reaction-role-bot/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-01-04T09_30_19_818Z-debug.log
exit status 254

BOT doesn’t add the emoji

I got the project running it works except for that the bot doesn’t add the emoji reaction to the message.

I am currently on mobile, I can look into the project myself tomorrow but if you know a quick fix please let me know :)

Your projects look awesome btw! :)

For anyone who has a problem with: “AbortController is not defined” make sure you are using the latest JS version.

check node version:

node -v

For using Discord.js v13 is that you need to use NodeJS v16.6 or higher

fix:

npm install -g n
n latest

role remove

the bot works, however when remove the reaction the role doesnt get removed, but it does if i react again. (using any policy)

Custom Emoji issue

Hello!

First off, great project, thanks a lot as it really takes a lot work off people's bottoms.
Anyways, to the issue I'm having.

Everything properly set up, if I start using a custom emoji, that is being added to the message as expected.

However, if I click on the emoji, the role isn't being assigned properly - in contrary to a utf-8 emoji. The reaction is being removed instantly as expected, so the bot "works with it", however it doesn't identify that the reaction was clicked.

I'm assuming it is a bug but didn't find the source yet. Maybe you'll have an idea. I'm assuming it could be an issue with identifying what emoji was clicked since it expects :emojiname:emojid, contrary to documentation.

Might be worth checking further

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.