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

@@ -36,25 +36,27 @@ class GroupDMChannel extends Channel {
this.messages = new Collection();
}
equals(other) {
const equal = other &&
this.id === other.id &&
this.name === other.name &&
this.icon === other.icon &&
this.owner.id === other.owner_id;
if (equal) {
const thisIDs = this.recipients.array().map(r => r.id);
const otherIDs = other.recipients.map(r => r.id);
return arraysEqual(thisIDs, otherIDs);
}
return equal;
}
setup(data) {
super.setup(data);
/**
* The name of this Group DM, can be null if one isn't set.
* @type {string}
*/
this.name = data.name;
/**
* A hash of the Group DM icon.
* @type {string}
*/
this.icon = data.icon;
/**
* The owner of this Group DM.
* @type {User}
*/
this.owner = this.client.users.get(data.owner_id);
if (!this.recipients) {
/**
* A collection of the recipients of this DM, mapped by their ID.
@@ -70,32 +72,25 @@ class GroupDMChannel extends Channel {
}
}
/**
* The name of this Group DM, can be null if one isn't set.
* @type {string}
*/
this.name = data.name;
/**
* The ID of this Group DM Channel.
* @type {string}
*/
this.id = data.id;
/**
* A hash of the Group DM icon.
* @type {string}
*/
this.icon = data.icon;
/**
* The ID of the last message in the channel, if one was sent.
* @type {?string}
*/
this.lastMessageID = data.last_message_id;
/**
* The owner of this Group DM.
* @type {User}
*/
this.owner = this.client.users.get(data.owner_id);
this.type = 'group';
this.lastMessageID = data.last_message_id;
}
equals(other) {
const equal = other &&
this.id === other.id &&
this.name === other.name &&
this.icon === other.icon &&
this.owner.id === other.owner_id;
if (equal) {
const thisIDs = this.recipients.array().map(r => r.id);
const otherIDs = other.recipients.map(r => r.id);
return arraysEqual(thisIDs, otherIDs);
}
return equal;
}
sendMessage() {