mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
GuildMember.roles is now a collection instead of an array
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user