This repository was archived by the owner on Nov 25, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.js
More file actions
43 lines (33 loc) · 1.07 KB
/
deploy.js
File metadata and controls
43 lines (33 loc) · 1.07 KB
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
36
37
38
39
40
41
42
43
import { REST, Routes } from 'discord.js';
import fs from 'fs/promises';
import dotenv from 'dotenv';
dotenv.config();
const deploy = async () => {
const commandData = [];
try {
const categories = await fs.readdir('./commands/');
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
const clientId = process.env.CLIENT_ID;
for (const category of categories) {
const commands = await fs.readdir(`./commands/${category}/`);
for (const command of commands) {
if (command.endsWith('.js')) {
const cmdModule = await import(`./commands/${category}/${command}`);
const cmd = cmdModule.default;
const cmdData = cmd.data.toJSON();
commandData.push(cmdData);
}
}
}
console.log('» Started refreshing Slash Commands and Context Menus...');
await rest.put(
Routes.applicationCommands(clientId),
{ body: commandData },
);
console.log('» Slash Commands and Context Menus have now been deployed.\n These may take up to an hour to fan out to all servers and users.');
}
catch (e) {
console.error(e);
}
};
deploy();