Skip to content

feat(Typing): cache member object - #10786

Closed
Pavel-Boyazov wants to merge 2 commits into
discordjs:mainfrom
Pavel-Boyazov:typingStart-member-caching
Closed

Pavel-Boyazov wants to merge 2 commits into
discordjs:mainfrom
Pavel-Boyazov:typingStart-member-caching

Conversation

@Pavel-Boyazov

Copy link
Copy Markdown
Contributor

Please describe the changes this PR makes and why it should be merged:
Discord API provides member object with TYPING_START event in guild. We can use this for cache update and getting value without getter

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

vercel Bot commented Mar 1, 2025 •

Copy link
Copy Markdown

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) Visit Preview Mar 1, 2025 11:18pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Mar 1, 2025 11:18pm

Comment on lines +37 to +43
if ('member' in data) {
/**
* The member that this guild typing instance represents
* @type {?GuildMember}
*/
this.member = this.channel.guild.members._add(data.member, true);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR makes the member only set when its provided, otherwise it will be undefined (not null). Either we keep the getter and add the caching logic in too, or we define a fallback that is the getter

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This can be done without getters. If the member property was not set when the object was created, then there can be no conditions when it will be set later (except manually). I can use the ternary operator to set null if there is no data.
What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

const user = this.getUserFromMember(data);
already adds the member to cache, so this is redundant. The getter was fine as is.

@github-project-automation github-project-automation Bot moved this from Todo to Review in Progress in discord.js Mar 1, 2025
@Pavel-Boyazov
Pavel-Boyazov requested a review from vladfrangu March 1, 2025 23:18
@Pavel-Boyazov
Pavel-Boyazov requested a review from Qjuh October 20, 2025 16:35
@Pavel-Boyazov
Pavel-Boyazov deleted the typingStart-member-caching branch January 13, 2026 21:11
@github-project-automation github-project-automation Bot moved this from Review in Progress to Denied in discord.js Jan 13, 2026
@Pavel-Boyazov
Pavel-Boyazov restored the typingStart-member-caching branch January 13, 2026 21:11
@Pavel-Boyazov Pavel-Boyazov reopened this Jan 13, 2026
@Qjuh

Qjuh commented Jan 14, 2026

Copy link
Copy Markdown
Member

#10786 (comment) still stands, this PR is adding nothing, the cache already gets updated and the getter is fine.

@Qjuh Qjuh closed this Jan 14, 2026
@Pavel-Boyazov
Pavel-Boyazov deleted the typingStart-member-caching branch January 14, 2026 13:49
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.

3 participants