discord.js icon indicating copy to clipboard operation
discord.js copied to clipboard

feat(builders): Allow passing `null` to optional setters

Open cobaltt7 opened this issue 2 years ago • 8 comments

Please describe the changes this PR makes and why it should be merged: Adds support for passing null to setters that set optional values to easily reset them, like Embed already does. Resolves #8350. I did not add support for undefined to be consistent with Embed 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

cobaltt7 avatar Aug 27 '22 22:08 cobaltt7

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

Name Status Preview Updated
discord-js ✅ Ready (Inspect) Visit Preview Oct 19, 2022 at 1:57PM (UTC)
discord-js-guide ✅ Ready (Inspect) Visit Preview Oct 19, 2022 at 1:57PM (UTC)

vercel[bot] avatar Aug 27 '22 22:08 vercel[bot]

Tests are not passing: https://github.com/discordjs/discord.js/runs/8160731228?check_suite_focus=true#step:7:246

@discordjs/builders:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@discordjs/builders:test: 
@discordjs/builders:test:  FAIL  __tests__/components/button.test.ts > Button Components > Assertion Tests > GIVEN invalid label THEN validator does throw
@discordjs/builders:test: AssertionError: expected [Function] to throw an error
@discordjs/builders:test:  ❯ __tests__/components/button.test.ts:23:50
@discordjs/builders:test:      21| 
@discordjs/builders:test:      22|   test('GIVEN invalid label THEN validator does throw', () => {
@discordjs/builders:test:      23|    expect(() => buttonLabelValidator.parse(null)).toThrowError();
@discordjs/builders:test:        |                                                  ^
@discordjs/builders:test:      24|    expect(() => buttonLabelValidator.parse('')).toThrowError();
@discordjs/builders:test:      25| 
@discordjs/builders:test: 
@discordjs/builders:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
@discordjs/builders:test: 
@discordjs/builders:test: Test Files  1 failed | 11 passed (12)
@discordjs/builders:test:      Tests  1 failed | 221 passed (222)

kyranet avatar Sep 03 '22 07:09 kyranet

I removed the failing test because null is not an invalid value. The Discord API allows passing an emoji and no label on a button, so labels can be null.

cobaltt7 avatar Sep 05 '22 15:09 cobaltt7

read my suggestion again. move the test under GIVEN valid label THEN validator does not throw section.

imranbarbhuiya avatar Sep 05 '22 15:09 imranbarbhuiya

Codecov Report

Merging #8559 (0671c89) into main (bf9aa18) will decrease coverage by 0.16%. The diff coverage is 73.43%.

@@            Coverage Diff             @@
##             main    #8559      +/-   ##
==========================================
- Coverage   85.81%   85.64%   -0.17%     
==========================================
  Files          91       91              
  Lines        9254     9263       +9     
  Branches     1125     1143      +18     
==========================================
- Hits         7941     7933       -8     
- Misses       1271     1288      +17     
  Partials       42       42              
Flag Coverage Δ
brokers 65.24% <ø> (ø)
builders 99.46% <73.43%> (-0.54%) :arrow_down:
collection 100.00% <ø> (ø)
proxy 81.53% <ø> (ø)
rest 92.06% <ø> (ø)
util 100.00% <ø> (ø)
utilities 100.00% <ø> (ø)
voice 63.70% <ø> (ø)
ws 59.83% <ø> (ø)

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

Impacted Files Coverage Δ
packages/builders/src/components/button/Button.ts 98.54% <50.00%> (-1.46%) :arrow_down:
...s/builders/src/components/selectMenu/SelectMenu.ts 98.15% <50.00%> (-1.85%) :arrow_down:
...ges/builders/src/components/textInput/TextInput.ts 97.31% <50.00%> (-2.69%) :arrow_down:
...s/src/interactions/slashCommands/options/number.ts 96.15% <50.00%> (-3.85%) :arrow_down:
...s/src/interactions/slashCommands/options/string.ts 96.36% <50.00%> (-3.64%) :arrow_down:
.../src/interactions/slashCommands/options/integer.ts 96.15% <60.00%> (-3.85%) :arrow_down:
...ders/src/components/selectMenu/SelectMenuOption.ts 97.97% <75.00%> (-2.03%) :arrow_down:
packages/builders/src/components/Assertions.ts 100.00% <100.00%> (ø)
...es/builders/src/components/textInput/Assertions.ts 100.00% <100.00%> (ø)
...ApplicationCommandNumericOptionMinMaxValueMixin.ts 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Sep 05 '22 16:09 codecov[bot]

What else can I do to get this merged?

cobaltt7 avatar Oct 06 '22 16:10 cobaltt7

@RedGuy12 is attempting to deploy a commit to the discordjs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 11 '22 14:10 vercel[bot]

I don't think this is stilll blocked...

cobaltt7 avatar Oct 31 '22 21:10 cobaltt7