Organise structure methods

This commit is contained in:
Schuyler Cebulskie
2016-09-07 02:07:39 -04:00
parent 73cb34ed37
commit 818649b94f
13 changed files with 493 additions and 577 deletions

View File

@@ -65,17 +65,6 @@ class Role {
this.managed = data.managed;
}
equals(role) {
return role &&
this.id === role.id &&
this.name === role.name &&
this.color === role.color &&
this.hoist === role.hoist &&
this.position === role.position &&
this.permissions === role.permissions &&
this.managed === role.managed;
}
/**
* The time the role was created
* @readonly
@@ -216,14 +205,6 @@ class Role {
return (this.permissions & permission) > 0;
}
/**
* When concatenated with a string, this automatically concatenates the Role mention rather than the Role object.
* @returns {string}
*/
toString() {
return `<@&${this.id}>`;
}
/**
* The hexadecimal version of the role color, with a leading hashtag.
* @type {string}
@@ -234,6 +215,32 @@ class Role {
while (col.length < 6) col = `0${col}`;
return `#${col}`;
}
/**
* Whether this role equals another role. It compares all properties, so for most operations
* it is advisable to just compare `role.id === role2.id` as it is much faster and is often
* what most users need.
* @param {Role} role The role to compare to
* @returns {boolean}
*/
equals(role) {
return role &&
this.id === role.id &&
this.name === role.name &&
this.color === role.color &&
this.hoist === role.hoist &&
this.position === role.position &&
this.permissions === role.permissions &&
this.managed === role.managed;
}
/**
* When concatenated with a string, this automatically concatenates the Role mention rather than the Role object.
* @returns {string}
*/
toString() {
return `<@&${this.id}>`;
}
}
module.exports = Role;