Calculating Permissions¶
You can calculate permissions with pekora calc
. You already saw an example of this in the introduction.
Note
By the way, these animated command prompts are used throughout the documentation. The formatting might look off if you're on a mobile device. Sorry!
pekora calc
takes a special kind of math-like expression called a Pekora expression. Pekora expressions can
contain three types of values: permission values, operators, and comparators.
Tip
You don't have to quote a Pekora expresssion that only contains one value. pekora calc "3072"
, for instance,
is just as valid as pekora calc 3072
.
Permission values¶
A permission value is any value that represents a Discord permission. Permision values can be Discord permission flags, integers, or Pekora permission groups.
Discord permission flags¶
A Discord permission flag is a snake_case
string that represents a single permission. read_messages
and
send_messages
, as you've surely realized by now, are examples of Discord permission flags. Other flags include
add_reactions
, attach_files
, and manage_messages
. If you're acquainted with Discord's permissions system (as
any Pekora user should be!), the names of these flags should be ringing bells.
Supported flags
Pekora supports all flags listed below. Pekora tries to maintain parity with Discord in this regard; if you notice something's missing, open an issue.
create_instant_invite
kick_members
ban_members
administrator
manage_channels
manage_guild
add_reactions
view_audit_log
priority_speaker
stream
view_channel
read_messages
send_messages
send_tts_messages
manage_messages
embed_links
attach_files
read_message_history
mention_everyone
external_emojis
use_external_emojis
view_guild_insights
connect
speak
mute_members
deafen_members
move_members
use_voice_activation
change_nickname
manage_nicknames
manage_roles
manage_permissions
manage_webhooks
manage_emojis
manage_emojis_and_stickers
use_slash_commands
use_application_commands
request_to_speak
manage_events
manage_threads
create_public_threads
create_private_threads
external_stickers
use_external_stickers
send_messages_in_threads
start_embedded_activities
moderate_members
Integers¶
Integers are, well, integers. Like we covered in the introduction, any set of Discord permissions can be represented as an integer. You can use these integers in Pekora expressions.
$ pekora calc "1024 + 2048"
<font color="#97C981">╭─ Result ───────────────────╮</font>
<font color="#97C981">│ <font color="#5CB8C2">3072</font> │</font>
<font color="#97C981">╰────────────────────────────╯</font>
$ pekora calc "3072 + embed_links + attach_files"
<font color="#97C981">╭─ Result ───────────────────╮</font>
<font color="#97C981">│ <font color="#5CB8C2">52224</font> │</font>
<font color="#97C981">╰────────────────────────────╯</font>
Pekora permission groups¶
Pekora permission groups are shorthands for predefined sets of permissions. You can use them in Pekora expressions
with the syntax pekora.<group>
, where <group>
is the name of the desired Pekora permission group.
$ pekora calc "pekora.text"
<font color="#97C981">╭─ Result ───────────────────╮</font>
<font color="#97C981">│ <font color="#5CB8C2">534723950656</font> │</font>
<font color="#97C981">╰────────────────────────────╯</font>
$ pekora calc "(pekora.text - 3072) + create_instant_invite"
<font color="#97C981">╭─ Result ───────────────────╮</font>
<font color="#97C981">│ <font color="#5CB8C2">534723947585</font> │</font>
<font color="#97C981">╰────────────────────────────╯</font>
A handful of Pekora permission groups exist. You can see them all and the permissions they include by expanding the dropdown below.
Technical Note
Pekora uses Pycord for permission resolution. Each Pekora permission group corresponds to
a method of the discord.Permissions
class.
All Pekora permission groups
pekora.advanced
-
administrator
pekora.all
create_instant_invite
kick_members
ban_members
administrator
manage_channels
manage_guild
add_reactions
view_audit_log
priority_speaker
stream
view_channel
read_messages
send_messages
send_tts_messages
manage_messages
embed_links
attach_files
read_message_history
mention_everyone
external_emojis
use_external_emojis
view_guild_insights
connect
speak
mute_members
deafen_members
move_members
use_voice_activation
change_nickname
manage_nicknames
manage_roles
manage_permissions
manage_webhooks
manage_emojis
manage_emojis_and_stickers
use_slash_commands
use_application_commands
request_to_speak
manage_events
manage_threads
create_public_threads
create_private_threads
external_stickers
use_external_stickers
send_messages_in_threads
start_embedded_activities
moderate_members
pekora.all_channel
create_instant_invite
manage_channels
add_reactions
priority_speaker
stream
view_channel
send_messages
send_tts_messages
manage_messages
embed_links
attach_files
read_message_history
mention_everyone
external_emojis
connect
speak
mute_members
deafen_members
move_members
use_voice_activation
manage_roles
manage_webhooks
use_slash_commands
request_to_speak
manage_threads
create_public_threads
create_private_threads
external_stickers
send_messages_in_threads
pekora.general
manage_channels
manage_guild
view_audit_log
view_channel
view_guild_insights
manage_roles
manage_webhooks
manage_emojis
pekora.membership
create_instant_invite
kick_members
ban_members
change_nickname
manage_nicknames
pekora.none
No permissions.
pekora.stage
request_to_speak
pekora.stage_moderator
mute_members
move_members
request_to_speak
pekora.text
add_reactions
send_messages
send_tts_messages
manage_messages
embed_links
attach_files
read_message_history
mention_everyone
external_emojis
use_slash_commands
manage_threads
create_public_threads
create_private_threads
external_stickers
send_messages_in_threads
pekora.voice
priority_speaker
stream
connect
speak
mute_members
deafen_members
move_members
use_voice_activation
Operators¶
Pekora, being a calculator, naturally supports a range of mathematical operations.
Addition (+
)¶
The addition operator adds two permission values together. Given the expression \(A + B\), the resulting value will represent all permissions that are in either \(A\) or \(B\).
Tip
You can also use the union (|
) operator.
Subtraction (-
)¶
The subtraction operator calculates the difference between two permission values. Given the expression \(A -B\), the resulting value will represent all permissions that are in \(A\) but not in \(B\).
Intersection (&
)¶
The intersection operator calculates the intersection1 between two permission values. Given the expression \(A \& B\), the resulting value will represent all permissions that are in both \(A\) and \(B\).
Inversion (~
)¶
The inversion operator inverts a permission value. Given the expression \(\sim A\), the resulting value will represent all permissions that are not in \(A\).
Parentheses (()
)¶
Pekora supports the use of parantheses to group parts of an expression together. They work exactly as you would expect.
Unsupported operations
Multiplication (*
), division (/
), modulo (%
), exponentiation (**
), matrix multiplication (@
), and
assignment (=
) operators are not supported.
Comparators¶
Pekora supports the use of standard mathematical comparators2 to compare permission values with each other.
Info
So far, you've only seen Pekora expressions evalute to integers. However, Pekora expressions with comparators
evaluate to either True
or False
.
Equality (==
)¶
The equality operator checks if two permission values are equal. Given the expression \(A == B\), the resulting value will
be True
if the permissions in \(A\) are the same as those in \(B\), and False
otherwise.
Inequality (!=
)¶
The inequality operator checks if two permission values are not equal. Given the expression \(A \neq B\), the resulting
value will be True
if the permissions in \(A\) are different than those in \(B\) and False
otherwise.
Greater Than (>
)¶
The greater than operator checks if one permission value is a strict superset of another. Given the expression \(A > B\),
the resulting value will be True
if \(A\) contains all the permissions in \(B\) and at least one permission not in \(B\),
and False
otherwise.
Greater Than or Equal To (>=
)¶
Given the expression \(A \geq B\), the resulting value will be True
if either \(A > B\) or \(A == B\) are
True
, and False
otherwise.
Less Than (<
)¶
The less than operator checks if one permission value is a strict subset of another. Given the expression \(A < B\),
the resulting value will be True
if all permissions in \(A\) are also in \(B\) and \(B\) contains at least one permission
not in \(A\), and False
otherwise.
Less Than or Equal To (<=
)¶
Given the expression \(A \leq B\), the resulting value will be True
if either \(A < B\) or \(A == B\) are
True
, and False
otherwise.
Combining comparators
You can use multiple <
, >
, <=
, and >=
comparators in a single Pekora expression (e.g. \(A < B \leq C\)).
There's no limit to the number of comparators you can use.
Equality comparators can't be combined
If you use an equality (==
) or inequality (!=
) comparator in a Pekora expression, it must be the only
comparator in that expression.
-
These are technically called "relational operators". Pekora refers to them as "comparators". ↩