Exec Command

This commit is contained in:
Dragon Fire
2020-09-14 10:07:42 -04:00
parent 7f457c33c9
commit 12925a9b15
3 changed files with 38 additions and 2 deletions
+2 -1
View File
@@ -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)
+35
View File
@@ -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();
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "119.23.5",
"version": "119.24.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {