aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/src/commands/eval.js58
-rw-r--r--bot/src/events/MessageCreate.js7
-rw-r--r--bot/src/plugins/eval.js52
-rw-r--r--bot/src/storage/consts.js1
4 files changed, 60 insertions, 58 deletions
diff --git a/bot/src/commands/eval.js b/bot/src/commands/eval.js
new file mode 100644
index 0000000..598c7fd
--- /dev/null
+++ b/bot/src/commands/eval.js
@@ -0,0 +1,58 @@
+import { SlashCommandBuilder } from 'discord.js';
+import { inspect } from 'util';
+import { userWhitelist } from '../storage/consts.js';
+
+
+export default {
+ data: new SlashCommandBuilder()
+ .setName('eval')
+ .setDescription('Evaluates code'),
+ async execute(interaction) {
+ if (!userWhitelist.includes(interaction.user.id)) return await interaction.reply('Nope! You don\'t have permission to use this command.');
+ await interaction.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 === interaction.user.id;
+
+ const collector = interaction.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 = await 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 interaction.followUp('Exiting evaluation mode.');
+ });
+ }
+};
diff --git a/bot/src/events/MessageCreate.js b/bot/src/events/MessageCreate.js
index 23aaf87..06f0808 100644
--- a/bot/src/events/MessageCreate.js
+++ b/bot/src/events/MessageCreate.js
@@ -1,6 +1,5 @@
import { Events } from 'discord.js';
import { ChatBot } from '../plugins/chatbot.js';
-import { Evaluation } from '../plugins/eval.js';
export default {
name: Events.MessageCreate,
@@ -12,11 +11,7 @@ export default {
const args = msg.content.slice(`${msg.client.user}`.length).trim();
if (msg.mentions.has(msg.client.user)) {
- if (args === 'execute') {
- await Evaluation(msg);
- } else {
- await ChatBot(msg, args);
- }
+ await ChatBot(msg, args);
}
}
};
diff --git a/bot/src/plugins/eval.js b/bot/src/plugins/eval.js
deleted file mode 100644
index c667dca..0000000
--- a/bot/src/plugins/eval.js
+++ /dev/null
@@ -1,52 +0,0 @@
-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.');
- });
-}
diff --git a/bot/src/storage/consts.js b/bot/src/storage/consts.js
index 80a65aa..9255cd2 100644
--- a/bot/src/storage/consts.js
+++ b/bot/src/storage/consts.js
@@ -3,6 +3,7 @@ export const readyMsg = false;
export const ollamaGlobal = true;
export const ollamaModel = 'aleebot-deepseek';
export const featureSuggestChannel = '427495678390960148';
+export const userWhitelist = ['242775871059001344'];
export const autoRole = true;
export const serverWhitelist = '243022206437687296';