Files
xiao/commands/util/exec.js
T
Dragon Fire 12925a9b15 Exec Command
2020-09-14 10:07:42 -04:00

36 lines
808 B
JavaScript

const Command = require('../../structures/Command');
const { promisify } = require('util');
const exec = promisify(require('child_process').exec);
module.exports = class ExecCommand extends Command {
constructor(client) {
super(client, {
name: 'exec',
aliases: ['execute', '$'],
group: 'util',
memberName: 'exec',
description: 'Executes a command-line application.',
ownerOnly: true,
guarded: true,
args: [
{
key: 'command',
prompt: 'What command do you want to execute?',
type: 'string'
}
]
});
}
async run(msg, { command }) {
const results = await this.exec(command);
return msg.code('sh', results);
}
async exec(command) {
const { stdout, stderr } = await exec(command);
if (stderr) return stderr.trim();
return stdout.trim();
}
};