mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
18 lines
797 B
TypeScript
18 lines
797 B
TypeScript
import Event from "../core/event";
|
|
import {Permissions} from "discord.js";
|
|
import {botHasPermission} from "../core/lib";
|
|
|
|
// A list of message ID and callback pairs. You get the emote name and ID of the user reacting.
|
|
export const eventListeners: Map<string, (emote: string, id: string) => void> = new Map();
|
|
|
|
// Attached to the client, there can be one event listener attached to a message ID which is executed if present.
|
|
export default new Event<"messageReactionRemove">({
|
|
on(reaction, user) {
|
|
const canDeleteEmotes = botHasPermission(reaction.message.guild, Permissions.FLAGS.MANAGE_MESSAGES);
|
|
|
|
if (!canDeleteEmotes) {
|
|
const callback = eventListeners.get(reaction.message.id);
|
|
callback && callback(reaction.emoji.name, user.id);
|
|
}
|
|
}
|
|
});
|