diff --git a/src/commands/utils/vm.ts b/src/commands/utils/vm.ts index c606cf5..e56412a 100644 --- a/src/commands/utils/vm.ts +++ b/src/commands/utils/vm.ts @@ -14,16 +14,27 @@ * You should have received a copy of the GNU General Public License * along with ArgonBot. If not, see . */ +import { VM } from 'vm2'; import Command from '@structures/command'; -import type { Client } from 'discord.js'; +import type { Client, Message } from 'discord.js'; export class vm extends Command { public constructor(client: Client) { super(client); } - public run(): void { - console.log('Test'); + public run(message: Message, vmLang: string, code: string): void { + const javascriptVM = new VM({ eval: false, timeout: 1000, wasm: false }); + + switch(vmLang.toLowerCase()) { + case 'js': + case 'javascript': + message.reply('Computing JavaScript code... Please wait!'); + javascriptVM.run(code); + break; + default: + message.reply('Unknown Language given!'); + } } } diff --git a/src/index.ts b/src/index.ts index 129c3bf..5e100af 100644 --- a/src/index.ts +++ b/src/index.ts @@ -112,13 +112,11 @@ client.on('ready', async () => { // eslint-disable-next-line @typescript-eslint/no-var-requires const fileCommand = require(file); - console.log(fileCommand); - const command = new fileCommand[path.basename(file, path.extname(file))](); commands.set(command.options.name, command); - debug(`Loaded ${command.options.name}`, ELoggingScope.Startup); + debug(`Loaded command ${command.options.name}`, ELoggingScope.Startup); } });