# Yzbot's Permission System & Moderator and Admin Roles

### **NEW: Permission Nodes!**

You can now grant or deny access to commands on a per-user, per-role or server-wide basis. This is through a highly configurable permission node system. A permission node can have three states: allowed, neutralised or negated. In order to manage these permission nodes, you must use the `;setperms` command.&#x20;

The command is used with the following syntax: `;setperms <command> <server/role name/mention/user ID>`. &#x20;

You replace \<command> with the name of the command whose permission node you want to manage.&#x20;

{% hint style="warning" %}
**IMPORTANT**: If you want to allow the permission node, you must put a **+** before the command name. If you want to negate it, you must put a **-** before the command name. To neutralise (remove) the permission node, put nothing before the command name.&#x20;
{% endhint %}

To set the permission node server-wide, type 'server' after the command name. If you want it to affect the members of a certain role, type the name of the role after the command name. Finally, if you just want to set the permission node for a specific member, then either mention them or provide their user ID.

Firstly, negating permission nodes:

![Now the test account can't even use ;ping!](https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M6AhilYpWhjlGHv8RHA%2F-M6ApisAPtRINT0mjpow%2Fimage.png?alt=media\&token=24dc3285-c491-4449-9159-9832c770cb3a)

If we try ;ping...

<div align="left"><img src="https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M6AhilYpWhjlGHv8RHA%2F-M6Ar0cGqFKowUA1LqiP%2Fimage.png?alt=media&#x26;token=e1b0ccb6-efb9-4bf2-9d4e-ab6d5091ab9c" alt=""></div>

We can't! If we want to 'remove' or neutralise the negated permission node (allowing the user to use ;ping again), we do the following:

![](https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M6AhilYpWhjlGHv8RHA%2F-M6ArVT52lSdJQ14xLwg%2Fimage.png?alt=media\&token=7c1bd4c6-8402-4c86-8bc2-6acdd8ef4908)

Finally, if we want to allow this user to use a command they otherwise would be unable to, we can allow a permission node like so:

![Even though this user isn't a moderator, they can now warn members!](https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M6AhilYpWhjlGHv8RHA%2F-M6As4ZgvsNpkUM5-l5t%2Fimage.png?alt=media\&token=a86c2fce-cb03-4f5d-b883-0445751a78f3)

#### Viewing Permission Nodes

If you need to know what permission nodes are set server-wide, for a user or a role, type `;permnodes`. If you pass it no arguments, it will show the server-wide permission nodes by default. To view permission nodes for a specific role, type `;permnodes <role name>`, replacing \<role name> with the name of the role. Finally, if you want to view user-specific permission nodes type `;permnodes <user>` and this time, you have to mention the user, you cannot provide an ID (this DOES NOT show you the accumulated permissions of a user, from roles or server-wide settings).

<div align="left"><img src="https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M6AhilYpWhjlGHv8RHA%2F-M6AwqZP_CeRWZfj-3wS%2Fimage.png?alt=media&#x26;token=0de20d85-6f0c-46a2-aa62-7d7c54d332c5" alt=""></div>

**NOTES**

* If you want to manage permissions of a role called 'server'... you can't. You have to contact Support.
* Changes take up to 15 seconds to take effect for performance reasons.
* If a user has one role that is higher than another role, then the higher role's permission node will take effect. Permission nodes for roles are determined based on the role's position in the hierarchy.
* Server-wide permission nodes are always overriden by role permission nodes, which are always overriden by user-specific permission nodes.
* If you negate a permission, it always overrides permission levels and Discord permissions. If you allow a permission node, a permission level check is carried out first, and if that fails, the permission node acts as a failsafe to allow the user to use the command.

### **Using Permissions**

Regardless of whether the moderator and administrator roles are configured or not, yzbot's commands have some permissions that will allow a user, by default, to use the command. For example, if someone has the `Kick Members` permission and wants to use the `kick` command, it doesn't matter whether or not they have the configured Server Moderator role (if one is), yzbot will still allow them to use the command.

### **Permission System**

Yzbot has a permission system, which is divided into five levels. Each level inherits all permissions from the level below and gets some extra permissions:

**Level 0 (User)** - This is your average bot user or server member. They can do plenty of things, but they will not be able to use moderation or administration commands.&#x20;

**Level 1 (Server Moderator)** - This permission level is intended for general server moderators. People with this permission level can kick, ban, mute, warn and much more. However, they cannot configure the bot's settings in the server. That job is for people at...

**Level 2 (Server Admin)** - These people get to moderate the server and configure the bot (it is mostly people at this permission level that this GitBook targets!)

**Level 3 (Server Owner)**  - The server owner is automatically assigned to this permission level. At the moment, I have not found a use for this permission level, but I will in the future.

**Level 4 (Yzbot Support Team Member)** - This permission level is given to my bot's support staff so that they can easily diagnose issues without having to mess around with permissions. This level also grants them the ability to reply to contact requests.

**Level 5 (Yzbot Developer)** - Me! Obviously, as the developer, I get the highest permission level, granting me some extra spooky secret commands.

### Managing Moderator and Admin Roles

Permission levels 1 and 2 are not assigned to anyone, or any role, by default. In order for people to have those permission levels, you must configure moderator and admin roles.

**Moderator**

In order to set up a moderator role, you need to type `;managepermroles mod <role name>`, and replace \<role name> with whatever role name that you want. Anyone with this role is now permission level 1 in yzbot's permission system. You can use the same command to change the Moderator role too.

![](https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M4KatQDRTrJiR879Zp_%2F-M4Ko2AyKE2pukO81gnm%2Fimage.png?alt=media\&token=77dacf7d-2bb8-4519-8a89-5d4eaa9a305d)

If you no longer want members of that role to be server moderators, simply type `;managepermroles delete mod` and it will delete the Moderator role setting.

<div align="left"><img src="https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M4KatQDRTrJiR879Zp_%2F-M4KoI7EgFiTzhQCla0s%2Fimage.png?alt=media&#x26;token=eac95abc-2d66-491b-86d7-b7839d29a568" alt=""></div>

**Admin**

Setting up the Admin role works exactly the same way. Just type `;managepermroles admin <role name>` this time, replacing \<role name> with the name of the role you want to have as the Admins. These people are now permission level 2 in yzbot's permission system. You can use the same command to edit the Admin role setting too.

![](https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M4KatQDRTrJiR879Zp_%2F-M4Kovqk5qZEOHI7T8mx%2Fimage.png?alt=media\&token=56d4b413-4371-4948-be4c-dd4ce05961e5)

In the same vein, if you no longer want the members of the role that you set as the Admin role to have Admin permissions with yzbot, simply type `;managepermroles delete admin` and the Admin role setting will be removed.

<div align="left"><img src="https://2214197333-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4KHeDkm4oqokce8Df5%2F-M4KatQDRTrJiR879Zp_%2F-M4KpWB0AhjcZTUV-GzD%2Fimage.png?alt=media&#x26;token=a00abe97-daee-42b8-8147-39fd523e1a8a" alt=""></div>
