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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import { colour } from '../../Config';
export default class HelpUtil extends Command {
public constructor() {
super('help', {
aliases: ['help'],
category: 'utility',
description: {
content: 'List help features or get information on a specified command.',
usage: '[command]',
examples: [
'',
'8ball'
]
},
ratelimit: 3,
clientPermissions: ['EMBED_LINKS'],
args: [
{
id: 'command',
type: 'commandAlias',
prompt: {
start: 'Which command do you need help with?',
retry: 'Please provide a valid command.',
optional: true
},
match: 'rest'
}
]
});
}
public exec(msg: Message, { command }): Promise<void | Message> {
if (!command) {
const embed = this.client.util.embed()
.setColor(colour)
.addFields([
{
name: 'Online Command List',
value: '*Coming soon!*'
},
{
name: 'Specific Command Help',
value: `${this.handler.prefix}help <command>`
},
{
name: 'List of all public categories',
value: `${this.handler.prefix}categories`
}
]);
return msg.channel.send({ embed });
}
const description = Object.assign({
content: 'No description available.',
usage: '',
examples: [],
fields: []
}, command.description);
const embed = this.client.util.embed()
.setColor(colour)
.setTitle(`\`${this.client.commandHandler.prefix}${command.aliases[0]} ${description.usage}\``)
.addField('Description', description.content);
for (const field of description.fields) embed.addField(field.name, field.value);
if (command.aliases.length > 1) {
embed.addField('Aliases', `\`${command.aliases.join('`, `')}\``, true);
}
if (command.description.examples.length >= 1) {
embed.addField('Examples', `\`${this.client.commandHandler.prefix}${command.aliases[0]} ${command.description.examples.join(`, ${this.client.commandHandler.prefix}${command.aliases[0]} `)}\``, true);
}
if (command.userPermissions) {
embed.addField('User permission', `\`${command.userPermissions.join('` `')}\``, true);
}
if (command.clientPermissions) {
embed.addField('Bot permission', `\`${command.clientPermissions.join('` `')}\``, true);
}
if (command.contentParser.flagWords.length) {
embed.addField('Command flags', `\`${command.contentParser.flagWords.join('` `')}\``, true);
}
if (command.contentParser.optionFlagWords.length) {
embed.addField('Command options flags', `\`${command.contentParser.optionFlagWords.join('` `')}\``, true);
}
if (msg.channel.type === 'dm') return msg.author.send({ embed });
return msg.reply('Sending you a DM with information...').then(async m => {
await msg.author.send({ embed });
m.edit('I\'ve send you a DM with information!');
});
}
}
|