aboutsummaryrefslogtreecommitdiff
path: root/bot/src/events
diff options
context:
space:
mode:
Diffstat (limited to 'bot/src/events')
-rw-r--r--bot/src/events/MessageCreate.js39
1 files changed, 7 insertions, 32 deletions
diff --git a/bot/src/events/MessageCreate.js b/bot/src/events/MessageCreate.js
index 406539e..23aaf87 100644
--- a/bot/src/events/MessageCreate.js
+++ b/bot/src/events/MessageCreate.js
@@ -1,7 +1,6 @@
-import {AttachmentBuilder, Events} from 'discord.js';
-import { ollama } from '../utils/ollama.js';
-import { ollamaGlobal, ollamaModel } from '../storage/consts.js';
-import { guildSettings } from '../models/guild-settings.js';
+import { Events } from 'discord.js';
+import { ChatBot } from '../plugins/chatbot.js';
+import { Evaluation } from '../plugins/eval.js';
export default {
name: Events.MessageCreate,
@@ -10,37 +9,13 @@ export default {
if (msg.author.bot) return;
if (!msg.guild) return;
- const guildSetting = await guildSettings.findOne({ where: { guildID: msg.guild.id } });
-
const args = msg.content.slice(`${msg.client.user}`.length).trim();
- // TODO: Check if the person mentions a specific command that executes eval, then start a message collection.
-
if (msg.mentions.has(msg.client.user)) {
- if (!guildSetting.ollamaEnabled) return;
- if (!ollamaGlobal) return msg.reply('Sorry, the LLM chatbot feature has been turned off.');
- if (!args) return msg.reply('Sorry? What was that?');
-
- try {
- const loadingMessage = await msg.reply('Thinking...');
-
- const response = await ollama.chat({
- model: ollamaModel,
- messages: [{ role: 'user', content: args }],
- });
-
- let content = response.message.content;
-
- if (content.length > 2000) {
- const attachment = new AttachmentBuilder(Buffer.from(content, 'utf-8'), { name: 'output.txt' });
- return await loadingMessage.edit({ files: [attachment] });
- } else {
- return await loadingMessage.edit({ content });
- }
-
- } catch (err) {
- console.error(err);
- await msg.reply(`Something went wrong. [Submit an issue at the AleeBot repository.](<https://github.com/Alee14/AleeBot/issues>)\nMessage:\n\`\`\`${err.stack}\`\`\``);
+ if (args === 'execute') {
+ await Evaluation(msg);
+ } else {
+ await ChatBot(msg, args);
}
}
}