Add pages to help command
This commit is contained in:
parent
b9eeeef97b
commit
e56d8e768c
1 changed files with 34 additions and 7 deletions
|
@ -6,7 +6,7 @@ const getSubdirFiles = require('../../util/getSubdirFiles');
|
|||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'List all available commands.',
|
||||
moreHelp: ["Examples:","`<prefix>help` will return help with a small description for each command",
|
||||
moreHelp: ["Examples:","`<prefix>help [optional_page]` will return help with a small description for each command",
|
||||
"`<prefix>help <another_command>` will return help with a more descriptive description",
|
||||
"The descriptive description isn't available on all commands",
|
||||
"`<prefix>help netmodules` to display help for netmodules"
|
||||
|
@ -15,7 +15,11 @@ module.exports = {
|
|||
let commands = ""
|
||||
let commandFiles = getSubdirFiles('commands/')
|
||||
let x = false;
|
||||
let fieldName = "General";
|
||||
let fieldName = `Page [[page]]/${Math.round(client.commands.size / 10)}`;
|
||||
let iteration = 0;
|
||||
let num_in_args = false;
|
||||
let added_commands = 0;
|
||||
let page = -1;
|
||||
if (args[0] == "netmodules") {
|
||||
commandFiles = fs.readdirSync('../../netload').filter(file => file.endsWith('.js'));
|
||||
if (commandFiles.length == 0) {
|
||||
|
@ -23,7 +27,17 @@ module.exports = {
|
|||
x = true;
|
||||
}
|
||||
|
||||
}else if(!isNaN(parseInt(args[0])) && parseInt(args[0])){
|
||||
num_in_args = true;
|
||||
iteration = ( parseInt(args[0]) - 1) * 10;
|
||||
page = Math.round(parseInt(args[0]))
|
||||
}
|
||||
if(page === -1){
|
||||
page = 1;
|
||||
}
|
||||
fieldName = fieldName.replace("[[page]]", page);
|
||||
const max_commands = iteration + 10;
|
||||
|
||||
if (x) return;
|
||||
|
||||
const embed = new Discord.MessageEmbed()
|
||||
|
@ -31,17 +45,26 @@ module.exports = {
|
|||
.setTitle("Commands")
|
||||
.setTimestamp()
|
||||
.setAuthor(client.user.username, client.user.avatarURL({ dynamic: true, size: 4096 }))
|
||||
|
||||
let start = 0;
|
||||
for (const file of commandFiles) {
|
||||
if(iteration >= max_commands) break;
|
||||
const command = require(`../../${file}`);
|
||||
|
||||
if(command.disabled) continue;
|
||||
|
||||
if (args[0] == "admin") {
|
||||
if (command.admin)
|
||||
commands = commands + `${prefix}${command.name} | ${command.description}\n`
|
||||
}else if(!args[0]){
|
||||
if (!command.admin)
|
||||
commands = commands + `${prefix}${command.name} | ${command.description}\n`
|
||||
}else if(!args[0] || num_in_args){
|
||||
if (!command.admin){
|
||||
if(start < iteration){
|
||||
}else{
|
||||
added_commands++
|
||||
commands = commands + `${prefix}${command.name} | ${command.description}\n`;
|
||||
iteration++
|
||||
}
|
||||
start++;
|
||||
}
|
||||
}else if(args[0] === command.name){
|
||||
commands = commands + `${prefix}${command.name}\n`
|
||||
embed.setTitle(command.name.charAt(0).toUpperCase() + command.name.slice(1))
|
||||
|
@ -65,6 +88,10 @@ module.exports = {
|
|||
embed.addFields(
|
||||
{ name: fieldName, value: commands },
|
||||
)
|
||||
if(embed.fields[0].value.length > 1023){
|
||||
message.channel.send(`There are more than 1023 characters`)
|
||||
}else {
|
||||
message.channel.send({embeds :[embed]});
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Reference in a new issue