summaryrefslogtreecommitdiff
path: root/src/utils/commandRegistry.js
blob: 918e7b360af27692a70855660e55f278cc272783 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const { REST, Routes } = require('discord.js');

async function registerCommands(commands, token, clientId) {
  const rest = new REST({ version: '10' }).setToken(token);

  try {
    await rest.put(
      Routes.applicationCommands(clientId),
      { body: commands.map(cmd => cmd.toJSON()) }
    );
  } catch (error) {
    console.error('Error registering commands:', error);
  }
}

module.exports = { registerCommands };