Linting
All checks were successful
release-tag / release-image (push) Successful in 1m52s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 29s

This commit is contained in:
Logan Cusano
2024-08-11 15:57:46 -04:00
parent 5cd47378d6
commit 117cbea67f
37 changed files with 2273 additions and 1738 deletions

View File

@@ -1,8 +1,8 @@
import { DebugBuilder } from "../../modules/debugger.mjs";
const log = new DebugBuilder("server", "discordBot.events.guildMemberAdd");
import dotenv from 'dotenv';
import dotenv from "dotenv";
dotenv.config();
import { Events } from 'discord.js';
import { Events } from "discord.js";
import { gptHandler } from "../modules/gptHandler.mjs";
const welcomeChannel = process.env.WELCOME_CHANNEL_ID; // TODO - Need to add a DB section for server configs so it's not static to one server
@@ -10,25 +10,24 @@ const welcomeChannel = process.env.WELCOME_CHANNEL_ID; // TODO - Need to add a D
export const name = Events.GuildMemberAdd;
export async function execute(nodeIo, member) {
log.INFO("New user joined the server", member);
let conversation = [];
conversation.push({
role: 'assistant',
content: `A new user has joined the server. Their name is '<@${member.id}>'. Please welcome them to the server and remind them about the rules.`
})
log.INFO("New user joined the server", member);
let conversation = [];
conversation.push({
role: "assistant",
content: `A new user has joined the server. 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;
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);
for (let i = 0; i < responseMessage.length; i += chunkSize) {
const chunk = responseMessage.substring(i, i + chunkSize);
log.DEBUG("Sending message chunk:", chunk);
log.DEBUG("Sending message chunk:", chunk);
await nodeIo.serverClient.channels.cache.get(welcomeChannel).send(chunk);
}
await nodeIo.serverClient.channels.cache.get(welcomeChannel).send(chunk);
}
}
}
}