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 (~
).
ADD_REACTIONS
class-attribute
instance-attribute
#
Allows for the addition of reactions to messages.
ADMINISTRATOR
class-attribute
instance-attribute
#
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
#
Allows for uploading images and files.
BAN_MEMBERS
class-attribute
instance-attribute
#
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
#
Allows for modification of own nickname.
CONNECT
class-attribute
instance-attribute
#
Allows for joining of a voice channel.
CREATE_EVENTS
class-attribute
instance-attribute
#
Allows to create scheduled events.
Additionally, it allows to edit and manage those created by the user.
CREATE_GUILD_EXPRESSIONS
class-attribute
instance-attribute
#
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
#
Allows creation of instant invites.
CREATE_PRIVATE_THREADS
class-attribute
instance-attribute
#
Allows for creating private threads.
CREATE_PUBLIC_THREADS
class-attribute
instance-attribute
#
Allows for creating threads.
DEAFEN_MEMBERS
class-attribute
instance-attribute
#
Allows for deafening of members in a voice channel.
EMBED_LINKS
class-attribute
instance-attribute
#
Links sent by users with this permission will be auto-embedded.
KICK_MEMBERS
class-attribute
instance-attribute
#
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
#
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
#
Allows for management and editing scheduled events
MANAGE_GUILD
class-attribute
instance-attribute
#
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
#
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
#
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
#
Allows for modification of other users nicknames.
MANAGE_ROLES
class-attribute
instance-attribute
#
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
#
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
#
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
#
Allows for using the @everyone
, @here
and @role
(regardless of its mention status) tag to notify users.
MODERATE_MEMBERS
class-attribute
instance-attribute
#
Allows for timing out members.
MOVE_MEMBERS
class-attribute
instance-attribute
#
Allows for moving of members between voice channels.
MUTE_MEMBERS
class-attribute
instance-attribute
#
Allows for muting members in a voice channel.
PRIORITY_SPEAKER
class-attribute
instance-attribute
#
Allows for using priority speaker in a voice channel.
READ_MESSAGE_HISTORY
class-attribute
instance-attribute
#
Allows for reading of message history.
REQUEST_TO_SPEAK
class-attribute
instance-attribute
#
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
#
Allows for sending messages in a channel.
SEND_MESSAGES_IN_THREADS
class-attribute
instance-attribute
#
Allows for sending messages in threads.
SEND_TTS_MESSAGES
class-attribute
instance-attribute
#
Allows for sending of [/tts][] messages.
SEND_VOICE_MESSAGES
class-attribute
instance-attribute
#
Allows sending voice messages.
START_EMBEDDED_ACTIVITIES
class-attribute
instance-attribute
#
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
#
Allows for using the application commands of guild integrations within a text channel.
USE_EXTERNAL_EMOJIS
class-attribute
instance-attribute
#
Allows the usage of custom emojis from other guilds.
USE_EXTERNAL_SOUNDS
class-attribute
instance-attribute
#
Allows the use of soundboard sounds from external servers.
USE_EXTERNAL_STICKERS
class-attribute
instance-attribute
#
Allows the usage of custom stickers from other servers.
USE_SOUNDBOARD
class-attribute
instance-attribute
#
Allows the use of soundboard in a voice chat.
USE_VOICE_ACTIVITY
class-attribute
instance-attribute
#
Allows for using voice-activity-detection in a voice channel.
VIEW_AUDIT_LOG
class-attribute
instance-attribute
#
Allows for viewing of audit logs.
VIEW_CHANNEL
class-attribute
instance-attribute
#
Allows guild members to view a channel, which includes reading messages in text channels.
VIEW_CREATOR_MONETIZATION_ANALYTICS
class-attribute
instance-attribute
#
Allows for viewing role subscription insights
VIEW_GUILD_INSIGHTS
class-attribute
instance-attribute
#
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. |
difference
#
Perform a set difference with the other set.
This will return all flags in this set that are not in the other value.
Equivalent to using the subtraction -
operator.
intersection
#
Return a combination of flags that are set for both given values.
Equivalent to using the "AND" &
operator.
is_disjoint
#
is_subset
#
Return whether another set contains this set or not.
Equivalent to using the "in" operator.
is_superset
#
Return whether this set contains another set or not.
none
#
none(*flags: Self) -> bool
Check if none of the given flags are part of this value.
Note
This is essentially the opposite of hikari.internal.enums.Flag.any
.
RETURNS | DESCRIPTION |
---|---|
bool
|
split
#
split() -> Sequence[Self]
Return a list of all defined atomic values for this flag.
Any unrecognised bits will be omitted for brevity.
The result will be a name-sorted typing.Sequence
of each member
symmetric_difference
#
Return a set with the symmetric differences of two flag sets.
Equivalent to using the "XOR" ^
operator.
For a ^ b
, this can be considered the same as (a - b) | (b - a)
.