add default value
This commit is contained in:
parent
eac9c4bceb
commit
97298f17f8
1 changed files with 5 additions and 4 deletions
|
@ -43,10 +43,10 @@ function parseFlags(
|
||||||
): void {
|
): void {
|
||||||
for (let i = 0; i < argsNullable.length; i++) {
|
for (let i = 0; i < argsNullable.length; i++) {
|
||||||
if (entry.flag === argsNullable[i]) {
|
if (entry.flag === argsNullable[i]) {
|
||||||
argsNullable[i] = null
|
|
||||||
args[entry.name] = true
|
args[entry.name] = true
|
||||||
break
|
break
|
||||||
} else args[entry.name] = entry.defaultValue
|
} else args[entry.name] = entry.defaultValue ?? false;
|
||||||
|
argsNullable[i] = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ function parseMention(
|
||||||
args[entry.name] =
|
args[entry.name] =
|
||||||
regexMatches !== null
|
regexMatches !== null
|
||||||
? regexMatches[0].replace(MessageMentions.USER_MENTION, '$1')
|
? regexMatches[0].replace(MessageMentions.USER_MENTION, '$1')
|
||||||
: null
|
: entry.defaultValue
|
||||||
argsNullable[index] = null
|
argsNullable[index] = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,5 +78,6 @@ function parseRest(
|
||||||
entry: Args,
|
entry: Args,
|
||||||
argsNullable: Array<string | null>
|
argsNullable: Array<string | null>
|
||||||
): void {
|
): void {
|
||||||
args[entry.name] = argsNullable.filter((x) => typeof x === 'string')
|
const restValues = argsNullable.filter((x) => typeof x === 'string')
|
||||||
|
args[entry.name] = restValues !== null ? restValues : entry.defaultValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue