From f2cd13b923413e4452dcce5b33bd38273fb5e226 Mon Sep 17 00:00:00 2001 From: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Date: Sat, 25 Sep 2021 14:50:18 +0100 Subject: [PATCH] feat: reaction detector --- events/messageReactionAdd.js | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 events/messageReactionAdd.js diff --git a/events/messageReactionAdd.js b/events/messageReactionAdd.js new file mode 100644 index 0000000..816c292 --- /dev/null +++ b/events/messageReactionAdd.js @@ -0,0 +1,41 @@ +module.exports = { + name: 'messageReactionAdd', + once: false, + async execute(reaction, user, client) { + if (reaction.partial) { + await reaction.fetch(); + } + + if (!reaction.message.channel.permissionsFor(client.user.id).has('MANAGE_MESSAGES') || reaction.emoji.name !== '🇬') { + return; + } + + reaction.remove(); + + if (user.bot) { + return; + } + + require('../detector/counter.js')(client, reaction.message.guildId, user.id); + + const logs = client.db.prepare('SELECT logs FROM guilds WHERE id = ?').get(reaction.message.guildId)?.logs; + const channel = reaction.message.guild.channels.cache.get(logs); + + channel?.send({ + embeds: [{ + title: 'G Removal', + url: 'https://h-projects.github.io/app/fuck-g/', + color: client.config.color, + fields: [ + { name: 'Type', value: 'Reaction' }, + { name: 'User', value: `${user} (${user.id})` }, + { name: 'Channel', value: `${reaction.message.channel} (${reaction.message.channelId})` }, + { name: 'Reaction', value: `${reaction.emoji}` } + ], + thumbnail: { + url: user.displayAvatarURL({ dynamic: true }) + } + }] + }); + } +};