Skip to content

Add Reaction Event

PetyXbron edited this page Oct 7, 2024 · 1 revision

messageReactionAdd is one of Discord's gateway events. The bot listens to it and triggers a code every time this event happens.

What is the procedure before giving the role by reacting?

  1. Database check
  2. Checks of arguments admin has set up
  3. Giving the role

Detailed questions of the bot asking itself

The database checks

Once a user posts a response, the bot starts to check eligibility (meet the conditions). In the process, the bot asks these questions:

  1. Does this Discord server even have a database with me? (have systems ever been created)
  2. Is this message and response in the database?

User limit checks

After loading the database, check the limit:

  1. Does this system have a limit of candidates that can get this role?
  2. If so, is the number of applicants already enrolled greater than or equal to this limit?

maxClaims checks

After checking the limit, check maxClaims:

ℹ️ maxClaims is the name of a command argument that specifies the number of how many roles/responses from the entirety of a single message can get.

  1. Does this system have maxClaims?
  2. How many times is a candidate registered for different responses in the database?

Role checks

Once they pass these setup checks, the last questions come up:

  1. Is there a role from the database?
  2. Do I have the right to edit the role (in Discord identical to the right to give the role)?

Role giving

After the last checks, the actual adding of the role occurs:

  1. Give the role to a candidate
  2. Write down his Discord ID - a record that he has picked up the role.
  3. Send a welcome message to the team.

Clone this wiki locally