26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
const Discord = require("discord.js");
|
|
const fs = require("fs");
|
|
|
|
const yaml = require('js-yaml');
|
|
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
|
|
|
|
|
|
|
|
module.exports = async (bot, message, packet) => {
|
|
if (!['MESSAGE_REACTION_ADD', 'MESSAGE_REACTION_REMOVE'].includes(packet.t)) return;
|
|
|
|
const channel = bot.channels.cache.get(packet.d.channel_id);
|
|
if (channel.messages.has(packet.d.message_id)) return;
|
|
|
|
channel.messages.fetch(packet.d.message_id).then(message => {
|
|
const emoji = packet.d.emoji.id ? `${packet.d.emoji.name}:${packet.d.emoji.id}` : packet.d.emoji.name;
|
|
const reaction = message.reactions.get(emoji);
|
|
if (reaction) reaction.users.set(packet.d.user_id, bot.users.get(packet.d.user_id));
|
|
if (packet.t === 'MESSAGE_REACTION_ADD') {
|
|
bot.emit('messageReactionAdd', reaction, bot.users.get(packet.d.user_id));
|
|
}
|
|
if (packet.t === 'MESSAGE_REACTION_REMOVE') {
|
|
bot.emit('messageReactionRemove', reaction, bot.users.get(packet.d.user_id));
|
|
}
|
|
});
|
|
} |