refactor: new node features (#5132)

Co-authored-by: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
Sugden
2021-06-30 21:40:33 +01:00
committed by GitHub
parent f108746c15
commit 1e8f01253e
68 changed files with 305 additions and 360 deletions

View File

@@ -105,9 +105,9 @@ class MessageReaction {
*/
async fetch() {
const message = await this.message.fetch();
const existing = message.reactions.cache.get(this.emoji.id || this.emoji.name);
const existing = message.reactions.cache.get(this.emoji.id ?? this.emoji.name);
// The reaction won't get set when it has been completely removed
this._patch(existing || { count: 0 });
this._patch(existing ?? { count: 0 });
return this;
}
@@ -128,7 +128,7 @@ class MessageReaction {
if (!this.me || user.id !== this.message.client.user.id) this.count--;
if (user.id === this.message.client.user.id) this.me = false;
if (this.count <= 0 && this.users.cache.size === 0) {
this.message.reactions.cache.delete(this.emoji.id || this.emoji.name);
this.message.reactions.cache.delete(this.emoji.id ?? this.emoji.name);
}
}
}