diff options
| author | Andrew Lee <andrew@alee14.me> | 2025-03-08 17:23:34 -0500 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2025-03-08 17:23:34 -0500 |
| commit | 48a576ab5605ec3ec9272809668b8d7ce91c477e (patch) | |
| tree | 7780c94dd6a39c5b5beae9edfc568e6669b88967 /bot/src/events/MessageCreate.js | |
| parent | 52f8826e526f0c0aadb86c3e29975aef4dc1ab85 (diff) | |
| download | AleeBot-48a576ab5605ec3ec9272809668b8d7ce91c477e.tar.gz AleeBot-48a576ab5605ec3ec9272809668b8d7ce91c477e.tar.bz2 AleeBot-48a576ab5605ec3ec9272809668b8d7ce91c477e.zip | |
Put LLM output on text file; Some fixes in logging; New command
Diffstat (limited to 'bot/src/events/MessageCreate.js')
| -rw-r--r-- | bot/src/events/MessageCreate.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/bot/src/events/MessageCreate.js b/bot/src/events/MessageCreate.js index e7af3a8..8753587 100644 --- a/bot/src/events/MessageCreate.js +++ b/bot/src/events/MessageCreate.js @@ -1,4 +1,4 @@ -import { Events } from 'discord.js'; +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'; @@ -12,11 +12,11 @@ export default { const guildSetting = await guildSettings.findOne({ where: { guildID: msg.guild.id } }); - const args = msg.content.slice(`<@${msg.client.user.id}>`.length).trim(); + const args = msg.content.slice(`${msg.client.user}`.length).trim(); if (msg.mentions.has(msg.client.user)) { if (!guildSetting.ollamaEnabled) return; - if (!ollamaGlobal) return msg.reply('Sorry, this feature has been turned off.'); + if (!ollamaGlobal) return msg.reply('Sorry, the LLM chatbot feature has been turned off.'); if (!args) return msg.reply('Sorry? What was that?'); try { @@ -26,15 +26,12 @@ export default { }); let content = response.message.content; - content = content.replace(/<think>.*?<\/think>/g, ''); if (content.length > 2000) { - const chunks = content.match(/[\s\S]{1,2000}/g) || []; - for (const chunk of chunks) { - await msg.reply({ content: chunk }); - } + const attachment = new AttachmentBuilder(Buffer.from(content, 'utf-8'), { name: 'output.txt' }); + return await msg.reply({ files: [attachment] }); } else { - await msg.reply({ content }); + return await msg.reply({ content }); } } catch (err) { |
