hikari.permissions
#
Bitfield of permissions.
Permissions #
Bases: 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 class-attribute
instance-attribute
#
ADD_REACTIONS = 1 << 6
Allows for the addition of reactions to messages.
ADMINISTRATOR class-attribute
instance-attribute
#
ADMINISTRATOR = 1 << 3
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 class-attribute
instance-attribute
#
ATTACH_FILES = 1 << 15
Allows for uploading images and files.
BAN_MEMBERS class-attribute
instance-attribute
#
BAN_MEMBERS = 1 << 2
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 class-attribute
instance-attribute
#
CHANGE_NICKNAME = 1 << 26
Allows for modification of own nickname.
CONNECT class-attribute
instance-attribute
#
CONNECT = 1 << 20
Allows for joining of a voice channel.
CREATE_EVENTS class-attribute
instance-attribute
#
CREATE_EVENTS = 1 << 44
Allows to create scheduled events.
Additionally, it allows to edit and manage those created by the user.
CREATE_GUILD_EXPRESSIONS class-attribute
instance-attribute
#
CREATE_GUILD_EXPRESSIONS = 1 << 43
Allows to create guild emojis, stickers and soundboard sounds.
Additionally, it allows to edit and manage those created by the user.
CREATE_INSTANT_INVITE class-attribute
instance-attribute
#
CREATE_INSTANT_INVITE = 1 << 0
Allows creation of instant invites.
CREATE_PRIVATE_THREADS class-attribute
instance-attribute
#
CREATE_PRIVATE_THREADS = 1 << 36
Allows for creating private threads.
CREATE_PUBLIC_THREADS class-attribute
instance-attribute
#
CREATE_PUBLIC_THREADS = 1 << 35
Allows for creating threads.
DEAFEN_MEMBERS class-attribute
instance-attribute
#
DEAFEN_MEMBERS = 1 << 23
Allows for deafening of members in a voice channel.
EMBED_LINKS class-attribute
instance-attribute
#
EMBED_LINKS = 1 << 14
Links sent by users with this permission will be auto-embedded.
KICK_MEMBERS class-attribute
instance-attribute
#
KICK_MEMBERS = 1 << 1
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 class-attribute
instance-attribute
#
MANAGE_CHANNELS = 1 << 4
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_EVENTS class-attribute
instance-attribute
#
MANAGE_EVENTS = 1 << 33
Allows for management and editing scheduled events
MANAGE_GUILD class-attribute
instance-attribute
#
MANAGE_GUILD = 1 << 5
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_GUILD_EXPRESSIONS class-attribute
instance-attribute
#
MANAGE_GUILD_EXPRESSIONS = 1 << 30
Allows management and editing emojis, stickers and soundboard sounds.
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 class-attribute
instance-attribute
#
MANAGE_MESSAGES = 1 << 13
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 class-attribute
instance-attribute
#
MANAGE_NICKNAMES = 1 << 27
Allows for modification of other users nicknames.
MANAGE_ROLES class-attribute
instance-attribute
#
MANAGE_ROLES = 1 << 28
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 class-attribute
instance-attribute
#
MANAGE_THREADS = 1 << 34
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 class-attribute
instance-attribute
#
MANAGE_WEBHOOKS = 1 << 29
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 class-attribute
instance-attribute
#
MENTION_ROLES = 1 << 17
Allows for using the @everyone
, @here
and @role
(regardless of its mention status) tag to notify users.
MODERATE_MEMBERS class-attribute
instance-attribute
#
MODERATE_MEMBERS = 1 << 40
Allows for timing out members.
MOVE_MEMBERS class-attribute
instance-attribute
#
MOVE_MEMBERS = 1 << 24
Allows for moving of members between voice channels.
MUTE_MEMBERS class-attribute
instance-attribute
#
MUTE_MEMBERS = 1 << 22
Allows for muting members in a voice channel.
PRIORITY_SPEAKER class-attribute
instance-attribute
#
PRIORITY_SPEAKER = 1 << 8
Allows for using priority speaker in a voice channel.
READ_MESSAGE_HISTORY class-attribute
instance-attribute
#
READ_MESSAGE_HISTORY = 1 << 16
Allows for reading of message history.
REQUEST_TO_SPEAK class-attribute
instance-attribute
#
REQUEST_TO_SPEAK = 1 << 32
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 class-attribute
instance-attribute
#
SEND_MESSAGES = 1 << 11
Allows for sending messages in a channel.
SEND_MESSAGES_IN_THREADS class-attribute
instance-attribute
#
SEND_MESSAGES_IN_THREADS = 1 << 38
Allows for sending messages in threads.
SEND_TTS_MESSAGES class-attribute
instance-attribute
#
SEND_TTS_MESSAGES = 1 << 12
Allows for sending of [/tts][] messages.
SEND_VOICE_MESSAGES class-attribute
instance-attribute
#
SEND_VOICE_MESSAGES = 1 << 46
Allows sending voice messages.
START_EMBEDDED_ACTIVITIES class-attribute
instance-attribute
#
START_EMBEDDED_ACTIVITIES = 1 << 39
Allows for launching activities in a voice channel.
Activities are applications that have the hikari.applications.ApplicationFlags.EMBEDDED
flag.
USE_APPLICATION_COMMANDS class-attribute
instance-attribute
#
USE_APPLICATION_COMMANDS = 1 << 31
Allows for using the application commands of guild integrations within a text channel.
USE_EXTERNAL_EMOJIS class-attribute
instance-attribute
#
USE_EXTERNAL_EMOJIS = 1 << 18
Allows the usage of custom emojis from other guilds.
USE_EXTERNAL_SOUNDS class-attribute
instance-attribute
#
USE_EXTERNAL_SOUNDS = 1 << 45
Allows the use of soundboard sounds from external servers.
USE_EXTERNAL_STICKERS class-attribute
instance-attribute
#
USE_EXTERNAL_STICKERS = 1 << 37
Allows the usage of custom stickers from other servers.
USE_SOUNDBOARD class-attribute
instance-attribute
#
USE_SOUNDBOARD = 1 << 42
Allows the use of soundboard in a voice chat.
USE_VOICE_ACTIVITY class-attribute
instance-attribute
#
USE_VOICE_ACTIVITY = 1 << 25
Allows for using voice-activity-detection in a voice channel.
VIEW_AUDIT_LOG class-attribute
instance-attribute
#
VIEW_AUDIT_LOG = 1 << 7
Allows for viewing of audit logs.
VIEW_CHANNEL class-attribute
instance-attribute
#
VIEW_CHANNEL = 1 << 10
Allows guild members to view a channel, which includes reading messages in text channels.
VIEW_CREATOR_MONETIZATION_ANALYTICS class-attribute
instance-attribute
#
VIEW_CREATOR_MONETIZATION_ANALYTICS = 1 << 41
Allows for viewing role subscription insights
VIEW_GUILD_INSIGHTS class-attribute
instance-attribute
#
VIEW_GUILD_INSIGHTS = 1 << 19
Allows the user to view guild insights for eligible guilds.
all_permissions classmethod
#
all_permissions() -> Permissions
Get an instance of hikari.permissions.Permissions
with all the known permissions.
RETURNS | DESCRIPTION |
---|---|
Permissions | A permissions instance with all the known permissions. |