-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
help.native.ts
58 lines (55 loc) · 1.65 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
56
57
58
// native file, if you want edit it, remove the "native" suffix from the filename
import * as app from "#app"
export default new app.Command({
name: "help",
description: "Help menu",
longDescription: "Show command details or list all commands",
channelType: "all",
aliases: ["h", "usage", "detail", "details"],
positional: [
{
name: "command",
type: "command",
description: "The target command name.",
},
],
async run(message) {
if (message.args.command) {
const cmd = message.args.command
if (cmd) {
return app.sendCommandDetails(message, cmd)
} else {
await message.channel.send(
await app.getSystemMessage(
"error",
`Unknown command "${message.args.command}"`,
),
)
}
} else {
new app.StaticPaginator({
pages: await app.divider(
(
await Promise.all(
app.commands.map(async (cmd) => {
const prepared = await app.prepareCommand(message, cmd)
if (prepared !== true) return ""
return app.commandToListItem(message, cmd)
}),
)
).filter((line) => line.length > 0),
10,
(page) => {
return app.getSystemMessage("default", {
header: "Command list",
body: page.join("\n"),
footer: `${message.usedPrefix}help <command>`,
})
},
),
filter: (reaction, user) => user.id === message.author.id,
target: message.channel,
})
}
},
})