Dynamic views for command help embeds#1939
Merged
Merged
Conversation
Adds views for commands to navigate groups. For subcommands, a button is added to show the parent's help embed. For groups, buttons are added for each subcommand to show their help embeds. The views are not generated when help is invoked in the context of an error. The code has gone through several iterations of design, and this is what I arrived at. Because conversion of callbacks to buttons is done in __subclass_init__ of the view baseclass, I had to create Button subclasses. Because the normalization of button positions is in the view init and is obfuscated, I had to meddle with discord.py internals a bit in GroupView to make it work.
Bluenix2
reviewed
Nov 8, 2021
jchristgit
approved these changes
Nov 16, 2021
Contributor
jchristgit
left a comment
There was a problem hiding this comment.
This is a very very very cool use of buttons. When the open discussions are addressed, this looks good to merge from me 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds views for commands to navigate groups.
For subcommands, a button is added to show the parent's help embed.
For groups, buttons are added for each subcommand to show their help embeds.
The views are not generated when help is invoked in the context of an error.
The code has gone through several iterations of design, and this is what I arrived at.
Because conversion of callbacks to buttons is done in subclass_init of the view baseclass, I had to create Button subclasses.
Because the normalization of button positions is in the view init and is obfuscated, I had to meddle with discord.py internals a bit in GroupView to make it work. The only way I can think of around all that is to instantiate an instance of
typeon the fly, but that doesn't sound very reader-friendly.I also don't really like the help formatting functions returning the views, so if anyone has a better idea let me know. At least in the case of a group, I had to do get the view from there because I needed the filtered subcommands. Since the filtering is asynchronous I couldn't do it in the view's init.
2021-11-04.23-08-02.mp4