diff --git a/commands/util/exec.js b/commands/util/exec.js index 5be10dbf..17cabea6 100644 --- a/commands/util/exec.js +++ b/commands/util/exec.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); -const { promisify } = require('util'); -const exec = promisify(require('child_process').exec); +const { execSync } = require('child_process'); +const { stripIndents } = require('common-tags'); module.exports = class ExecCommand extends Command { constructor(client) { @@ -22,14 +22,19 @@ module.exports = class ExecCommand extends Command { }); } - async run(msg, { command }) { - const results = await this.exec(command); - return msg.code('sh', results); + run(msg, { command }) { + const results = this.exec(command); + return msg.reply(stripIndents` + _${results.err ? 'Successfully executed.' : 'An error occurred:'}_ + \`\`\`sh + ${results.std} + \`\`\` + `); } - async exec(command) { - const { stdout, stderr } = await exec(command); - if (stderr) return stderr.trim(); - return stdout.trim(); + exec(command) { + const { stdout, stderr } = execSync(command); + if (stderr) return { err: true, std: stderr.trim() }; + return { err: false, std: stdout.trim() }; } }; diff --git a/package.json b/package.json index 625ba3be..c1368d9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.24.2", + "version": "119.24.3", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {