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

types(MessageManager): Allow comparison of messages again #9612

Merged
merged 10 commits into from
Jul 7, 2023

Conversation

Jiralite
Copy link
Member

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

Resolves #8545 by loosening the strict message types for direct messages. Instead of false, they are now boolean, which is the prior behaviour. This means Message<true> and Message<boolean> are now comparable with each other in the overloads.

In addition, DMMessageManager and GuildMessageManager have been created. crosspost() cannot be used in a direct message channel, hence the need for the separation.

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
  • This PR changes the library's interface (methods or parameters added)

@vercel
Copy link

vercel bot commented May 29, 2023

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 Jul 7, 2023 9:35pm
discord-js-guide ⬜️ Ignored (Inspect) Jul 7, 2023 9:35pm

@Jiralite Jiralite changed the title types(MessageManager): allow comparison of messages again types(MessageManager): Allow comparison of messages again May 29, 2023
@Jiralite Jiralite marked this pull request as ready for review May 29, 2023 20:22
@Jiralite Jiralite requested a review from a team as a code owner May 29, 2023 20:22
Copy link
Contributor

@jaw0r3k jaw0r3k left a comment

Choose a reason for hiding this comment

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

Looks little bit unnecessary
but its working then fine

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.

I feel like the creation of the JS classes to aid in TS strictness isn't needed but LGTM I suppose

@github-actions
Copy link

github-actions bot commented Jun 14, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 99
🟢 Accessibility 100
🟢 Best practices 100
🟢 SEO 100
🟠 PWA 70

Lighthouse ran on https://discord-js-git-types-loosen-message-manager-discordjs.vercel.app/

@codecov
Copy link

codecov bot commented Jul 7, 2023

Codecov Report

Merging #9612 (dbfa42f) into main (75d91b5) will decrease coverage by 0.01%.
The diff coverage is n/a.

❗ Current head dbfa42f differs from pull request most recent head 2430257. Consider uploading reports for the commit 2430257 to get more accurate results

@@            Coverage Diff             @@
##             main    #9612      +/-   ##
==========================================
- Coverage   58.20%   58.19%   -0.01%     
==========================================
  Files         227      227              
  Lines       14902    14901       -1     
  Branches     1131     1131              
==========================================
- Hits         8673     8672       -1     
  Misses       6189     6189              
  Partials       40       40              
Flag Coverage Δ
builders 98.69% <ø> (-0.01%) ⬇️
next ∅ <ø> (∅)
rest 93.13% <ø> (ø)
voice 63.47% <ø> (ø)
ws 53.86% <ø> (ø)

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

see 1 file with indirect coverage changes

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

@kodiakhq kodiakhq bot merged commit a48d0ef into main Jul 7, 2023
@kodiakhq kodiakhq bot deleted the types/loosen-message-manager branch July 7, 2023 21:39
Vylpes pushed a commit to Vylpes/vylbot-app that referenced this pull request Dec 11, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [discord.js](https://discord.js.org) ([source](https://github.com/discordjs/discord.js)) | dependencies | minor | [`14.11.0` -> `14.14.1`](https://renovatebot.com/diffs/npm/discord.js/14.11.0/14.14.1) |

---

### Release Notes

<details>
<summary>discordjs/discord.js (discord.js)</summary>

### [`v14.14.1`](https://github.com/discordjs/discord.js/blob/HEAD/packages/discord.js/CHANGELOG.md#14141---2023-11-12)

[Compare Source](discordjs/discord.js@14.14.0...14.14.1)

#### Bug Fixes

-   **Emoji:** `id` set as `undefined` edge case ([#&#8203;9953](discordjs/discord.js#9953)) ([cc07a28](discordjs/discord.js@cc07a28))
-   **BaseClient:** Default in objects properly ([#&#8203;9952](discordjs/discord.js#9952)) ([f93abf7](discordjs/discord.js@f93abf7))

#### Documentation

-   Use preferred nullable syntax (`?T` over `T | null`) ([#&#8203;9946](discordjs/discord.js#9946)) ([1e4ef35](discordjs/discord.js@1e4ef35))

#### Refactor

-   Use formatters ([#&#8203;9956](discordjs/discord.js#9956)) ([40726db](discordjs/discord.js@40726db))

#### Typings

-   Use wrapper utilities ([#&#8203;9945](discordjs/discord.js#9945)) ([4bc1dae](discordjs/discord.js@4bc1dae))

### [`v14.14.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/discord.js/CHANGELOG.md#14140---2023-11-12)

[Compare Source](discordjs/discord.js@14.13.0...14.14.0)

#### Bug Fixes

-   **Client:** Ensure destroyed connections are not ready ([#&#8203;9942](discordjs/discord.js#9942)) ([b5e23ec](discordjs/discord.js@b5e23ec))
-   **Webhook:** Do not call `client.deleteWebhook` in `delete` ([#&#8203;9786](discordjs/discord.js#9786)) ([31d914e](discordjs/discord.js@31d914e))
-   **GuildManager#fetch:** Inject shard id ([#&#8203;9921](discordjs/discord.js#9921)) ([85753a9](discordjs/discord.js@85753a9))
-   Prevent 'undefined' debug message on intentional shard closure ([#&#8203;9846](discordjs/discord.js#9846)) ([0e0b85b](discordjs/discord.js@0e0b85b))
-   **Role:** Calculate position correctly when rawPositions are equal ([#&#8203;9871](discordjs/discord.js#9871)) ([0529b2a](discordjs/discord.js@0529b2a))
-   **GuildScheduledEvent:** Use `if...else` pattern and handle partials ([#&#8203;9802](discordjs/discord.js#9802)) ([32d614c](discordjs/discord.js@32d614c))

#### Documentation

-   **Message:** Remove duplicated word 'of' in description ([#&#8203;9923](discordjs/discord.js#9923)) ([85a78f9](discordjs/discord.js@85a78f9))
-   **GuildMember:** Clarify display color ([#&#8203;9891](discordjs/discord.js#9891)) ([e38d03f](discordjs/discord.js@e38d03f))
-   Remove duplicate `APIEmoji` ([#&#8203;9880](discordjs/discord.js#9880)) ([8cfadb6](discordjs/discord.js@8cfadb6))
-   Consolidate API types ([#&#8203;9881](discordjs/discord.js#9881)) ([44a3cbf](discordjs/discord.js@44a3cbf))
-   Remove `FileOptions` ([#&#8203;9855](discordjs/discord.js#9855)) ([eaabcdf](discordjs/discord.js@eaabcdf))
-   **DiscordjsErrorCodes:** Deprecate unused properties ([#&#8203;9790](discordjs/discord.js#9790)) ([4588e07](discordjs/discord.js@4588e07))
-   **ApplicationCommandManager:** Id parameter can take options ([#&#8203;9664](discordjs/discord.js#9664)) ([ed14135](discordjs/discord.js@ed14135))
-   **Attachment:** Add MIME types link to `contentType` ([#&#8203;9824](discordjs/discord.js#9824)) ([85b2498](discordjs/discord.js@85b2498))
-   Fix "its" typo ([#&#8203;9825](discordjs/discord.js#9825)) ([c50809e](discordjs/discord.js@c50809e))
-   **GuildMember:** Clarify timeout parameter wording ([#&#8203;9800](discordjs/discord.js#9800)) ([8d97e2d](discordjs/discord.js@8d97e2d))
-   **create-discord-bot:** Support bun in create-discord-bot ([#&#8203;9798](discordjs/discord.js#9798)) ([7157748](discordjs/discord.js@7157748))

#### Features

-   Default select menu values ([#&#8203;9867](discordjs/discord.js#9867)) ([4ff3ea4](discordjs/discord.js@4ff3ea4))
-   Mainlib docs on new website ([#&#8203;9930](discordjs/discord.js#9930)) ([da455bc](discordjs/discord.js@da455bc))
-   **cleanContent:** Add slash commands and emojis ([#&#8203;9809](discordjs/discord.js#9809)) ([c2349d4](discordjs/discord.js@c2349d4))
-   **Emoji:** Add `imageURL()` ([#&#8203;9788](discordjs/discord.js#9788)) ([b6c762c](discordjs/discord.js@b6c762c))
-   Onboarding mode and edit method ([#&#8203;9647](discordjs/discord.js#9647)) ([7671a83](discordjs/discord.js@7671a83))
-   Support new application properties and patch endpoint ([#&#8203;9709](discordjs/discord.js#9709)) ([1fe7247](discordjs/discord.js@1fe7247))
-   **BaseChannel:** Add `isThreadOnly()` ([#&#8203;9847](discordjs/discord.js#9847)) ([699b232](discordjs/discord.js@699b232))
-   **StageInstanceManager:** Add `guildScheduledEvent` to `create()` ([#&#8203;8885](discordjs/discord.js#8885)) ([931c3ed](discordjs/discord.js@931c3ed))
-   Support `default_thread_rate_limit_per_user` in channel creation ([#&#8203;9273](discordjs/discord.js#9273)) ([1e5c14b](discordjs/discord.js@1e5c14b))
-   Add media channels ([#&#8203;9662](discordjs/discord.js#9662)) ([571aedd](discordjs/discord.js@571aedd))
-   Support widget image URL ([#&#8203;9782](discordjs/discord.js#9782)) ([b6a2441](discordjs/discord.js@b6a2441))
-   **GuildAuditLogsEntry:** Expose extra integrationType in relevant log types ([#&#8203;9796](discordjs/discord.js#9796)) ([3109798](discordjs/discord.js@3109798))
-   Add support for teams update ([#&#8203;9805](discordjs/discord.js#9805)) ([c66636d](discordjs/discord.js@c66636d))
-   **Presence:** Expose sync_id in Activity ([#&#8203;9766](discordjs/discord.js#9766)) ([485dd71](discordjs/discord.js@485dd71))

#### Refactor

-   **utils:** Remove `mergeDefault` ([#&#8203;9938](discordjs/discord.js#9938)) ([5b0aa92](discordjs/discord.js@5b0aa92))
-   Use proper variable names in callbacks ([#&#8203;9840](discordjs/discord.js#9840)) ([11f6955](discordjs/discord.js@11f6955))
-   **GuildAuditLogsEntry:** Abstract reduce logic into a new function ([#&#8203;9845](discordjs/discord.js#9845)) ([19ea0ba](discordjs/discord.js@19ea0ba))
-   Stickers are free (no more "premium" packs) ([#&#8203;9791](discordjs/discord.js#9791)) ([e02a59b](discordjs/discord.js@e02a59b))

#### Typings

-   **Partials:** Add toString() method to supported Partials ([#&#8203;9835](discordjs/discord.js#9835)) ([7422d9f](discordjs/discord.js@7422d9f))
-   **MessageEditOptions:** Correct `attachments` type ([#&#8203;9874](discordjs/discord.js#9874)) ([2aa3250](discordjs/discord.js@2aa3250))
-   **UserContextMenuCommandInteraction:** Nullify `targetMember` ([#&#8203;9844](discordjs/discord.js#9844)) ([3c043d8](discordjs/discord.js@3c043d8))
-   Don't include dom types ([#&#8203;9831](discordjs/discord.js#9831)) ([9dbc954](discordjs/discord.js@9dbc954))
-   **Client:** Fix isReady narrowing ([#&#8203;9828](discordjs/discord.js#9828)) ([6404c01](discordjs/discord.js@6404c01))

### [`v14.13.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/discord.js/CHANGELOG.md#14130---2023-08-17)

[Compare Source](discordjs/discord.js@14.12.1...14.13.0)

#### Bug Fixes

-   **Action:** Do not add the client user as a recipient ([#&#8203;9774](discordjs/discord.js#9774)) ([24fbb11](discordjs/discord.js@24fbb11))
-   **DMChannel:** Correct partial typo ([#&#8203;9773](discordjs/discord.js#9773)) ([c1ff545](discordjs/discord.js@c1ff545))
-   **CachedManager:** Allow overriding constructor for makeCache ([#&#8203;9763](discordjs/discord.js#9763)) ([346fa57](discordjs/discord.js@346fa57))
-   **types:** Fixed CachedManager constructor arguments in type ([#&#8203;9761](discordjs/discord.js#9761)) ([b3c85d3](discordjs/discord.js@b3c85d3))
-   **Action:** Do not set `undefined` values ([#&#8203;9755](discordjs/discord.js#9755)) ([d8e3755](discordjs/discord.js@d8e3755))

#### Documentation

-   **EmbedBuilder:** `@readonly` length ([#&#8203;9778](discordjs/discord.js#9778)) ([8f572a6](discordjs/discord.js@8f572a6))
-   **WebhookEditOptions:** Add all of the types ([#&#8203;9776](discordjs/discord.js#9776)) ([d5be424](discordjs/discord.js@d5be424))
-   Update Node.js requirement to 16.11.0 ([#&#8203;9764](discordjs/discord.js#9764)) ([188877c](discordjs/discord.js@188877c))

#### Features

-   **Client:** Add deleteWebhook method ([#&#8203;9777](discordjs/discord.js#9777)) ([d90ba8d](discordjs/discord.js@d90ba8d))
-   **ClientPresence:** Allow setting activity state ([#&#8203;9743](discordjs/discord.js#9743)) ([9ed1b59](discordjs/discord.js@9ed1b59))
-   **ClientApplication:** Approximate guild count and new `GET` route ([#&#8203;9713](discordjs/discord.js#9713)) ([632a9b4](discordjs/discord.js@632a9b4))
-   **Role:** Add `flags` ([#&#8203;9694](discordjs/discord.js#9694)) ([3b18e5b](discordjs/discord.js@3b18e5b))
-   **Attachment:** Add `flags` ([#&#8203;9686](discordjs/discord.js#9686)) ([692f0fc](discordjs/discord.js@692f0fc))
-   Add `Client#webhooksUpdate` ([#&#8203;9732](discordjs/discord.js#9732)) ([0de071d](discordjs/discord.js@0de071d))

#### Typings

-   **GuildInvitableChannelResolvable:** Allow forum channels ([#&#8203;9775](discordjs/discord.js#9775)) ([727dc09](discordjs/discord.js@727dc09))
-   Make activity name required ([#&#8203;9765](discordjs/discord.js#9765)) ([0a9a3ed](discordjs/discord.js@0a9a3ed))
-   **BaseButtonComponentData:** Narrow component type ([#&#8203;9735](discordjs/discord.js#9735)) ([a30d46c](discordjs/discord.js@a30d46c))

### [`v14.12.1`](https://github.com/discordjs/discord.js/blob/HEAD/packages/discord.js/CHANGELOG.md#14121---2023-08-01)

[Compare Source](discordjs/discord.js@14.12.0...14.12.1)

#### Bug Fixes

-   **BaseClient:** Fix destroy method ([#&#8203;9742](discordjs/discord.js#9742)) ([1af7e5a](discordjs/discord.js@1af7e5a))

### [`v14.12.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/discord.js/CHANGELOG.md#14120---2023-07-31)

[Compare Source](discordjs/discord.js@14.11.0...14.12.0)

#### Bug Fixes

-   **ChannelUpdate:** Check against unknown channels ([#&#8203;9697](discordjs/discord.js#9697)) ([7fb91c5](discordjs/discord.js@7fb91c5))
-   **Action:** Use existing recipients if available ([#&#8203;9653](discordjs/discord.js#9653)) ([719e54a](discordjs/discord.js@719e54a))
-   Everyone role members ([#&#8203;9685](discordjs/discord.js#9685)) ([0803eb5](discordjs/discord.js@0803eb5))
-   `awaitMessageComponent` with `MessageComponentInteraction`s ([#&#8203;8598](discordjs/discord.js#8598)) ([b61e4fb](discordjs/discord.js@b61e4fb))
-   **ThreadManager:** Fix internal crash upon conditionally resolving thread members ([#&#8203;9648](discordjs/discord.js#9648)) ([a6dbe16](discordjs/discord.js@a6dbe16))
-   **User:** Check global name in equals ([#&#8203;9631](discordjs/discord.js#9631)) ([8f3bd38](discordjs/discord.js@8f3bd38))
-   **WebSocketManager:** Await WebSocket destroy ([#&#8203;9519](discordjs/discord.js#9519)) ([75308f2](discordjs/discord.js@75308f2))
-   **Client:** Safe call for possibly null WebSocket ([#&#8203;9600](discordjs/discord.js#9600)) ([24a6149](discordjs/discord.js@24a6149))
-   **ThreadManager:** Ensure `fetchActive()` only returns active threads in a channel ([#&#8203;9568](discordjs/discord.js#9568)) ([53aa24d](discordjs/discord.js@53aa24d))
-   **LimitedCollection:** Allow items to be stored if keepOverLimit is true when maxSize is 0 ([#&#8203;9534](discordjs/discord.js#9534)) ([9345d1b](discordjs/discord.js@9345d1b))
-   **AutocompleteInteraction:** Prevent snake casing of locales ([#&#8203;9565](discordjs/discord.js#9565)) ([7196fe3](discordjs/discord.js@7196fe3))

#### Documentation

-   Change `Channel` to `BaseChannel` ([#&#8203;9718](discordjs/discord.js#9718)) ([e5effb6](discordjs/discord.js@e5effb6))
-   **BaseChannel:** Remove `APIChannel` ([#&#8203;9717](discordjs/discord.js#9717)) ([125405f](discordjs/discord.js@125405f))
-   **BuildersSelectMenuOption:** Update link ([#&#8203;9690](discordjs/discord.js#9690)) ([ede9f4e](discordjs/discord.js@ede9f4e))
-   **ClientOptions:** Change default value of sweepers in docs ([#&#8203;9591](discordjs/discord.js#9591)) ([911e6ef](discordjs/discord.js@911e6ef))
-   **Client:** Correct invite gateway permission checks ([#&#8203;9597](discordjs/discord.js#9597)) ([e1b6eee](discordjs/discord.js@e1b6eee))
-   Fix broken links to new documentation ([#&#8203;9563](discordjs/discord.js#9563)) ([d01e8aa](discordjs/discord.js@d01e8aa))

#### Features

-   Add ws option support for "buildIdentifyThrottler" ([#&#8203;9728](discordjs/discord.js#9728)) ([6307f81](discordjs/discord.js@6307f81))
-   **Client:** Add `guildAvailable` event ([#&#8203;9692](discordjs/discord.js#9692)) ([3c85fb2](discordjs/discord.js@3c85fb2))
-   User avatar decorations ([#&#8203;8914](discordjs/discord.js#8914)) ([8d97017](discordjs/discord.js@8d97017))
-   Add silent option to ShardingManager ([#&#8203;9506](discordjs/discord.js#9506)) ([df40dcd](discordjs/discord.js@df40dcd))
-   **EmbedBuilder:** Add `.length` ([#&#8203;8682](discordjs/discord.js#8682)) ([53c17e0](discordjs/discord.js@53c17e0))
-   Guild onboarding ([#&#8203;9120](discordjs/discord.js#9120)) ([dc73c93](discordjs/discord.js@dc73c93))
-   Add resume event in shard ([#&#8203;9650](discordjs/discord.js#9650)) ([a73d54e](discordjs/discord.js@a73d54e))
-   **presence:** Re-introduce image resolving for other platforms ([#&#8203;9637](discordjs/discord.js#9637)) ([73c2f8a](discordjs/discord.js@73c2f8a))
-   Add message to send resume event to shard ([#&#8203;9626](discordjs/discord.js#9626)) ([a873ec1](discordjs/discord.js@a873ec1))
-   Support new username system ([#&#8203;9512](discordjs/discord.js#9512)) ([1ab60f9](discordjs/discord.js@1ab60f9))
-   **GuildAuditLogsEntry#extra:** Add missing `channel` property ([#&#8203;9518](discordjs/discord.js#9518)) ([2272321](discordjs/discord.js@2272321))

#### Performance

-   **Channel:** Linear speed position getter ([#&#8203;9497](discordjs/discord.js#9497)) ([09b0382](discordjs/discord.js@09b0382))
-   **Role:** Improve `members` getter ([#&#8203;9529](discordjs/discord.js#9529)) ([37181ab](discordjs/discord.js@37181ab))

#### Refactor

-   **User:** Remove deprecation warning from tag ([#&#8203;9660](discordjs/discord.js#9660)) ([cf8012c](discordjs/discord.js@cf8012c))
-   **GuildMember:** Make `_roles` property non-enumerable ([#&#8203;9387](discordjs/discord.js#9387)) ([46167a7](discordjs/discord.js@46167a7))
-   **rest:** Switch api to fetch-like and provide strategies ([#&#8203;9416](discordjs/discord.js#9416)) ([cdaa0a3](discordjs/discord.js@cdaa0a3))
    -   **BREAKING CHANGE:** NodeJS v18+ is required when using node due to the use of global `fetch`
    -   **BREAKING CHANGE:** The raw method of REST now returns a web compatible `Respone` object.
    -   **BREAKING CHANGE:** The `parseResponse` utility method has been updated to operate on a web compatible `Response` object.
    -   **BREAKING CHANGE:** Many underlying internals have changed, some of which were exported.
    -   **BREAKING CHANGE:** `DefaultRestOptions` used to contain a default `agent`, which is now set to `null` instead.

#### Typings

-   **MessageManager:** Allow comparison of messages again ([#&#8203;9612](discordjs/discord.js#9612)) ([a48d0ef](discordjs/discord.js@a48d0ef))
-   **AutoModerationActionExecution:** Add forum channels as a possible type in `channel()` ([#&#8203;9623](discordjs/discord.js#9623)) ([d64330a](discordjs/discord.js@d64330a))
-   **ModalSubmitFields:** Components is an array ([#&#8203;9406](discordjs/discord.js#9406)) ([1cab79f](discordjs/discord.js@1cab79f))
-   Use `readonly` arrays and `const` type parameters in places ([#&#8203;9641](discordjs/discord.js#9641)) ([cd69868](discordjs/discord.js@cd69868))
-   **BaseInteraction:** `appPermissions` not `null` in guilds ([#&#8203;9601](discordjs/discord.js#9601)) ([6c2242f](discordjs/discord.js@6c2242f))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/351
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.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.

MessageManager#fetch has signatures, but none of those signatures are compatible with each other.
5 participants