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

Option returning null with generator arguments #204

Open
Lioness100 opened this issue Mar 8, 2021 · 3 comments
Open

Option returning null with generator arguments #204

Lioness100 opened this issue Mar 8, 2021 · 3 comments

Comments

@Lioness100
Copy link
Contributor

Lioness100 commented Mar 8, 2021

I'm using generator arguments and the last option, --name, always returns null when I try to set it.

*args() {
  const member = yield {
    type: "memberMention",
    prompt: {
      start: "...",
      retry: "...",
    },
  };

  const playlist = yield {
    type: (message, phrase) =>
      Playlist.resolvePlaylist(phrase, message.client, member.id), // returns null or object
    match: "rest",
    prompt: {
      start: "...",
      retry: `...`,
    },
  };

  const name = yield {
    type: Argument.validate("string", (m, p, str: string) => str.length <= 20),
    match: "option",
    flag: ["--name", "-n"],
    default: playlist.title,
    prompt: {
      optional: true,
      retry: "Please limit the name to 20 letters and try again",
    },
  };

  return { member, playlist, name };
}

If I omit --name then it uses the set default and works fine. However, if I do use --name or -n, it returns null. This is also the case if I don't provide a string after the flag, or if I provide a string over 20 characters. There is no prompting.

Logging parsed.optionFlags at the bottom also returns an empty array.

@yoon4027
Copy link

I guess you are using the stable version?

@Lioness100
Copy link
Contributor Author

@yoon4027 Yes

@yoon4027
Copy link

yoon4027 commented May 15, 2021

try using the master version and see if works or not. Let me know!

yarn: yarn add discord-akairo/discord-akairo
npm: npm i discord-akairo/discord-akairo

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

No branches or pull requests

2 participants