question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support context menus

See original GitHub issue

Summary

Be able to create context menus & listen for them properly

What is the feature request for?

The core library

The Problem

Having a way for users to create and listen for the new context menus natively.

The Ideal Solution

The context menus are somewhat similiar to buttons, and should be created in the same way, if possible.

  • Like buttons, context menus are very easily created, even more so than buttons. You can create a simple one with a 2 line POST request. The decorator interface like we have for discord.ui.button could work pretty well for this. The decorator would decorate the callback, and said callback is called when the specific interaction is recieved.
  • Buttons also allow for subclassing, which could also be done here. Subclass a ContextMenu class or something of that sort. The subclass will also have an overrideable callback class, just like the button class.

The Current Solution

I’ve managed to get it to work by doing the following:

  • Manually registering the command either using aiohttp, or some other way.
  • Using on_interaction to listen for incoming interactions, and getting interaction data using interaction.data as the given attributes for interactions won’t always work since the layout of the returned json from Discord is slightly different.

Additional Context

I believe this shouldn’t be too hard to implement, consider it is very similar to buttons, and those were added relatively quickly to the library.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:16
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Nyghlcommented, Mar 6, 2022

Well well, it’s already in the D.py 2.0 atm 😅

0reactions
Infiniticitycommented, Mar 15, 2022

It has already been implemented @itttgg

Read more comments on GitHub >

github_iconTop Results From Across the Web

"contextmenu" | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
chrome.contextMenus - Chrome Developers
Use the chrome.contextMenus API to add items to Google Chrome's context menu. You can choose what types of objects your context menu additions...
Read more >
Context menu items - Mozilla - MDN Web Docs
The full list of supported contexts is available at menus.ContextType and includes contexts outside of a web page, such as bookmark items in...
Read more >
Context menus - Components - Human Interface Guidelines
A context menu provides access to functionality that's directly related to an onscreen item, without cluttering the interface.
Read more >
Support legacy context menus for packaged apps
The context menu is one of the most popular and useful shell extensions. If you are already in File Explorer or on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found