Skip to content

Commit

Permalink
refactor(ThreadChannel): use single thread member endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sdanialraza committed Feb 18, 2024
1 parent 992aa67 commit d1ca6c7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/discord.js/src/structures/ThreadChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,11 @@ class ThreadChannel extends BaseChannel {
* @param {BaseFetchOptions} [options] The options for fetching the member
* @returns {Promise<?ThreadMember>}
*/
async fetchOwner({ cache = true, force = false } = {}) {
if (!force) {
const existing = this.members.cache.get(this.ownerId);
if (existing) return existing;
}
async fetchOwner(options) {
if (!this.ownerId) return null;

// We cannot fetch a single thread member, as of this commit's date, Discord API responds with 405
const members = await this.members.fetch({ cache });
return members.get(this.ownerId) ?? null;
const member = await this.members.fetch({ ...options, member: this.ownerId }).catch(() => null);
return member;
}

/**
Expand Down

0 comments on commit d1ca6c7

Please sign in to comment.