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

Subcommands are registered to guilds where there are not allowed #88

Closed
mike1808 opened this issue Feb 6, 2021 · 8 comments
Closed

Comments

@mike1808
Copy link
Contributor

mike1808 commented Feb 6, 2021

I've noticed that when I use guild_ids on a subcommand for a command which is shared between multiple guilds, that subcommand is registered to all guilds where one of its subcommands is allowed.

Steps

  1. Register a subcommand s1 for command c for Guild A:
       @slash.subcommand(
          base="c",
          name="s1",
          guilds_ids=[GUILD_A_ID],
       )
       def _handle(ctx):
          # ....
  2. Register a subcommand s2 for command c for Guild B:
       @slash.subcommand(
          base="c",
          name="s2",
          guilds_ids=[GUILD_A_ID],
       )
       def _handle(ctx):
          # ....

Expected behavior

Guild A has /c s1 command only and Guild B has /c s2 command only.

Actual behavior

Guild A has /c s1 and /c s2 but only can use /c s1, and Guild B has /c s1 and /c s2 but only can use /c s2.

@mike1808
Copy link
Contributor Author

mike1808 commented Feb 6, 2021

I need to fix this ASAP. And I think, I can do it by fixing Client#to_dict so that it makes copies of the commands with appropriate subcommand for each guild.

@eunwoo1104
Copy link
Contributor

eunwoo1104 commented Feb 6, 2021

This happens due to merging subcommands to one command add body when requesting to API. If possible, fixing this will require complete redesign of auto-registering. Unfortunately I'm not sure if it will work since subcommands is actually one of the option type of a command. Nevermind, I just realized this was about seperate guild command.

@mike1808
Copy link
Contributor Author

mike1808 commented Feb 6, 2021

@eunwoo1104 after few hours of digging I realized that this really needs a complete redesign of the current merging. There are many corner cases, for example:

  1. One subcommand is a guild command and another is not.
  2. One subcommand in subgroup is a guild command and another is not.

So anytime there is guild subcommand/subgroup and global subcommand/subgroup you have to split the command into several: a command with a global subcommand + guild specific sub command and repeat that for allow guild commands.

It increases the number of requests and memory usage with the current implementation exponentially.

Also, it's unclear what Discord will do with guild commands and permissions model in general.

@mike1808
Copy link
Contributor Author

mike1808 commented Feb 6, 2021

I still prefer this issue to stay open just for other members to be aware of it. It maybe makes sense to add a warning to not use different guild ids for subcommands.

@AnotherCat
Copy link
Contributor

AnotherCat commented Feb 6, 2021

I've been thinking about this and there's even more problems when you take into consideration that commands in different guilds could also have different descriptions, options, etc. This is not going to be a simple fix, possibly requiring a rewrite of how commands are created by the user.
I wouldn't worry about this increasing the amount of requests made though, it already makes at least one request per guild, and i don't think this would actually increase the amount at all.

@eunwoo1104
Copy link
Contributor

This should be fixed and will be included at next release.

@diogorocha18
Copy link

Is there already a solution for permissions to register subcommands?

@i0bs
Copy link
Contributor

i0bs commented Dec 3, 2023

Is there already a solution for permissions to register subcommands?

Lack of permissions for subcommands are an API limitation, we have no control over that. I suggest hard coding conditionals in your subcommand declarations for handling this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants