Archived
0
0
Fork 0

feat(commands): added base structure for vm command

This commit is contained in:
Daryl Ronningen 2021-06-20 22:46:35 -07:00
parent e16c815617
commit 83259240a9
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
2 changed files with 15 additions and 6 deletions

View file

@ -14,16 +14,27 @@
* You should have received a copy of the GNU General Public License
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
*/
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!');
}
}
}

View file

@ -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);
}
});