-
-
Notifications
You must be signed in to change notification settings - Fork 4k
fix(guildChannel): better channel editing #11072
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
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 don't know whether I like the setters in the object, but I suppose it works for this use-case here.
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.
Aside from @SpaceEEC's comment, the rest looks good to me
); | ||
} | ||
|
||
if (snakeCaseBody.default_reaction_emoji?.id) { |
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 reason for checking id
specifically here? Passing name
wouldn't work this way.
if (snakeCaseBody.default_reaction_emoji?.id) { | |
if (snakeCaseBody.default_reaction_emoji) { |
If there is a reason for the id
check then we must also check for name
.
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.
sorry, I could be completely off base here since I haven't read everything/the types, but wouldn't your diff cause trouble if {}
was passed?
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.
good callout, I forgot emoji's can be name only. I'll add || name to it.
and @didinele no, {} would pass through in the body. Though speaking of types, I didn't add a | RESTPatchAPIChannelJSONBody to the types for this method, but I theoretically could at this point....should I?
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.
Is that the direction we foresee the discord.js library going in (i.e., allowing passing raw payloads everywhere appropriate)?
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 think we should allow it (to better support new features that don't have real support yet), but I don't know that we should actually document it that way. It might be something we mention somewhere once, but I don't think we should specifically call it out except maybe types...my opinion will probably change once the lib is actually ts native and the underlying support for raw data is way better.
|
||
if (snakeCaseBody.available_tags) { | ||
snakeCaseBody.available_tags = snakeCaseBody.available_tags.map(availableTag => | ||
'emoji' in availableTag ? transformGuildForumTag(availableTag) : availableTag, |
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.
While this is not problematic currently, it could potentially be if discord adds a property to available tags that has 2 words. Since transformGuildForumTag
expects a discord.js object (aka camel cased) and we're passing the snake cased version here.
Might be worth doing something along the lines of options.availableTags?.map(x => toSnakeCase(blah...)) ?? options.available_tags
instead to prevent future headaches.
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.
emoji is only a property if it's a djs object, we only call transformGuildForumTag if the caller is passing non-api data (it's emoji_id and emoji_name to discord)
if (snakeCaseBody.flags) { | ||
snakeCaseBody.flags = ChannelFlagsBitField.resolve(snakeCaseBody.flags); | ||
} |
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.
Ditto. I don't know if this one would cause issues but I also wouldn't want to find out.
if (snakeCaseBody.flags) { | |
snakeCaseBody.flags = ChannelFlagsBitField.resolve(snakeCaseBody.flags); | |
} | |
if (options.flags) { | |
snakeCaseBody.flags = ChannelFlagsBitField.resolve(options.flags); | |
} |
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.
the only valid value to pass as raw api data is properly resolved by the resolve function, I could realistically do either, want opinions
Please describe the changes this PR makes and why it should be merged:
Changes how channel edits are handled to allow sublimits to be handled properly within /rest.
Byproduct is channel editing is much more robust, allows raw api data, and can edit uncached channels now.
Supercedes #11000
Status and versioning classification: