You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey!
I'm trying to propose choices for typo's to the users with one of my custom argument type, and this doesn't look feasible within Akairo.
The idea
The idea: Providing choices for the user to pick from when a custom argument type value isn't valid
Here are few sample scenarios:
Typo and confirmation
!pokemon pikacho
[bot] Did you mean: pickachu?
yes
With a positive answer (yes), the value pikachu would be sent to the custom argument function and hopefully be accepted.
Options
!definition cot
[bot] Did you mean: cat (1) or cut (2)
1
In this case, as options were presented, the first option cat would be sent.
Solutions
Here is how I think such a feature could be integrated within the framework
Resolver returning metadata
The resolver could return a normalized object instead of only null | value
This way we can transfer metadata between the resolver and the prompt.
Then, using a prompt function, we can access the metadata and provide the choices, or provide a global default.
Resolver options
The previous solution requires each command's prompt to handle the new cases.
Instead, we can do it at the resolver level, by registering a matching prompt function with the resolver itself.
Something like the following:
functionpokemonPrompt(message,phrase,data){return{options: data.choices,text: "This pokemon was not found! Did you mean:"}}this.commandHandler.resolver.addType("pokemon",pokemonResolver,pokemonPrompt);
Alternatives
Here are few ways to perform a similar action I can think of, working with Akairo's existing structure.
Sending a message from the argument resolver
As we have access to the Message object itself from the resolver, we can reply to the message directly
This would send two messages:
The choice[s] from the resolver
The prompt message
Then, the user would have to manually enter the proper value.
This has few drawbacks:
Sending two messages
Not having the context of the command
Doing this within an async resolver
This is similar to the previous option, but with a twist.
You can send a message and listen to the reactions or to an event, before returning the proper result.
This means only one message will be sent, but unlike normal prompts you won't receive text answers to the channel.
The text was updated successfully, but these errors were encountered:
Hey!
I'm trying to propose choices for typo's to the users with one of my custom argument type, and this doesn't look feasible within Akairo.
The idea
The idea: Providing choices for the user to pick from when a custom argument type value isn't valid
Here are few sample scenarios:
Typo and confirmation
With a positive answer (
yes
), the valuepikachu
would be sent to the custom argument function and hopefully be accepted.Options
In this case, as options were presented, the first option
cat
would be sent.Solutions
Here is how I think such a feature could be integrated within the framework
Resolver returning metadata
The resolver could return a normalized object instead of only
null | value
This way we can transfer metadata between the resolver and the prompt.
Then, using a prompt function, we can access the metadata and provide the choices, or provide a global default.
Resolver options
The previous solution requires each command's prompt to handle the new cases.
Instead, we can do it at the resolver level, by registering a matching prompt function with the resolver itself.
Something like the following:
Alternatives
Here are few ways to perform a similar action I can think of, working with Akairo's existing structure.
Sending a message from the argument resolver
As we have access to the Message object itself from the resolver, we can reply to the message directly
This would send two messages:
Then, the user would have to manually enter the proper value.
This has few drawbacks:
Doing this within an async resolver
This is similar to the previous option, but with a twist.
You can send a message and listen to the reactions or to an event, before returning the proper result.
This means only one message will be sent, but unlike normal prompts you won't receive text answers to the channel.
The text was updated successfully, but these errors were encountered: