misc changes

This commit is contained in:
mierenmanz 2021-04-28 15:09:39 +02:00
parent e7715b75cf
commit 58ad6fcd3d
1 changed files with 5 additions and 4 deletions

View File

@ -1,14 +1,15 @@
import { MessageMentions } from "../structures/messageMentions.ts";
export type CommandArgumentMatchTypes = 'flag' | 'mention' | 'content' | 'rest' export type CommandArgumentMatchTypes = 'flag' | 'mention' | 'content' | 'rest'
export interface Args { export interface Args {
name: string name: string
match: CommandArgumentMatchTypes match: CommandArgumentMatchTypes
type?: unknown // Still needs to be implemented // Still needs to be implemented
defaultValue?: unknown // Still needs to be implemented // type?: unknown
defaultValue?: string;
flag?: string flag?: string
} }
const mentionRegex = /([0-9]{18})/g
export function parseArgs( export function parseArgs(
commandArgs: Args[] | undefined, commandArgs: Args[] | undefined,
@ -56,7 +57,7 @@ function parseMention(
argsNullable: Array<string | null> argsNullable: Array<string | null>
): void { ): void {
const index = argsNullable.findIndex((x) => typeof x === 'string') const index = argsNullable.findIndex((x) => typeof x === 'string')
const mention = mentionRegex.exec(argsNullable[index]!)![0] const mention = MessageMentions.USER_MENTION.exec(argsNullable[index]!)![0]
argsNullable[index] = null argsNullable[index] = null
args[entry.name] = mention args[entry.name] = mention
} }