Skip to content

Conversation

ckohen
Copy link
Member

@ckohen ckohen commented Sep 1, 2025

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:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Copy link

vercel bot commented Sep 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
discord-js Ignored Ignored Preview Sep 12, 2025 9:40am
discord-js-guide Ignored Ignored Preview Sep 12, 2025 9:40am

Copy link
Member

@SpaceEEC SpaceEEC left a 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.

@Jiralite Jiralite added this to the discord.js 15.0.0 milestone Sep 2, 2025
Copy link
Member

@kyranet kyranet left a 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

@github-project-automation github-project-automation bot moved this from Todo to Review Approved in discord.js Sep 4, 2025
@Jiralite Jiralite self-requested a review September 5, 2025 19:34
);
}

if (snakeCaseBody.default_reaction_emoji?.id) {
Copy link
Member

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.

Suggested change
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.

Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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)?

Copy link
Member Author

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,
Copy link
Member

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.

Copy link
Member Author

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)

Comment on lines +378 to +380
if (snakeCaseBody.flags) {
snakeCaseBody.flags = ChannelFlagsBitField.resolve(snakeCaseBody.flags);
}
Copy link
Member

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.

Suggested change
if (snakeCaseBody.flags) {
snakeCaseBody.flags = ChannelFlagsBitField.resolve(snakeCaseBody.flags);
}
if (options.flags) {
snakeCaseBody.flags = ChannelFlagsBitField.resolve(options.flags);
}

Copy link
Member Author

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

@github-project-automation github-project-automation bot moved this from Review Approved to Review in Progress in discord.js Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

6 participants