Skip to content

Conversation

@AsadHumayun
Copy link
Contributor

This PR will add the SKU structure, based on the documentation of the structure on the Discord API, found here.

This PR does not add tests for the associated structure.

This PR also adds a new SKUFlagsBitField to /bitfields.

Mentioning #10981 for visibility.

@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 27, 2026 11:37pm
discord-js-guide Skipped Skipped Jan 27, 2026 11:37pm

Request Review

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

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.62%. Comparing base (b0e413c) to head (25d86fa).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/structures/src/skus/SKU.ts 0.00% 15 Missing ⚠️
...kages/structures/src/bitfields/SKUFlagsBitField.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11389      +/-   ##
==========================================
- Coverage   31.66%   31.62%   -0.05%     
==========================================
  Files         383      385       +2     
  Lines       13900    13918      +18     
  Branches     1095     1096       +1     
==========================================
  Hits         4401     4401              
- Misses       9365     9383      +18     
  Partials      134      134              
Flag Coverage Δ
structures 35.66% <0.00%> (-0.46%) ⬇️

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.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new SKU (Stock Keeping Unit) structure to the codebase. It adds a generic SKU class that extends Structure, along with an associated SKUFlagsBitField class for managing SKU-related bitfield flags. Both are exported from the structures package.

Changes

Cohort / File(s) Summary
SKU Bitfield Implementation
packages/structures/src/bitfields/SKUFlagsBitField.ts
New class extending BitField<keyof SKUFlags> with static Flags member exposing SKUFlags definitions and custom toJSON() method for specific JSON representation.
SKU Structure Class
packages/structures/src/skus/SKU.ts
New generic SKU class extending Structure<APISKU, Omitted> with public getters for id, type, applicationId, name, slug, and a flags getter that returns SKUFlagsBitField or null. Includes DataTemplate static member and parameterized constructor.
SKU Exports
packages/structures/src/skus/index.ts, packages/structures/src/index.ts
Barrel export from skus directory and public API export making SKU class available from main structures package.

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 'feat(structures): add SKU structure' directly and concisely summarizes the main change - adding a new SKU structure to the structures package.
Description check ✅ Passed The description explains the purpose of the PR (adding SKU structure based on Discord API), mentions the related SKUFlagsBitField addition, notes that tests are not included, and references a related issue for visibility.
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

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/skus/SKU.ts`:
- Around line 63-67: The flags getter in SKU (the get flags() accessor that
reads this[kData].flags and returns new SKUFlagsBitField(this[kData].flags as
SKUFlags) or null) wrongly uses a truthy check so a value of 0 becomes null;
change the check to a nullish check (e.g., test for null/undefined) so 0 is
treated as a valid bitfield and only undefined/null returns null, and apply the
same nullish-check fix to the equivalent getters in Message.ts, Attachment.ts,
and GuildChannelMixin.ts (use the corresponding BitField classes and kData
accessors in each file).
📜 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 62a3511.

📒 Files selected for processing (4)
  • packages/structures/src/bitfields/SKUFlagsBitField.ts
  • packages/structures/src/index.ts
  • packages/structures/src/skus/SKU.ts
  • packages/structures/src/skus/index.ts
🧰 Additional context used
🧬 Code graph analysis (2)
packages/structures/src/skus/SKU.ts (1)
packages/structures/src/utils/symbols.ts (1)
  • kData (1-1)
packages/structures/src/bitfields/SKUFlagsBitField.ts (1)
packages/discord.js/typings/index.d.ts (1)
  • BitField (663-680)
⏰ 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/skus/index.ts (1)

1-1: LGTM: simple barrel export.

packages/structures/src/index.ts (1)

11-11: LGTM: public export is straightforward.

packages/structures/src/bitfields/SKUFlagsBitField.ts (1)

7-11: The typing pattern in SKUFlagsBitField is consistent with 4 of 5 BitField implementations in the codebase (MessageFlagsBitField, ChannelFlagsBitField, AttachmentFlagsBitField all use keyof FlagType directly). SKUFlagsBitField is actively used in production code (SKU.ts) without type errors. The claim that keyof SKUFlags evaluates to never contradicts the actual behavior of identical patterns elsewhere in the same codebase and package. No fix is required.

Likely an incorrect or invalid review comment.

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

@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js Jan 22, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js January 22, 2026 13:29 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 22, 2026 13:29 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 23, 2026 09:41 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 23, 2026 09:41 Inactive
Qjuh
Qjuh previously requested changes Jan 24, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 19:55 Inactive
@Jiralite Jiralite added this to the structures 1.0.0 milestone Jan 24, 2026
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 21:58 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 21:58 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 24, 2026 22:32 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 24, 2026 22:32 Inactive
@AsadHumayun AsadHumayun requested a review from Qjuh January 24, 2026 22:32
@vercel vercel bot temporarily deployed to Preview – discord-js January 27, 2026 23:23 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 27, 2026 23:23 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js-guide January 27, 2026 23:37 Inactive
@vercel vercel bot temporarily deployed to Preview – discord-js January 27, 2026 23:37 Inactive
@github-project-automation github-project-automation bot moved this from Review in Progress to Review Approved in discord.js Jan 28, 2026
@kodiakhq kodiakhq bot merged commit c71228a into discordjs:main Jan 28, 2026
27 checks passed
@github-project-automation github-project-automation bot moved this from Review Approved to Done in discord.js Jan 28, 2026
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.

5 participants