Send a command to the server
This commit is contained in:
parent
4ed89650ea
commit
4967b412c4
1 changed files with 38 additions and 0 deletions
38
commands/owner/exec.js
Normal file
38
commands/owner/exec.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
|
||||
class execCommand extends Command {
|
||||
constructor() {
|
||||
super('exec', {
|
||||
aliases: ['exec'],
|
||||
category: 'owner',
|
||||
ownerOnly: 'true',
|
||||
args: [
|
||||
{
|
||||
id: 'exec',
|
||||
type: 'string',
|
||||
match: 'rest'
|
||||
}
|
||||
],
|
||||
description: {
|
||||
content: 'execute a command on the server',
|
||||
usage: '[a command on the server]',
|
||||
examples: ['pm2 list']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
async function update() {
|
||||
const { stdout, stderr } = await exec(args.exec).catch(err => {
|
||||
return message.channel.send(`Oh no, an error has occured\n${err}`);
|
||||
});
|
||||
message.channel.send(`stdout: ${stdout}`, { split: true });
|
||||
message.channel.send(`stderr: ${stderr}`, { split: true });
|
||||
}
|
||||
return update();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = execCommand;
|
Loading…
Reference in a new issue