Skip to content

Commit

Permalink
feat: reaction detector
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Sep 25, 2021
1 parent aeb15e2 commit f2cd13b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions events/messageReactionAdd.js
Original file line number Diff line number Diff line change
@@ -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 })
}
}]
});
}
};

0 comments on commit f2cd13b

Please sign in to comment.