Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't call the retry prompt if a command has a default value #208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Norviah
Copy link
Contributor

@Norviah Norviah commented Mar 28, 2021

issue

when executing Argument.process, choice is called to determine if the command has optional arguments or not. the problem being in the first parameter, this.prompt && this.prompt.optional, determines if a optional value is set within a command's args object, however it doesn't check if a default value is set.

so, if a command is ran with a default value, a retry prompt is still executed as the first parameter doesn't check if a default value is set for the argument.

example

if we have a command with args set as

// alias: greet
args: [
  {
    id: 'member',
    type: 'member',
    prompt: { retry: 'please provide a valid member.' },
    default: (message: Message) => message.member,
  },
],

and the command is run as .greet, a retry prompt is called even though the command has a default value set.

solution

the solution is rather simple, just check if the command has a default value before checking if the optional property is set within the command's prompt.

update check to use a ternary operation, as the previous solution had false positives if both the default values and `optional` property isn't set.
Zendrex added a commit to Zendrex/discord-akairo that referenced this pull request May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant