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
fix(ApplicationCommands): allow managing commands for uncached guilds #5729
Merged
+249
−161
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to make a note here about passing
undefined
. I don't love this pattern, but as Monbrey said in the discord, I don't love having to pass{ command: '123456789012345678' }
either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the guild ID is the required one, put it first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when called from a GuildApplicationCommandManager its not required, although I suppose I could just use super in that class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I tried to do this, and it simply doesn't work as wanted.
Putting guildID as the first parameter means implementing
fetchPermissions
andsetPermissions
inGuildApplicationCommandManager
which we can do in js, but because guildID is not a parameter there, typescript really doesn't like it, suggesting this is a bad pattern in general.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any other suggestions for this (or a suggestion for how to make typescript happy with different method signatures 😆 )?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override
still doesn't let you remove / repurpose parameters in the signature though from what I can tell.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not nice, but you could allow either just a command resolvable, or an object with it and the guild.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is precedent for this elsewhere in the library actulaly, so it works, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A CommandResolvable can't be accepted as the only parameter because this.resolve (when providing an id) can't resolve guild application commands, which are required when not passing guildID so that we can get command.guild.id instead. And typescript will complain if I try to make it ApplicationCommand | { guildID: Snowflake | command?: ApplciationCommandResolvable } and then override that to ApplicationCommandResolvable in the subclass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excuse a stranger, but if I've understood correctly the goal here is to somehow put the
guildId
parameter to thefetchPermissions
method (possibly to more methods) and at the same time satisfy the TypeScript compiler in theGuildApplicationCommandManager
, right?So I've created a small "demo" of my approach on the TS Playground here and with this solution you can pass all combinations: no params, only command and guild id + previous combinations. I've based it on the @SpaceEEC suggestion to put either a resolvable or an object with
guildId
and the command.(I know that I wrote it entirely in TypeScript, and it may or may not be 100% applicable but maybe at the very least it will notch you guys in the right direction, hope I've helped)