Clean up a bunch of stuff

- Channel typing data is now a Map
- Client properties on structures are now non-enumerable and
non-configurable
This commit is contained in:
Schuyler Cebulskie
2016-09-07 00:24:45 -04:00
parent 3a790e74f4
commit b7f582b7f0
22 changed files with 411 additions and 316 deletions

View File

@@ -7,36 +7,47 @@ const Constants = require('../util/Constants');
*/
class User {
constructor(client, data) {
/**
* The Client that created the instance of the the User.
* @type {Client}
*/
this.client = client;
Object.defineProperty(this, 'client', { enumerable: false, configurable: false });
if (data) this.setup(data);
}
setup(data) {
/**
* The username of the User
* @type {string}
*/
this.username = data.username;
/**
* The ID of the User
* @type {string}
*/
this.id = data.id;
/**
* The username of the User
* @type {string}
*/
this.username = data.username;
/**
* A discriminator based on username for the User
* @type {string}
*/
this.discriminator = data.discriminator;
/**
* The ID of the user's avatar
* @type {string}
*/
this.avatar = data.avatar;
/**
* Whether or not the User is a Bot.
* @type {boolean}
*/
this.bot = Boolean(data.bot);
/**
* The status of the user:
*
@@ -46,6 +57,7 @@ class User {
* @type {string}
*/
this.status = data.status || this.status || 'offline';
/**
* The game that the user is playing, `null` if they aren't playing a game.
* @type {string}
@@ -99,8 +111,8 @@ class User {
*/
equals(user) {
let equal = user &&
this.username === user.username &&
this.id === user.id &&
this.username === user.username &&
this.discriminator === user.discriminator &&
this.avatar === user.avatar &&
this.bot === Boolean(user.bot);