-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
help.native.ts
55 lines (47 loc) · 1.55 KB
/
help.native.ts
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
import * as app from "#app"
export default new app.SlashCommand({
name: "help",
description: "Show slash command details or list all slash commands",
guildOnly: true,
build() {
this.addStringOption((option) =>
option
.setName("command")
.setDescription("The target command name.")
.setRequired(false),
)
},
async run(interaction) {
const commandName = interaction.options.getString("command")
const commands = Array.from(
(await interaction.client.application.commands.fetch()).values(),
)
commands.push(...(await interaction.guild.commands.fetch()).values())
const command = commands.find((cmd) => cmd.name === commandName)
if (command) return app.sendSlashCommandDetails(interaction, command)
else {
await interaction.deferReply()
new app.StaticPaginator({
pages: await app.divider(
app.slashCommands
.map((cmd) => {
const command = commands.find((c) => c.name === cmd.options.name)
if (!command) return `unknown command ${cmd.options.name}`
return app.slashCommandToListItem(command)
})
.filter((line) => line.length > 0),
10,
(page) => {
return app.getSystemMessage("default", {
header: "Command list",
body: page.join("\n"),
footer: "/help <command>",
})
},
),
filter: (reaction, user) => user.id === interaction.user.id,
target: interaction,
})
}
},
})