-
Notifications
You must be signed in to change notification settings - Fork 9
/
help.js
70 lines (62 loc) · 1.99 KB
/
help.js
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
const { ChatInputCommand } = require('../../classes/Commands');
const {
getCommandSelectMenu,
generateCommandOverviewEmbed,
generateCommandInfoEmbed
} = require('../../handlers/commands');
const { commandAutoCompleteOption } = require('../../interactions/autocomplete/command');
module.exports = new ChatInputCommand({
global: true,
aliases: [ 'commands' ],
cooldown: {
// Use user cooldown type instead of default member
type: 'user',
usages: 2,
duration: 10
},
clientPerms: [ 'EmbedLinks' ],
data: {
description: 'Receive detailed command information',
options: [ commandAutoCompleteOption ]
},
run: (client, interaction) => {
// Destructuring
const { member } = interaction;
const {
commands, contextMenus, emojis
} = client.container;
// Check for optional autocomplete focus
const commandName = interaction.options.getString('command');
const hasCommandArg = commandName !== null && typeof commandName !== 'undefined';
// Show command overview if no command parameter is supplied
if (!hasCommandArg) {
// Getting our command select menu, re-used
const cmdSelectMenu = getCommandSelectMenu(member);
// Reply to the interaction with our embed
interaction.reply({
embeds: [ generateCommandOverviewEmbed(commands, interaction) ],
components: [ cmdSelectMenu ]
});
return;
}
// Request HAS optional command argument
// Assigning our data
const clientCmd = commands.get(commandName)
|| contextMenus.get(commandName);
// Checking if the commandName is a valid client command
if (!clientCmd) {
interaction.reply({
content: `${ emojis.error } ${ member }, I couldn't find the command **\`/${ commandName }\`**`,
ephemeral: true
});
return;
}
// Replying with our command information embed
interaction.reply({ embeds: [
generateCommandInfoEmbed(
clientCmd,
interaction
)
] });
}
});