Kord-Extensions / kord-extensions

Kord extensions framework, providing commands and distinct units of functionality
https://kordex.dev
European Union Public License 1.2
113 stars 27 forks source link

Make enum choice converters act the same as regular enum converters in the context of chat commands #137

Closed russellbanks closed 5 months ago

russellbanks commented 2 years ago

Summary

When using an enum choice converter on a chat command, it will result in an java.lang.IllegalStateException: Choice converters may only be used with slash commands error. In the use case of hybrid commands, it would beneficial to ensure that a hybrid command, utilising an enum choice, can work with a slash command whilst not failing as a chat command.

Current Behaviour

Using an enum choice on a chat command results in a java.lang.IllegalStateException: Choice converters may only be used with slash commands error.

Preferred Behaviour

An enum choice converter for a chat command should work the same as a normal enum choice converter.

Suggestions

#1 of Kordex hybrid commands documents this better.

Media

Using a command with a choice converter: image

Using the equivalent chat command: image

boring-cyborg[bot] commented 2 years ago

Hello, and thanks for opening an issue! As this is the first time you've created an issue on this repository, we'd just like to offer you a warm welcome to the project, and the following pointers:

gdude2002 commented 2 years ago

I think we could probably fix up converters a bit like this - I agree that supporting both in the same converter is likely to be the best option.

I'm not sure whether I'll get a chance to work on this soon, however, so I'd suggest making use of the latest snapshot (1.5.2-SNAPSHOT) and using a regular enum converter with an autoComplete set up as a workaround temporarily.

gdude2002 commented 5 months ago

This has just been pushed to 1.8.1-SNAPSHOT, and should be available in about 15 minutes. Thanks for your patience!

Chat commands should now support choice converters. Users may specify either the keys or values (case-insensitively wherever strings are involved) and an error showing the possible values will be returned if nothing matches.

The new documentation site has been updated to match this change.