diff --git a/README.md b/README.md index 0ef98cdb..7010ccbd 100644 --- a/README.md +++ b/README.md @@ -256,7 +256,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 540 +Total: 541 ### Utility: @@ -278,6 +278,7 @@ Total: 540 * **eval:** Executes JavaScript code. (Owner-Only) * **command-leaderboard-export:** Exports a command leaderboard JSON file. (Owner-Only) * **command-leaderboard-import:** Imports a command leaderboard JSON file. (Owner-Only) +* **exec:** Executes a command-line application. (Owner-Only) * **generate-commands:** Generates the commands list for Xiao's README. (Owner-Only) * **generate-credit:** Generates the credit list for Xiao's README. (Owner-Only) * **generate-fun-information:** Generates the "Fun Information" for Xiao's README. (Owner-Only) diff --git a/commands/util/exec.js b/commands/util/exec.js new file mode 100644 index 00000000..5be10dbf --- /dev/null +++ b/commands/util/exec.js @@ -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(); + } +}; diff --git a/package.json b/package.json index 12ad204d..d5602ed9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.23.5", + "version": "119.24.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {