Add update command

Uses git pull to update to latest commit
This commit is contained in:
SileNce5k 2021-07-01 18:08:10 +02:00
parent 29d5d81edc
commit 73b0b5f4ed
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
3 changed files with 34 additions and 19 deletions

View file

@ -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);
}
});
}
};