aboutsummaryrefslogtreecommitdiff
path: root/bot/src/plugins/eval.js
diff options
context:
space:
mode:
authorAndrew Lee <andrew@alee14.me>2025-03-20 16:20:59 -0400
committerAndrew Lee <andrew@alee14.me>2025-03-20 16:20:59 -0400
commit0f55f5f52e84fd5cdedb448d408dfa3c69c5fe5f (patch)
tree8ec510bcfaabd2adb2d3e13407658c13ec3deb64 /bot/src/plugins/eval.js
parentc06c0be2e7520ceaf5284472d0d99c7417aceb7a (diff)
downloadAleeBot-0f55f5f52e84fd5cdedb448d408dfa3c69c5fe5f.tar.gz
AleeBot-0f55f5f52e84fd5cdedb448d408dfa3c69c5fe5f.tar.bz2
AleeBot-0f55f5f52e84fd5cdedb448d408dfa3c69c5fe5f.zip
Modularized LLM chatbot; Added back eval
Diffstat (limited to 'bot/src/plugins/eval.js')
-rw-r--r--bot/src/plugins/eval.js51
1 files changed, 50 insertions, 1 deletions
diff --git a/bot/src/plugins/eval.js b/bot/src/plugins/eval.js
index 47b3988..c667dca 100644
--- a/bot/src/plugins/eval.js
+++ b/bot/src/plugins/eval.js
@@ -1,3 +1,52 @@
-export async function evaluation() {
+import { inspect } from 'util';
+export async function Evaluation(msg) {
+ if (!['242775871059001344'].includes(msg.author.id)) return await msg.reply('Nope! You need the person who created this bot to use this command.');
+ await msg.reply('You have entered evaluation mode. Enter the code for AleeBot to evaluate.\nType in `exit` to exit evaluation mode.');
+
+ let evaled;
+ let remove;
+
+ const filter = (i) => i.author.id === msg.author.id;
+
+ const collector = msg.channel.createMessageCollector({
+ filter,
+ time: 1000 * 600
+ });
+
+ collector.on('collect', async (msg) => {
+ if (msg.content.toLowerCase() === 'exit') {
+ return collector.stop();
+ }
+
+ try {
+ remove = (text) => {
+ if (typeof(text) === 'string') {
+ return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
+ } else {
+ return text;
+ }
+ };
+
+ evaled = eval(msg.content);
+
+ if (typeof evaled !== 'string') {
+ evaled = inspect(evaled);
+ }
+
+ } catch (err) {
+ return await msg.reply(`**Error:**\n\`\`\`\n${err.stack}\n\`\`\``);
+ }
+
+ try {
+ return await msg.reply(`**Output:**\n\`\`\`js\n${remove(evaled)}\n\`\`\``);
+ } catch (err) {
+ return await msg.reply(`**Error:**\n\`\`\`\n${err.stack}\n\`\`\``);
+ }
+
+ });
+
+ collector.on('end', async () => {
+ return await msg.reply('Exiting evaluation mode.');
+ });
}