const {MessageEmbed,Message} = require("discord.js"); const { stripIndents } = require("common-tags"); const {resddirSync, readFileSync, readdirSync } = require("fs") module.exports ={ name:"help", aliases:["h","help","commands"], category:"info", description:" gives the list of commands of the bot and tells the usage", usage:"(command)", run: async(client,message,args) =>{ const embed = new MessageEmbed() .setColor("RED") .setAuthor(`${message.guild.me.displayName} Help`,message.guild.iconURL) .setThumbnail(client.user.displayAvatar) if(!args[0]){ const categories = readdirSync("./commands/") embed.setDescription(`These are the available commands for ${message.guild.me.displayName}\nThe bot prefix is: **s!**`) embed.setFooter(`${message.guild.me.displayName} Total Commands: ${client.commands.size}`,client.user.displayAvatarURL) categories.forEach(category =>{ const dir = client.commands.filter(c => c.config.category === category) const capitalise = category.slice(0, 1).toUpperCase() + category.slice(1) try{ embed.addField(`> ${capitalise} [${dir.size}]:`,dir.map(c=>`\`${config.name}\``).join(" ")) }catch(e){ message.channel.send(e) } }) return message.channel.send(embed) }else{ let command = client.commands.get(bot.aliases.get(args[0].toLowerCase()) || args[0].toLowerCase()) if(!command) return message.channel.send(embed.setTitle("Invalid command,").setDescription(`Do s!help for the list of the commands`)) command = command.config embed.setDescription(stripIndents`The bot prefix is \`s!\`\n **Command:** ${command.slice(0, 1).toLowerCase() + command.name.slice(1)} **Description:** ${command.description || "No Description provided"} **Usage:** ${command.usage ? `\`s!${command.name} ${command.usage}\`` : "No usage"} **Accessible by:** ${command.accessabley || "Members"} **Aliases:** ${command.aliases ? command.aliases.join(" ") :"None"}`) return message.channel.send(embed) } } }