Permission
channelPermissions
$channelPermissions
The function $channelPermissions lists what a member or a role can really do in one channel. It is not a copy of $userPerms (the permissions stored in the roles) or of $checkChannelPerms (the @everyone role only): it answers for the channel, as Discord does. This function does not exist in BibiScript: it is specific to Bot Creator.
Syntax
$channelPermissions[channelID;(memberOrRoleID);(separator)]
Parameters
| Parameter | Description |
|---|---|
channelID |
Required. The ID of a channel (or thread) of a server, otherwise Invalid Discord ID. A thread uses the overwrites of its parent channel. |
memberOrRoleID |
Optional. The ID of a member or of a role of the server. Empty or absent: the member who ran the command (the bot when there is none). |
separator |
Optional. Text placed between two permissions. Default , . Kept literally, spaces included. |
What is taken into account
- The permissions of the
@everyonerole and of the member’s roles (for a role: its own permissions and those of@everyone). - The
@everyoneoverwrite of the channel, then the overwrites of the member’s roles (or of the role), then the overwrite of the member himself, each with its denied and allowed permissions. - Administrator and the server owner: they hold every permission, whatever the overwrites.
- A member in timeout keeps only
VIEW_CHANNELandREAD_MESSAGE_HISTORY.
Return value
- Type: String
- The permission names in Discord’s order, as
$userPermswrites them (VIEW_CHANNEL,SEND_MESSAGES, …) joined by the separator. Empty when the target has none. - An error is raised if the channel is not on a server, or if the member is not on the server.
Examples
Permission diagnosis
$sendMessage[Your permissions here: $channelPermissions[$channelID]]
One member, with another separator
$sendMessage[Permissions of $username here: $channelPermissions[$channelID;$authorID; | ]]
Access check
$if[$checkContains[$channelPermissions[$channelID;$roleID[Staff]];SEND_MESSAGES]==true]
Staff can write here.
$endif
Notes
- Use
$checkUserPermsor$hasPermsto test named permissions,$checkChannelPermsfor the @everyone role only. - JavaScript:
channel.permissionsFor(memberOrRole).toArray().
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.