Added check to make sure help list isn't generated multiple times
This commit is contained in:
		
							parent
							
								
									8d5cd12a45
								
							
						
					
					
						commit
						963d5247f6
					
				
					 2 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
					@ -53,7 +53,7 @@ class HelpCommand extends Command {
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
 | 
					      if (this.message.channel.guild && !this.message.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
 | 
				
			||||||
      const pages = [];
 | 
					      const pages = [];
 | 
				
			||||||
      if (help.categories === help.categoryTemplate) await help.generateList();
 | 
					      if (help.categories === help.categoryTemplate && !help.generated) await help.generateList();
 | 
				
			||||||
      for (const category of Object.keys(help.categories)) {
 | 
					      for (const category of Object.keys(help.categories)) {
 | 
				
			||||||
        const splitPages = help.categories[category].map((item, index) => {
 | 
					        const splitPages = help.categories[category].map((item, index) => {
 | 
				
			||||||
          return index % 15 === 0 ? help.categories[category].slice(index, index + 15) : null;
 | 
					          return index % 15 === 0 ? help.categories[category].slice(index, index + 15) : null;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,8 @@ export const categoryTemplate = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export let categories = categoryTemplate;
 | 
					export let categories = categoryTemplate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export let generated = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function generateList() {
 | 
					export async function generateList() {
 | 
				
			||||||
  categories = categoryTemplate;
 | 
					  categories = categoryTemplate;
 | 
				
			||||||
  for (const [command] of commands) {
 | 
					  for (const [command] of commands) {
 | 
				
			||||||
| 
						 | 
					@ -24,6 +26,7 @@ export async function generateList() {
 | 
				
			||||||
      categories[category].push(`**${command}**${params ? ` ${params}` : ""} - ${description}`);
 | 
					      categories[category].push(`**${command}**${params ? ` ${params}` : ""} - ${description}`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  generated = true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function createPage(output) {
 | 
					export async function createPage(output) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue