(client, clientId, commands, totalSubcommands)
| 239 | } |
| 240 | |
| 241 | async function registerGlobalCommands(client, clientId, commands, totalSubcommands) { |
| 242 | if (!clientId) { |
| 243 | throw new Error('CLIENT_ID is required for global command registration when MULTI_GUILD=true'); |
| 244 | } |
| 245 | |
| 246 | if (!client.rest) { |
| 247 | throw new Error('Discord REST client is not available for global command registration'); |
| 248 | } |
| 249 | |
| 250 | logger.info(`Preparing to register ${totalSubcommands + commands.length} commands globally (multi-guild mode)`); |
| 251 | logger.info('Validating commands before registration...'); |
| 252 | validateCommands(commands); |
| 253 | logger.info('Command validation passed'); |
| 254 | |
| 255 | const commandsToRegister = prepareCommandsForRegistration(commands, { multiGuild: true }); |
| 256 | |
| 257 | logger.info(`Registering ${commandsToRegister.length} global commands...`); |
| 258 | await client.rest.put(`/applications/${clientId}/commands`, { body: commandsToRegister }); |
| 259 | logger.info(`Successfully registered ${commandsToRegister.length} global commands`); |
| 260 | logger.info('Global commands may take up to an hour to appear in all servers on first deploy'); |
| 261 | } |
| 262 | |
| 263 | async function registerGuildCommands(client, guildId, commands, totalSubcommands) { |
| 264 | logger.info(`Preparing to register ${totalSubcommands + commands.length} commands for guild ${guildId}`); |
no test coverage detected