-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandDeployer.ts
More file actions
31 lines (26 loc) · 881 Bytes
/
commandDeployer.ts
File metadata and controls
31 lines (26 loc) · 881 Bytes
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 Command from "./src/classes/Command";
import { ApplicationCommandOptionData, Collection } from "discord.js";
import { REST } from "@discordjs/rest";
import { Routes } from "discord-api-types/v9";
export default async function (
commands: Collection<string, Command>,
applicationId: string,
token: string
): Promise<void> {
const commandsArray: {
name: string;
description: string;
options: ApplicationCommandOptionData[];
}[] = [];
commands.forEach((cmd) => {
commandsArray.push(cmd.data);
});
const rest = new REST({ version: "9" }).setToken(token);
console.log("Started refreshing application (/) commands.");
await rest
.put(Routes.applicationGuildCommands(applicationId, "743079416560615504"), {
body: commandsArray,
})
.catch(console.error);
console.log("Successfully reloaded application (/) commands.");
}