Skip to content

Commit

Permalink
Make moderation actions === instead of >=
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonejt committed Nov 25, 2023
1 parent 49d8821 commit bb33936
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions events/guildMemberAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ async function moderate(member: GuildMember, action: number, reasons: Reason[])

const reason = reasons.map(reason => `${ATTR_PRETTY[reason.attribute as keyof typeof ATTR_PRETTY]}: ${reason.score} >= ${reason.threshold}`).toString();

if (action >= ACTIONS.indexOf("BAN")) member.ban({ reason });
else if (action >= ACTIONS.indexOf("KICK")) member.kick(reason);
else if (action >= ACTIONS.indexOf("MUTE")) member.timeout(DEFAULT_MUTE_PERIOD, reason);
if (action === ACTIONS.indexOf("BAN")) member.ban({ reason });
else if (action === ACTIONS.indexOf("KICK")) member.kick(reason);
else if (action === ACTIONS.indexOf("MUTE")) member.timeout(DEFAULT_MUTE_PERIOD, reason);

console.log(`Action: ${ACTIONS[action]} has been taken on @${member.user.username} (${member.user.id}) in Server: ${member.guild.name} (${member.guild.id}) because of ${reason}`);
}
7 changes: 4 additions & 3 deletions events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ export async function moderateMessage(message: Message, action: number, reasons:

const reason = reasons.map(reason => `${ATTR_PRETTY[reason.attribute as keyof typeof ATTR_PRETTY]}: ${reason.score} >= ${reason.threshold}`).toString();

if (action >= ACTIONS.indexOf("BAN")) message.member!.ban({ reason });
else if (action >= ACTIONS.indexOf("KICK")) message.member!.kick(reason);
else if (action >= ACTIONS.indexOf("MUTE")) message.member!.timeout(DEFAULT_MUTE_PERIOD, reason);
if (action >= ACTIONS.indexOf("REMOVE")) message.delete();
if (action === ACTIONS.indexOf("BAN")) message.member!.ban({ reason });
else if (action === ACTIONS.indexOf("KICK")) message.member!.kick(reason);
else if (action === ACTIONS.indexOf("MUTE")) message.member!.timeout(DEFAULT_MUTE_PERIOD, reason);


console.log(`Action: ${ACTIONS[action]} has been taken on @${message.author.username} (${message.author.id}) in Server: ${message.guild?.name} (${message.guild?.id}) because of ${reason}`);

Expand Down

0 comments on commit bb33936

Please sign in to comment.