-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix: Remove data conditional check #11250
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the conditional if (data) checks before calling _patch(data) in the constructors of multiple structures including Webhook, ThreadChannel, Role, PermissionOverwrites, and GuildMember. The changes standardize the initialization pattern by always calling _patch regardless of whether data is provided.
- Removes conditional data checks before
_patch()calls in constructors - Affects 5 structure classes: Webhook, ThreadChannel, Role, PermissionOverwrites, and GuildMember
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/discord.js/src/structures/Webhook.js | Removes if (data) check before calling _patch(data) in constructor |
| packages/discord.js/src/structures/ThreadChannel.js | Removes if (data) check before calling _patch(data) in constructor |
| packages/discord.js/src/structures/Role.js | Removes if (data) check before calling _patch(data) in constructor |
| packages/discord.js/src/structures/PermissionOverwrites.js | Removes if (data) check before calling _patch(data) in constructor |
| packages/discord.js/src/structures/GuildMember.js | Removes if (data) check before calling _patch(data) in constructor |
Comments suppressed due to low confidence (1)
packages/discord.js/src/structures/ThreadChannel.js:43
- The constructor accesses
data.owner_iddirectly on line 43 before calling_patch. With the removedif (data)check, ifdatais null or undefined, this will throw a TypeError. The same issue exists on line 36 withdata.guild_id. Either restore the conditional check or add null/undefined handling in the constructor.
this.ownerId = data.owner_id;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Even though these constructors are private, typings needs to be updated discord.js/packages/discord.js/typings/index.d.ts Lines 3527 to 3528 in 7e5accf
discord.js/packages/discord.js/typings/index.d.ts Lines 3823 to 3824 in 7e5accf
|
Qjuh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from typings already pointed out LGTM
7e5accf to
47faf6b
Compare
vladfrangu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets hope nothing breaks :))
* fix: remove conditional * types: sort types
These should never be constructed without data...
The blame seems to go years and years back. Was likely ancient logic made redundant over time.