Repository: Rapptz/discord.py

Issue:
`@app_commands.guilds` doesn't work with `@app_commands.context_menu`
### Summary

The `app_commands.guilds` decorator doesn't work with the `app_commands.context_menu` decorator. The `app_commands.guilds` decorator is ignored and the context menu application command is added as a global command. This also applies to the `app_commands.CommandTree.context_menu` decorator.

### Reproduction Steps

- Use the `app_commands.guilds` decorator with the `app_commands.context_menu` (or `app_commands.CommandTree.context_menu`) decorator.
- Attempt to sync the context menu application command as a guild command
- Notice the command was not synced
- Attempt to sync the same command as a global command
- Notice the command was successfully synced

With the following code this can be accomplished by the following steps:
- Run the bot
- Use the `!sync_guild` command
- Check the console (and/or check for the context menu application command in the guild)
- Use the `!sync_global` command
- Check the console (and/or check for the context menu application command in any guild)

### Minimal Reproducible Code

```python
import discord
from discord import app_commands
from discord.ext import commands


GUILD_ID = 336642139381301249  # Replace as needed
TOKEN = "Token Here"


intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)


@app_commands.context_menu()
@app_commands.guilds(GUILD_ID)
async def test(interaction, message: discord.Message):
    await interaction.response.send_message("Test response message")

bot.tree.add_command(test)

# This results in the same behavior:
# @bot.tree.context_menu()
# @app_commands.guilds(GUILD_ID)
# async def test(interaction, message: discord.Message):
#     await interaction.response.send_message("Test response message")

# However, this works as expected:
# @bot.tree.context_menu(guild = discord.Object(GUILD_ID))
# async def test(interaction, message: discord.Message):
#     await interaction.response.send_message("Test response message")


@bot.command()
async def sync_guild(ctx):
    synced = await ctx.bot.tree.sync(guild = discord.Object(GUILD_ID))
    print(len(synced))


@bot.command()
async def sync_global(ctx):
    synced = await ctx.bot.tree.sync()
    print(len(synced))


bot.run(TOKEN)
```


### Expected Results

The `!sync_guild` command should print `1` in the console when executed (and the context menu application command should be available in the guild) and the `!sync_global` command should print `0` in the console when executed.

### Actual Results

The `!sync_guild` command prints `0` in the console when executed (and the context menu application command is not available in the guild) and the `!sync_global` command prints `1` in the console when executed (and the context menu application command is then available in all guilds).

### Intents

Default with message content (to sync the command)

### System Information

- Python v3.9.10-final
- discord.py v2.0.0-alpha
    - discord.py pkg_resources: v2.0.0a4106+g242d3f7
- aiohttp v3.8.1
- system info: Windows 10 10.0.19043

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

The cause of this seems to be that the `app_commands.guild` decorator assigns the guild IDs to the `__discord_app_commands_default_guilds__ ` attribute of the callback:
https://github.com/Rapptz/discord.py/blob/4fb1309e2ae103820e980697e90f4345597d4f3e/discord/app_commands/commands.py#L1639-L1655 which isn't used for `ContextMenu._guild_ids` in `ContextMenu.__init__`:
https://github.com/Rapptz/discord.py/blob/4fb1309e2ae103820e980697e90f4345597d4f3e/discord/app_commands/commands.py#L876 whereas it *is* used for `Command._guild_ids` in `Command.__init__`:
https://github.com/Rapptz/discord.py/blob/4fb1309e2ae103820e980697e90f4345597d4f3e/discord/app_commands/commands.py#L494-L496


Discussion:

Resolving patch:
diff --git a/discord/app_commands/commands.py b/discord/app_commands/commands.py
--- a/discord/app_commands/commands.py
+++ b/discord/app_commands/commands.py
@@ -873,7 +873,7 @@ def __init__(
         self._param_name = param
         self._annotation = annotation
         self.module: Optional[str] = callback.__module__
-        self._guild_ids = guild_ids
+        self._guild_ids = guild_ids or getattr(callback, '__discord_app_commands_default_guilds__', None)
         self.on_error: Optional[UnboundError] = None
         self.checks: List[Check] = getattr(callback, '__discord_app_commands_checks__', [])
 


Test patch: