Add gitreset command for resetting to master

Useful for my testing bot
Usually I'd have to go log onto my server to reset, but now I can just
use this command like a lazy person instead :)
This commit is contained in:
SileNce5k 2022-04-29 14:55:04 +02:00
parent 52e832101f
commit 5deecaa788
No known key found for this signature in database
GPG key ID: C507260E7F2583AD

View file

@ -0,0 +1,24 @@
const fs = require('fs');
const reloadCommands = require("../../util/reloadCommands");
const convertDateToISOString = require("../../util/convertDateToISOString");
module.exports = {
name: 'gitreset',
description: 'Reset head to master, and reload commands',
admin: true,
execute({message, client}) {
let cmd = "git reset --hard master";
const exec = require("child_process").exec;
let sendText = "";
exec(cmd, (err, stdout, stderr) => {
reloadCommands(client);
sendText = `${stdout}\nCommands reloaded`;
if(err){
fs.writeFileSync("../../data/log.txt", `${convertDateToISOString(new Date())}\n${stderr}\n`, {flag: 'a'});
sendText = `Something went wrong, check data/log.txt for more information`;
}
});
message.channel.send(sendText);
}
};