Skip to content

Commit 3a873be

Browse files
committed
chore: Add remove* commands
1 parent e5e581a commit 3a873be

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/ps/handlers/commands/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ export async function commandHandler(message: PSMessage, indirect: IndirectCtx |
6565
} catch (originalError) {
6666
try {
6767
// Custom 'commands' with `,add*`. Try parsing `,addpoints abc def` as `,add points, abc, def`.
68-
if (!argData.startsWith('add')) throw new ChatError($T('CMD_NOT_FOUND'));
69-
const pointsType = baseSpacedArgs.shift()!.toLowerCase().replace(/^add/, '');
70-
const newArgData = `add ${pointsType}, ${baseSpacedArgs.join('')}`;
68+
if (!argData.startsWith('add') && !argData.startsWith('remove')) throw new ChatError($T('CMD_NOT_FOUND'));
69+
const pointsType = baseSpacedArgs
70+
.shift()!
71+
.toLowerCase()
72+
.replace(/^add|^remove/, '');
73+
const newArgData = `${argData.startsWith('add') ? 'add' : 'remove'} ${pointsType}, ${baseSpacedArgs.join('')}`;
7174
const args = newArgData.split(/ +/);
7275
const spacedArgs = newArgData.split(/( +)/);
7376
({ command: commandObj, sourceCommand, cascade, context: parsedCtx } = parse(args, spacedArgs, $T));

0 commit comments

Comments
 (0)