Skip to content

Conversation

@Pavel-Boyazov
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged:
This PR based on previous PR's conversation.

Discord API's Guild Member object has isn't nullable joinedAt property.
This also confirms the partial property set to false, which depends on the nullability of joinedAt and the use of Partialize for this property to create the PartialGuildMember interface.
It's also incorrect that caching of a partial member is performed despite the provided partials options.

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

@vercel
Copy link

vercel bot commented Mar 1, 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 Oct 5, 2025 8:18pm
discord-js-guide Ignored Ignored Preview Oct 5, 2025 8:18pm

private constructor(guild: Guild, iterable?: Iterable<RawGuildMemberData>);
public guild: Guild;
public get me(): GuildMember | null;
public get me(): GuildMember | PartialGuildMember | null;
Copy link
Member

Choose a reason for hiding this comment

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

We always get the full GuildMember data for the ClientUser on GUILD_CREATE, so this can never be a PartialGuildMember to begin with.

Copy link
Contributor Author

@Pavel-Boyazov Pavel-Boyazov Mar 2, 2025

Choose a reason for hiding this comment

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

GUILD_CREATE not emit if Guilds intent not set

Copy link
Member

Choose a reason for hiding this comment

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

Without Guilds intent you wouldn't have any GuildMembers cached and the whole GuildMemberManager would be inaccessible because you don't have a Guild having it as property to begin with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What prevents us from using fetch to get and cache guilds with specific members exclude client member?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get me() {
return (
this.cache.get(this.client.user.id) ??
(this.client.options.partials.includes(Partials.GuildMember)
? this._add({ user: { id: this.client.user.id } }, true)
: null)
);
}

And if it like you say, why exist this functionality?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, that's a good catch indeed. Guess GuildMemberManager#me can be a PartialGuildMember after all, if the GuildMemberManager cache is limited to 0 without exception for the ClientUser.
But about no Guilds intent: most of the typings rely on that being present. Because several helper methods need it to work anyway.

| Guild
| NonThreadGuildBasedChannel
| GuildMember
| PartialGuildMember
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it makes much sense to resolve a Guild from a partial member, but that one's up to debate I'd say

@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js Mar 2, 2025
Comment on lines +4555 to +4558
export interface PartialGuildMemberRoleManager extends Partialize<GuildMemberRoleManager, null, null, 'member'> {
get partial(): true;
member: PartialGuildMember;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand need I and how to override constructor

@Pavel-Boyazov
Copy link
Contributor Author

That's about it. If I forgot something, please remind me.

@Pavel-Boyazov Pavel-Boyazov requested a review from Qjuh September 21, 2025 12:36
@Pavel-Boyazov Pavel-Boyazov changed the title fix(GuildMember): cache based on partials options fix(GuildMember): cache without partials Sep 21, 2025
@Pavel-Boyazov Pavel-Boyazov changed the title fix(GuildMember): cache without partials fix(GuildMember): cache without partial structures Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review in Progress

Development

Successfully merging this pull request may close these issues.

2 participants