Skip to content

Separate application commands with same name+type but in different guilds don't work #260

@shiftinv

Description

@shiftinv

Summary

see title

Reproduction Steps

Create two commands with the same type (e.g. both slash) and same name, but with different guild_ids

Minimal Reproducible Code

@bot.slash_command(name="test", guild_ids=[id1])
async def test1(inter: disnake.GuildCommandInteraction):
    pass

@bot.slash_command(name="test", guild_ids=[id2])
async def test2(inter: disnake.GuildCommandInteraction):
    pass

Expected Results

One command gets registered in one guild, while the other one gets registered in the other guild

Actual Results

  ...
  File "...\disnake\test_bot\main.py", line 108, in <module>
    async def test2(inter: disnake.GuildCommandInteraction):
  File "...\disnake\ext\commands\interaction_bot_base.py", line 500, in decorator
    self.add_slash_command(result)
  File "...\disnake\ext\commands\interaction_bot_base.py", line 241, in add_slash_command
    raise CommandRegistrationError(slash_command.name)
disnake.ext.commands.errors.CommandRegistrationError: The command test is already an existing command or alias.

Intents

all

System Information

latest / 2025dfb

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

This is technically also an issue for prefix commands, although those don't really have a concept of guild-specific commands. The only thing that would emulate something like that is a @commands.check(lambda ctx: ctx.guild.id == ...).

The primary reason for all this is that the InteractionBotBase.all_slash_commands dict uses the command names as keys; fixing this would likely need a pretty large refactor, and I'm unsure how methods like InteractionBotBase.get_slash_command would work.

thanks for the hint, alento

Metadata

Metadata

Labels

bugSomething isn't workings: in progressIssue/PR is being worked on

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions