|
|
|
@ -1,4 +1,3 @@
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
|
|
|
|
|
|
// @ts-expect-error
|
|
|
|
// @ts-expect-error
|
|
|
|
import { HaikuClient } from "jshaiku";
|
|
|
|
import { HaikuClient } from "jshaiku";
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
@ -14,12 +13,11 @@ import createLogException from "../utils/createLogException.js";
|
|
|
|
import getEmojiByName from "../utils/getEmojiByName.js";
|
|
|
|
import getEmojiByName from "../utils/getEmojiByName.js";
|
|
|
|
import client from "../utils/client.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";
|
|
|
|
import { Message, ThreadChannel } from "discord.js";
|
|
|
|
|
|
|
|
|
|
|
|
export const event = "messageCreate";
|
|
|
|
export const event = "messageCreate";
|
|
|
|
|
|
|
|
|
|
|
|
export async function callback(_client: HaikuClient, message: Message) {
|
|
|
|
export async function callback(_client: HaikuClient, message: Message) {
|
|
|
|
if (!message) return;
|
|
|
|
|
|
|
|
if (!message.guild) return;
|
|
|
|
if (!message.guild) return;
|
|
|
|
if (message.author.bot) return;
|
|
|
|
if (message.author.bot) return;
|
|
|
|
if (message.channel.type === "DM") return;
|
|
|
|
if (message.channel.type === "DM") return;
|
|
|
|
@ -112,18 +110,14 @@ export async function callback(_client: HaikuClient, message: Message) {
|
|
|
|
|
|
|
|
|
|
|
|
if (fileNames.files.length > 0) {
|
|
|
|
if (fileNames.files.length > 0) {
|
|
|
|
for (const element of fileNames.files) {
|
|
|
|
for (const element of fileNames.files) {
|
|
|
|
if (!message) return;
|
|
|
|
|
|
|
|
const url = element.url ? element.url : element.local;
|
|
|
|
const url = element.url ? element.url : element.local;
|
|
|
|
if (url !== undefined) {
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(
|
|
|
|
/\.(jpg|jpeg|png|gif|gifv|webm|webp|mp4|wav|mp3|ogg)$/.test(url)
|
|
|
|
url
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
config.filters.images.NSFW &&
|
|
|
|
config.filters.images.NSFW &&
|
|
|
|
!(message.channel.type === "GUILD_PUBLIC_THREAD"
|
|
|
|
!(message.channel instanceof ThreadChannel
|
|
|
|
? false
|
|
|
|
? message.channel.parent?.nsfw
|
|
|
|
: message.channel.nsfw)
|
|
|
|
: message.channel.nsfw)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
if (await NSFWCheck(url)) {
|
|
|
|
if (await NSFWCheck(url)) {
|
|
|
|
@ -234,7 +228,7 @@ export async function callback(_client: HaikuClient, message: Message) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (config.filters.malware) {
|
|
|
|
if (config.filters.malware) {
|
|
|
|
if (!MalwareCheck(url)) {
|
|
|
|
if (!(await MalwareCheck(url))) {
|
|
|
|
createLogException(
|
|
|
|
createLogException(
|
|
|
|
message.guild.id,
|
|
|
|
message.guild.id,
|
|
|
|
message.channel.id,
|
|
|
|
message.channel.id,
|
|
|
|
@ -268,8 +262,6 @@ export async function callback(_client: HaikuClient, message: Message) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!message) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const linkDetectionTypes = await LinkCheck(message);
|
|
|
|
const linkDetectionTypes = await LinkCheck(message);
|
|
|
|
if (linkDetectionTypes.length > 0) {
|
|
|
|
if (linkDetectionTypes.length > 0) {
|
|
|
|
@ -363,7 +355,6 @@ export async function callback(_client: HaikuClient, message: Message) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (config.filters.pings.roles) {
|
|
|
|
if (config.filters.pings.roles) {
|
|
|
|
for (const roleId in message.mentions.roles) {
|
|
|
|
for (const roleId in message.mentions.roles) {
|
|
|
|
if (!message) return;
|
|
|
|
|
|
|
|
if (!config.filters.pings.allowed.roles.includes(roleId)) {
|
|
|
|
if (!config.filters.pings.allowed.roles.includes(roleId)) {
|
|
|
|
createLogException(
|
|
|
|
createLogException(
|
|
|
|
message.guild.id,
|
|
|
|
message.guild.id,
|
|
|
|
|