Cog-Creators / Cog-Creators/Red-DiscordBot

[Feature Request] Allow passing on **kwargs to red.menu to be used in custom button actions.

Open
#2,362 3 comments 0 reactions 0 assignees View on GitHub
Category: Core - API - Utils Package Status: Needs Discussion Type: Enhancement
Dominant language
Python
Stars
5.7k
Forks
2.5k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

# Feature request

#### Select the type of feature you are requesting:

- [ ] Cog
- [ ] Command
- [X] API functionality

#### 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...
- Output the embed's contents to a file. This is actually what I would personally use this for. In some of my commands, I make an embed of a certain list, which due its size is split across pages. However, in addition to just browsing it, I want to make people able to download that list in `.csv` if they click on a certain emoji, like ⏬.
- Selection of a specific embed in the page list by using number emojis 1️⃣ 2️⃣ 3️⃣ 4️⃣ . An example usage for this would be a FAQ command, where one could see some frequently asked questions on the first embed along with a number, and the answer to the pages on the numbers
- Nested selection menus. If you click on an emoji in a certain embed, it returns a new series of embeds to do things with. An example would be a command that would go through recently created cases in a moderation log, and by clicking e.g. a 👤 button, you switch to a view where you only see the cases of that specific user.

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 `nonlocal` inside the nested function to use certain variables.

Being able to pass on `**kwargs` and catch those inside the custom functions would be much more convenient (and cleaner) than the above.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.