The official leaked source code of the Dyno Discord Bot.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

53 lines
1.1 KiB

'use strict';
const { exec } = require('child_process');
const {Command} = require('@dyno.gg/dyno-core');
class Update extends Command {
constructor(...args) {
super(...args);
this.name = 'update';
this.aliases = ['update'];
this.group = 'Admin';
this.description = 'Update the bot';
this.usage = 'update (branch)';
this.hideFromHelp = true;
this.permissions = 'admin';
this.expectedArgs = 0;
}
exec(command) {
return new Promise((resolve, reject) => {
exec(command, (err, stdout, stderr) => {
if (err) return reject(err);
return resolve(stdout || stderr);
});
});
}
async execute({ message, args }) {
let msgArray = [],
result;
const branch = args && args.length ? args[0] : 'develop';
this.sendMessage(message.channel, `Pulling the latest from ${branch}...`);
try {
result = await this.exec(`git pull origin ${branch}; gulp build`);
} catch (err) {
result = err;
}
msgArray = msgArray.concat(this.utils.splitMessage(result, 1990));
for (let m of msgArray) {
this.sendCode(message.channel, m, 'js');
}
return Promise.resolve();
}
}
module.exports = Update;