disagreement/docs/context_menus.md
Slipstreamm e965a675c1
Some checks failed
Deploy MkDocs / deploy (push) Has been cancelled
refactor(api): Re-export common symbols from top-level package
Makes commonly used classes, functions, and decorators from `disagreement.ext` and `disagreement.ui` submodules directly accessible under the `disagreement` namespace.

This change simplifies import statements for users, leading to cleaner and more concise code. Documentation and examples have been updated to reflect these new, simplified import paths.
2025-06-14 18:57:12 -06:00

21 lines
713 B
Markdown

# Context Menu Commands
`disagreement` supports Discord's user and message context menu commands. Use the
`user_command` and `message_command` decorators to define them.
```python
from disagreement import User, Message
from disagreement import User, Message, user_command, message_command, AppCommandContext
@user_command(name="User Info")
async def user_info(ctx: AppCommandContext, user: User) -> None:
await ctx.send(f"User: {user.username}#{user.discriminator}")
@message_command(name="Quote")
async def quote(ctx: AppCommandContext, message: Message) -> None:
await ctx.send(message.content)
```
Add the commands to your client's handler and run `sync_commands()` to register
them with Discord.