Custom Command
FunctionsMember Functions

$hasAnyRole

Checks if a user has one of the given roles. Returns true or false.

Usage

$hasAnyRole[userID;roleID1;roleID2;...]
  1. userID - (Optional) default value: $authorID. If not included or left empty, $authorID will be used.
  2. role N - You can add as many roles as needed.

Example

Using $hasAnyRole

How to use $hasAnyRole without user argument. Keep in mind that if the user does have only one of listed roles, true will be returned.

Member
9/5/2026

!!exec I have Admin OR Manager role: $hasAnyRole[admin;manager]

Custom Command
APP
9/5/2026

I have Admin OR Manager role: true

Member
9/5/2026

!!exec I have Admin role: $hasAnyRole[admin], I have Manager role: $hasAnyRole[manager]

Custom Command
APP
9/5/2026

I have Admin role: true, I have Manager role: false

Suggestion

To make code stop if the user doesn't have the needed role, you can check out $onlyIf. For multiple actions, check $if.

Related Functions: $hasPerms $hasAnyPerm $hasRole

Function difficulty: Easy

Tags: roles management

On this page