From 7d9754d6f8153e1820fc5c84956a32b7b6e815b0 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 13 Jul 2023 11:05:27 -0600 Subject: [PATCH] Allow configuring what model is to be used for each channel/category --- .gitignore | 0 basePrompt.txt | 0 commands.json | 0 config.json.default | 0 index.js | 9 +++++---- lang.json | 0 nsfwPrompt.txt | 0 package-lock.json | 0 package.json | 0 9 files changed, 5 insertions(+), 4 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 basePrompt.txt mode change 100644 => 100755 commands.json mode change 100644 => 100755 config.json.default mode change 100644 => 100755 index.js mode change 100644 => 100755 lang.json mode change 100644 => 100755 nsfwPrompt.txt mode change 100644 => 100755 package-lock.json mode change 100644 => 100755 package.json diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/basePrompt.txt b/basePrompt.txt old mode 100644 new mode 100755 diff --git a/commands.json b/commands.json old mode 100644 new mode 100755 diff --git a/config.json.default b/config.json.default old mode 100644 new mode 100755 diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 43bdddd..7afa0ae --- a/index.js +++ b/index.js @@ -21,7 +21,7 @@ const colors = require("colors"); // Create a new Discord client const client = new Discord.Client({ - intents: ["MessageContent", "GuildMessages", "Guilds", "DirectMessages"] + intents: ["MessageContent", "GuildMessages", "Guilds", "DirectMessages", "GuildMessages"] }); @@ -88,7 +88,7 @@ client.on("ready", async () => { client.on('interactionCreate', async (interaction) => { if (!interaction.isCommand()) return; if (interaction.guild !== null) { - if ((!config.discord.authorized_channels.includes(interaction.channelId) && !config.discord.authorized_channels.includes(interaction.channel.parentId))) return interaction.reply({ + if ((!config.discord.authorized_channels[message.channelId] && !config.discord.authorized_channels[message.channel.parentId])) return interaction.reply({ ephemeral: true, content: lang.noauth }); // Only allow messages in the authorized channels @@ -171,7 +171,7 @@ client.on('interactionCreate', async (interaction) => { client.on('messageCreate', async (message) => { if (message.author.bot) return; if (message.guild !== null) { - if ((!config.discord.authorized_channels.includes(message.channelId) && !config.discord.authorized_channels.includes(message.channel.parentId))) return; // Only allow messages in the authorized channels + if ((!config.discord.authorized_channels[message.channelId] && !config.discord.authorized_channels[message.channel.parentId])) return; // Only allow messages in the authorized channels } if (message.content.startsWith("!!")) return; // So you can chat without the bot replying // If the session doesn't exist, create it @@ -217,8 +217,9 @@ client.on('messageCreate', async (message) => { "role": "user" }); // Send the message to OpenAI + var model = config.discord.authorized_channels[message.channelId] || config.discord.authorized_channels[message.channel.parentId]; await openai.createChatCompletion({ - model: "gpt-3.5-turbo", + model: model, messages: sessions[message.channelId].messages }).then((data) => { output = data.data.choices[0].message; diff --git a/lang.json b/lang.json old mode 100644 new mode 100755 diff --git a/nsfwPrompt.txt b/nsfwPrompt.txt old mode 100644 new mode 100755 diff --git a/package-lock.json b/package-lock.json old mode 100644 new mode 100755 diff --git a/package.json b/package.json old mode 100644 new mode 100755