From 9e63e0ff0910d781f5bf6d26a0bdd3fe4d54af86 Mon Sep 17 00:00:00 2001 From: DuAnti7423 <82730507+DuAnti7423@users.noreply.github.com> Date: Sun, 23 May 2021 10:41:05 +0200 Subject: [PATCH] Create raw.js Added Raw-Event, probably fixxed the ticketreaction isnt 100% workin --- events/raw.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 events/raw.js diff --git a/events/raw.js b/events/raw.js new file mode 100644 index 0000000..400b0b5 --- /dev/null +++ b/events/raw.js @@ -0,0 +1,26 @@ +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)); + } + }); +} \ No newline at end of file