|
|
|
|
@ -5,11 +5,19 @@ import { messageException } from "../utils/createTemporaryStorage.js";
|
|
|
|
|
import getEmojiByName from "../utils/getEmojiByName.js";
|
|
|
|
|
import client from "../utils/client.js";
|
|
|
|
|
import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
|
|
|
|
|
import { ChannelType, Message, ThreadChannel } from "discord.js";
|
|
|
|
|
import { ChannelType, GuildMember, Message, ThreadChannel } from "discord.js";
|
|
|
|
|
import singleNotify from "../utils/singleNotify.js";
|
|
|
|
|
|
|
|
|
|
export const event = "messageCreate";
|
|
|
|
|
|
|
|
|
|
function checkUserForExceptions(user: GuildMember, exceptions: { roles: string[]; users: string[] }) {
|
|
|
|
|
if (exceptions.users.includes(user.id)) return true;
|
|
|
|
|
for (const role of user.roles.cache.values()) {
|
|
|
|
|
if (exceptions.roles.includes(role.id)) return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
if (!message.guild) return;
|
|
|
|
|
const config = await client.memory.readGuildInfo(message.guild.id);
|
|
|
|
|
@ -45,10 +53,7 @@ export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
|
|
|
|
|
const content = message.content.toLowerCase() || "";
|
|
|
|
|
if (config.filters.clean.channels.includes(message.channel.id)) {
|
|
|
|
|
const memberRoles = message.member!.roles.cache.map((role) => role.id);
|
|
|
|
|
const roleAllow = config.filters.clean.allowed.roles.some((role) => memberRoles.includes(role));
|
|
|
|
|
const userAllow = config.filters.clean.allowed.users.includes(message.author.id);
|
|
|
|
|
if (!roleAllow && !userAllow) return await message.delete();
|
|
|
|
|
if (!checkUserForExceptions(message.member!, config.filters.clean.allowed)) return await message.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const filter = getEmojiByName("ICONS.FILTER");
|
|
|
|
|
@ -72,7 +77,10 @@ export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (config.filters.invite.enabled) {
|
|
|
|
|
if (!config.filters.invite.allowed.channels.includes(message.channel.id)) {
|
|
|
|
|
if (
|
|
|
|
|
!config.filters.invite.allowed.channels.includes(message.channel.id) ||
|
|
|
|
|
!checkUserForExceptions(message.member!, config.filters.invite.allowed)
|
|
|
|
|
) {
|
|
|
|
|
if (/(?:https?:\/\/)?discord(?:app)?\.(?:com\/invite|gg)\/[a-zA-Z0-9]+\/?/.test(content)) {
|
|
|
|
|
messageException(message.guild.id, message.channel.id, message.id);
|
|
|
|
|
await message.delete();
|
|
|
|
|
@ -149,7 +157,11 @@ export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
config.filters.wordFilter.words.loose,
|
|
|
|
|
config.filters.wordFilter.words.strict
|
|
|
|
|
);
|
|
|
|
|
if (check !== null) {
|
|
|
|
|
if (
|
|
|
|
|
check !== null &&
|
|
|
|
|
(!checkUserForExceptions(message.member!, config.filters.wordFilter.allowed) ||
|
|
|
|
|
!config.filters.wordFilter.allowed.channels.includes(message.channel.id))
|
|
|
|
|
) {
|
|
|
|
|
messageException(message.guild.id, message.channel.id, message.id);
|
|
|
|
|
await message.delete();
|
|
|
|
|
const data = {
|
|
|
|
|
@ -264,7 +276,11 @@ export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
return log(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.filters.wordFilter.enabled) {
|
|
|
|
|
if (
|
|
|
|
|
config.filters.wordFilter.enabled &&
|
|
|
|
|
(!checkUserForExceptions(message.member!, config.filters.wordFilter.allowed) ||
|
|
|
|
|
!config.filters.wordFilter.allowed.channels.includes(message.channel.id))
|
|
|
|
|
) {
|
|
|
|
|
const check = TestString(
|
|
|
|
|
content,
|
|
|
|
|
config.filters.wordFilter.words.loose,
|
|
|
|
|
@ -297,7 +313,11 @@ export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.filters.pings.everyone && message.mentions.everyone) {
|
|
|
|
|
if (
|
|
|
|
|
config.filters.pings.everyone &&
|
|
|
|
|
message.mentions.everyone &&
|
|
|
|
|
!checkUserForExceptions(message.member!, config.filters.pings.allowed)
|
|
|
|
|
) {
|
|
|
|
|
if (!(await isLogging(message.guild.id, "messageMassPing"))) return;
|
|
|
|
|
const data = {
|
|
|
|
|
meta: {
|
|
|
|
|
@ -318,7 +338,7 @@ export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
};
|
|
|
|
|
return log(data);
|
|
|
|
|
}
|
|
|
|
|
if (config.filters.pings.roles) {
|
|
|
|
|
if (config.filters.pings.roles && !checkUserForExceptions(message.member!, config.filters.pings.allowed)) {
|
|
|
|
|
for (const roleId in message.mentions.roles) {
|
|
|
|
|
if (!config.filters.pings.allowed.roles.includes(roleId)) {
|
|
|
|
|
messageException(message.guild.id, message.channel.id, message.id);
|
|
|
|
|
@ -347,7 +367,11 @@ export async function callback(_client: NucleusClient, message: Message) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 &&
|
|
|
|
|
!checkUserForExceptions(message.member!, config.filters.pings.allowed)
|
|
|
|
|
) {
|
|
|
|
|
messageException(message.guild.id, message.channel.id, message.id);
|
|
|
|
|
await message.delete();
|
|
|
|
|
if (!(await isLogging(message.guild.id, "messageMassPing"))) return;
|
|
|
|
|
|