hikari.permissions#
Bitfield of permissions.
Module Contents#
- class hikari.permissions.Permissions[source]#
Bases:
hikari.internal.enums.Flag
Represents the permissions available in a given channel or guild.
This enum is an
enum.IntFlag
, which means that it is stored as a bit field where each bit represents a permission. You can use bitwise operators to efficiently manipulate and compare permissions.Examples
You can create an enum which combines multiple permissions using the bitwise OR operator (
|
):my_perms = Permissions.MANAGE_CHANNELS | Permissions.MANAGE_GUILD required_perms = ( Permissions.CREATE_INSTANT_INVITE | Permissions.KICK_MEMBERS | Permissions.BAN_MEMBERS | Permissions.MANAGE_GUILD )
To find the intersection of two sets of permissions, use the bitwise AND operator (
&
) between them. By then applying the==
operator, you can check if all permissions from one set are present in another set. This is useful, for instance, for checking if a user has all the required permissionsif (my_perms & required_perms) == required_perms: print("I have all of the required permissions!") else: print("I am missing at least one required permission!")
To determine which permissions from one set are missing from another, you can use the bitwise equivalent of the set difference operation, as shown below. This can be used, for instance, to find which of a user’s permissions are missing from the required permissions.
missing_perms = ~my_perms & required_perms if (missing_perms): print(f"I'm missing these permissions: {missing_perms}")
Lastly, if you need all the permissions from a set except for a few, you can use the bitwise NOT operator (
).
# All permissions except ADMINISTRATOR. my_perms = ~Permissions.ADMINISTRATOR
- ADMINISTRATOR[source]#
Allows all permissions and bypasses channel permission overwrites.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- BAN_MEMBERS[source]#
Allows banning members.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- KICK_MEMBERS[source]#
Allows kicking members.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MANAGE_CHANNELS[source]#
Allows management and editing of channels.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MANAGE_EMOJIS_AND_STICKERS[source]#
Allows management and editing of emojis and stickers.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MANAGE_GUILD[source]#
Allows management and editing of the guild.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MANAGE_MESSAGES[source]#
Allows for deletion of other users messages.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MANAGE_ROLES[source]#
Allows management and editing of roles.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MANAGE_THREADS[source]#
Allows for deleting and archiving threads, and viewing all private threads.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MANAGE_WEBHOOKS[source]#
Allows management and editing of webhooks.
Note
In guilds with server-wide 2FA enabled this permission can only be used by users who have two-factor authentication enabled on their account (or their owner’s account in the case of bot users) and the guild owner.
- MENTION_ROLES[source]#
Allows for using the
@everyone
,@here
and@role
(regardless of its mention status) tag to notify users.
- REQUEST_TO_SPEAK[source]#
Allows for requesting to speak in stage channels.
Warning
This permissions is currently defined as being “under active development” by Discord meaning that “it may be changed or removed” without warning.
- START_EMBEDDED_ACTIVITIES[source]#
Allows for launching activities (applications with the
EMBEDDED
flag) in a voice channel.
- USE_APPLICATION_COMMANDS[source]#
Allows for using the application commands of guild integrations within a text channel.
- VIEW_CHANNEL[source]#
Allows guild members to view a channel, which includes reading messages in text channels.
- classmethod all_permissions()[source]#
Get an instance of
Permissions
with all the known permissions.- Returns:
Permissions
A permissions instance with all the known permissions.