# Context Menu Commands

{% hint style="danger" %}
This guide has been moved to <https://namantech.me/pycord>. Please visit the new guide instead, since this one might be outdated.

The new guide looks better, has better explanations, and is way better overall.
{% endhint %}

## What are User Commands and Message Commands?

![Preview of User commands and Message commands - click to expand](/files/-MjSYM78m_x2LUvCexhn)

When you right click a message, you may see a option called "Apps". Hover over it and you can see commands a bot can run with that message. These are called message commands.

When you right click a message in the user list, you can once again see an option called "Apps". Hover over it and you can see commands a bot can run with that message. These are called user commands.

## How to create User Commands

Docs: <https://pycord.readthedocs.io/en/master/api.html#discord.Bot.user_command>

Very Simple!

```python
@bot.user_command(guild_ids=[...])  # create a user command for the supplied guilds
async def mention(ctx, member: discord.Member):  # user commands return the member
    await ctx.respond(f"{ctx.author.name} just mentioned {member.mention}!")
```

If you want to make the command global, remove guild\_ids. Note that global application commands can take up to an hour to register.

## How to create Message Commands

Docs: <https://pycord.readthedocs.io/en/master/api.html#discord.Bot.message_command>

Similar to user commands,

```python
@bot.message_command(name="Show ID")  # creates a global message command. use guild_ids=[] to create guild-specific commands.
async def show_id(ctx, message: discord.Message):  # message commands return the message
    await ctx.respond(f"{ctx.author.name}, here's the message id: {message.id}!")
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brucecodes.gitbook.io/pycord/interactions/context-menu-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
