MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / executePrefixCommand

Function executePrefixCommand

src/utils/messageAdapter.js:188–224  ·  view source on GitHub ↗
(command, message, args, client, prefixOverride = null)

Source from the content-addressed store, hash-verified

186}
187
188export async function executePrefixCommand(command, message, args, client, prefixOverride = null) {
189 const mockInteraction = createMockInteraction(message, command.data, args);
190 const coordinator = mockInteraction._responseCoordinator;
191 const prefix = prefixOverride || message.client?.config?.bot?.prefix || '!';
192
193 try {
194 const validation = mockInteraction.options.validateRequired();
195 if (!validation.valid) {
196 await coordinator.respondUsageFromCommand(prefix, command.data, validation);
197 return;
198 }
199
200 if (command.prefixExecute) {
201 await command.prefixExecute(mockInteraction, client.config, client);
202 } else {
203 await command.execute(mockInteraction, client.config, client);
204 }
205 } catch (error) {
206 logger.error('Prefix command execution error:', {
207 command: command.data.name,
208 args,
209 error: error.message,
210 stack: error.stack,
211 });
212
213 if (!coordinator.hasResponded()) {
214 const embed = createEmbed({
215 title: 'Command Execution Failed',
216 description: `An error occurred while executing this command.\n\n${error.message}`,
217 color: 'error',
218 });
219 await coordinator.respond({ embeds: [embed] });
220 }
221
222 throw error;
223 }
224}

Callers 2

handlePrefixCommandFunction · 0.90

Calls 5

createEmbedFunction · 0.90
createMockInteractionFunction · 0.85
hasRespondedMethod · 0.80
respondMethod · 0.80

Tested by

no test coverage detected