there might not be a first or last value in the unnamed arg list

This commit is contained in:
LenAnderson 2024-07-20 16:41:01 -04:00
parent c06f422e76
commit 4556684e76

View File

@ -1097,7 +1097,7 @@ export class SlashCommandParser {
} }
if (isList) { if (isList) {
const firstVal = listValues[0]; const firstVal = listValues[0];
if (typeof firstVal.value == 'string') { if (typeof firstVal?.value == 'string') {
if (!listQuoted[0]) { if (!listQuoted[0]) {
// only trim the first part if it wasn't quoted // only trim the first part if it wasn't quoted
firstVal.value = firstVal.value.trimStart(); firstVal.value = firstVal.value.trimStart();
@ -1108,7 +1108,7 @@ export class SlashCommandParser {
} }
} }
const lastVal = listValues.slice(-1)[0]; const lastVal = listValues.slice(-1)[0];
if (typeof lastVal.value == 'string') { if (typeof lastVal?.value == 'string') {
if (!listQuoted.slice(-1)[0]) { if (!listQuoted.slice(-1)[0]) {
// only trim the last part if it wasn't quoted // only trim the last part if it wasn't quoted
lastVal.value = lastVal.value.trimEnd(); lastVal.value = lastVal.value.trimEnd();