|
1 | | -import { REST, Routes } from 'discord.js'; |
2 | 1 | import { readdirSync } from 'fs'; |
3 | 2 | import chalk from 'chalk'; |
4 | | -import config from '../data/config.js'; |
5 | | - |
6 | | -const rest = new REST({ version: '10' }).setToken(config.bot.token); |
7 | 3 |
|
8 | 4 | async function loadSlashCommands(client) { |
9 | | - const slashCommands = readdirSync('./src/commands').filter(file => file.endsWith('.js')); |
| 5 | + const slashCommands = readdirSync('./src/interactions/commands').filter(file => file.endsWith('.js')); |
10 | 6 | for (let i = 0; i < slashCommands.length; i++) { |
11 | | - const command = await import(`../commands/${slashCommands[i]}?${Date.now()}`); |
| 7 | + const command = await import(`../interactions/commands/${slashCommands[i]}`); |
12 | 8 | client.slashCommands.set(command.default.data.toJSON().name, command.default); |
13 | 9 | console.log(chalk.greenBright(`[SLASHCOMMAND] Loaded ${chalk.yellow(slashCommands[i])} with command ${chalk.yellow(command.default.data.toJSON().name)}`)); |
14 | 10 | } |
15 | | - rest.put( |
16 | | - Routes.applicationCommands(client.user.id), |
17 | | - { body: client.slashCommands.map(cmd => cmd.data.toJSON()) }, |
18 | | - ); |
19 | 11 | } |
20 | 12 |
|
21 | 13 | async function reloadSlashCommands(client) { |
22 | 14 | client.slashCommands.clear(); |
23 | | - const slashCommands = readdirSync('./src/commands').filter(file => file.endsWith('.js')); |
| 15 | + const slashCommands = readdirSync('./src/interactions/commands').filter(file => file.endsWith('.js')); |
24 | 16 | for (let i = 0; i < slashCommands.length; i++) { |
25 | | - const command = await import(`../commands/${slashCommands[i]}`); |
| 17 | + const command = await import(`../interactions/commands/${slashCommands[i]}?${Date.now()}`); |
26 | 18 | client.slashCommands.set(command.default.data.toJSON().name, command.default); |
27 | 19 | console.log(chalk.greenBright(`[SLASHCOMMAND] Reloaded ${chalk.yellow(slashCommands[i])} with command ${chalk.yellow(command.default.data.toJSON().name)}`)); |
28 | 20 | } |
29 | | - rest.put( |
30 | | - Routes.applicationCommands(client.user.id), |
31 | | - { body: client.slashCommands.map(cmd => cmd.data.toJSON()) }, |
32 | | - ); |
33 | 21 | return slashCommands.length; |
34 | 22 | } |
35 | 23 |
|
|
0 commit comments