Skip to content

Conversation

@Jiralite
Copy link
Member

Please describe the changes this PR makes and why it should be merged:
We have methods like ChannelsAPI#createMessage(), InteractionsAPI#reply(), InteractionsAPI#updateMessage(), etc. where the body parameters are of types that intersect with objects. That means we have to do this as they are not exported:

const payload: Parameters<ChannelsAPI["createMessage"]>[1] = {
    allowed_mentions: { parse: [] },
    embeds,
    files,
};

if (content) {
    payload.content = `${stamp} ${content}`;
}

The reason for this is because content is conditionally present. We cannot type this as RESTPostAPIChannelMessageJSONBody because files is not there. This is a @discordjs/core-specific type.

Doing Parameters<ChannelsAPI["createMessage"]>[1] is not ideal as when the library introduces minor or major changes, parameters may shift which results in yet again browsing the source code to see the intersected types. These types should be exported for ease.

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

@Jiralite Jiralite added this to the core 2.1.0 milestone Nov 27, 2024
@Jiralite Jiralite requested a review from a team as a code owner November 27, 2024 15:54
@vercel
Copy link

vercel bot commented Nov 27, 2024

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

Name Status Preview Comments Updated (UTC)
discord-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 9:05am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Dec 5, 2024 9:05am

@kodiakhq kodiakhq bot merged commit abf4b61 into main Dec 5, 2024
8 checks passed
@kodiakhq kodiakhq bot deleted the types/export-specific-types branch December 5, 2024 09:09
@codecov
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 38.20%. Comparing base (bd7a995) to head (5cce2a9).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10620      +/-   ##
==========================================
+ Coverage   36.98%   38.20%   +1.22%     
==========================================
  Files         239      239              
  Lines       15292    15533     +241     
  Branches     1379     1369      -10     
==========================================
+ Hits         5656     5935     +279     
+ Misses       9621     9583      -38     
  Partials       15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Jiralite Jiralite modified the milestones: core 2.1.0, core 3.0.0 Dec 8, 2024
Jiralite added a commit that referenced this pull request Nov 12, 2025
types: export core-specific types
Co-Authored-By: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants