detect users adding/removing reactions

This commit is contained in:
Baipyrus 2024-01-28 18:33:03 +01:00
parent 713135a021
commit 0edf46856a
3 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,8 @@
import { Events } from 'discord.js';
export const name = Events.MessageReactionAdd;
export async function execute(messageReaction, user) {
console.log(messageReaction, user);
export async function execute(reaction, user) {
const uname = user.username;
const rname = reaction._emoji.name;
console.debug(`[DEBUG] User '${uname}' reacted with emoji '${rname}'.`);
}

View File

@ -1,6 +1,8 @@
import { Events } from 'discord.js';
export const name = Events.MessageReactionRemove;
export async function execute(messageReaction, user) {
console.log(messageReaction, user);
export async function execute(reaction, user) {
const uname = user.username;
const rname = reaction._emoji.name;
console.debug(`[DEBUG] User '${uname}' removed reaction of emoji '${rname}'.`);
}

View File

@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
import { promisify } from 'util';
import { config } from 'dotenv';
import { readdir } from 'fs';
import { Partials } from 'discord.js';
config();
const readdirAsync = promisify(readdir);
@ -13,7 +14,14 @@ const optional = ['autocomplete', 'modalSubmit'];
const runClient = (commands, events) => {
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions
],
partials: [Partials.Message, Partials.Reaction]
});
client.commands = new Collection();
commands.forEach((c) => client.commands.set(c.data.name, c));
events.forEach((e) =>