remove unneeded functions

This commit is contained in:
rhearmas 2019-12-20 19:58:46 -05:00
parent a32079a4f0
commit ac967fc98e

View file

@ -77,68 +77,6 @@ module.exports = (client) => {
} }
}; };
client.unloadCommand = async (commandName) => {
let command;
if (client.commands.has(commandName)) {
command = client.commands.get(commandName);
} else if (client.aliases.has(commandName)) {
command = client.commands.get(client.aliases.get(commandName));
}
if (!command) return `The command \`${commandName}\` doesn\'t seem to exist, nor is it an alias. Try again!`;
if (command.shutdown) {
await command.shutdown(client);
}
const mod = require.cache[require.resolve(`../commands/${command.help.category}/${command.help.name}`)];
delete require.cache[require.resolve(`../commands/${command.help.category}/${command.help.name}.js`)];
for (let i = 0; i < mod.parent.children.length; i++) {
if (mod.parent.children[i] === mod) {
mod.parent.children.splice(i, 1);
break;
}
}
return false;
};
client.reloadCommand = async(commandName) => {
// step 1: unload the command
let command;
if (client.commands.has(commandName)) {
command = client.commands.get(commandName);
} else if (client.aliases.has(commandName)) {
command = client.commands.get(client.aliases.get(commandName));
}
if (!command) return `The command \`${commandName}\` doesn\'t seem to exist, nor is it an alias. Try again!`;
if (command.shutdown) {
await command.shutdown(client);
}
const mod = require.cache[require.resolve(`../commands/${command.help.category}/${commandName}.js`)];
delete require.cache[require.resolve(`../commands/${command.help.category}/${commandName}.js`)];
for (let i = 0; i < mod.parent.children.length; i++) {
if (mod.parent.children[i] === mod) {
mod.parent.children.splice(i, 1);
break;
}
}
return false;
// step 2: load said command
try {
const props = require(`../commands/${command.help.category}/${command.Name}`);
if (props.init) {
props.init(client);
}
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
return false;
} catch (e) {
return `Unable to load command ${commandName}: ${e}`;
}
}
Object.defineProperty(String.prototype, "toProperCase", { Object.defineProperty(String.prototype, "toProperCase", {
value: function() { value: function() {
return this.replace(/([^\W_]+[^\s-]*) */g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()); return this.replace(/([^\W_]+[^\s-]*) */g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());