Skip to content

docs(structures): update DataTemplate docs#11388

Draft
AsadHumayun wants to merge 2 commits intodiscordjs:mainfrom
AsadHumayun:chore/update-datatemplate-docs
Draft

docs(structures): update DataTemplate docs#11388
AsadHumayun wants to merge 2 commits intodiscordjs:mainfrom
AsadHumayun:chore/update-datatemplate-docs

Conversation

@AsadHumayun
Copy link
Contributor

This PR will correct comments on constructors of structures that contain defaults.

No code changes are introduced in this PR.

@vercel
Copy link

vercel bot commented Jan 20, 2026

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

2 Skipped Deployments
Project Deployment Review Updated (UTC)
discord-js Skipped Skipped Jan 20, 2026 0:12am
discord-js-guide Skipped Skipped Jan 20, 2026 0:12am

Request Review

@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 20, 2026 00:04 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 20, 2026 00:04 Inactive
@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This PR adds documentation remarks to DataTemplate JSDoc comments across multiple structure classes, explaining default values and how to override them using Object.defineProperties. No functional or behavioral changes.

Changes

Cohort / File(s) Summary
Message-related structures
packages/structures/src/messages/Message.ts, packages/structures/src/messages/MessageCall.ts, packages/structures/src/messages/Reaction.ts, packages/structures/src/messages/embeds/Embed.ts
Added or expanded @remarks blocks to DataTemplate JSDoc comments documenting defaults and override patterns
Other structures
packages/structures/src/channels/mixins/ChannelPinMixin.ts, packages/structures/src/users/User.ts
Added @remarks blocks to DataTemplate JSDoc clarifying defaults and override mechanisms

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, stating that it corrects comments on constructors containing defaults and clarifies no code changes are introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: updating DataTemplate documentation across multiple structure files with no functional code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/structures/src/users/User.ts`:
- Around line 15-21: The JSDoc for User.DataTemplate claims "This template has
defaults" but User.DataTemplate is an empty object; update the comment to
reflect there are no defaults or remove the remarks block entirely. Locate the
static property User.DataTemplate in the User class and either change the
remarks text to say there are no defaults (or that defaults live elsewhere) or
delete the paragraph about using Object.defineProperties/overriding defaults so
the documentation matches the actual empty Partial<APIUser> value.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0171769 and 78e3168.

📒 Files selected for processing (6)
  • packages/structures/src/channels/mixins/ChannelPinMixin.ts
  • packages/structures/src/messages/Message.ts
  • packages/structures/src/messages/MessageCall.ts
  • packages/structures/src/messages/Reaction.ts
  • packages/structures/src/messages/embeds/Embed.ts
  • packages/structures/src/users/User.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests
🔇 Additional comments (5)
packages/structures/src/messages/embeds/Embed.ts (1)

14-22: LGTM!

The documentation accurately reflects the DataTemplate behavior. The template has a default setter for timestamp, and the remarks correctly explain how to extend or override it.

packages/structures/src/messages/MessageCall.ts (1)

11-19: LGTM!

The documentation correctly describes the DataTemplate which has a default setter for ended_timestamp. The remarks about using Object.defineProperties to extend defaults are appropriate.

packages/structures/src/messages/Reaction.ts (1)

13-21: LGTM!

The documentation is consistent with the actual DataTemplate implementation, which has a default setter for burst_colors.

packages/structures/src/channels/mixins/ChannelPinMixin.ts (1)

17-27: LGTM!

The documentation accurately reflects the DataTemplate which contains a default setter for last_pin_timestamp. The remarks are helpful for developers extending this mixin.

packages/structures/src/messages/Message.ts (1)

22-31: LGTM!

The documentation correctly describes the DataTemplate which has default setters for both timestamp and edited_timestamp. The remarks about extending vs. overriding defaults are clear and accurate.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 20, 2026 00:12 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 20, 2026 00:12 Inactive
@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.26%. Comparing base (7884ecd) to head (c557c30).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11388      +/-   ##
==========================================
- Coverage   32.43%   32.26%   -0.17%     
==========================================
  Files         369      371       +2     
  Lines       13616    13691      +75     
  Branches     1068     1078      +10     
==========================================
+ Hits         4416     4418       +2     
- Misses       9065     9138      +73     
  Partials      135      135              
Flag Coverage Δ
structures 42.88% <ø> (-2.75%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ckohen
Copy link
Member

ckohen commented Jan 20, 2026

DataTemplate is readonly by design, meaning you cannot directly set the property to another object, to avoid accidentally overwriting the defaults.

@AsadHumayun
Copy link
Contributor Author

Thanks for getting back to me. Considering what you've pointed out, I see it wouldn't be a good idea to suggest setting the value directly as defaults should realistically not be overridden.

I'll go ahead and remove this part of the comment:

To override the defaults, set this value directly.

Is this something that I should bring up with the wider structures team? It seems that this is/was the convention and is present in other files as well, at the moment (eg the Invite structure).

Let me know if you think this looks good or other teams should be notified.

@ckohen
Copy link
Member

ckohen commented Jan 24, 2026

I missed the change to readonly in the initial PR. I had originally not made them readonly so that consumers could actually overwrite completely, but overwritting individual properties in the same way you add properties seems better. The docs change was missed during this switch, you could update the rest of the docs as well.

@Jiralite Jiralite changed the title chore(structures): update DataTemplate docs docs(structures): update DataTemplate docs Jan 24, 2026
@AsadHumayun
Copy link
Contributor Author

AsadHumayun commented Jan 24, 2026

Just to confirm we're both on the same page, is this the kind of final doc you're expecting?

	/**
	 * The template used for removing data from the raw data stored for each team.
	 * 
	 * @remarks DataTemplate is readonly by design, meaning you cannot directly set the property to another object,
	 * to avoid accidentally overwriting the defaults.
	 */
	public static override readonly DataTemplate: Partial<APITeam> = {};

(along with removing any mentions of "To override the defaults, set this value directly.")

Since there's quite a few structures PRs in progress at the moment, I'm thinking of keeping this PR as draft and just setting them here at once, once they get merged. This saves from having to update each PR individually, though do let me know if you would prefer an alternative approach. Happy to adapt.

@AsadHumayun AsadHumayun marked this pull request as draft January 24, 2026 17:23
@ckohen
Copy link
Member

ckohen commented Feb 2, 2026

I think keeping mention of Object.defineProperties is a good idea, but otherwise yes

* The template used for removing data from the raw data stored for each Channel.
*
* @remarks This template has defaults, if you want to remove additional data and keep the defaults,
* use `Object.defineProperties`. To override the defaults, set this value directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* use `Object.defineProperties`. To override the defaults, set this value directly.
* use `Object.defineProperties`.

* The template used for removing data from the raw data stored for each Embed.
*
* @remarks This template has defaults, if you want to remove additional data and keep the defaults,
* use `Object.defineProperties`. To override the defaults, set this value directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* use `Object.defineProperties`. To override the defaults, set this value directly.
* use `Object.defineProperties`.

* The template used for removing data from the raw data stored for each Message.
*
* @remarks This template has defaults, if you want to remove additional data and keep the defaults,
* use `Object.defineProperties`. To override the defaults, set this value directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* use `Object.defineProperties`. To override the defaults, set this value directly.
* use `Object.defineProperties`.

* The template used for removing data from the raw data stored for each MessageCall.
*
* @remarks This template has defaults, if you want to remove additional data and keep the defaults,
* use `Object.defineProperties`. To override the defaults, set this value directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* use `Object.defineProperties`. To override the defaults, set this value directly.
* use `Object.defineProperties`.

* The template used for removing data from the raw data stored for each Reaction.
*
* @remarks This template has defaults, if you want to remove additional data and keep the defaults,
* use `Object.defineProperties`. To override the defaults, set this value directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* use `Object.defineProperties`. To override the defaults, set this value directly.
* use `Object.defineProperties`.

@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js Feb 21, 2026
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.

4 participants