Skip to content

Commit

Permalink
refactor(GuildChannel): use filter method for #members (#6253)
Browse files Browse the repository at this point in the history
Co-authored-by: ckohen <[email protected]>
  • Loading branch information
kevinbioj and ckohen authored Aug 1, 2021
1 parent 774f5b7 commit 7c54076
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/structures/GuildChannel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const { Collection } = require('@discordjs/collection');
const Channel = require('./Channel');
const PermissionOverwrites = require('./PermissionOverwrites');
const { Error } = require('../errors');
Expand Down Expand Up @@ -258,13 +257,7 @@ class GuildChannel extends Channel {
* @readonly
*/
get members() {
const members = new Collection();
for (const member of this.guild.members.cache.values()) {
if (this.permissionsFor(member).has(Permissions.FLAGS.VIEW_CHANNEL, false)) {
members.set(member.id, member);
}
}
return members;
return this.guild.members.cache.filter(m => this.permissionsFor(m).has(Permissions.FLAGS.VIEW_CHANNEL, false));
}

/**
Expand Down

0 comments on commit 7c54076

Please sign in to comment.