generated from Discord-Botique/bot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-commands.ts
31 lines (27 loc) · 1021 Bytes
/
deploy-commands.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
import { REST } from "@discordjs/rest";
import { Routes } from "discord-api-types/v9";
import { logtail } from "@utils/logtail";
import { Command } from "@commands/types";
import { steam } from "@commands/steam";
import { help } from "@commands/help";
import { birthday } from "@commands/birthday";
import { twitch } from "@commands/twitch";
const rest = new REST({ version: "9" }).setToken(process.env.TOKEN);
const commands: Command[] = [steam, help, birthday, twitch];
const commandsJSON = commands.map((command) => command.data.toJSON());
const commandsRoute = process.env.TEST_SERVER_ID
? Routes.applicationGuildCommands(
process.env.CLIENT_ID,
process.env.TEST_SERVER_ID,
)
: Routes.applicationCommands(process.env.CLIENT_ID);
rest
.put(commandsRoute, {
body: commandsJSON,
})
.then(() => logtail.debug("Successfully registered application commands."))
.catch((err) =>
logtail.error("Error registering application commands.", {
error: JSON.stringify(err),
}),
);