Skip to content
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

fix: message builders #10802

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: message builders #10802

wants to merge 1 commit into from

Conversation

almeidx
Copy link
Member

@almeidx almeidx commented Mar 15, 2025

  • Added clearParse, clearRoles, and clearUsers methods to the AllowedMentionsBuilder, since passing an empty array and omitting the these fields behave differently
  • Strictened assertions
  • Removed AttachmentBuilder#clearId, as it is a required field
  • Added missing MessageBuilder#setEmbeds
  • Added missing MessageReferenceBuilder#setFailIfNotExists
  • Improve/fix documentation
  • Consistency:tm:

@almeidx almeidx requested a review from a team as a code owner March 15, 2025 20:09
Copy link

vercel bot commented Mar 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Mar 15, 2025 8:11pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Mar 15, 2025 8:11pm

- Added `clearParse`, `clearRoles`, and `clearUsers` methods to the `AllowedMentionsBuilder`, since passing an empty array and omitting the these fields behave differently
- Strictened assertions
- Removed `AttachmentBuilder#clearId`, as it is a required field
- Added missing `MessageBuilder#setEmbeds`
- Added missing `MessageReferenceBuilder#setFailIfNotExists`
- Improve/fix documentation
- Consistency:tm:
@almeidx almeidx force-pushed the fix/message-builders branch from 1cdd834 to ec66fee Compare March 15, 2025 20:11
@Jiralite Jiralite added this to the builders 2.0.0 milestone Mar 15, 2025
Copy link

codecov bot commented Mar 15, 2025

Codecov Report

Attention: Patch coverage is 72.36842% with 21 lines in your changes missing coverage. Please review.

Project coverage is 39.90%. Comparing base (09beb8a) to head (ec66fee).

Files with missing lines Patch % Lines
packages/builders/src/messages/AllowedMentions.ts 25.00% 9 Missing ⚠️
packages/builders/src/messages/Message.ts 67.85% 9 Missing ⚠️
packages/builders/src/messages/MessageReference.ts 66.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10802      +/-   ##
==========================================
+ Coverage   39.66%   39.90%   +0.24%     
==========================================
  Files         249      249              
  Lines       15206    15239      +33     
  Branches     1456     1463       +7     
==========================================
+ Hits         6031     6081      +50     
+ Misses       9163     9146      -17     
  Partials       12       12              
Flag Coverage Δ
builders 77.93% <72.36%> (+1.06%) ⬆️

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.

* @param embeds - The embeds to set
*/
public setEmbeds(...embeds: RestOrArray<APIEmbed | EmbedBuilder | ((builder: EmbedBuilder) => EmbedBuilder)>): this {
return this.spliceEmbeds(0, this.embeds.length, ...normalizeArray(embeds));
Copy link
Member

Choose a reason for hiding this comment

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

I tested it and while it works, I would much rather stick to explicitly overriding the array instead on relying on splicing to replicate a set operator

Copy link
Member Author

@almeidx almeidx Mar 15, 2025

Choose a reason for hiding this comment

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

This (and the other changes like this) fall under the "Consistency:tm:" part of the description

Copy link
Member

Choose a reason for hiding this comment

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

Well I am against relying on splice to do a set 🤷, would love to hear other's thoughts.

Copy link
Member

@didinele didinele Mar 18, 2025

Choose a reason for hiding this comment

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

Well I am against relying on splice to do a set 🤷, would love to hear other's thoughts.

I don't see a problem with using the splice method, but if we're not going to, then we should update it everywhere else too.

Copy link
Member

@didinele didinele left a comment

Choose a reason for hiding this comment

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

thanks

* @param embeds - The embeds to set
*/
public setEmbeds(...embeds: RestOrArray<APIEmbed | EmbedBuilder | ((builder: EmbedBuilder) => EmbedBuilder)>): this {
return this.spliceEmbeds(0, this.embeds.length, ...normalizeArray(embeds));
Copy link
Member

@didinele didinele Mar 18, 2025

Choose a reason for hiding this comment

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

Well I am against relying on splice to do a set 🤷, would love to hear other's thoughts.

I don't see a problem with using the splice method, but if we're not going to, then we should update it everywhere else too.

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