[Feature Request] Allow passing on **kwargs to red.menu to be used in custom button actions. #2362
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot#2362
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Feature request
Select the type of feature you are requesting:
Describe your requested feature
In addition to just browsing between different page in the page list, it should be possible to (properly) use custom-made actions on a Red Menu. For this, one should be able to pass on **kwargs to the Red Menu, so that they can be caught and used by the custom button actions. Especially since Red is meant to be modular, I think adding this would be handy. Also because this makes the menu usable in a lot more scenarios.
Think about...
.csvif they click on a certain emoji, like ⏬.Technically this can already be achieved in a "hacky" way, namely by making an asynchronous function inside a command, making a custom embed control dict, and calling that internal command in one of the values. However, it forces someone to rewrite this function inside every command that they would like to have it for, and that for every single function. Also, it would either force people to (temporarily) store values in class attributes, or to call a
nonlocalinside the nested function to use certain variables.Being able to pass on
**kwargsand catch those inside the custom functions would be much more convenient (and cleaner) than the above.Hi, I see where you're coming from when you speak to your complaints about the menu system and how it can be customised in its current form. I've been thinking about creating a new system (to prevent breaking the old one) which involves a class-based approach with decorators to assign actions to emojis. Creating a custom menu would simply involve subclassing the base menu, or an existing custom menu, and then adding methods. I would also aim to include some common custom menus in the core utils module. Here might be an example, just brainstorming:
This way a menu can be defined in a declarative style, outside the scope of wherever you're sending it, and it's all nicely grouped together in the code, so I think it's an improvement stylistically as well.
Making a new class system like that sounds like an interesting idea.
One potential issue I foresee (if I understood you right, correct me if I'm wrong), is that by using another custom menu as basis, you will be bound to all the methods that the author in question added to their method.
In other words, if another user made a class with a tutorial action (❓), and a "go back" action (↩️), you will not be able to use their ↩️ action without adding their ❓ action too. That is, without recycling their code.
Similarly, cherry-picking decorators between different custom menu classes should become possible as well.
Maybe adding a bare-bones menu as a base option to the system, which only provides the menu logic without also supplying any actions, could solve such problems.
I do like the idea though, and I'd definitely make use of such a class if it would be added as a util to Red. I would be curious to see how it develops, and how others would like to use such a class.
I know that this is just a brainstorm, but do you have any ideas on how such an implementation would look like inside commands? For example, do you expect the embed call to still be a one-liner like it is now?
As of #2720 you can properly use functools.partial with menus. This should be included in 3.1.2
I'm leaving this open for now given the direction this took about adding an additional class based menu for use.
Offene Diskussion bzw. Feature-Wunsch mit geringem Nutzen im Verhältnis zum Aufwand (oder Nischenfall), der seit Langem ohne Ergebnis offen ist. Ich schließe das Issue; bei konkretem Bedarf kann es gern wieder geöffnet werden.
Generated by Claude Code