Skip to content

Permissions

Zach | xDest edited this page Feb 28, 2018 · 2 revisions

Permissions

This page is to explain how permissions work, how the default permissions system works, and how to use both. Permissions are specifically for interactions with the bot, and not with your server.

How permissions work

For ComBot, permissions work in a hierarchy. Providing someone with the "*" permission gives them all rights (for bot related functions, not to your server). The bot comes with two default commands, restart and shutdown. The permission system works as follows:

  • The restart command requires the bot.restart permission
  • The shutdown command requires the bot.shutdown permission

Assigning someone (or some role) the bot permission will not allow them to do anything

Assigning someone (or some role...) the bot.restart allows them to restart the bot, but not shutdown

Assigning the bot.shutdown permission allows them to shutdown the bot, but not restart

Assigning the bot.* permission allows them to both restart and shutdown the bot

Assigning the * permission allows any command.

As you can see, permissions cascade downwards. In addition, they don't only work with commands, they can work with any function as long as the plugin creator checks for it. Permissions are enforced by plugin creators, not the bot.

How the default permission system works

The bot comes with a built in manager to function as the default system for setting up permissions with users, roles, and @everyone. You can find its file in ~/ComBot/settings/ as permissions.json. The JSON file includes a single object with three components, an array of roles, an array of users, and an array called everyone. This is an example of a working permissions.json file:

{
    users:[
        {userId:"878738274839274837",permissions:[
            "*"
        ]}
    ],
    roles:[
        {roleName:"moderator",permissions:[
            "bot.restart"
        ]},
        {roleName:"admin",permissions:[
            "bot.*"
        ]}
    ],
    everyone:[
        ""
    ]
}

In this file you can see that one user is given the "*" permission, giving them access to all bot features. You can also see that two roles are given permissions: Moderator is given permission to restart the bot, and Admin is given permission to do anything under the bot. permission. You can add and remove from these as you like.

Clone this wiki locally