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

Allow guild & global slash commands with same name #143

Open
priyanuj-gogoi opened this issue Oct 25, 2023 · 1 comment
Open

Allow guild & global slash commands with same name #143

priyanuj-gogoi opened this issue Oct 25, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@priyanuj-gogoi
Copy link

priyanuj-gogoi commented Oct 25, 2023

Describe the bug

Throws CommandRegistrationError when trying to create a guild & a global slash command having same name.

To Reproduce

  1. Create a guild & a global slash command with same name.
    final globalSlash = ChatCommand(
      'slash', // Same name as "guildSlash"
      'placeholder',
      id(...)
    );
    
    final guildSlash = ChatCommand(
      'slash', // Same name as "globalSlash"
      'placeholder',
      singleChecks: [GuildCheck.id(...)],
      id(...)
    );
  2. Add them in your client's CommandsPlugin().
    final commands = CommandsPlugin(...)
      ..addCommand(globalSlash)
      ..addCommand(guildSlash);
  3. Run the bot & you'll get this error.
    Command with name "slash" already exists
    

Expected behavior

Perform the below curl command & then, check your bot slash commands. You'll see 2 slash commands having same name slash. Here, one is guild & the other one is global. This is what we want i.e to create guild & global slash commands with same name in nyxx_commands.

curl 'https://discord.com/api/v10/applications/BOT_ID/{guilds/GUILD_ID/,}commands' \
  -H 'Content-Type: application/json' -H 'Authorization: Bot TOKEN' \
  -d '{"name": "slash", "description": "placeholder"}'

Important

When performing the above request, do replace BOT_ID, GUILD_ID & TOKEN with actual values.

Desktop:

  • OS: Android
  • Dart version: 3.1.5
  • Nyxx version: 6.0.0 (GitHub dev branch)
  • nyxx_commands version: 6.0.0 (GitHub main branch)
@priyanuj-gogoi priyanuj-gogoi added the bug Something isn't working label Oct 25, 2023
@abitofevrything
Copy link
Member

Just had a look at this, and it's more complicated that it might first seem.

These are the two big issues:

  • A command isn't necessarily bound to a single guild. It can be bound to multiple (GuildCheck.anyId([1, 2, 3])), which can then lead to overlaps with other commands: command A with guilds 1, 2 and 3 conflicts with command B with guild 2. This complicates the detection algorithm quite a bit.
  • When using text commands, it's unclear whether !test in guild 1 should run the global !test or the guild !test.

I think the best solution would be to disallow this. It is supported by Discord, but I don't think it's great for UX and it's ambiguous how nyxx_commands should handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants