mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Exec Command
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user