Skip to content

The way to get all members with certain role. #1166

Answered by key2peace
sanovskiy asked this question in Q&A
Discussion options

You must be logged in to vote

There is ->filter() which pretty much does the same, just looks easier to use

$roleholders = $guild->members->filter(function($member) use ($role) { return $member->roles->has($role->id); });

This should return a Collection of members with a specified role.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@sanovskiy
Comment options

Answer selected by sanovskiy
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants