From eac9c4bceb6296460bb303f607c81e2ca43f5a74 Mon Sep 17 00:00:00 2001 From: mierenmanz Date: Wed, 28 Apr 2021 16:17:39 +0200 Subject: [PATCH] fix test --- src/utils/command.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils/command.ts b/src/utils/command.ts index d4b699f..6debad4 100644 --- a/src/utils/command.ts +++ b/src/utils/command.ts @@ -1,4 +1,4 @@ -import { MessageMentions } from "../structures/messageMentions.ts"; +import { MessageMentions } from '../structures/messageMentions.ts' export type CommandArgumentMatchTypes = 'flag' | 'mention' | 'content' | 'rest' export interface Args { @@ -6,11 +6,10 @@ export interface Args { match: CommandArgumentMatchTypes // Still needs to be implemented // type?: unknown - defaultValue?: string; + defaultValue?: string flag?: string } - export function parseArgs( commandArgs: Args[] | undefined, messageArgs: string[] @@ -57,9 +56,12 @@ function parseMention( argsNullable: Array ): void { const index = argsNullable.findIndex((x) => typeof x === 'string') - const mention = MessageMentions.USER_MENTION.exec(argsNullable[index]!)![0] + const regexMatches = MessageMentions.USER_MENTION.exec(argsNullable[index]!) + args[entry.name] = + regexMatches !== null + ? regexMatches[0].replace(MessageMentions.USER_MENTION, '$1') + : null argsNullable[index] = null - args[entry.name] = mention } function parseContent(