Clean up recent User changes a bit

This commit is contained in:
Schuyler Cebulskie
2016-09-11 23:34:09 -04:00
parent 032d6613f7
commit d7bcf9564f

View File

@@ -1,10 +1,6 @@
const TextBasedChannel = require('./interface/TextBasedChannel'); const TextBasedChannel = require('./interface/TextBasedChannel');
const Constants = require('../util/Constants'); const Constants = require('../util/Constants');
function defined(p) {
return typeof p !== 'undefined';
}
/** /**
* Represents a User on Discord. * Represents a User on Discord.
* @implements {TextBasedChannel} * @implements {TextBasedChannel}
@@ -21,24 +17,6 @@ class User {
if (data) this.setup(data); 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) { setup(data) {
/** /**
* The ID of the User * The ID of the User
@@ -68,7 +46,7 @@ class User {
* Whether or not the User is a Bot. * Whether or not the User is a Bot.
* @type {boolean} * @type {boolean}
*/ */
this.bot = data.bot || false; this.bot = Boolean(data.bot);
/** /**
* The status of the user: * The status of the user:
@@ -95,6 +73,12 @@ class User {
this.game = data.game; 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 * The time the user was created
* @readonly * @readonly