diff --git a/src/structures/User.js b/src/structures/User.js index ddabee570..13783b969 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -1,10 +1,6 @@ const TextBasedChannel = require('./interface/TextBasedChannel'); const Constants = require('../util/Constants'); -function defined(p) { - return typeof p !== 'undefined'; -} - /** * Represents a User on Discord. * @implements {TextBasedChannel} @@ -21,24 +17,6 @@ class User { if (data) this.setup(data); } - patch(data) { - for (const item of ['id', 'username', 'discriminator', 'game', 'avatar']) { - if (defined(data[item])) { - this[item] = data[item]; - } - } - if (defined[data.bot]) { - this.bot = data.bot; - } else { - this.bot = this.bot || false; - } - if (defined[data.status]) { - this.status = data.status; - } else { - this.status = this.status || 'offline'; - } - } - setup(data) { /** * The ID of the User @@ -68,7 +46,7 @@ class User { * Whether or not the User is a Bot. * @type {boolean} */ - this.bot = data.bot || false; + this.bot = Boolean(data.bot); /** * The status of the user: @@ -95,6 +73,12 @@ class User { this.game = data.game; } + patch(data) { + for (const prop of ['id', 'username', 'discriminator', 'status', 'game', 'avatar', 'bot']) { + if (typeof data[prop] !== 'undefined') this[prop] = data[prop]; + } + } + /** * The time the user was created * @readonly