Skip to content

Conversation

@Jiralite
Copy link
Member

@Jiralite Jiralite commented Nov 5, 2025

These should never be constructed without data...

The blame seems to go years and years back. Was likely ancient logic made redundant over time.

@vercel
Copy link

vercel bot commented Nov 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
discord-js Ignored Ignored Preview Nov 12, 2025 0:21am
discord-js-guide Ignored Ignored Preview Nov 12, 2025 0:21am

Copy link
Contributor

Copilot AI left a 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_id directly on line 43 before calling _patch. With the removed if (data) check, if data is null or undefined, this will throw a TypeError. The same issue exists on line 36 with data.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.

@vakiliner
Copy link
Contributor

vakiliner commented Nov 5, 2025

Even though these constructors are private, typings needs to be updated

export class ThreadChannel<ThreadOnly extends boolean = boolean> extends BaseChannel {
private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client<true>);

export class Webhook<Type extends WebhookType = WebhookType> {
private constructor(client: Client<true>, data?: unknown);

Copy link
Member

@Qjuh Qjuh left a 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

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.

Lets hope nothing breaks :))

@github-project-automation github-project-automation bot moved this from Todo to Review Approved in discord.js Nov 12, 2025
@kodiakhq kodiakhq bot merged commit 837af56 into main Nov 12, 2025
8 checks passed
@kodiakhq kodiakhq bot deleted the fix/data-removal branch November 12, 2025 13:31
@github-project-automation github-project-automation bot moved this from Review Approved to Done in discord.js Nov 12, 2025
Jiralite added a commit that referenced this pull request Nov 12, 2025
* fix: remove conditional

* types: sort types
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.

7 participants