(message, client)
| 44 | }; |
| 45 | |
| 46 | async function handlePrefixCommand(message, client) { |
| 47 | try { |
| 48 | const guildConfig = await getGuildConfig(client, message.guild.id); |
| 49 | const prefix = guildConfig?.prefix || client.config.bot.prefix || '!'; |
| 50 | const parsed = parsePrefixCommand(message.content, prefix); |
| 51 | |
| 52 | if (!parsed) { |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | const { commandName, args } = parsed; |
| 57 | logger.info(`Prefix command detected: ${commandName}, args: ${args.join(', ')}`); |
| 58 | |
| 59 | const resolvedCommandName = resolveCommandAlias(commandName); |
| 60 | logger.info(`Resolved command name: ${resolvedCommandName}`); |
| 61 | const command = client.commands.get(resolvedCommandName); |
| 62 | |
| 63 | if (!command) { |
| 64 | logger.warn(`Command not found: ${resolvedCommandName}`); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | const restriction = getPrefixRestriction(command, args, resolveSubcommandAlias); |
| 69 | if (!supportsPrefixExecution(command) || restriction.blocked) { |
| 70 | if (restriction.blocked && restriction.reason) { |
| 71 | const embed = createEmbed({ |
| 72 | title: 'Slash Command Only', |
| 73 | description: `${restriction.reason}\nUse \`/${resolvedCommandName}\` instead.`, |
| 74 | color: 'info', |
| 75 | }); |
| 76 | await message.channel.send({ embeds: [embed] }).catch(() => {}); |
| 77 | } |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | if (!(await isCommandEnabled(client, message.guild.id, resolvePrefixAccessKey(command.data, args), command.category))) { |
| 82 | const embed = createEmbed({ |
| 83 | title: 'Command Disabled', |
| 84 | description: 'This command has been disabled for this server.', |
| 85 | color: 'error', |
| 86 | }); |
| 87 | await message.channel.send({ embeds: [embed] }).catch(() => {}); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | const mockInteractionForProtection = { |
| 92 | guildId: message.guild.id, |
| 93 | user: message.author, |
| 94 | }; |
| 95 | const abuseProtection = await enforceAbuseProtection( |
| 96 | mockInteractionForProtection, |
| 97 | command, |
| 98 | resolvedCommandName, |
| 99 | ); |
| 100 | if (!abuseProtection.allowed) { |
| 101 | const formattedCooldown = formatCooldownDuration(abuseProtection.remainingMs); |
| 102 | const embed = createEmbed({ |
| 103 | title: 'Command Cooldown', |
no test coverage detected