Permissions

Restrict certain commands to specific users

What is a Permission

A Permission level restricts a command to be used only by a certain group of users or an individual. For example, restricting users from restarting the bot but only allowing the owner to do so. Permission levels can come very handy to bot developers to restrict the use of commands to certain people. You can make as many permission levels as you want and assign certain people to those levels.

Permissions can be restricted to certain permission levels. In addition, you can choose to disable a Permission file easily.

Below you will find out the default, pre-made Permissions that already exist within Spark. You will also find out how to create a Permission file, as well as the methods and properties that may be used to help you with creating a Permission file.

Default Permissions

Important
Listed below are the default Permissions that already exist within Spark that you may use. However, you also have the option to override them and create your own.

  • Member Level 0


  • Owner Level 10

Constructor

To create a Permission file, you will need to create a new ".js" file inside the permissions folder.

Below is an example of how a default Permission file is structured:

var Spark = require("sparkbots")
const Permission = Spark.permission("Member")

Permission.setLevel(0)

Permission.code = (client, message) => {

    return true // Blocks execution
    return false // Completes execution
                
}
module.exports = Permission;
        

Methods

  • setLevel( Number )

    • Number

      Type number
  • .disable()

Properties

  • level

    Type integer
    Required
  • This can also be set by: .setLevel()