29 lines
992 B
JavaScript
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;
|
|
} |