diff options
| author | Andrew Lee <andrew@alee14.me> | 2025-03-04 10:05:14 -0500 |
|---|---|---|
| committer | Andrew Lee <andrew@alee14.me> | 2025-03-04 10:05:14 -0500 |
| commit | cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a (patch) | |
| tree | deffb57bee9fe24a8d1b8143fba603774544ee00 /bot/src/events/MessageCreate.js | |
| parent | 11bb9ab6b30314d91209bc9888d95783cc247e98 (diff) | |
| download | AleeBot-cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a.tar.gz AleeBot-cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a.tar.bz2 AleeBot-cc06b8ed4e4e0aef02dfd8ab15df22a57a177a0a.zip | |
Readme change; Docker; Logging
Diffstat (limited to 'bot/src/events/MessageCreate.js')
| -rw-r--r-- | bot/src/events/MessageCreate.js | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/bot/src/events/MessageCreate.js b/bot/src/events/MessageCreate.js index 9394a20..90b517d 100644 --- a/bot/src/events/MessageCreate.js +++ b/bot/src/events/MessageCreate.js @@ -12,35 +12,31 @@ export default { const args = msg.content.slice(`<@${msg.client.user.id}>`.length).trim(); if (msg.mentions.has(msg.client.user)) { - if (ollamaEnabled) { - if (!args) return msg.reply('Sorry? What was that?'); - - try { - const response = await ollama.chat({ - model: ollamaModel, - messages: [{ role: 'user', content: args }], - }); - - 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 }); - } - } else { - msg.reply({ content }); + if (!ollamaEnabled) return msg.reply('Sorry, this feature has been turned off.'); + if (!args) return msg.reply('Sorry? What was that?'); + + try { + const response = await ollama.chat({ + model: ollamaModel, + messages: [{ role: 'user', content: args }], + }); + + 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 }); } - - } catch (err) { - console.error(err); - msg.reply('Something went wrong.'); + } else { + await msg.reply({ content }); } - } else { - return msg.reply('Sorry, this feature has been turned off.'); - } + } catch (err) { + console.error(err); + await msg.reply('Something went wrong.'); + } } } }; |
