Files
drb-server/discordBot/events/messageCreate.mjs
Logan Cusano 697025ec1e
All checks were successful
release-tag / release-image (push) Successful in 4m25s
DRB Tests / drb_mocha_tests (push) Successful in 32s
Updated environment var names to match convention
2024-06-02 19:35:01 -04:00

29 lines
992 B
JavaScript

import { DebugBuilder } from "../../modules/debugger.mjs";
const log = new DebugBuilder("server", "discordBot.events.messageCreate");
import dotenv from 'dotenv';
dotenv.config();
import { Events } from 'discord.js';
import { gptInteraction } from '../addons/gptInteraction.mjs';
import { linkCop } from '../addons/linkCop.mjs';
const IGNORED_CHANNELS = process.env.IGNORED_CHANNEL_IDS.split(',');
export const name = Events.MessageCreate;
export async function execute(nodeIo, message) {
// Ignore ignored channels
if (IGNORED_CHANNELS.includes(message.channel.id)) return;
// Ignore messages from a bot
if (message.author.bot) return;
log.INFO("Message create", message);
// Check if the message mentions the bot
if (message.mentions.users.has(nodeIo.serverClient.user.id)) {
return await gptInteraction(nodeIo, message);
}
// Check if the message contains a link in a channel it shouldn't
if (await linkCop(nodeIo, message)) return;
}