diff --git a/src/structures/User.js b/src/structures/User.js index 937d9ab..568f690 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -178,7 +178,25 @@ class User extends Base { } /** - * Check relationship status + * Get all mutual friends (Client -> User) + * @type {Promise>} + * @readonly + */ + get mutualFriends() { + // eslint-disable-next-line no-async-promise-executor + return new Promise(async resolve => { + const all = new Collection(); + if (this.bot || this.client.user.id === this.id) return resolve(all); + const data = await this.client.api.users(this.id).relationships.get(); + for (const u of data) { + all.set(u.id, this.client.users._add(u)); + } + return resolve(all); + }); + } + + /** + * Check relationship status (Client -> User) * @type {RelationshipTypes} * @readonly */ diff --git a/typings/index.d.ts b/typings/index.d.ts index b8c205a..ec3bd8a 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3044,6 +3044,7 @@ export class User extends PartialTextBasedChannel(Base) { public readonly premiumGuildSince: Date; public readonly bio: string | null; public readonly mutualGuilds: Collection; + public readonly mutualFriends: Promise>; public readonly voice: VoiceState; public avatarURL(options?: ImageURLOptions): string | null; public bannerURL(options?: ImageURLOptions): string | null;