Skip to content

New slash-commands are unintentionally Guild-installable #10183

Open
@MysticMia

Description

@MysticMia

Summary

Syncing a (new?) command allows users to use it outside the bot's server without being user- or guild-installable.

Reproduction Steps

I'm not entirely sure what causes this to occur, but it has happened to me on two occasions already.
I have a bot with 1 user-installable command in total:

class Foo(commands.Cog):
    @app_commands.allowed_installs(guilds=True, users=True)
    @app_commands.allowed_contexts(guilds=True, private_channels=True, dms=True)
    async def foo(self, itx: discord.Interaction):
        ...

Sometimes, I add new commands. For example:

class ChangeChannel(commands.Cog):
    @app_commands.command(name="changechannel")
    @module_enabled_check(ModuleKeys.change_channel)
    async def changechannel(self, itx):
        ...

The above command was available in guilds that the bot was not a member of. The command does not show up in DMs.

Minimal Reproducible Code

Expected Results

I expected not to see new commands to be usable in servers that don't have the bot without explicitly setting allowed_installs(guilds=True) for the command.

Things I tried:
I deleted the command code, and updated the command tree. The command disappeared from the command list (as expected).
I then undid the deletion, and updated the command tree again. The command returned in the command list, and was still usable in other guilds.

Actual Results

When I create new slash commands, they sometimes become available for users. Oddly enough, it doesn't happen to every new command. Perhaps only the newest one of the bunch.

I haven't seen more than 1 unintended command being added to the guild list, because I have manually removed them both of the times it happened to me:
Adding @app_commands.allowed_installs(guilds=True) to the command, syncing, then removing the decorator, and restarting the discord client, fixes the issue.

Intents

intents = discord.Intents.default(); intents.members = True; intents.messages = True

System Information

  • Python v3.12.10-final
  • discord.py v2.5.2-final
  • aiohttp v3.9.5
  • system info: Windows 11 10.0.26100

The slash commands appear in other servers on (at least) Windows 11 and Android

Checklist

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

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions