mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Finished help command.
Also categorized all commands.
This commit is contained in:
		
							parent
							
								
									a5da139b97
								
							
						
					
					
						commit
						e04587ffca
					
				
					 9 changed files with 44 additions and 9 deletions
				
			
		|  | @ -1,4 +1,5 @@ | ||||||
| { | { | ||||||
|     "prefix": "!!", |     "prefix": "!!", // Bot Prefix | ||||||
|     "token": "<token>" |     "token": "<token>", // Bot Token | ||||||
|  |     "owners": ["<id>"] // Array of bot owner IDs | ||||||
| } | } | ||||||
|  | @ -9,7 +9,8 @@ module.exports = class extends Command { | ||||||
| 
 | 
 | ||||||
| 	constructor(...args) { | 	constructor(...args) { | ||||||
| 		super(...args, { | 		super(...args, { | ||||||
| 			aliases: ['info', 'bot', 'botinfo'] | 			aliases: ['info', 'bot', 'botinfo'], | ||||||
|  | 			category: 'Information' | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -36,7 +36,8 @@ module.exports = class extends Command { | ||||||
| 
 | 
 | ||||||
| 	constructor(...args) { | 	constructor(...args) { | ||||||
| 		super(...args, { | 		super(...args, { | ||||||
| 			aliases: ['server', 'guild', 'guildinfo'] | 			aliases: ['server', 'guild', 'guildinfo'], | ||||||
|  | 			category: 'Information' | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -22,7 +22,8 @@ module.exports = class extends Command { | ||||||
| 
 | 
 | ||||||
| 	constructor(...args) { | 	constructor(...args) { | ||||||
| 		super(...args, { | 		super(...args, { | ||||||
| 			aliases: ['user', 'ui'] | 			aliases: ['user', 'ui'], | ||||||
|  | 			category: 'Information' | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -5,7 +5,8 @@ module.exports = class extends Command { | ||||||
| 
 | 
 | ||||||
| 	constructor(...args) { | 	constructor(...args) { | ||||||
| 		super(...args, { | 		super(...args, { | ||||||
| 			aliases: ['help', 'halp'] | 			aliases: ['help', 'halp'], | ||||||
|  | 			category: 'Utilities' | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -22,13 +23,33 @@ module.exports = class extends Command { | ||||||
| 
 | 
 | ||||||
| 			if (!cmd) return message.channel.send(`\`${command}\` is not a valid command.`); | 			if (!cmd) return message.channel.send(`\`${command}\` is not a valid command.`); | ||||||
| 
 | 
 | ||||||
| 			embed.setAuthor(`${this.client.utils.captalise(cmd.name)} Command Help`, this.client.user.displayAvatarURL()); | 			embed.setAuthor(`${this.client.utils.capitalise(cmd.name)} Command Help`, this.client.user.displayAvatarURL()); | ||||||
| 			embed.setDescription([ | 			embed.setDescription([ | ||||||
| 				`**❯ Aliases:** ${cmd.aliases.length ? cmd.aliases.map(alias => `\`${alias}\``).join(' ') : 'No Aliases'}`, | 				`**❯ Aliases:** ${cmd.aliases.length ? cmd.aliases.map(alias => `\`${alias}\``).join(' ') : 'No Aliases'}`, | ||||||
| 				`**❯ Description:** ${cmd.description}`, | 				`**❯ Description:** ${cmd.description}`, | ||||||
| 				`**❯ Category:** ${cmd.category}`, | 				`**❯ Category:** ${cmd.category}`, | ||||||
| 				`**❯ Usage:** ${cmd.usage}` | 				`**❯ Usage:** ${cmd.usage}` | ||||||
| 			]); | 			]); | ||||||
|  | 
 | ||||||
|  | 			return message.channel.send(embed); | ||||||
|  | 		} else { | ||||||
|  | 			embed.setDescription([ | ||||||
|  | 				`These are the available commands for ${message.guild.name}`, | ||||||
|  | 				`This bot's prefix is: ${this.client.prefix}`, | ||||||
|  | 				`Command Parameters: \`<>\` is a strict & \`[]\` is optional` | ||||||
|  | 			]); | ||||||
|  | 			let categories; | ||||||
|  | 			if (!this.client.owners.includes(message.author.id)) { | ||||||
|  | 				categories = this.client.utils.removeDuplicates(this.client.commands.filter(cmd => cmd.category !== 'Owner').map(cmd => cmd.category)); | ||||||
|  | 			} else { | ||||||
|  | 				categories = this.client.utils.removeDuplicates(this.client.commands.map(cmd => cmd.category)); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			for (const category of categories) { | ||||||
|  | 				embed.addField(`**${this.client.utils.capitalise(category)}**`, this.client.commands.filter(cmd => | ||||||
|  | 					cmd.category === category).map(cmd => `\`${cmd.name}\``).join(' ')); | ||||||
|  | 			} | ||||||
|  | 			return message.channel.send(embed); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,7 +4,8 @@ module.exports = class extends Command { | ||||||
| 
 | 
 | ||||||
| 	constructor(...args) { | 	constructor(...args) { | ||||||
| 		super(...args, { | 		super(...args, { | ||||||
| 			aliases: ['pong'] | 			aliases: ['pong'], | ||||||
|  | 			category: 'Utilities' | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,6 +3,13 @@ const ms = require('ms'); | ||||||
| 
 | 
 | ||||||
| module.exports = class extends Command { | module.exports = class extends Command { | ||||||
| 
 | 
 | ||||||
|  | 	constructor(...args) { | ||||||
|  | 		super(...args)({ | ||||||
|  | 			aliases: ['uptime'], | ||||||
|  | 			category: 'Utilities' | ||||||
|  | 		}); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	async run(message) { | 	async run(message) { | ||||||
| 		message.channel.send(`My uptime is \`${ms(this.client.uptime, { long: true })}\``); | 		message.channel.send(`My uptime is \`${ms(this.client.uptime, { long: true })}\``); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -15,6 +15,8 @@ module.exports = class BotClient extends Client { | ||||||
| 
 | 
 | ||||||
| 		this.utils = new Util(this); | 		this.utils = new Util(this); | ||||||
| 
 | 
 | ||||||
|  | 		this.owners = options.owners; | ||||||
|  | 
 | ||||||
| 		this.once('ready', () => { | 		this.once('ready', () => { | ||||||
| 			console.log(`Logged in as ${this.user.username}.`); | 			console.log(`Logged in as ${this.user.username}.`); | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ module.exports = class Command { | ||||||
| 		this.aliases = options.aliases || []; | 		this.aliases = options.aliases || []; | ||||||
| 		this.description = options.description || 'No description provided.'; | 		this.description = options.description || 'No description provided.'; | ||||||
| 		this.category = options.category || 'Miscellaneous'; | 		this.category = options.category || 'Miscellaneous'; | ||||||
| 		this.usage = `${this.client.prefix}${this.name} ${options.usage || ''}`.trim() | 		this.usage = `${this.client.prefix}${this.name} ${options.usage || ''}`.trim(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// eslint-disable-next-line no-unused-vars
 | 	// eslint-disable-next-line no-unused-vars
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue