Skip to main content

๐ŸŽญ Reactions

๐ŸŽŠ Multi eventsโ€‹

There is 2 kinds of events here:

Since we have 2 kinds of events, we can no longer simply put them in ./sources/modules/<module_name>/channels, we need to specify which of the 2 events is to be used. To do this, we add an extension to the end of the file:

โŽฏ Example for each classes replace <module_name> by the name of your module

  • add โ†’ ./sources/modules/<module_name>/reactions/add.js
  • remove โ†’ ./sources/modules/<module_name>/channels/remove.js

๐Ÿค” "MessageReaction"โ€‹

MessageReaction is an object with several data and methods, you should read discord.js documentation to see how to work with MessageReaction.

โž• MessageReactionAddโ€‹

Has two arguments reaction who is an instance of MessageReaction and user who is an instance of User.

async function parse(reaction, user)
{
console.log(message.author.username, "reacted with", reaction)
}

module.exports = {
parse,
conditions: [],
any_guild: false,
dm: false,
allow_bots: false
}

โž– MessageReactionRemoveโ€‹

Has two arguments reaction who is an instance of MessageReaction and user who is an instance of User.

async function parse(reaction, user)
{
console.log("reaction of", message.author.username, "has been removed", reaction)
}

module.exports = {
parse,
conditions: [],
any_guild: false,
dm: false,
allow_bots: false
}

๐Ÿ–ฅ๏ธ Methods and parametersโ€‹

โŽฏ Exports

At the bottom of the file we have exports, which includes several important elements.

module.exports = {
parse,
conditions: [],
any_guild: false,
dm: false,
allow_bots: false
}
  • parse โ†’ method to handle the event
  • conditions โ†’ list of methods to check if reaction and user has the right conditions
  • any_guild โ†’ if false, the command can be executed only on the main guild
  • dm โ†’ if true, we can use this command in direct messages
  • allow_bots โ†’ if false, it will ignore events when the user is a bot