Add update command
Uses git pull to update to latest commit
This commit is contained in:
parent
29d5d81edc
commit
73b0b5f4ed
3 changed files with 34 additions and 19 deletions
|
@ -1,18 +1,28 @@
|
|||
const calculateReloaded = require("../util/calculateReloaded");
|
||||
const reloadCommands = require("../util/reloadCommands");
|
||||
|
||||
module.exports = {
|
||||
name: 'update',
|
||||
description: 'pull changes from master and reload commands',
|
||||
admin: true,
|
||||
execute({message}) {
|
||||
execute({message, client}) {
|
||||
let cmd = "git pull";
|
||||
const exec = require("child_process").exec;
|
||||
|
||||
exec(cmd, (err, stdout, stderr) => {
|
||||
process.stdout.write(stdout);
|
||||
if(stdout.startsWith("Already up to date.")){
|
||||
message.channel.send("Already up to date.\nNo updating needed.")
|
||||
}else{
|
||||
let beforeSize = client.commands.size;
|
||||
reloadCommands(client)
|
||||
let sendText = `${stdout}\nBot updated, and\n${calculateReloaded(beforeSize, client)}`
|
||||
message.channel.send(sendText)
|
||||
}
|
||||
if (err) {
|
||||
message.channel.send("Something went wrong...");
|
||||
console.log(stderr);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue