Skip to content

Commit

Permalink
Set default action to -1 to not Notify
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonejt committed Nov 25, 2023
1 parent 9f372da commit 49d8821
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions embeds/memberModeration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { ACTIONS, ATTR_PRETTY, Reason } from "../clients/constants.js";

export default function embedMemberModeration(member: GuildMember, action: number, reasons: Reason[]) {
const embed = new EmbedBuilder()
.setTitle(`Flagged Psycho-Pass of ${member.user.username}`)
.setAuthor({ name: "Sibyl System", iconURL: member.client.user.avatarURL()! })
.setTimestamp()
.setFooter({ text: member.id });

if (ACTIONS[action] === "BAN") embed.setTitle(`Banned ${member.user.username}`);
else if (ACTIONS[action] === "KICK") embed.setTitle(`Kicked ${member.user.username}`);
else if (ACTIONS[action] === "MUTE") embed.setTitle(`Muted ${member.user.username}`);
else if (action >= ACTIONS.indexOf("NOTIFY")) embed.setTitle("Notified Moderators");
if (ACTIONS[action] === "BAN") embed.setDescription(`Banned ${member.user.username}`);
else if (ACTIONS[action] === "KICK") embed.setDescription(`Kicked ${member.user.username}`);
else if (ACTIONS[action] === "MUTE") embed.setDescription(`Muted ${member.user.username}`);
else if (action >= ACTIONS.indexOf("NOTIFY")) embed.setDescription("Notified Moderators");

for (const reason of reasons) {
embed.addFields(
Expand Down
4 changes: 2 additions & 2 deletions events/guildMemberAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function moderateMember(member: GuildMember) {
const [psychoPass, dominator] = await Promise.all([PsychoPasses.read(member.user.id), MemberDominators.read(member.guild.id)]);
if (psychoPass === undefined || dominator === undefined) throw new Error("Psycho-Pass or Dominator undefined!");
if (psychoPass.messages < 25) return;
let maxAction = ACTIONS.indexOf("NOTIFY");
let maxAction = -1;
const reasons: Reason[] = [];
for (const attribute of ATTRIBUTES) {
const score = psychoPass[attribute as keyof PsychoPass] as number;
Expand All @@ -41,7 +41,7 @@ export async function moderateMember(member: GuildMember) {
threshold: 100
});
}
moderate(member, maxAction, reasons);
if (maxAction >= 0) moderate(member, maxAction, reasons);
}

async function moderate(member: GuildMember, action: number, reasons: Reason[]) {
Expand Down
4 changes: 2 additions & 2 deletions events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function messageCreate(message: Message) {
analysis.userID = message.author.id;
analysis.communityID = message.guildId!;
ingestMessage(analysis);
let maxAction = ACTIONS.indexOf("NOTIFY");
let maxAction = -1;
const reasons: Reason[] = [];
for (const attribute in analysis.attributeScores) {
const score = analysis.attributeScores[attribute as keyof MessageAnalysis["attributeScores"]].summaryScore.value;
Expand All @@ -31,7 +31,7 @@ export async function messageCreate(message: Message) {
reasons.push({ attribute: attribute.toLowerCase(), score, threshold });
}
}
moderateMessage(message, maxAction, reasons);
if (maxAction >= 0) moderateMessage(message, maxAction, reasons);
moderateMember(message.member!);
} catch (error) {
console.error(error);
Expand Down

0 comments on commit 49d8821

Please sign in to comment.