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

Function collectCommandPayloads

src/handlers/commandLoader.js:122–152  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

120}
121
122function 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
154function validateCommands(commands) {
155 const validationErrors = [];

Callers 1

registerCommandsFunction · 0.85

Calls 1

getSubcommandInfoFunction · 0.85

Tested by

no test coverage detected