Skip to content

Conversation

@Qjuh
Copy link
Member

@Qjuh Qjuh commented Jan 25, 2026

Please describe the changes this PR makes and why it should be merged:
If flags get omitted downstream the getters might error, added checks to account for that.
Status and versioning classification:

@Qjuh Qjuh requested a review from a team as a code owner January 25, 2026 09:56
@vercel
Copy link

vercel bot commented Jan 25, 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 27, 2026 4:45pm
discord-js-guide Skipped Skipped Jan 27, 2026 4:45pm

Request Review

@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 25, 2026 09:56 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 25, 2026 09:56 Inactive
@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

Three flag property getters refactored from truthy checks to explicit type and existence validation. Changes standardize flag handling across Channel, Attachment, and Message structures, ensuring zero values are recognized as valid bitfields rather than falsy.

Changes

Cohort / File(s) Summary
Flag Property Validation Refactoring
packages/structures/src/channels/Channel.ts, packages/structures/src/messages/Attachment.ts, packages/structures/src/messages/Message.ts
Replaced truthy checks with explicit typeof number validation for flags properties. Each getter now returns a corresponding FlagsBitField only when the flags property exists and is a number, otherwise null. Handles edge case where flags is zero (falsy but valid).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding correct checks for the presence of flags in structures, which matches the changeset across three files.
Description check ✅ Passed The description is directly related to the changeset, explaining that flags might be omitted and checks were added to prevent getter errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3550b49 and 99b104a.

📒 Files selected for processing (3)
  • packages/structures/src/channels/Channel.ts
  • packages/structures/src/messages/Attachment.ts
  • packages/structures/src/messages/Message.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-24T21:41:15.330Z
Learnt from: Qjuh
Repo: discordjs/discord.js PR: 11393
File: packages/structures/src/bitfields/ApplicationFlagsBitField.ts:13-15
Timestamp: 2026-01-24T21:41:15.330Z
Learning: In discord.js BitField classes, the toJSON(asNumber?: boolean) method returns a numeric value when asNumber is true, and returns a string representation when asNumber is false or undefined. To preserve numeric flags, use super.toJSON(true).

Applied to files:

  • packages/structures/src/channels/Channel.ts
  • packages/structures/src/messages/Message.ts
🧬 Code graph analysis (1)
packages/structures/src/channels/Channel.ts (2)
packages/structures/src/utils/symbols.ts (1)
  • kData (1-1)
packages/structures/src/bitfields/ChannelFlagsBitField.ts (1)
  • ChannelFlagsBitField (7-16)
⏰ 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 (3)
packages/structures/src/channels/Channel.ts (1)

84-87: LGTM: robust flags guard and zero-safe bitfield creation.
The new presence/type check avoids missing-flag errors and keeps 0 as a valid bitfield.

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

114-117: LGTM: safer Attachment flags handling.
The presence/type guard prevents missing-flag errors while preserving zero-valued flags.

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

112-115: LGTM: Message flags check is now zero-safe and resilient.
This avoids exceptions on missing flags while still allowing 0-valued bitfields.

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


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.

@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.89%. Comparing base (323d8e7) to head (986e14c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/structures/src/channels/Channel.ts 0.00% 0 Missing and 1 partial ⚠️
packages/structures/src/messages/Attachment.ts 0.00% 1 Missing ⚠️
packages/structures/src/messages/Message.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11404      +/-   ##
==========================================
- Coverage   32.05%   31.89%   -0.16%     
==========================================
  Files         375      375              
  Lines       13710    13675      -35     
  Branches     1077     1068       -9     
==========================================
- Hits         4395     4362      -33     
+ Misses       9180     9179       -1     
+ Partials      135      134       -1     
Flag Coverage Δ
structures 41.47% <57.14%> (+0.21%) ⬆️

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.

@vercel vercel bot temporarily deployed to Preview – discord-js January 25, 2026 15:26 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 25, 2026 15:26 Inactive
@github-project-automation github-project-automation bot moved this from Todo to Review Approved in discord.js Jan 27, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 27, 2026 16:45 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 27, 2026 16:45 Inactive
@kodiakhq kodiakhq bot merged commit 7a7fecb into discordjs:main Jan 27, 2026
8 checks passed
@github-project-automation github-project-automation bot moved this from Review Approved to Done in discord.js Jan 27, 2026
@Qjuh Qjuh deleted the fix/bitfield-in-structures branch January 27, 2026 16:54
AsadHumayun added a commit to AsadHumayun/discord.js that referenced this pull request Jan 27, 2026
kodiakhq bot pushed a commit that referenced this pull request Jan 28, 2026
* feat(structures): update barrel exports in preparation for SKU structure

* feat(structures): add SKUFlagsBitField to /bitfields

* feat(structures): add SKU structure

* chore(structures): correct barrel exports

* chore(structures): export SKUBitfieldFlags

* docs(structures): correct usage of see/link doc comments

* chore(structures): correct usage of bitfields in extending classes

* docs(structures): remove unnecessary links

* fix(structures): correctly apply bitfields, introduced in #11404

---------

Co-authored-by: Almeida <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants