Fixed typing
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index f00e82c..192be25 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -5,9 +5,9 @@
import type Discord from "discord.js";
import client from "../utils/client.js";
import { createHash } from "crypto";
-import * as nsfwjs from 'nsfwjs';
-import * as clamscan from 'clamscan'
-import * as tf from "@tensorflow/tfjs-node";
+// import * as nsfwjs from "nsfwjs";
+// import * as clamscan from "clamscan";
+// import * as tf from "@tensorflow/tfjs-node";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
@@ -21,10 +21,10 @@
errored?: boolean;
}
-const model = await nsfwjs.load();
+// const model = await nsfwjs.load();
export async function testNSFW(link: string): Promise<NSFWSchema> {
- const [fileName, hash] = await saveAttachment(link);
+ const [_fileName, hash] = await saveAttachment(link);
const alreadyHaveCheck = await client.database.scanCache.read(hash);
if (alreadyHaveCheck) return { nsfw: alreadyHaveCheck.data };
@@ -167,7 +167,12 @@
}
}
-export function TestString(string: string, soft: string[], strict: string[], enabled?: boolean): {word: string, type: string} | null {
+export function TestString(
+ string: string,
+ soft: string[],
+ strict: string[],
+ enabled?: boolean
+): { word: string; type: string } | null {
if (!enabled) return null;
for (const word of strict) {
if (string.toLowerCase().includes(word)) {
@@ -197,34 +202,56 @@
if (member.user.bot) return;
const guildData = await client.database.guilds.read(guild.id);
if (!guildData.logging.staff.channel) return;
- const [ loose, strict ] = [guildData.filters.wordFilter.words.loose, guildData.filters.wordFilter.words.strict];
+ const [loose, strict] = [guildData.filters.wordFilter.words.loose, guildData.filters.wordFilter.words.strict];
// Does the username contain filtered words
const usernameCheck = TestString(member.user.username, loose, strict, guildData.filters.wordFilter.enabled);
// Does the nickname contain filtered words
const nicknameCheck = TestString(member.nickname ?? "", loose, strict, guildData.filters.wordFilter.enabled);
// Does the profile picture contain filtered words
- const avatarTextCheck = TestString(await TestImage(member.user.displayAvatarURL({ forceStatic: true })) ?? "", loose, strict, guildData.filters.wordFilter.enabled);
+ const avatarTextCheck = TestString(
+ (await TestImage(member.user.displayAvatarURL({ forceStatic: true }))) ?? "",
+ loose,
+ strict,
+ guildData.filters.wordFilter.enabled
+ );
// Is the profile picture NSFW
- const avatarCheck = guildData.filters.images.NSFW && await NSFWCheck(member.user.displayAvatarURL({ forceStatic: true }));
+ const avatarCheck =
+ guildData.filters.images.NSFW && (await NSFWCheck(member.user.displayAvatarURL({ forceStatic: true })));
// Does the username contain an invite
- const inviteCheck = guildData.filters.invite.enabled && member.user.username.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
+ const inviteCheck =
+ guildData.filters.invite.enabled && member.user.username.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
// Does the nickname contain an invite
- const nicknameInviteCheck = guildData.filters.invite.enabled && member.nickname?.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
+ const nicknameInviteCheck =
+ guildData.filters.invite.enabled && member.nickname?.match(/discord\.gg\/[a-zA-Z0-9]+/gi) !== null;
- if (usernameCheck !== null || nicknameCheck !== null || avatarCheck || inviteCheck || nicknameInviteCheck || avatarTextCheck !== null) {
+ if (
+ usernameCheck !== null ||
+ nicknameCheck !== null ||
+ avatarCheck ||
+ inviteCheck ||
+ nicknameInviteCheck ||
+ avatarTextCheck !== null
+ ) {
const infractions = [];
if (usernameCheck !== null) {
infractions.push(`Username contains a ${usernameCheck.type}ly filtered word (${usernameCheck.word})`);
- } if (nicknameCheck !== null) {
+ }
+ if (nicknameCheck !== null) {
infractions.push(`Nickname contains a ${nicknameCheck.type}ly filtered word (${nicknameCheck.word})`);
- } if (avatarCheck) {
+ }
+ if (avatarCheck) {
infractions.push("Profile picture is NSFW");
- } if (inviteCheck) {
+ }
+ if (inviteCheck) {
infractions.push("Username contains an invite");
- } if (nicknameInviteCheck) {
+ }
+ if (nicknameInviteCheck) {
infractions.push("Nickname contains an invite");
- } if (avatarTextCheck !== null) {
- infractions.push(`Profile picture contains a ${avatarTextCheck.type}ly filtered word: ${avatarTextCheck.word}`);
+ }
+ if (avatarTextCheck !== null) {
+ infractions.push(
+ `Profile picture contains a ${avatarTextCheck.type}ly filtered word: ${avatarTextCheck.word}`
+ );
}
if (infractions.length === 0) return;
// This is bad - Warn in the staff notifications channel
@@ -234,34 +261,43 @@
.setTitle("Member Flagged")
.setEmoji("ICONS.FLAGS.RED")
.setStatus("Danger")
- .setDescription(`**Member:** ${member.user.username} (<@${member.user.id}>)\n\n` +
- infractions.map((element) => `${filter} ${element}`).join("\n")
- )
+ .setDescription(
+ `**Member:** ${member.user.username} (<@${member.user.id}>)\n\n` +
+ infractions.map((element) => `${filter} ${element}`).join("\n")
+ );
await channel.send({
embeds: [embed],
- components: [new ActionRowBuilder<ButtonBuilder>().addComponents(...[
- new ButtonBuilder()
- .setCustomId(`mod:warn:${member.user.id}`)
- .setLabel("Warn")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId(`mod:mute:${member.user.id}`)
- .setLabel("Mute")
- .setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId(`mod:kick:${member.user.id}`)
- .setLabel("Kick")
- .setStyle(ButtonStyle.Danger),
- new ButtonBuilder()
- .setCustomId(`mod:ban:${member.user.id}`)
- .setLabel("Ban")
- .setStyle(ButtonStyle.Danger),
- ].concat((usernameCheck !== null || nicknameCheck !== null || avatarTextCheck !== null) ? [
- new ButtonBuilder()
- .setCustomId(`mod:nickname:${member.user.id}`)
- .setLabel("Change Name")
- .setStyle(ButtonStyle.Primary)
- ] : []))]
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents(
+ ...[
+ new ButtonBuilder()
+ .setCustomId(`mod:warn:${member.user.id}`)
+ .setLabel("Warn")
+ .setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId(`mod:mute:${member.user.id}`)
+ .setLabel("Mute")
+ .setStyle(ButtonStyle.Primary),
+ new ButtonBuilder()
+ .setCustomId(`mod:kick:${member.user.id}`)
+ .setLabel("Kick")
+ .setStyle(ButtonStyle.Danger),
+ new ButtonBuilder()
+ .setCustomId(`mod:ban:${member.user.id}`)
+ .setLabel("Ban")
+ .setStyle(ButtonStyle.Danger)
+ ].concat(
+ usernameCheck !== null || nicknameCheck !== null || avatarTextCheck !== null
+ ? [
+ new ButtonBuilder()
+ .setCustomId(`mod:nickname:${member.user.id}`)
+ .setLabel("Change Name")
+ .setStyle(ButtonStyle.Primary)
+ ]
+ : []
+ )
+ )
+ ]
});
}
-}
\ No newline at end of file
+}