mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
Equals updates (#987)
* Docs update
Changed the param names and param descriptions to be consistent.
* Added === comparison
Changed Presence.equals and Game.equals to first compare using ===
* Collection.equals fix
Now returns false when collection is undefined, instead of crashing
💯
This commit is contained in:
committed by
Schuyler Cebulskie
parent
906bb3c5f3
commit
264ee8e7f1
@@ -28,14 +28,14 @@ class Presence {
|
||||
|
||||
/**
|
||||
* Whether this presence is equal to another
|
||||
* @param {Presence} other the presence to compare
|
||||
* @param {Presence} presence Presence to compare with
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(other) {
|
||||
return (
|
||||
other &&
|
||||
this.status === other.status &&
|
||||
this.game ? this.game.equals(other.game) : !other.game
|
||||
equals(presence) {
|
||||
return this === presence || (
|
||||
presence &&
|
||||
this.status === presence.status &&
|
||||
this.game ? this.game.equals(presence.game) : !presence.game
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -75,15 +75,15 @@ class Game {
|
||||
|
||||
/**
|
||||
* Whether this game is equal to another game
|
||||
* @param {Game} other the other game to compare
|
||||
* @param {Game} game Game to compare with
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(other) {
|
||||
return (
|
||||
other &&
|
||||
this.name === other.name &&
|
||||
this.type === other.type &&
|
||||
this.url === other.url
|
||||
equals(game) {
|
||||
return this === game || (
|
||||
game &&
|
||||
this.name === game.name &&
|
||||
this.type === game.type &&
|
||||
this.url === game.url
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user