Files
drb-server/discordBot/events/messageCreate.mjs
Logan Cusano 961a7cc2bd
All checks were successful
release-tag / release-image (push) Successful in 4m19s
DRB Tests / drb_mocha_tests (push) Successful in 1m16s
Implement early AI integration #18
- Added new event to catch messageCreate events
- @ messages to the server will use ChatGPT to respond to the message with an indepth prompt about the server
- Implement module to interact with chatGPT repeatably
- Add linkcop with GPT integration #12
- Added environment variable for inital prompt for GPT integration
2024-06-02 19:16:01 -04:00

29 lines
989 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_CHANNELS.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;
}