mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
36 lines
808 B
JavaScript
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();
|
|
}
|
|
};
|