(text, prefixes)
| 198 | await this.loadCommands(); |
| 199 | } |
| 200 | getCommand(text, prefixes) { |
| 201 | const usedPrefix = prefixes.find(p => text.startsWith(p)); |
| 202 | const firstWord = text.trim().split(' ')[0].toLowerCase(); |
| 203 | if (!usedPrefix) { |
| 204 | if (this.prefixlessCommands.has(firstWord)) { |
| 205 | const targetCmd = this.prefixlessCommands.get(firstWord); |
| 206 | return this.commands.get(targetCmd); |
| 207 | } |
| 208 | return null; |
| 209 | } |
| 210 | const fullCommand = text.slice(usedPrefix.length).trim().split(' ')[0].toLowerCase(); |
| 211 | if (this.commands.has(fullCommand)) { |
| 212 | return this.commands.get(fullCommand); |
| 213 | } |
| 214 | if (this.aliases.has(fullCommand)) { |
| 215 | const mainCommand = this.aliases.get(fullCommand); |
| 216 | return this.commands.get(mainCommand); |
| 217 | } |
| 218 | const suggestion = this.findSuggestion(fullCommand); |
| 219 | if (suggestion) { |
| 220 | return { |
| 221 | command: suggestion, |
| 222 | handler: async (sock, message) => { |
| 223 | const chatId = message.key.remoteJid; |
| 224 | await sock.sendMessage(chatId, { |
| 225 | text: `❓ Did you mean *${usedPrefix}${suggestion}*?` |
| 226 | }, { quoted: message }); |
| 227 | } |
| 228 | }; |
| 229 | } |
| 230 | return null; |
| 231 | } |
| 232 | getCommandsByCategory(category) { |
| 233 | return this.categories.get(category.toLowerCase()) || []; |
| 234 | } |
no test coverage detected