Get Users by Role

Get Users by Role

This command (get_users_by_role) returns a list of users who match the given role filters. Useful for querying server members without needing to export the server member list. All filter parameters are additive — i.e. if more than one filter is added, it will only return members who match all criteria.

Permissions

Bot Permissions

  • If this command is run from a thread, then the bot must have the VIEW_CHANNEL permission for the parent channel. Otherwise, no extra permissions are needed.

Parameters

included_roles

Optional. A space-separated list of role @mentions (like @role1 @role2) to filter server members by. If more than one role is present, only members will all roles will be returned. If this parameter and excluded_roles are left blank, only users with no roles will be returned. To get a list of all users, type @everyone here instead.

excluded_roles

Optional. A space-separated list of role @mentions (like @role1 @role2) to filter server members by. If more than one role is present, only members without any roles will be returned. If this parameter and included_roles are left blank, only users with no roles will be returned.

limit

Optional. Limit the number of members affected. If larger than the maximum value (or left out), the maximum value will be used instead. This value depends on the tier of Shield being used. See the limits section for more information.

limit_to_channel

Optional. If set, will limit members returned to those who have access to the channel in which this command is run.

ephemeral

Optional. Whether other server members should be able to see the bot's response. Does not affect logging.

Cooldown

Like other commands, cooldowns operate at the server level. The cooldown values are:

BasicStandardAdvanced
30 minutes15 minutes5 minutes

Limits

The maximum number of members affected depends on the tier of Shield being used. These values are:

BasicStandardAdvanced
100500500