(command, message, args, client, prefixOverride = null)
| 186 | } |
| 187 | |
| 188 | export 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 | } |
no test coverage detected