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_invitekick_membersban_membersadministratormanage_channelsmanage_guildadd_reactionsview_audit_logpriority_speakerstreamview_channelread_messagessend_messagessend_tts_messagesmanage_messagesembed_linksattach_filesread_message_historymention_everyoneexternal_emojisuse_external_emojisview_guild_insightsconnectspeakmute_membersdeafen_membersmove_membersuse_voice_activationchange_nicknamemanage_nicknamesmanage_rolesmanage_permissionsmanage_webhooksmanage_emojismanage_emojis_and_stickersuse_slash_commandsuse_application_commandsrequest_to_speakmanage_eventsmanage_threadscreate_public_threadscreate_private_threadsexternal_stickersuse_external_stickerssend_messages_in_threadsstart_embedded_activitiesmoderate_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_invitekick_membersban_membersadministratormanage_channelsmanage_guildadd_reactionsview_audit_logpriority_speakerstreamview_channelread_messagessend_messagessend_tts_messagesmanage_messagesembed_linksattach_filesread_message_historymention_everyoneexternal_emojisuse_external_emojisview_guild_insightsconnectspeakmute_membersdeafen_membersmove_membersuse_voice_activationchange_nicknamemanage_nicknamesmanage_rolesmanage_permissionsmanage_webhooksmanage_emojismanage_emojis_and_stickersuse_slash_commandsuse_application_commandsrequest_to_speakmanage_eventsmanage_threadscreate_public_threadscreate_private_threadsexternal_stickersuse_external_stickerssend_messages_in_threadsstart_embedded_activitiesmoderate_members
pekora.all_channel
create_instant_invitemanage_channelsadd_reactionspriority_speakerstreamview_channelsend_messagessend_tts_messagesmanage_messagesembed_linksattach_filesread_message_historymention_everyoneexternal_emojisconnectspeakmute_membersdeafen_membersmove_membersuse_voice_activationmanage_rolesmanage_webhooksuse_slash_commandsrequest_to_speakmanage_threadscreate_public_threadscreate_private_threadsexternal_stickerssend_messages_in_threads
pekora.general
manage_channelsmanage_guildview_audit_logview_channelview_guild_insightsmanage_rolesmanage_webhooksmanage_emojis
pekora.membership
create_instant_invitekick_membersban_memberschange_nicknamemanage_nicknames
pekora.none
No permissions.
pekora.stage
request_to_speak
pekora.stage_moderator
mute_membersmove_membersrequest_to_speak
pekora.text
add_reactionssend_messagessend_tts_messagesmanage_messagesembed_linksattach_filesread_message_historymention_everyoneexternal_emojisuse_slash_commandsmanage_threadscreate_public_threadscreate_private_threadsexternal_stickerssend_messages_in_threads
pekora.voice
priority_speakerstreamconnectspeakmute_membersdeafen_membersmove_membersuse_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". ↩