feat: User#mutualFriends

This commit is contained in:
March 7th
2022-12-13 14:55:51 +07:00
parent ad8bed71c8
commit 6ef8970a1e
2 changed files with 20 additions and 1 deletions

View File

@@ -178,7 +178,25 @@ class User extends Base {
}
/**
* Check relationship status
* Get all mutual friends (Client -> User)
* @type {Promise<Collection<Snowflake, User>>}
* @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
*/