Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions src/features/emojiMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "../helpers/discord.js";
import { partition } from "../helpers/array.js";
import { EMBED_COLOR } from "./commands.js";
import { logger } from "./log.js";

const config = {
// This is how many ️️warning reactions a post must get until it's considered an official warning
Expand Down Expand Up @@ -146,31 +147,45 @@ const emojiMod: ChannelHandlers = {
if (!reactionHandlers[emoji]) {
return;
}

const [fullReaction, fullMessage, reactor] = await Promise.all([
reaction.partial ? reaction.fetch() : reaction,
message.partial ? message.fetch() : message,
guild.members.fetch(user.id),
]);
const [usersWhoReacted, authorMember] = await Promise.all([
fetchReactionMembers(guild, fullReaction),
guild.members.fetch(fullMessage.author.id),
]);

if (authorMember.id === bot.user?.id) return;

if (authorMember.id === bot.user?.id) return;

reactionHandlers[emoji]({
guild,
author: authorMember,
reactor,
message: fullMessage,
reaction: fullReaction,
usersWhoReacted: usersWhoReacted.filter(
(x): x is GuildMember => Boolean(x) && authorMember.id !== reactor.id,
),
});
try {
const [fullReaction, fullMessage, reactor] = await Promise.all([
reaction.partial ? reaction.fetch() : reaction,
message.partial ? message.fetch() : message,
guild.members.fetch(user.id),
]);
const [usersWhoReacted, authorMember] = await Promise.all([
fetchReactionMembers(guild, fullReaction),
guild.members.fetch(fullMessage.author.id),
]);

if (authorMember.id === bot.user?.id) return;

if (authorMember.id === bot.user?.id) return;

reactionHandlers[emoji]({
guild,
author: authorMember,
reactor,
message: fullMessage,
reaction: fullReaction,
usersWhoReacted: usersWhoReacted.filter(
(x): x is GuildMember => Boolean(x) && authorMember.id !== reactor.id,
),
});
} catch (e) {
if (e instanceof Error) {
let descriptiveMessage = `Channel id: ${message.channelId}`;
if (message.channel.isThread()) {
const thread = message.channel;
descriptiveMessage += `Thread id: ${thread.id}`;
}
logger.log(
`${descriptiveMessage} username: ${user.username} message: ${message.content}`,
e,
);
}
throw e;
}
},
};

Expand Down