-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.ts
More file actions
24 lines (19 loc) · 815 Bytes
/
deploy.ts
File metadata and controls
24 lines (19 loc) · 815 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
import { REST, type RESTPutAPIApplicationCommandsResult, Routes } from 'discord.js';
import { commands } from '../commands/index.js';
import { config } from '../env.js';
export async function deployCommands(): Promise<RESTPutAPIApplicationCommandsResult> {
const commandData = [...commands.values()].map((command) => command.data);
const rest = new REST({ version: '10' }).setToken(config.discord.token);
const result = (await rest.put(
Routes.applicationGuildCommands(config.discord.clientId, config.serverId),
{
body: commandData,
}
)) as RESTPutAPIApplicationCommandsResult;
console.log(`Successfully registered ${result.length} commands.`);
return result;
}
// If run directly with `node deploy.ts`
if (import.meta.url === `file://${process.argv[1]}`) {
deployCommands();
}