(client)
| 120 | } |
| 121 | |
| 122 | function collectCommandPayloads(client) { |
| 123 | const commands = []; |
| 124 | let totalSubcommands = 0; |
| 125 | const registeredNames = new Set(); |
| 126 | |
| 127 | for (const command of client.commands.values()) { |
| 128 | if (!command.data || typeof command.data.toJSON !== 'function') { |
| 129 | logger.warn(`Command missing data or toJSON method: ${command}`); |
| 130 | continue; |
| 131 | } |
| 132 | |
| 133 | const commandName = command.data.name; |
| 134 | logger.debug(`Processing command for registration: ${commandName}`); |
| 135 | |
| 136 | if (registeredNames.has(commandName)) { |
| 137 | logger.debug(`Skipping duplicate command: ${commandName}`); |
| 138 | continue; |
| 139 | } |
| 140 | |
| 141 | registeredNames.add(commandName); |
| 142 | const commandJson = command.data.toJSON(); |
| 143 | commands.push(commandJson); |
| 144 | totalSubcommands += getSubcommandInfo(commandJson).length; |
| 145 | |
| 146 | if (process.env.NODE_ENV !== 'production') { |
| 147 | logger.debug(`Registering command: ${commandName}`); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | return { commands, totalSubcommands }; |
| 152 | } |
| 153 | |
| 154 | function validateCommands(commands) { |
| 155 | const validationErrors = []; |
no test coverage detected