Skip to content

Commit

Permalink
fix(package/addCommand): argument validation
Browse files Browse the repository at this point in the history
Get the first index of raw.split for the command name.
Check if value is defined (as 0 is falsey).
Don't subscribe to 0-index propaganda (argument index+1).
  • Loading branch information
thelindat committed Jan 15, 2024
1 parent c383e42 commit 2aa21e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package/server/resource/addCommand/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function parseArguments(
break;
}

if (!value && (!param.optional || (param.optional && arg))) {
if (value === undefined && (!param.optional || (param.optional && arg))) {
return Citizen.trace(
`^1command '${raw.split(' ') || raw}' received an invalid ${param.paramType} for argument ${index} (${
`^1command '${raw.split(' ')[0] || raw}' received an invalid ${param.paramType} for argument ${index + 1} (${
param.name
}), received '${arg}'^0`
);
Expand Down

0 comments on commit 2aa21e7

Please sign in to comment.