feat: Update

- Event for GroupDM
- Friend nickname
#29
This commit is contained in:
March 7th
2022-09-16 19:08:15 +07:00
parent 84b6842db0
commit 70cde7df55
12 changed files with 130 additions and 12 deletions

View File

@@ -91,6 +91,7 @@ class RelationshipManager {
_setup(users) {
if (!Array.isArray(users)) return;
for (const relationShip of users) {
this.client.user.friendNicknames.set(relationShip.id, relationShip.nickname);
this.cache.set(relationShip.id, relationShip.type);
}
}
@@ -211,6 +212,23 @@ class RelationshipManager {
return true;
}
/**
* Changes the nickname of a friend.
* @param {UserResolvable} user The user to change the nickname
* @param {?string} nickname New nickname
* @returns {Promise<boolean>}
*/
async setNickname(user, nickname) {
const id = this.resolveId(user);
if (this.cache.get(id) !== RelationshipTypes.FRIEND) return false;
await this.client.api.users['@me'].relationships[id].patch({
data: {
nickname: typeof nickname === 'string' ? nickname : null,
},
});
return true;
}
/**
* Blocks a user.
* @param {UserResolvable} user User to block