mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 06:10:49 +02:00
Exec Command
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "119.23.5",
|
||||
"version": "119.24.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user