Skip to content

PermCalc

Martin Persson edited this page Aug 22, 2019 · 1 revision

PermCalc

PermCalc is a sub-package of DiscordConsole you can use in your own applications. It's a simple Discord permission calculator, hence the name: PermCalc; Permission Calculator.

Typial usage

As a general user of DiscordConsole you will probably come across PermCalc with the command "permcalc" in the console.

PermCalc is built into DiscordConsole. When the command is run you will start PermCalc. Here you can select which permissions you want DiscordConsole to calculate for you. Press space to toggle permissions. Press Esc or Q to exit.

When exiting you will recieve a number. This is the permission number. You can use the permission number when editing a role to make to role inherit the permissions that you entered.

> permcalc
=> 8
roleedit 286474580430815232 perms 8
=> ...

8, in this case, means the permission "Administrator".

API

There is also a PermCalc API. It's simple to use:

perm, err := permcalc.Show()

perm is the permission as an integer. See earlier example for more info. err is any error encountered during the process.

You can also pre-set permissions:

pm := permcalc.PermCalc{
	Perm: 8,
}
err := pm.Show()
perm := pm.Perm // Updated by Show()

... or even make it read-only!

pm := permcalc.PermCalc{
	ReadOnly: true,
}
err := pm.Show()
Clone this wiki locally