Haha-Yes/commands/owner/update.js

36 lines
884 B
JavaScript
Raw Normal View History

const { Command } = require('discord-akairo');
2019-11-22 12:54:32 +01:00
const Util = require('util');
const exec = Util.promisify(require('child_process').exec);
class EvalCommand extends Command {
constructor() {
super('update', {
2019-03-15 23:41:34 +01:00
aliases: ['update', 'pull', 'git pull'],
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-11-22 12:30:20 +01:00
const Embed = this.client.util.embed()
2019-03-31 00:39:36 +01:00
.addField('stdout', stdout)
.addField('stderr', stderr);
2019-11-22 12:32:08 +01:00
message.channel.send({embed: Embed})
.catch(() => {
message.channel.send(`stdout: ${stdout}\nstderr: ${stderr}`);
});
2019-02-13 17:55:47 +01:00
console.log(`stdout: ${stdout}`);
2019-04-01 01:38:26 +02:00
console.error(`stderr: ${stderr}`);
}
update();
}
}
module.exports = EvalCommand;