From c5589008b7091d977f21f2c11fc0c378b2f8800c Mon Sep 17 00:00:00 2001 From: Faf4a <87046111+Faf4a@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:44:55 +0200 Subject: [PATCH] fix: reaction events --- src/events/GuildMessageReactions/add.js | 2 +- src/events/GuildMessageReactions/remove.js | 2 +- src/events/GuildMessageReactions/removeAll.js | 2 +- src/events/GuildMessageReactions/removeEmoji.js | 2 +- src/functions/reactionData.js | 15 ++++++--------- src/utils/Constants.js | 13 +++++++++++++ 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/events/GuildMessageReactions/add.js b/src/events/GuildMessageReactions/add.js index 8643fc31f..60242281c 100644 --- a/src/events/GuildMessageReactions/add.js +++ b/src/events/GuildMessageReactions/add.js @@ -5,7 +5,7 @@ const Interpreter = require("../../core/interpreter.js"); * @param {User} user * @param {import('../../classes/AoiClient.js')} client */ -module.exports = async (newReaction, user, client) => { +module.exports = async (newReaction, user, burst, client) => { const cmds = client.cmd?.reactionAdd.V(); if (!cmds) return; const data = { diff --git a/src/events/GuildMessageReactions/remove.js b/src/events/GuildMessageReactions/remove.js index 45512519a..7588d3e23 100644 --- a/src/events/GuildMessageReactions/remove.js +++ b/src/events/GuildMessageReactions/remove.js @@ -5,7 +5,7 @@ const { MessageReaction } = require("discord.js"); * @param {User} user * @param {import('../../classes/AoiClient.js')} client */ -module.exports = async (oldReaction, user, client) => { +module.exports = async (oldReaction, user, burst, client) => { const cmds = client.cmd?.reactionRemove.V(); if (!cmds) return; const data = { diff --git a/src/events/GuildMessageReactions/removeAll.js b/src/events/GuildMessageReactions/removeAll.js index bcd97fa61..cee0a14ae 100644 --- a/src/events/GuildMessageReactions/removeAll.js +++ b/src/events/GuildMessageReactions/removeAll.js @@ -4,7 +4,7 @@ const { Message } = require("discord.js"); * @param {Message} reactionMessage * @param {import('../../classes/AoiClient.js')} client */ -module.exports = async (reactionMessage, client) => { +module.exports = async (reactionMessage, burst, client) => { const cmds = client.cmd?.reactionRemoveAll.V(); if (!cmds) return; const data = { diff --git a/src/events/GuildMessageReactions/removeEmoji.js b/src/events/GuildMessageReactions/removeEmoji.js index 290da5e1f..ee845c7c8 100644 --- a/src/events/GuildMessageReactions/removeEmoji.js +++ b/src/events/GuildMessageReactions/removeEmoji.js @@ -5,7 +5,7 @@ const { MessageReaction } = require("discord.js"); * @param {User} user * @param {import('../../classes/AoiClient.js')} client */ -module.exports = async (oldReaction, client) => { +module.exports = async (oldReaction, burst, client) => { const cmds = client.cmd?.reactionRemoveEmoji.V(); if (!cmds) return; const data = { diff --git a/src/functions/reactionData.js b/src/functions/reactionData.js index dc2e51a7b..0a57eb884 100644 --- a/src/functions/reactionData.js +++ b/src/functions/reactionData.js @@ -1,20 +1,17 @@ -const {Emoji} = require('../core/functions.js'); +const { ReactionOptions } = require("../utils/Constants"); /** * @param {import("..").Data} d */ -module.exports = async d => { +module.exports = async (d) => { const data = d.util.aoiFunc(d); const [option = "name"] = data.inside.splits; - const reactionData = Emoji(d.data.reactionData.emoji); - reactionData.usernames = d.data.reactionData.users.cache.map(y => y.username.deleteBrackets()).join(" , "); - reactionData.userIds = d.data.reactionData.users.cache.map(y => y.id).join(" , "); - reactionData.tags = d.data.reactionData.users.cache.map(y => y.tag.deleteBrackets()).join(" , "); + const reactionData = ReactionOptions[option](d.data.reactionData); - data.result = reactionData?.[option].deleteBrackets(); + data.result = reactionData ?? null; return { code: d.util.setCode(data) - } -} \ No newline at end of file + }; +}; diff --git a/src/utils/Constants.js b/src/utils/Constants.js index 99b471c3e..a00ed7cb0 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -173,6 +173,18 @@ const MemberOptions = { threadFlags: (member) => member.flags?.toArray() || [] }; +const ReactionOptions = { + channelId: (reaction) => reaction.message.channel.id, + guildId: (reaction) => reaction.message.guild.id, + messageId: (reaction) => reaction.message.id, + name: (reaction) => reaction._emoji.name, + id: (reaction) => reaction._emoji.id, + emoji: (reaction) => reaction._emoji.toString(), + count: (reaction) => reaction.count, + usernames: (reaction) => reaction.users.cache.map(y => y.username.deleteBrackets()).join(" , "), + userIds: (reaction) => reaction.users.cache.map(y => y.id).join(" , "), +} + const ButtonStyleOptions = { primary: 1, secondary: 2, @@ -514,6 +526,7 @@ module.exports = { ButtonStyleOptions, ChannelOptions, MemberOptions, + ReactionOptions, CacheOptions, SlashOptionTypes, Permissions,