๐ญ Reactions
๐ Multi eventsโ
There is 2 kinds of events here:
MessageReactionAddโ when a reaction is added to a messageMessageReactionDeleteโ when a reaction is removed from a message
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:
addโ to handleMessageReactionAddremoveโ to handleMessageReactionDelete
โฏ Example for each classes
replace <module_name> by the name of your module
addโ./sources/modules/<module_name>/reactions/add.jsremoveโ./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 eventconditionsโ list of methods to check ifreactionanduserhas the right conditionsany_guildโ if false, the command can be executed only on the main guilddmโ if true, we can use this command in direct messagesallow_botsโ if false, it will ignore events when the user is a bot