Moving ChannelID list to .env, Parsing array instead of checking both vars

This commit is contained in:
Raven Scott 2023-04-11 14:50:19 +02:00
parent 8eb1b34d4e
commit d90ceab967
2 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,4 @@
THE_TOKEN = "DISCORD_TOKEN_HERE"
CHANNEL_ID = CHANNEL_ID_HERE
CHANNEL_ID_2 = CHANNEL_ID_HERE
CHANNEL_IDS = 1094494101631680653,1094628334727614605
ROOT_IP = 192.168.0.15
ROOT_PORT = 8000

View File

@ -24,8 +24,8 @@ const client = new Client({
partials: [Partials.Channel],
});
const channelID = '1094494101631680653'; // Replace with your channel ID
const channelID2 = '1094628334727614605'; // Replace with your channel ID
// Grab ChannelIDs from the .env file
const channelIDs = process.env.CHANNEL_IDS.split(',');
const conversations = new Map();
@ -88,9 +88,10 @@ client.on('messageCreate', async (message) => {
}
// Only respond in the specified channels
if (message.channel.id !== channelID && message.channel.id !== channelID2) {
return;
if (!channelIDs.includes(message.channel.id)) {
return;
}
if (message.author.bot) return; // Ignore messages from bots
// Check if any conversation is busy
@ -110,11 +111,11 @@ client.on('messageCreate', async (message) => {
if (conversation.messages.length === 0) {
conversation.messages.push({
role: 'user',
content: `You are rAi, the most helpful writing AI, you code and write without any mistakes.`
content: `You are rAi, the most helpful writing AI, you code, write and provide information without any mistakes.`
});
conversation.messages.push({
role: 'user',
content: `My name is ${message.author.username}.`
content: `My name is ${message.author.username}. \nIf you address me, tag me using @${message.author.username}`
});
conversation.messages.push({
role: 'assistant',