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

Function parsePrefixCommand

src/utils/prefixParser.js:6–30  ·  view source on GitHub ↗
(content, prefix)

Source from the content-addressed store, hash-verified

4import { logger } from './logger.js';
5
6export 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
32function parseArguments(input) {
33 const args = [];

Callers 2

handlePrefixCommandFunction · 0.90

Calls 1

parseArgumentsFunction · 0.85

Tested by

no test coverage detected