discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.44k stars 3.97k forks source link

fix: type guard for sendable text-based channels #10482

Closed vladfrangu closed 2 months ago

vladfrangu commented 2 months ago

Please describe the changes this PR makes and why it should be merged:

Adds in BaseChannel#isSendable, which is a mix of isTextBased() and checking if you can actually send messages in the channel. This way, we can have the correct types for interaction.channel, and you can assert whether you got the interaction from a Group DM Channel or not

Status and versioning classification:

vercel[bot] commented 2 months ago

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](https://vercel.com/discordjs/discord-js/AF4NTaU6eY5Nv2tp7y1md9RTS5RG)) | [Visit Preview](https://discord-js-git-fix-issendable-discordjs.vercel.app) | | Sep 6, 2024 7:15am | | **discord-js-guide** | ⬜️ Ignored ([Inspect](https://vercel.com/discordjs/discord-js-guide/FpqrDHANDt7RXHe4jLhsigTLefMn)) | [Visit Preview](https://discord-js-guide-git-fix-issendable-discordjs.vercel.app) | | Sep 6, 2024 7:15am |
imnaiyar commented 2 months ago

IG this (and the JSDoc) can also be updated to include PartialGroupDMChannel since it's considered text-based now https://github.com/discordjs/discord.js/blob/4594896b5404c6a34e07544951c59ff8f3657184/packages/discord.js/src/util/Constants.js#L96-L122