-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-commands.ts
34 lines (29 loc) · 1.09 KB
/
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
32
33
34
import { ApplicationCommand, REST, Routes } from "discord.js";
import { clientId, guildId, token } from "./src/config.json";
import { returnCommandCollection } from "./src/utils/collections";
const commands = returnCommandCollection();
const slashCommands = commands.map((item) => item.data.toJSON());
const rest = new REST().setToken(token);
(async () => {
try {
console.log(
`\nStarted refreshing ${slashCommands.length} application (/) commands.`,
);
const data: any = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: slashCommands },
);
const castedResponse: Array<ApplicationCommand> = data;
console.log(
`Successfully reloaded ${castedResponse.length} application (/) commands.`,
);
console.log(
"List of commands: " +
castedResponse.map((item) => item.name).join(", ") +
"\n",
);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();