Skip to content

Commit

Permalink
fix: reaction events
Browse files Browse the repository at this point in the history
  • Loading branch information
Faf4a committed Oct 11, 2024
1 parent 60409a3 commit c558900
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/events/GuildMessageReactions/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/events/GuildMessageReactions/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/events/GuildMessageReactions/removeAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/events/GuildMessageReactions/removeEmoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
15 changes: 6 additions & 9 deletions src/functions/reactionData.js
Original file line number Diff line number Diff line change
@@ -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)
}
}
};
};
13 changes: 13 additions & 0 deletions src/utils/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -514,6 +526,7 @@ module.exports = {
ButtonStyleOptions,
ChannelOptions,
MemberOptions,
ReactionOptions,
CacheOptions,
SlashOptionTypes,
Permissions,
Expand Down

0 comments on commit c558900

Please sign in to comment.