MCPcopy Create free account
hub / github.com/codebymitch/TitanBot / registerGlobalCommands

Function registerGlobalCommands

src/handlers/commandLoader.js:241–261  ·  view source on GitHub ↗
(client, clientId, commands, totalSubcommands)

Source from the content-addressed store, hash-verified

239}
240
241async 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
263async function registerGuildCommands(client, guildId, commands, totalSubcommands) {
264 logger.info(`Preparing to register ${totalSubcommands + commands.length} commands for guild ${guildId}`);

Callers 1

registerCommandsFunction · 0.85

Calls 2

validateCommandsFunction · 0.85

Tested by

no test coverage detected