Skip to content

Commit

Permalink
fix #274
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsundso committed Dec 12, 2024
1 parent ddabe91 commit c09e749
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 75 deletions.
43 changes: 11 additions & 32 deletions src/Events/BotEvents/messageEvents/messageReactionAdd/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,18 @@ export default async (
const lan = language.events.logs.reaction;
const con = msg.client.util.constants.events.logs.reaction;
const files: Discord.AttachmentPayload[] = [];
const embeds: Discord.APIEmbed[] = [];

const embed: Discord.APIEmbed = {
author: {
icon_url: con.create,
name: lan.nameAdd,
},
author: { icon_url: con.create, name: lan.nameAdd },
description: lan.descAdded(reaction.emoji, user, msg),
fields: [],
color: CT.Colors.Success,
timestamp: new Date().toISOString(),
};

embeds.push(embed);

if (msg.reactions.cache?.size) {
embeds.push({
title: lan.reactions,
description: msg.reactions.cache
.map(
(r) =>
`\`${msg.client.util.spaces(`${r.count ?? 1}`, 5)}\` ${
(reaction.emoji.id && r.emoji.id && reaction.emoji.id === r.emoji.id) ||
(!reaction.emoji.id && reaction.emoji.name === r.emoji.name)
? ` ${msg.client.util.constants.standard.getEmote(msg.client.util.emotes.plusBG)}`
: ` ${msg.client.util.constants.standard.getEmote(msg.client.util.emotes.invis)}`
} ${language.languageFunction.getEmote(r.emoji)}`,
)
.join(''),
color: CT.Colors.Ephemeral,
});
}

embed.thumbnail = {
url: `attachment://${msg.client.util.getNameAndFileType(
msg.client.util.constants.standard.emoteURL(reaction.emoji),
)}`,
thumbnail: {
url: `attachment://${msg.client.util.getNameAndFileType(
msg.client.util.constants.standard.emoteURL(reaction.emoji),
)}`,
},
};

const attachment = (
Expand All @@ -62,5 +37,9 @@ export default async (

if (attachment) files.push(...attachment);

await msg.client.util.send({ id: channels, guildId: msg.guildId }, { embeds, files }, 10000);
await msg.client.util.send(
{ id: channels, guildId: msg.guildId },
{ embeds: [embed], files },
10000,
);
};
46 changes: 11 additions & 35 deletions src/Events/BotEvents/messageEvents/messageReactionRemove/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,18 @@ export default async (
const lan = language.events.logs.reaction;
const con = reaction.client.util.constants.events.logs.reaction;
const files: Discord.AttachmentPayload[] = [];
const embeds: Discord.APIEmbed[] = [];

const embed: Discord.APIEmbed = {
author: {
icon_url: con.remove,
name: lan.nameRemove,
},
author: { icon_url: con.remove, name: lan.nameRemove },
description: lan.descRemoved(reaction.emoji, user, msg),
fields: [],
color: CT.Colors.Danger,
timestamp: new Date().toISOString(),
};

embeds.push(embed);

if (msg.reactions.cache.filter((r) => Number(r.count) !== 0)?.size) {
embeds.push({
title: lan.reactions,
description: (msg.reactions.cache ?? [{ count: 0, emoji: reaction.emoji }])
.filter((r) => Number(r.count) !== 0)
?.map(
(r) =>
`\`${reaction.client.util.spaces(`${Number(r.count)}`, 5)}\` ${
(reaction.emoji.id && r.emoji.id && reaction.emoji.id === r.emoji.id) ||
(!reaction.emoji.id && reaction.emoji.name === r.emoji.name)
? ` ${reaction.client.util.constants.standard.getEmote(
reaction.client.util.emotes.minusBG,
)}`
: ` ${reaction.client.util.constants.standard.getEmote(reaction.client.util.emotes.invis)}`
} ${language.languageFunction.getEmote(r.emoji)}`,
)
.join(''),
color: CT.Colors.Ephemeral,
});
}

embed.thumbnail = {
url: `attachment://${reaction.client.util.getNameAndFileType(
reaction.client.util.constants.standard.emoteURL(reaction.emoji),
)}`,
thumbnail: {
url: `attachment://${reaction.client.util.getNameAndFileType(
reaction.client.util.constants.standard.emoteURL(reaction.emoji),
)}`,
},
};

const attachment = (
Expand All @@ -64,5 +36,9 @@ export default async (
)?.[0];
if (attachment) files.push(attachment);

await reaction.client.util.send({ id: channels, guildId: msg.guildId }, { embeds, files }, 10000);
await reaction.client.util.send(
{ id: channels, guildId: msg.guildId },
{ embeds: [embed], files },
10000,
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ export default async (
const files: Discord.AttachmentPayload[] = [];

const embed: Discord.APIEmbed = {
author: {
name: lan.nameRemoveAll,
icon_url: con.remove,
url: msg.url,
},
author: { name: lan.nameRemoveAll, icon_url: con.remove, url: msg.url },
description: lan.descRemovedAll(msg),
color: CT.Colors.Danger,
fields: [],
Expand All @@ -37,11 +33,16 @@ export default async (
r.emoji,
)}`,
)
.join('\n'),
.join(''),
});

const users = msg.client.util.txtFileWriter(
reactions.map((r) => r.users.cache.map(String).join(', ')).join('\n'),
reactions
.map(
(r) =>
`${language.languageFunction.getEmote(r.emoji)}\n- ${r.users.cache.map((u) => language.languageFunction.getUser(u)).join('')}`,
)
.join('\n\n'),
undefined,
lan.reactions,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default async (reaction: Discord.MessageReaction, msg: Discord.Message<tr
});

const users = reaction.client.util.txtFileWriter(
reaction.users.cache.map((r) => r.id).join(', '),
`${language.languageFunction.getEmote(reaction.emoji)}\n- ${reaction.users.cache.map((u) => language.languageFunction.getUser(u)).join('')}`,
undefined,
lan.reactions,
);
Expand Down

0 comments on commit c09e749

Please sign in to comment.