Compare commits

..

2 Commits

Author SHA1 Message Date
Logan Cusano
697025ec1e Updated environment var names to match convention
All checks were successful
release-tag / release-image (push) Successful in 4m25s
DRB Tests / drb_mocha_tests (push) Successful in 32s
2024-06-02 19:35:01 -04:00
Logan Cusano
3350b9f191 Added new event for new member joining #18
- When a new member joins the server, GPT integration will welcome them
2024-06-02 19:34:41 -04:00
4 changed files with 37 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ import dotenv from 'dotenv';
dotenv.config(); dotenv.config();
const approvedLinksChannel = "767303243285790721"; const approvedLinksChannel = "767303243285790721";
const restrictedChannelIds = process.env.LINKCOP_RESTRICTED_CHANNELS.split(','); const restrictedChannelIds = process.env.LINKCOP_RESTRICTED_CHANNEL_IDS.split(',');
const linkRegExp = /(?:http[s]?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g const linkRegExp = /(?:http[s]?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g

View File

@@ -79,7 +79,7 @@ export function addEnabledEventListeners(serverClient, _eventsPath = "./events")
} }
// The discord client // The discord client
export const serverClient = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] }); export const serverClient = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences] });
// Run when the bot is ready // Run when the bot is ready
serverClient.on('ready', async () => { serverClient.on('ready', async () => {

View File

@@ -0,0 +1,34 @@
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);
}
}
}

View File

@@ -6,7 +6,7 @@ import { Events } from 'discord.js';
import { gptInteraction } from '../addons/gptInteraction.mjs'; import { gptInteraction } from '../addons/gptInteraction.mjs';
import { linkCop } from '../addons/linkCop.mjs'; import { linkCop } from '../addons/linkCop.mjs';
const IGNORED_CHANNELS = process.env.IGNORED_CHANNELS.split(','); const IGNORED_CHANNELS = process.env.IGNORED_CHANNEL_IDS.split(',');
export const name = Events.MessageCreate; export const name = Events.MessageCreate;