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 permissions

if (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
ADD_REACTIONS[source]#

Allows for the addition of reactions to messages.

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.

ATTACH_FILES[source]#

Allows for uploading images and files.

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.

CHANGE_NICKNAME[source]#

Allows for modification of own nickname.

CONNECT[source]#

Allows for joining of a voice channel.

CREATE_INSTANT_INVITE[source]#

Allows creation of instant invites.

CREATE_PRIVATE_THREADS[source]#

Allows for creating private threads.

CREATE_PUBLIC_THREADS[source]#

Allows for creating threads.

DEAFEN_MEMBERS[source]#

Allows for deafening of members in a voice channel.

Links sent by users with this permission will be auto-embedded.

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_EVENTS[source]#

Allows for creating, editing, and deleting scheduled events

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_NICKNAMES[source]#

Allows for modification of other users nicknames.

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.

MODERATE_MEMBERS[source]#

Allows for timing out members.

MOVE_MEMBERS[source]#

Allows for moving of members between voice channels.

MUTE_MEMBERS[source]#

Allows for muting members in a voice channel.

NONE = 0[source]#

Empty permission.

PRIORITY_SPEAKER[source]#

Allows for using priority speaker in a voice channel.

READ_MESSAGE_HISTORY[source]#

Allows for reading of message history.

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.

SEND_MESSAGES[source]#

Allows for sending messages in a channel.

SEND_MESSAGES_IN_THREADS[source]#

Allows for sending messages in threads.

SEND_TTS_MESSAGES[source]#

Allows for sending of /tts messages.

SPEAK[source]#

Allows for speaking in a voice channel.

START_EMBEDDED_ACTIVITIES[source]#

Allows for launching activities (applications with the EMBEDDED flag) in a voice channel.

STREAM[source]#

Allows the user to go live.

USE_APPLICATION_COMMANDS[source]#

Allows for using the application commands of guild integrations within a text channel.

USE_EXTERNAL_EMOJIS[source]#

Allows the usage of custom emojis from other guilds.

USE_EXTERNAL_STICKERS[source]#

Allows the usage of custom stickers from other servers.

USE_VOICE_ACTIVITY[source]#

Allows for using voice-activity-detection in a voice channel.

VIEW_AUDIT_LOG[source]#

Allows for viewing of audit logs.

VIEW_CHANNEL[source]#

Allows guild members to view a channel, which includes reading messages in text channels.

VIEW_GUILD_INSIGHTS[source]#

Allows the user to view guild insights for eligible guilds.

classmethod all_permissions()[source]#

Get an instance of Permissions with all the known permissions.

Returns:
Permissions

A permissions instance with all the known permissions.