This repository was archived by the owner on Jun 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathhelp.js
More file actions
54 lines (47 loc) · 2.5 KB
/
help.js
File metadata and controls
54 lines (47 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const { MessageEmbed } = require("discord.js");
const { prefix } = require("../../botconfig.json");
const { readdirSync } = require("fs")
const { stripIndents } = require("common-tags")
const { cyan } = require("../../colours.json")
module.exports = {
config: {
name: "help",
aliases: ["h", "halp", "commands"],
usage: "(command)",
category: "miscellaneous",
description: "Displays all commands that the bot has.",
accessableby: "Members"
},
run: async (bot, message, args) => {
const embed = new MessageEmbed()
.setColor(cyan)
.setAuthor(`${message.guild.me.displayName} Help`, message.guild.iconURL)
.setThumbnail(bot.user.displayAvatarURL)
if(!args[0]) {
const categories = readdirSync("./commands/")
embed.setDescription(`These are the avaliable commands for ${message.guild.me.displayName}\nThe bot prefix is: **${prefix}**`)
embed.setFooter(`© ${message.guild.me.displayName} | Total Commands: ${bot.commands.size}`, bot.user.displayAvatarURL);
categories.forEach(category => {
const dir = bot.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 => `\`${c.config.name}\``).join(" "))
} catch(e) {
console.log(e)
}
})
return message.channel.send(embed)
} else {
let command = bot.commands.get(bot.aliases.get(args[0].toLowerCase()) || args[0].toLowerCase())
if(!command) return message.channel.send(embed.setTitle("Invalid Command.").setDescription(`Do \`${prefix}help\` for the list of the commands.`))
command = command.config
embed.setDescription(stripIndents`The bot's prefix is: \`${prefix}\`\n
**Command:** ${command.name.slice(0, 1).toUpperCase() + command.name.slice(1)}
**Description:** ${command.description || "No Description provided."}
**Usage:** ${command.usage ? `\`${prefix}${command.name} ${command.usage}\`` : "No Usage"}
**Accessible by:** ${command.accessableby || "Members"}
**Aliases:** ${command.aliases ? command.aliases.join(", ") : "None."}`)
return message.channel.send(embed)
}
}
}