-
-
Notifications
You must be signed in to change notification settings - Fork 89
Rework command system to add context command and autocomplete support #368
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
Comments
If we agree, I'll work on this with love :p |
Me likes autocomplete very much, so you have my unwavering support. 🥰 Now, don't know what 'context command' is, but I see interfaces, and interfaces are good, so I guess I like that too. I'm a bit suspicious that you bundled these two together, tho. Feels like a Trojan horse, you know, since everyone loves autocomplete... 🤔 |
Context menu's are commands you receive when you right click an user / message. |
Auto complete could come in extremely handy in a lot of use cases, and I guess like Marko said interfaces makes it better |
Im all in for the autocomplete and im also all in for context menus. But I dont quite get why context menus and slash commands are put together. Like, I am not sure why you proposed your design in the way you proposed it. So from my side: green light on adding those features. That said, feel free to get started and once I am more familiar with whats going on, I might propose something different. Or you elaborate a bit on how things work and your reasoning and maybe I can give my 2cents then earlier already. |
Within Discord's design context-commands and slash-commands are within the same hierarchy, thus I "copied" their design.
|
I see.
Our That said, if it makes sense to change existing design for new stuff, it is totally reasonable to do so. In general, it might maybe make sense to first create the new context commands by copy-pasta and then we see which parts are identical and which not and can unify them nicely. We just have to be aware that in the future there might be another XY-Command thingy coming our way that we want to unify into the system... so as much as it makes sense to merge things together, we also have to be flexible enough to support extra logic at some point. tldr: Your plan sounds reasonable, go ahead. But be prepared that we will probably change design a bit once we all have a clearer picture on the concrete code. |
Will make 2 separate designs, and take a look at mixing them together in the end then ^^ |
When finished, I'll create a draft PR to the This way the command-system can be viewed without having all changes from the Once JDA5 is merged, we'll change the target for sure, but this allows us to take a look at the system before hand |
This issue is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days. |
This issue is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days. |
This is a major rework of the command system Support for both autocompletion events and context commands has been added in this rework. The reload command has been removed, instead commands are automatically reloaded on server start tldr: Added classes: CommandReloading UserInteractorPrefix BotCommand BotCommandAdapter MessageContextcommand UserContextCommand Renamed classes: SlashCommandPriver to CommandProvider SlashCommandVisibility to CommandVisibility Removed classes: ReloadCommand ReloadCommandTest Full change log Application: the Application now waits till JDA is ready before creating the BotCore, this means that commands can use the cached guilds and such. CommandReloading: added reloadCommands(JDA, CommandProvider), this method only automatically runs on start-up, but this can technically be used later on too. BotCommand: Added getName, getType, getVisibility and getData BotCommandAdapter: Overrides the above listed methods by requiring a CommandData and CommandVisibility in the constructor. This also adds the generateComponenttId methods MessageContextCommand: Adds the onMessageContext method SlashCommand: Has been stripped down and many things have been moved to BotCommand This method also adds onAutoComplete SlashCommandAdapter: Overrode getData to return SlashCommandData Moved ID generation to BotCommandAdapter UserContextCommand: Adds the onUserContext method UserInteractor: acceptComponentIdGenerator has received documentation about how ID generation is done UserInteractorPrefix: Contains the prefixes for classes, in our system slashcommands get annotated with `s-` so other UserInteractor's can have the same name. This is useful for a.e a report command, this way it can have a report slash command and message context to improve UX Botcore: Interactor names are validated here, this way a name cannot start with any of the assigned prefixes. Also removed the code that registered the reload command, and removed the onReady method CommandProvider: This one contains many of the methods BotCore has to implement. getInteractors and getCommands are part of this. This also contains methods to get an interactor based of a Class<?> instance, or their prefixedName. Closes #368
Is your feature request related to a problem? Please describe.
Discord has added a lot of things, and to use those, we need to update our command system to reflect these changes.
Describe the solution you'd like
Initial proposal
Context commands:
We add BotCommand which extends the UserInteractor added with b9b047a
This interface gets getType, getVisibility and getData.
After that we'll add a MessageContextInteraction and UserContextInteraction interface (for the context menus)
Those 2 and SlashCommand will all implement the BotCommand interface.
Now we will rename SlashCommandVisibility to CommandVisibility
Note, SlashCommand will return SlashCommandData instead of CommandData for the getData method
There will probably also come an abstract class like SlashCommand has for context-command's, but will see that when I go deeper into our system
Autocomplete:
JDA added
OptionData#setAutoComplete(boolean)
. If autocomplete is set to true, Discord will send autocomplete interactions.Thus, we add
onCommandAutoCompleteInteractionEvent(CommandAutoCompleteInteractionEvent)
to the SlashCommandThe command has to filter for which option the event is, our command-system will filter for which command.
To-do
getType
,getVisibility
andgetData
to BotCommand a0fb71eonAutoComplete
to SlashCommand and SlashCommandAdapter a0fb71eFuture:
onModal
methodThe text was updated successfully, but these errors were encountered: