-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-commands.ts
35 lines (28 loc) · 1.11 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
35
import dotenv from 'dotenv';
import {
REST,
RESTPostAPIChatInputApplicationCommandsJSONBody,
Routes,
RESTPutAPIApplicationCommandsResult,
} from 'discord.js';
import * as Interactions from './interactions';
import { InteractionsImport } from './types';
dotenv.config();
const rest = new REST().setToken(process.env.DISCORD_TOKEN ?? '');
const interactionsJSON: RESTPostAPIChatInputApplicationCommandsJSONBody[] = [];
for (const name in Interactions) {
const interaction = (Interactions as InteractionsImport)[name];
if (!!interaction.data && !!interaction.execute) interactionsJSON.push(interaction.data);
else console.warn(`Interaction ${name} is missing a required "data" or "execute" export.`);
}
(async () => {
try {
console.log(`Started refreshing ${interactionsJSON.length} application (/) commands.`);
const data = await rest.put(Routes.applicationCommands(process.env.APP_ID ?? ''), { body: interactionsJSON });
console.log(
`Successfully reloaded ${(data as RESTPutAPIApplicationCommandsResult).length} application (/) commands.`,
);
} catch (e) {
console.error(e);
}
})();