2019-02-13 17:53:52 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const util = require('util');
|
|
|
|
const exec = util.promisify(require('child_process').exec);
|
2019-03-31 00:39:36 +01:00
|
|
|
const { MessageEmbed } = require('discord.js');
|
2019-02-13 17:53:52 +01:00
|
|
|
|
|
|
|
class EvalCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('update', {
|
2019-03-15 23:41:34 +01:00
|
|
|
aliases: ['update', 'pull', 'git pull'],
|
2019-02-13 17:53:52 +01:00
|
|
|
category: 'owner',
|
|
|
|
ownerOnly: 'true',
|
|
|
|
description: {
|
|
|
|
content: 'Update the bot with git pull',
|
|
|
|
usage: '',
|
|
|
|
examples: ['']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message) {
|
|
|
|
async function update() {
|
|
|
|
const { stdout, stderr } = await exec('git pull');
|
2019-03-31 00:39:36 +01:00
|
|
|
const Embed = new MessageEmbed()
|
|
|
|
.addField('stdout', stdout)
|
|
|
|
.addField('stderr', stderr);
|
|
|
|
message.channel.send({embed: Embed});
|
2019-02-13 17:55:47 +01:00
|
|
|
console.log(`stdout: ${stdout}`);
|
2019-04-01 01:38:26 +02:00
|
|
|
console.error(`stderr: ${stderr}`);
|
2019-02-13 17:53:52 +01:00
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = EvalCommand;
|