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(SlashCommandBuilder): add missing shared properties #10255

Merged
merged 7 commits into from May 15, 2024

Conversation

TAEMBO
Copy link
Contributor

@TAEMBO TAEMBO commented May 6, 2024

Please describe the changes this PR makes and why it should be merged:
Following #10253, other properties were observed to also not be present when using options or subcommands. This PR adds those properties on the type level where they are present during runtime.

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

@TAEMBO TAEMBO requested a review from a team as a code owner May 6, 2024 00:20
Copy link

vercel bot commented May 6, 2024

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

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview May 15, 2024 1:51am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview May 15, 2024 1:51am

@Jiralite Jiralite requested a review from Qjuh May 6, 2024 00:32
@Jiralite Jiralite changed the title types(SlashCommandBuilder): add missing shared properties fix(SlashCommandBuilder): add missing shared properties May 6, 2024
@Jiralite
Copy link
Member

Jiralite commented May 6, 2024

Do you mind providing an example of where this fails?

@Anonymous4078
Copy link

This should fix my issue

@Jiralite Jiralite linked an issue May 6, 2024 that may be closed by this pull request
@TAEMBO
Copy link
Contributor Author

TAEMBO commented May 6, 2024

Do you mind providing an example of where this fails?

import { SlashCommandBuilder } from "@discordjs/builders";

const command = new SlashCommandBuilder().setNSFW(true).addSubcommand(x => x);

command.nsfw; // Property 'nsfw' does not exist on type 'SlashCommandOptionsOnlyBuilder'.ts(2339)

console.log(command); // { ..., nsfw: true }

Node: v22.1.0
@discordjs/builders: v1.8.1
TypeScript: v5.4.5

Edit: I realize the error comment says "Options" however my code shows a subcommand - I was debugging the extent this issue reaches. For clarity, this issue is present when using both subcommands and options - using addStringOption() or any others will give the same result w/ SlashCommandOptionsOnlyBuilder or SlashCommandSubcommandsOnlyBuilder accordingly.

@Anonymous4078

This comment was marked as spam.

Copy link
Member

@vladfrangu vladfrangu left a comment

Choose a reason for hiding this comment

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

Can you add in tests for this please, so we can be sure we don't make a regression again in the future 🙏

@Jiralite Jiralite added this to the builders 1.8.2 milestone May 10, 2024
@TAEMBO
Copy link
Contributor Author

TAEMBO commented May 10, 2024

Vitest doesn't allow us to enable type checking as proposed in Discord in these *.test.ts files, as it produces an error
Error: test.each syntax is not supported when testing types, of which there are 5 instances of that being used in /builders and /voice. Let me know how you guys would like to handle that - i.e. enable it anyways, skip it, or make other changes.

@vladfrangu
Copy link
Member

Couldn't we have a separate test file just for types, and make vitest use type checking just in that one?

Copy link

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.89%. Comparing base (616208b) to head (d97372d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main   #10255       +/-   ##
===========================================
+ Coverage   19.14%   95.89%   +76.75%     
===========================================
  Files          31       44       +13     
  Lines        6246     3634     -2612     
  Branches       73      111       +38     
===========================================
+ Hits         1196     3485     +2289     
+ Misses       5050      149     -4901     
Flag Coverage Δ
brokers 95.89% <100.00%> (+76.75%) ⬆️
builders 95.89% <100.00%> (+76.75%) ⬆️
collection 95.89% <100.00%> (+76.75%) ⬆️
discord.js 95.89% <100.00%> (+76.75%) ⬆️
formatters 95.89% <100.00%> (+76.75%) ⬆️
guide 95.89% <100.00%> (+76.75%) ⬆️
next 95.89% <100.00%> (+76.75%) ⬆️
proxy 95.89% <100.00%> (+76.75%) ⬆️
rest 95.89% <100.00%> (+76.75%) ⬆️
util 95.89% <100.00%> (+76.75%) ⬆️
utilities 95.89% <100.00%> (+76.75%) ⬆️
voice 95.89% <100.00%> (+76.75%) ⬆️
website 95.89% <100.00%> (+76.75%) ⬆️
ws 95.89% <100.00%> (+76.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.

@kodiakhq kodiakhq bot merged commit 29fd89f into discordjs:main May 15, 2024
6 checks passed
@TAEMBO TAEMBO deleted the missing-builder-props branch May 17, 2024 06:47
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.

Slash command builder type incompatibility
7 participants