feat(commands): added base structure for vm command
This commit is contained in:
parent
e16c815617
commit
83259240a9
2 changed files with 15 additions and 6 deletions
|
@ -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!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Reference in a new issue