Fix a bunch of linter errors
diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts
index bbb6a32..53de4df 100644
--- a/src/events/messageCreate.ts
+++ b/src/events/messageCreate.ts
@@ -1,24 +1,42 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import { HaikuClient } from "jshaiku";
-import { LinkCheck, MalwareCheck, NSFWCheck, SizeCheck, TestString, TestImage } from "../reflex/scanners.js";
+import {
+ LinkCheck,
+ MalwareCheck,
+ NSFWCheck,
+ SizeCheck,
+ TestString,
+ TestImage
+} from "../reflex/scanners.js";
import logAttachment from "../premium/attachmentLogs.js";
import createLogException from "../utils/createLogException.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import client from "../utils/client.js";
-import {callback as a} from "../reflex/statsChannelUpdate.js";
+import { callback as a } from "../reflex/statsChannelUpdate.js";
import type { Message } from "discord.js";
export const event = "messageCreate";
export async function callback(_client: HaikuClient, message: Message) {
- if(!message) return;
- if(!message.guild) return;
+ if (!message) return;
+ if (!message.guild) return;
if (message.author.bot) return;
if (message.channel.type === "DM") return;
- try { await a(client, await message.guild.members.fetch(message.author.id)); } catch(e) { console.log(e);}
+ try {
+ await a(client, await message.guild.members.fetch(message.author.id));
+ } catch (e) {
+ console.log(e);
+ }
- const { log, NucleusColors, entry, renderUser, renderDelta, renderChannel } = client.logger;
+ const {
+ log,
+ NucleusColors,
+ entry,
+ renderUser,
+ renderDelta,
+ renderChannel
+ } = client.logger;
const fileNames = await logAttachment(message);
@@ -26,36 +44,61 @@
const config = await client.memory.readGuildInfo(message.guild.id);
const filter = getEmojiByName("ICONS.FILTER");
let attachmentJump = "";
- if (config.logging.attachments.saved[message.channel.id + message.id]) { attachmentJump = ` [[View attachments]](${config.logging.attachments.saved[message.channel.id + message.id]})`; }
+ if (config.logging.attachments.saved[message.channel.id + message.id]) {
+ attachmentJump = ` [[View attachments]](${
+ config.logging.attachments.saved[message.channel.id + message.id]
+ })`;
+ }
const list = {
messageId: entry(message.id, `\`${message.id}\``),
sentBy: entry(message.author.id, renderUser(message.author)),
sentIn: entry(message.channel.id, renderChannel(message.channel)),
deleted: entry(new Date().getTime(), renderDelta(new Date().getTime())),
mentions: message.mentions.users.size,
- attachments: entry(message.attachments.size, message.attachments.size + attachmentJump),
+ attachments: entry(
+ message.attachments.size,
+ message.attachments.size + attachmentJump
+ ),
repliedTo: entry(
message.reference ? message.reference.messageId : null,
- message.reference ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})` : "None"
+ message.reference
+ ? `[[Jump to message]](https://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.reference.messageId})`
+ : "None"
)
};
if (config.filters.invite.enabled) {
- if (!config.filters.invite.allowed.channels.includes(message.channel.id)) {
- if ((/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content))) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ if (
+ !config.filters.invite.allowed.channels.includes(message.channel.id)
+ ) {
+ if (
+ /(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(
+ content
+ )
+ ) {
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
message.delete();
const data = {
meta: {
type: "messageDelete",
- displayName: "Message Deleted (Automated, Contained Invite)",
+ displayName:
+ "Message Deleted (Automated, Contained Invite)",
calculateType: "autoModeratorDeleted",
color: NucleusColors.red,
emoji: "MESSAGE.DELETE",
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Contained invite\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
+ start:
+ filter +
+ " Contained invite\n\n" +
+ (content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -69,15 +112,26 @@
if (fileNames.files.length > 0) {
for (const element of fileNames.files) {
- if(!message) return;
+ if (!message) return;
const url = element.url ? element.url : element.local;
if (url !== undefined) {
- if(/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)) {
- if (config.filters.images.NSFW && !(
- message.channel.type === "GUILD_PUBLIC_THREAD" ? false : message.channel.nsfw
- )) {
+ if (
+ /\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(
+ url
+ )
+ ) {
+ if (
+ config.filters.images.NSFW &&
+ !(message.channel.type === "GUILD_PUBLIC_THREAD"
+ ? false
+ : message.channel.nsfw)
+ ) {
if (await NSFWCheck(url)) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -89,7 +143,12 @@
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Image detected as NSFW\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
+ start:
+ filter +
+ " Image detected as NSFW\n\n" +
+ (content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -101,9 +160,17 @@
}
if (config.filters.wordFilter.enabled) {
const text = await TestImage(url);
- const check = TestString(text ?? "", config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict);
- if(check !== null) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ const check = TestString(
+ text ?? "",
+ config.filters.wordFilter.words.loose,
+ config.filters.wordFilter.words.strict
+ );
+ if (check !== null) {
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -115,7 +182,12 @@
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Image contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
+ start:
+ filter +
+ " Image contained filtered word\n\n" +
+ (content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -126,9 +198,13 @@
}
}
if (config.filters.images.size) {
- if(url.match(/\.+(webp|png|jpg)$/gi)) {
- if(!await SizeCheck(element)) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ if (url.match(/\.+(webp|png|jpg)$/gi)) {
+ if (!(await SizeCheck(element))) {
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -140,7 +216,12 @@
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Image was too small\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
+ start:
+ filter +
+ " Image was too small\n\n" +
+ (content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -154,7 +235,11 @@
}
if (config.filters.malware) {
if (!MalwareCheck(url)) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -166,7 +251,12 @@
timestamp: new Date().getTime()
},
separate: {
- start: filter + " File detected as malware\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
+ start:
+ filter +
+ " File detected as malware\n\n" +
+ (content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -179,7 +269,7 @@
}
}
}
- if(!message) return;
+ if (!message) return;
const linkDetectionTypes = await LinkCheck(message);
if (linkDetectionTypes.length > 0) {
@@ -195,7 +285,12 @@
timestamp: new Date().getTime()
},
separate: {
- start: filter + ` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
+ start:
+ filter +
+ ` Link filtered as ${linkDetectionTypes[0]?.toLowerCase()}\n\n` +
+ (content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -206,9 +301,17 @@
}
if (config.filters.wordFilter.enabled) {
- const check = TestString(content, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict);
- if(check !== null) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ const check = TestString(
+ content,
+ config.filters.wordFilter.words.loose,
+ config.filters.wordFilter.words.strict
+ );
+ if (check !== null) {
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -220,7 +323,12 @@
timestamp: new Date().getTime()
},
separate: {
- start: filter + " Message contained filtered word\n\n" + (content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*")
+ start:
+ filter +
+ " Message contained filtered word\n\n" +
+ (content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*")
},
list: list,
hidden: {
@@ -242,7 +350,9 @@
timestamp: new Date().getTime()
},
separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
+ start: content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*"
},
list: list,
hidden: {
@@ -252,10 +362,14 @@
return log(data);
}
if (config.filters.pings.roles) {
- for(const roleId in message.mentions.roles) {
- if(!message) return;
+ for (const roleId in message.mentions.roles) {
+ if (!message) return;
if (!config.filters.pings.allowed.roles.includes(roleId)) {
- createLogException(message.guild.id, message.channel.id, message.id);
+ createLogException(
+ message.guild.id,
+ message.channel.id,
+ message.id
+ );
await message.delete();
const data = {
meta: {
@@ -267,7 +381,9 @@
timestamp: new Date().getTime()
},
separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
+ start: content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*"
},
list: list,
hidden: {
@@ -278,7 +394,10 @@
}
}
}
- if (message.mentions.users.size >= config.filters.pings.mass && config.filters.pings.mass) {
+ if (
+ message.mentions.users.size >= config.filters.pings.mass &&
+ config.filters.pings.mass
+ ) {
createLogException(message.guild.id, message.channel.id, message.id);
await message.delete();
const data = {
@@ -291,7 +410,9 @@
timestamp: new Date().getTime()
},
separate: {
- start: content ? `**Message:**\n\`\`\`${content}\`\`\`` : "**Message:** *Message had no content*"
+ start: content
+ ? `**Message:**\n\`\`\`${content}\`\`\``
+ : "**Message:** *Message had no content*"
},
list: list,
hidden: {