Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default installation/interaction contexts do not match documentation #7108

Open
thegamecracks opened this issue Aug 27, 2024 · 0 comments
Open
Labels
bug slash commands synced Synced to internal tracker

Comments

@thegamecracks
Copy link

thegamecracks commented Aug 27, 2024

Description

According to the Application Command Structure reference, the default installation context is based on the application's "configured contexts", presumably meaning the contexts configured in the "Installation" tab on the application's page:

integration_types?
Installation contexts where the command is available, only for globally-scoped commands.
Defaults to your app's configured contexts

And the default for interaction contexts is all contexts:

contexts?
Interaction context(s) where the command can be used, only for globally-scoped commands.
By default, all interaction context types included for new commands.

Which is also reflected in the Interaction Contexts section:

By default, contexts includes all interaction context types.

However, when testing this with "integration_types": null and "contexts": null on a newly created command, it appears that the default contexts do not include the USER_INSTALL context or the PRIVATE_CHANNEL interaction context.

Steps to Reproduce

I have tested this using discord.py 2.4.0. Payloads described here are as reported by the library. Notably, discord.py does not support excluding the contexts and integration_types keys, only nullifying them. I have not tested whether the behaviour changes with omitted keys.

  1. Set the application's supported installation contexts to Guild Install and User Install.

  2. Authorize the application with a User Install.

  3. Define a command without any contexts set:

    import json
    
    import discord
    from discord import app_commands
    from discord.ext import commands
    
    bot = commands.Bot(command_prefix=commands.when_mentioned, intents=discord.Intents.default())
    
    @bot.tree.command()
    # @app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
    # @app_commands.allowed_installs(guilds=True, users=True)
    async def greet(interaction: discord.Interaction, user: discord.User):
        """Ask me to greet someone!"""
        await interaction.response.send_message(f"Hello, {user.mention}!")
    
    print(json.dumps(greet.to_dict(bot.tree), indent=4))
  4. Create the command on Discord (in discord.py's case, using Bulk Overwrite Global Commands via bot.tree.sync()):

    @bot.event
    async def setup_hook():
        await bot.tree.sync()
     
    bot.run("TOKEN")
  5. Reload the client (Ctrl+R).

  6. Check where the command can be used:

    • Guilds where the application has a bot in
    • Guilds where the application does not have a bot in
    • The Direct Messages of the bot
    • The (Group) DMs for other users
  7. Uncomment just the @allowed_contexts() decorator and repeat steps 4-6.

  8. Comment the @allowed_contexts() and uncomment just the @allowed_installs() decorator, then repeat steps 4-6.

  9. Uncomment both decorators and repeat steps 4-6.

The command payloads printed in steps 4, 7, 8, and 9 are as follows:

No contexts explicitly defined
{
    "name": "greet",
    "description": "Ask me to greet someone!",
    "type": 1,
    "options": [
        {
            "type": 6,
            "name": "user",
            "description": "\u2026",
            "required": true
        }
    ],
    "nsfw": false,
    "dm_permission": true,
    "default_member_permissions": null,
    "contexts": null,
    "integration_types": null
}
Defined interaction contexts
{
    "name": "greet",
    "description": "Ask me to greet someone!",
    "type": 1,
    "options": [
        {
            "type": 6,
            "name": "user",
            "description": "\u2026",
            "required": true
        }
    ],
    "nsfw": false,
    "dm_permission": true,
    "default_member_permissions": null,
    "contexts": [
        0,
        1,
        2
    ],
    "integration_types": null
}
Defined installation contexts
{
    "name": "greet",
    "description": "Ask me to greet someone!",
    "type": 1,
    "options": [
        {
            "type": 6,
            "name": "user",
            "description": "\u2026",
            "required": true
        }
    ],
    "nsfw": false,
    "dm_permission": true,
    "default_member_permissions": null,
    "contexts": null,
    "integration_types": [
        0,
        1
    ]
}
Defined installation and interaction contexts
{
    "name": "greet",
    "description": "Ask me to greet someone!",
    "type": 1,
    "options": [
        {
            "type": 6,
            "name": "user",
            "description": "\u2026",
            "required": true
        }
    ],
    "nsfw": false,
    "dm_permission": true,
    "default_member_permissions": null,
    "contexts": [
        0,
        1,
        2
    ],
    "integration_types": [
        0,
        1
    ]
}

Expected Behavior

In steps 4, 7, 8, and 9, I would expect the command to be usable in all interaction contexts, since both Guild and User installation contexts were enabled in the Developer Portal and according to the documentation, the default installation and interaction contexts would all be allowed by default.

Current Behavior

In step 4 (default installation and interaction contexts), the command could not be accessed anywhere unless I shared a guild with the bot, then it was allowed for that guild and the bot's DMs.
In step 7 (defined interaction contexts only), it was the same as above.
In step 8 (defined installation contexts only), the command could be used in any guild and the bot's DMs (including with no mutual guilds), but the command was not available in other DM channels.
In step 9 (defined installation and interaction contexts), the command could be used in all guilds and DM channels.

Screenshots/Videos

No response

Client and System Information

Client: canary 322306 (15152ef) Host 1.0.437 x64 (51549) Build Override: N/A Windows 11 64-bit (10.0.22631)
Library: discord.py 2.4.0

@Rodentman87 Rodentman87 added the synced Synced to internal tracker label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug slash commands synced Synced to internal tracker
Projects
None yet
Development

No branches or pull requests

2 participants