(content, prefix)
| 4 | import { logger } from './logger.js'; |
| 5 | |
| 6 | export function parsePrefixCommand(content, prefix) { |
| 7 | if (!content || !content.startsWith(prefix)) { |
| 8 | return null; |
| 9 | } |
| 10 | |
| 11 | const withoutPrefix = content.slice(prefix.length).trim(); |
| 12 | |
| 13 | if (!withoutPrefix) { |
| 14 | return null; |
| 15 | } |
| 16 | |
| 17 | const args = parseArguments(withoutPrefix); |
| 18 | |
| 19 | if (args.length === 0) { |
| 20 | return null; |
| 21 | } |
| 22 | |
| 23 | const commandName = args[0].toLowerCase(); |
| 24 | const commandArgs = args.slice(1); |
| 25 | |
| 26 | return { |
| 27 | commandName, |
| 28 | args: commandArgs |
| 29 | }; |
| 30 | } |
| 31 | |
| 32 | function parseArguments(input) { |
| 33 | const args = []; |
no test coverage detected