Split commands into subdirectories
* Move command files into directories * Edit relative paths * Update gitignore * Finish support for commands in subdir * Split up getCommandFiles into own function * Add support for subdirs on help command
This commit is contained in:
parent
8993eeaf7a
commit
e7cdd425d1
21 changed files with 55 additions and 35 deletions
17
commands/admin/reload.js
Normal file
17
commands/admin/reload.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
const calculateReloaded = require("../../util/calculateReloaded.js");
|
||||
const reloadNetModules = require("../../util/reloadNetModules.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'reload',
|
||||
description: 'Reloads modules.',
|
||||
admin: true,
|
||||
execute({message, client}) {
|
||||
|
||||
let reloadCommands = require("../../util/reloadCommands.js")
|
||||
let beforeSize = client.commands.size;
|
||||
reloadNetModules(client)
|
||||
reloadCommands(client)
|
||||
let sendText = calculateReloaded(beforeSize, client)
|
||||
message.channel.send(sendText)
|
||||
}
|
||||
};
|
32
commands/admin/setPresence.js
Normal file
32
commands/admin/setPresence.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
const setPresence = require("../../util/setPresence");
|
||||
|
||||
module.exports = {
|
||||
name: 'setpresence',
|
||||
description: 'Set the presence for the bot',
|
||||
moreHelp: ["Presence types you can use:","PLAY, LISTEN, WATCH","Presence type have to be the first argument"],
|
||||
admin: true,
|
||||
execute({message, client, args, globalPrefix}) {
|
||||
const savePresence = require("../util/savePresence");
|
||||
let presenceType = args[0].toLocaleUpperCase();
|
||||
if(presenceType == "PLAY" || presenceType == "LISTEN" || presenceType == "WATCH"){
|
||||
|
||||
switch (presenceType) {
|
||||
case "PLAY":
|
||||
presenceType = "PLAYING";
|
||||
break;
|
||||
case "LISTEN":
|
||||
presenceType = "LISTENING";
|
||||
break;
|
||||
case "WATCH":
|
||||
presenceType = "WATCHING";
|
||||
}
|
||||
const firstArg = args[0].length + 1;
|
||||
let temp = args.join(" ");
|
||||
let presenceText = temp.slice(firstArg, temp.length)
|
||||
setPresence({presenceText: presenceText,presenceType: presenceType, client: client, globalPrefix: globalPrefix});
|
||||
savePresence(presenceType, presenceText);
|
||||
message.channel.send("Updated presence.")
|
||||
}
|
||||
|
||||
}
|
||||
};
|
41
commands/admin/update.js
Normal file
41
commands/admin/update.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
const calculateReloaded = require("../../util/calculateReloaded");
|
||||
const reloadCommands = require("../../util/reloadCommands");
|
||||
|
||||
module.exports = {
|
||||
name: 'update',
|
||||
description: 'pull changes from remote and reload commands with git',
|
||||
admin: true,
|
||||
execute({message, client}) {
|
||||
let cmd = "git pull --ff-only";
|
||||
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)}`
|
||||
if(stdout.includes("server.js") || stdout.includes("server/")){
|
||||
sendText = sendText + "\nServer.js OR a file the server/ directory has been updated.\nThis requires the bot to be restarted."
|
||||
}
|
||||
message.channel.send(sendText).then(function(msg){
|
||||
let regex = /([^\s]+)\.\.([^\s]+)/
|
||||
let commits = stdout.match(regex)[0]
|
||||
cmd = `git log --oneline ${commits}`;
|
||||
exec(cmd, (err, stdout, stderr) =>{
|
||||
process.stdout.write(stdout)
|
||||
let commitCount = stdout.split(/\r\n|\r|\n/).length - 1
|
||||
msg.edit(`${sendText}\n\nLatest commits (${commitCount}):\n${stdout}`)
|
||||
if (err) console.log(stderr)
|
||||
})
|
||||
})
|
||||
}
|
||||
if (err) {
|
||||
message.channel.send("Something went wrong...");
|
||||
console.log(stderr);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue