Skip to content

Commit 792c958

Browse files
authored
Add context menu example to README.md
This commit adds an example of how to make a context menu.
1 parent 89d99ab commit 792c958

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,26 @@ await ctx.send(components=[action_row])
143143
### Advanced
144144
For more advanced use, please refer to our official documentation on [selects here.](https://discord-py-slash-command.readthedocs.io/en/latest/components.html#what-about-selects-dropdowns)
145145

146+
## Context Menus
147+
This basic example shows how to add a message context menu.
148+
149+
```py
150+
from discord_slash.context import MenuContext
151+
from discord_slash.model import ContextMenuType
152+
153+
@slash.context_menu(target=ContextMenuType.MESSAGE,
154+
name="commandname",
155+
guild_ids=[789032594456576001])
156+
async def commandname(ctx: MenuContext):
157+
await ctx.send(
158+
content=f"Responded! The content of the message targeted: {ctx.target_message.content}",
159+
hidden=True
160+
)
161+
```
162+
163+
### Advanced
164+
For more advanced use, please refer to our official documentation on [context menus here.](https://discord-py-slash-command.readthedocs.io/en/latest/gettingstarted.html#adding-context-menus)
165+
146166
--------
147167

148168
- The discord-interactions library is based off of API gateway events. If you are looking for a library webserver-based, please consider:

0 commit comments

Comments
 (0)