This commit is contained in:
Logan Cusano
2024-08-11 20:14:36 -04:00
parent 94374b4d45
commit cf49ac414a
6 changed files with 187 additions and 97 deletions

View File

@@ -2,20 +2,30 @@ import { DebugBuilder } from "../../modules/debugger.mjs";
const log = new DebugBuilder("server", "discordBot.addons.linkCop");
import { gptHandler } from "../modules/gptHandler.mjs";
import dotenv from "dotenv";
import { getGuildConfig, setGuildConfig } from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
import {
getGuildConfig,
setGuildConfig,
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
dotenv.config();
const linkRegExp = /http[s]?:\/\/\S+/g;
export const linkCop = async (nodeIo, message) => {
// Set the channel IDs based on the guild the message was sent in
const approvedLinksChannel = await getGuildConfig(message.guild.id, "approvedLinksChannel") || "767303243285790721";
const restrictedChannelIds = await getGuildConfig(message.guild.id, "restrictedChannelIds");
const approvedLinksChannel =
(await getGuildConfig(message.guild.id, "approvedLinksChannel")) ||
"767303243285790721";
const restrictedChannelIds = await getGuildConfig(
message.guild.id,
"restrictedChannelIds",
);
// Check if the message was sent in an restricted channel
if (
message.channel.id == approvedLinksChannel || !Array.isArray(restrictedChannelIds) ||
(Array.isArray(restrictedChannelIds) || !restrictedChannelIds.includes(message.channel.id))
message.channel.id == approvedLinksChannel ||
!Array.isArray(restrictedChannelIds) ||
Array.isArray(restrictedChannelIds) ||
!restrictedChannelIds.includes(message.channel.id)
) {
return false;
}