GuildMember.roles is now a collection instead of an array

This commit is contained in:
Amish Shah
2016-09-03 22:56:27 +01:00
parent 59a5862f2d
commit fced6983d9
2 changed files with 7 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
const TextBasedChannel = require('./interface/TextBasedChannel'); const TextBasedChannel = require('./interface/TextBasedChannel');
const Collection = require('../util/Collection');
/** /**
* Represents a Member of a Guild on Discord * Represents a Member of a Guild on Discord
@@ -82,22 +83,22 @@ class GuildMember {
} }
/** /**
* A list of roles that are applied to this GuildMember * A list of roles that are applied to this GuildMember, mapped by the role ID.
* @type {Array<Role>} * @type {Collection<string, Role>}
* @readonly * @readonly
*/ */
get roles() { get roles() {
const list = []; const list = new Collection();
const everyoneRole = this.guild.roles.get(this.guild.id); const everyoneRole = this.guild.roles.get(this.guild.id);
if (everyoneRole) { if (everyoneRole) {
list.push(everyoneRole); list.set(everyoneRole.id, everyoneRole);
} }
for (const roleID of this._roles) { for (const roleID of this._roles) {
const role = this.guild.roles.get(roleID); const role = this.guild.roles.get(roleID);
if (role) { if (role) {
list.push(role); list.set(role.id, role);
} }
} }