Files
drb-server/discordBot/events/guildMemberAdd.mjs
Logan Cusano 24296c2ae4
All checks were successful
release-tag / release-image (push) Successful in 3m3s
DRB Tests / drb_mocha_tests (push) Successful in 1m6s
Update the prompt with the proper discord tag for the member ID
2024-06-06 23:01:08 -04:00

34 lines
1.2 KiB
JavaScript

import { DebugBuilder } from "../../modules/debugger.mjs";
const log = new DebugBuilder("server", "discordBot.events.guildMemberAdd");
import dotenv from 'dotenv';
dotenv.config();
import { Events } from 'discord.js';
import { gptHandler } from "../modules/gptHandler.mjs";
const welcomeChannel = process.env.WELCOME_CHANNEL_ID;
export const name = Events.GuildMemberAdd;
export async function execute(nodeIo, member) {
log.INFO("New user joined the server", member);
let conversation = [];
conversation.push({
role: 'system',
content: `There has been a new user that joined. Their name is '<@${member.id}>'. Please welcome them to the server and remind them about the rules.`
})
const response = await gptHandler(conversation);
if (response) {
const responseMessage = response.choices[0].message.content;
const chunkSize = 2500;
for (let i = 0; i < responseMessage.length; i += chunkSize) {
const chunk = responseMessage.substring(i, i + chunkSize);
log.DEBUG("Sending message chunk:", chunk);
await nodeIo.serverClient.channels.cache.get(welcomeChannel).send(chunk);
}
}
}