Permissions¶
This section documents everything related to permissions - a way of granting (or limiting) certain entities access to certain information/actions.
Data Classes¶
Permissions¶
- add_reactions
- administrator
- attach_files
- ban_members
- change_nickname
- connect
- create_events
- create_forum_threads
- create_guild_expressions
- create_instant_invite
- create_private_threads
- create_public_threads
- deafen_members
- embed_links
- external_emojis
- external_stickers
- kick_members
- manage_channels
- manage_emojis
- manage_emojis_and_stickers
- manage_events
- manage_guild
- manage_guild_expressions
- manage_messages
- manage_nicknames
- manage_permissions
- manage_roles
- manage_threads
- manage_webhooks
- mention_everyone
- moderate_members
- move_members
- mute_members
- priority_speaker
- read_message_history
- read_messages
- request_to_speak
- send_messages
- send_messages_in_threads
- send_polls
- send_tts_messages
- send_voice_messages
- speak
- start_embedded_activities
- stream
- use_application_commands
- use_embedded_activities
- use_external_apps
- use_external_emojis
- use_external_sounds
- use_external_stickers
- use_slash_commands
- use_soundboard
- use_voice_activation
- value
- view_audit_log
- view_channel
- view_creator_monetization_analytics
- view_guild_insights
- clsPermissions.advanced
- clsPermissions.all
- clsPermissions.all_channel
- clsPermissions.apps
- clsPermissions.events
- clsPermissions.general
- clsPermissions.membership
- clsPermissions.none
- clsPermissions.private_channel
- clsPermissions.stage
- clsPermissions.stage_moderator
- clsPermissions.text
- clsPermissions.voice
- defis_strict_subset
- defis_strict_superset
- defis_subset
- defis_superset
- defupdate
- class disnake.Permissions(permissions=0, **kwargs)[source]¶
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
To construct an object you can pass keyword arguments denoting the permissions to enable or disable. Arguments are applied in order, which notably also means that supplying a flag and its alias will make whatever comes last overwrite the first one; as an example,
Permissions(external_emojis=True, use_external_emojis=False)
andPermissions(use_external_emojis=True, external_emojis=False)
both result in the same permissions value (0
).Changed in version 1.3: You can now use keyword arguments to initialize
Permissions
similar toupdate()
.- x == y
Checks if two permissions are equal.
- x != y
Checks if two permissions are not equal.
- x <= y
Checks if a permission is a subset of another permission.
- x >= y
Checks if a permission is a superset of another permission.
- x < y
Checks if a permission is a strict subset of another permission.
- x > y
Checks if a permission is a strict superset of another permission.
- x | y, x |= y
Returns a new Permissions instance with all enabled permissions from both x and y. (Using
|=
will update in place).New in version 2.6.
- x & y, x &= y
Returns a new Permissions instance with only permissions enabled on both x and y. (Using
&=
will update in place).New in version 2.6.
- x ^ y, x ^= y
Returns a new Permissions instance with only permissions enabled on one of x or y, but not both. (Using
^=
will update in place).New in version 2.6.
- ~x
Returns a new Permissions instance with all permissions from x inverted.
New in version 2.6.
- hash(x)
Return the permission’s hash.
- iter(x)
Returns an iterator of
(perm, value)
pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
Additionally supported are a few operations on class attributes.
- Permissions.y | Permissions.z, Permissions(y=True) | Permissions.z
Returns a Permissions instance with all provided permissions enabled.
New in version 2.6.
- ~Permissions.y
Returns a Permissions instance with all permissions except
y
inverted from their default value.New in version 2.6.
- value¶
The raw value. This value is a bit array field of a 53-bit integer representing the currently available permissions. You should query permissions via the properties rather than using this raw value.
- Type:
- is_strict_subset(other)[source]¶
Returns
True
if the permissions on self are a strict subset of those on other.
- is_strict_superset(other)[source]¶
Returns
True
if the permissions on self are a strict superset of those on other.
- classmethod none()[source]¶
A factory method that creates a
Permissions
with all permissions set toFalse
.
- classmethod all()[source]¶
A factory method that creates a
Permissions
with all permissions set toTrue
.
- classmethod all_channel()[source]¶
A
Permissions
with all channel-specific permissions set toTrue
and the guild-specific ones set toFalse
. The guild-specific permissions are currently:Changed in version 1.7: Added
stream
,priority_speaker
anduse_slash_commands
permissions.Changed in version 2.0: Added
create_public_threads
,create_private_threads
,manage_threads
,use_external_stickers
,send_messages_in_threads
andrequest_to_speak
permissions.Changed in version 2.3: Added
use_embedded_activities
permission.Changed in version 2.9: Added
use_soundboard
andsend_voice_messages
permissions.Changed in version 2.10: Added
create_events
permission.
- classmethod general()[source]¶
A factory method that creates a
Permissions
with all “General” permissions from the official Discord UI set toTrue
.Changed in version 1.7: Permission
read_messages
is now included in the general permissions, but permissionsadministrator
,create_instant_invite
,kick_members
,ban_members
,change_nickname
andmanage_nicknames
are no longer part of the general permissions.Changed in version 2.9: Added
view_creator_monetization_analytics
permission.Changed in version 2.10: Added
create_guild_expressions
permission.
- classmethod membership()[source]¶
A factory method that creates a
Permissions
with all “Membership” permissions from the official Discord UI set toTrue
.New in version 1.7.
Changed in version 2.3: Added
moderate_members
permission.
- classmethod text()[source]¶
A factory method that creates a
Permissions
with all “Text” permissions from the official Discord UI set toTrue
.Changed in version 1.7: Permission
read_messages
is no longer part of the text permissions. Addeduse_slash_commands
permission.Changed in version 2.0: Added
create_public_threads
,create_private_threads
,manage_threads
,send_messages_in_threads
anduse_external_stickers
permissions.Changed in version 2.9: Added
send_voice_messages
permission.Changed in version 2.10: Moved
use_application_commands
permission toapps
.
- classmethod voice()[source]¶
A factory method that creates a
Permissions
with all “Voice” permissions from the official Discord UI set toTrue
.Changed in version 2.3: Added
use_embedded_activities
permission.Changed in version 2.9: Added
use_soundboard
anduse_external_sounds
permissions.Changed in version 2.10: Moved
use_embedded_activities
permission toapps
.
- classmethod stage()[source]¶
A factory method that creates a
Permissions
with all “Stage Channel” permissions from the official Discord UI set toTrue
.New in version 1.7.
- classmethod stage_moderator()[source]¶
A factory method that creates a
Permissions
with all “Stage Moderator” permissions from the official Discord UI set toTrue
.New in version 1.7.
- classmethod apps()[source]¶
A factory method that creates a
Permissions
with all “Apps” permissions from the official Discord UI set toTrue
.New in version 2.10.
- classmethod events()[source]¶
A factory method that creates a
Permissions
with all “Events” permissions from the official Discord UI set toTrue
.New in version 2.4.
Changed in version 2.10: Added
create_events
permission.
- classmethod advanced()[source]¶
A factory method that creates a
Permissions
with all “Advanced” permissions from the official Discord UI set toTrue
.New in version 1.7.
- classmethod private_channel()[source]¶
A factory method that creates a
Permissions
with the best representation of a PrivateChannel’s permissions.This exists to maintain compatibility with other channel types.
This is equivalent to
Permissions.text()
withview_channel
with the following set to False:send_tts_messages
: You cannot send TTS messages in a DM.manage_messages
: You cannot delete others messages in a DM.manage_threads
: You cannot manage threads in a DM.send_messages_in_threads
: You cannot make threads in a DM.create_public_threads
: You cannot make public threads in a DM.create_private_threads
: You cannot make private threads in a DM.
New in version 2.4.
- update(**kwargs)[source]¶
Bulk updates this permission object.
Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored.
Arguments are applied in order, similar to the constructor.
- Parameters:
**kwargs – A list of key/value pairs to bulk update permissions with.
- administrator¶
Returns
True
if a user is an administrator. This role overrides all other permissions.This also bypasses all channel-specific overrides.
- Type:
- manage_channels¶
Returns
True
if a user can edit, delete, or create channels in the guild.This also corresponds to the “Manage Channel” channel-specific override.
- Type:
- view_channel¶
Returns
True
if a user can view all or specific channels.New in version 1.3.
Changed in version 2.4:
read_messages
is now an alias ofview_channel
.- Type:
- read_messages¶
An alias for
view_channel
.- Type:
- send_messages¶
Returns
True
if a user can send messages from all or specific text channels and create threads in forum/media channels.- Type:
- create_forum_threads¶
An alias for
send_messages
.New in version 2.5.
- Type:
- send_tts_messages¶
Returns
True
if a user can send TTS messages from all or specific text channels.- Type:
- manage_messages¶
Returns
True
if a user can delete or pin messages in a text channel.Note
Note that there are currently no ways to edit other people’s messages.
- Type:
- embed_links¶
Returns
True
if a user’s messages will automatically be embedded by Discord.- Type:
- read_message_history¶
Returns
True
if a user can read a text channel’s previous messages.- Type:
- mention_everyone¶
Returns
True
if a user’s @everyone or @here will mention everyone in the text channel.- Type:
- use_external_emojis¶
An alias for
external_emojis
.New in version 1.3.
- Type:
- view_guild_insights¶
Returns
True
if a user can view the guild’s insights.New in version 1.3.
- Type:
- manage_roles¶
Returns
True
if a user can create or edit roles less than their role’s position.This also corresponds to the “Manage Permissions” channel-specific override.
- Type:
- manage_permissions¶
An alias for
manage_roles
.New in version 1.3.
- Type:
- manage_guild_expressions¶
Returns
True
if a user can edit or delete emojis, stickers, and soundboard sounds created by all users.See also
create_guild_expressions
.New in version 2.9.
- Type:
- manage_emojis¶
An alias for
manage_guild_expressions
.- Type:
- manage_emojis_and_stickers¶
An alias for
manage_guild_expressions
.New in version 2.0.
- Type:
- use_application_commands¶
Returns
True
if a user can use application commands.New in version 2.6.
- Type:
- use_slash_commands¶
An alias for
use_application_commands
.New in version 1.7.
Changed in version 2.6: Became an alias for
use_application_commands
.- Type:
- request_to_speak¶
Returns
True
if a user can request to speak in a stage channel.New in version 1.7.
- Type:
- manage_events¶
Returns
True
if a user can edit or delete guild scheduled events created by all users.See also
create_events
.New in version 2.0.
- Type:
- create_public_threads¶
Returns
True
if a user can create public threads.New in version 2.0.
- Type:
- create_private_threads¶
Returns
True
if a user can create private threads.New in version 2.0.
- Type:
- external_stickers¶
Returns
True
if a user can use stickers from other guilds.New in version 2.0.
- Type:
- use_external_stickers¶
An alias for
external_stickers
.New in version 2.0.
- Type:
- send_messages_in_threads¶
Returns
True
if a user can send messages in threads.New in version 2.0.
- Type:
- use_embedded_activities¶
Returns
True
if a user can use activities (applications with theembedded
flag) in a voice channel.New in version 2.6.
- Type:
- start_embedded_activities¶
An alias for
use_embedded_activities
.New in version 2.3.
Changed in version 2.6: Became an alias for
use_embedded_activities
.- Type:
- moderate_members¶
Returns
True
if a user can perform limited moderation actions, such as timeouts or editing members’ flags.New in version 2.3.
- Type:
- view_creator_monetization_analytics¶
Returns
True
if a user can view role subscription insights.New in version 2.9.
- Type:
- use_soundboard¶
Returns
True
if a user can use the soundboard in voice channels.New in version 2.9.
- Type:
- create_guild_expressions¶
Returns
True
if a user can create emojis, stickers, and soundboard sounds, as well as edit and delete the ones they created.See also
manage_guild_expressions
.New in version 2.10.
- Type:
- create_events¶
Returns
True
if a user can create guild scheduled events, as well as edit and delete the ones they created.See also
manage_events
.New in version 2.10.
- Type:
- use_external_sounds¶
Returns
True
if a user can use custom soundboard sounds from other guilds.New in version 2.9.
- Type:
- use_external_apps¶
Returns
True
if a user’s apps can send public responses.If disabled, users can still use their user-installed applications, but the responses will be forced ephemeral (i.e. only visible to them). Only applies to user-installed apps that are not also installed to the guild.
New in version 2.10.
- Type:
PermissionOverwrite¶
- clsPermissionOverwrite.from_pair
- defis_empty
- defpair
- defupdate
- class disnake.PermissionOverwrite(**kwargs)[source]¶
A type that is used to represent a channel specific permission.
Unlike a regular
Permissions
, the default value of a permission is equivalent toNone
and notFalse
. Setting a value toFalse
is explicitly denying that permission, while setting a value toTrue
is explicitly allowing that permission.The values supported by this are the same as
Permissions
with the added possibility of it being set toNone
.- x == y
Checks if two overwrites are equal.
- x != y
Checks if two overwrites are not equal.
- iter(x)
Returns an iterator of
(perm, value)
pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
- Parameters:
**kwargs – Set the value of permissions by their name.
- pair()[source]¶
Tuple[
Permissions
,Permissions
]: Returns the (allow, deny) pair from this overwrite.
- classmethod from_pair(allow, deny)[source]¶
Creates an overwrite from an allow/deny pair of
Permissions
.
- is_empty()[source]¶
Checks if the permission overwrite is currently empty.
An empty permission overwrite is one that has no overwrites set to
True
orFalse
.- Returns:
Indicates if the overwrite is empty.
- Return type:
- update(**kwargs)[source]¶
Bulk updates this permission overwrite object.
Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored.
- Parameters:
**kwargs – A list of key/value pairs to bulk update with.