Kord-Extensions / kord-extensions

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

Add an easy way to send command help from its action #26

Closed Forbidden-A closed 3 years ago

Forbidden-A commented 3 years ago

Current Behaviour

There is no easy way to send help from a command action

boring-cyborg[bot] commented 3 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 3 years ago

This is a little trickier to solve than it first appears, as the bot's help is provided by the bundled HelpExtension, which is intended to be entirely replaceable if it doesn't suit one's needs.

As I feel that it would be for the best if functionality like this didn't rely on a specific implementation of the help extension being present, the best approach may be to separate the help extension out from its logic - some sort of replaceable HelpProvider, perhaps, and a help extension that can be extended somehow.

Does that sound like a good approach to you?

gdude2002 commented 3 years ago

Actually, I just thought of an idea that may have more use-cases aside from this one - searching for a loaded extension (or a set of loaded extensions) based on type-checking. If a help extension uses a provided interface, then we can just search the loaded extensions for one that implements it.

It would be trivial for us to add an API wrapping this for extensions to send their own formatted help.

gdude2002 commented 3 years ago

A HelpProvider interface has been added, which needs to be implemented by all help extensions (the bundled one does this already). Additionally, the help extension has been refactored to provide a much more usable API.

This adds a sendHelp function to the MessageCommandContext objects that are bound to this in message command action { } blocks. Please try out the latest snapshot and let me know if this works how you'd like it to!

gdude2002 commented 3 years ago

Have you had a chance to try this out yet? I'd love some feedback if so.

gdude2002 commented 3 years ago

As the issue author has failed to respond in the last two weeks, I'm closing this issue under the assumption that the feature as implemented is sufficient.

If this isn't the case, open another issue.

Forbidden-A commented 3 years ago

As the issue author has failed to respond in the last two weeks, I'm closing this issue under the assumption that the feature as implemented is sufficient.

If this isn't the case, open another issue.

Yeah seems good, sorry I've been busy with family