Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

[actions] havePermission

Thedark1337 edited this page Sep 20, 2016 · 4 revisions

havePermission(userID, permission, global)

Check if a user's permission matches the permission


Parameters

userID number

ID of the user.

permission number

The permission to check (one of the following):

PlugAPI.ROOM_ROLE.NONE
PlugAPI.ROOM_ROLE.RESIDENTDJ
PlugAPI.ROOM_ROLE.BOUNCER
PlugAPI.ROOM_ROLE.MANAGER
PlugAPI.ROOM_ROLE.COHOST
PlugAPI.ROOM_ROLE.HOST
global boolean (optional)

Whether to only check for global permission (BA / Admin) or to check both (Default is false)


Returns

true if user's permission matches; otherwise it returns false


Note: If utilizing plugAPI's command handler it would be data.havePermission and checks for both normal roles and global roles and also includes an optional callback function.


Example

// Check for Bouncer & above permissions
if (bot.havePermission(1234567, PlugAPI.ROOM_ROLE.BOUNCER)) {
    // code here
}

// Check for BA / Admin only
if (bot.havePermission(1234567, PlugAPI.ROOM_ROLE.BOUNCER, true)) {
    // code here
}
Clone this wiki locally