detect users adding/removing reactions
This commit is contained in:
parent
713135a021
commit
0edf46856a
|
@ -1,6 +1,8 @@
|
||||||
import { Events } from 'discord.js';
|
import { Events } from 'discord.js';
|
||||||
|
|
||||||
export const name = Events.MessageReactionAdd;
|
export const name = Events.MessageReactionAdd;
|
||||||
export async function execute(messageReaction, user) {
|
export async function execute(reaction, user) {
|
||||||
console.log(messageReaction, user);
|
const uname = user.username;
|
||||||
|
const rname = reaction._emoji.name;
|
||||||
|
console.debug(`[DEBUG] User '${uname}' reacted with emoji '${rname}'.`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { Events } from 'discord.js';
|
import { Events } from 'discord.js';
|
||||||
|
|
||||||
export const name = Events.MessageReactionRemove;
|
export const name = Events.MessageReactionRemove;
|
||||||
export async function execute(messageReaction, user) {
|
export async function execute(reaction, user) {
|
||||||
console.log(messageReaction, user);
|
const uname = user.username;
|
||||||
|
const rname = reaction._emoji.name;
|
||||||
|
console.debug(`[DEBUG] User '${uname}' removed reaction of emoji '${rname}'.`);
|
||||||
}
|
}
|
||||||
|
|
10
index.js
10
index.js
|
@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
import { readdir } from 'fs';
|
import { readdir } from 'fs';
|
||||||
|
import { Partials } from 'discord.js';
|
||||||
|
|
||||||
config();
|
config();
|
||||||
const readdirAsync = promisify(readdir);
|
const readdirAsync = promisify(readdir);
|
||||||
|
@ -13,7 +14,14 @@ const optional = ['autocomplete', 'modalSubmit'];
|
||||||
|
|
||||||
const runClient = (commands, events) => {
|
const runClient = (commands, events) => {
|
||||||
// Create a new client instance
|
// 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();
|
client.commands = new Collection();
|
||||||
commands.forEach((c) => client.commands.set(c.data.name, c));
|
commands.forEach((c) => client.commands.set(c.data.name, c));
|
||||||
events.forEach((e) =>
|
events.forEach((e) =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user