Skip to content

Commit 59d57e0

Browse files
authored
Merge pull request #297 from Toricane/patch-1
Context menu example to README + indentation 4 spaces
2 parents 89d99ab + 5d6c9cf commit 59d57e0

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
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:

docs/gettingstarted.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ Unlike ``manage_commands`` and ``manage_components``, you will have to use a dec
367367
name="commandname",
368368
guild_ids=[789032594456576001])
369369
async def commandname(ctx: MenuContext):
370-
await ctx.send(
371-
content=f"Responded! The content of the message targeted: {ctx.target_message.content}",
372-
hidden=True
373-
)
370+
await ctx.send(
371+
content=f"Responded! The content of the message targeted: {ctx.target_message.content}",
372+
hidden=True
373+
)
374374
375375
The ``@slash.context_menu`` decorator takes in the context type as given (to either appear when you right-click on a user or when you right-click on a message) as well
376376
as the name of the command, and any guild IDs if given if you would like to make it applicable to only a guild. **We only accept connected names** for the time being,

0 commit comments

Comments
 (0)