Skip to content

Dynamic views for command help embeds#1939

Merged
mbaruh merged 5 commits into
mainfrom
dynamic-views
Dec 1, 2021
Merged

Dynamic views for command help embeds#1939
mbaruh merged 5 commits into
mainfrom
dynamic-views

Conversation

@mbaruh
Copy link
Copy Markdown
Member

@mbaruh mbaruh commented Nov 5, 2021

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 type on 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

@mbaruh mbaruh added a: frontend Related to output and formatting a: information Related to information commands: (doc, help, information, reddit, site, tags) p: 3 - low Low Priority s: needs review Author is waiting for someone to review and approve t: feature New feature or request labels Nov 5, 2021
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.
Comment thread bot/exts/backend/error_handler.py
Comment thread bot/exts/backend/error_handler.py
Comment thread bot/exts/info/help.py
Comment thread bot/exts/info/help.py
Comment thread bot/exts/info/help.py Outdated
Comment thread bot/exts/info/help.py Outdated
Copy link
Copy Markdown
Contributor

@jchristgit jchristgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very very very cool use of buttons. When the open discussions are addressed, this looks good to merge from me 👍

Comment thread bot/exts/info/help.py
Comment thread bot/exts/info/help.py Outdated
@mbaruh mbaruh requested a review from Bluenix2 December 1, 2021 19:27
Copy link
Copy Markdown
Contributor

@Bluenix2 Bluenix2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely, thanks!

@mbaruh mbaruh enabled auto-merge (squash) December 1, 2021 22:43
@mbaruh mbaruh merged commit 8408fb5 into main Dec 1, 2021
@mbaruh mbaruh deleted the dynamic-views branch December 1, 2021 22:44
@Xithrius Xithrius removed the s: needs review Author is waiting for someone to review and approve label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: frontend Related to output and formatting a: information Related to information commands: (doc, help, information, reddit, site, tags) p: 3 - low Low Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants