Permissions

This section documents everything related to permissions - a way of granting (or limiting) certain entities access to certain information/actions.

Data Classes

Permissions

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) and Permissions(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 to update().

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:

int

is_subset(other)[source]

Returns True if self has the same or fewer permissions as other.

is_superset(other)[source]

Returns True if self has the same or more permissions as other.

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 to False.

classmethod all()[source]

A factory method that creates a Permissions with all permissions set to True.

classmethod all_channel()[source]

A Permissions with all channel-specific permissions set to True and the guild-specific ones set to False. The guild-specific permissions are currently:

Changed in version 1.7: Added stream, priority_speaker and use_slash_commands permissions.

Changed in version 2.3: Added use_embedded_activities permission.

Changed in version 2.9: Added use_soundboard and send_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 to True.

Changed in version 1.7: Permission read_messages is now included in the general permissions, but permissions administrator, create_instant_invite, kick_members, ban_members, change_nickname and manage_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 to True.

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 to True.

Changed in version 1.7: Permission read_messages is no longer part of the text permissions. Added use_slash_commands permission.

Changed in version 2.9: Added send_voice_messages permission.

Changed in version 2.10: Moved use_application_commands permission to apps.

classmethod voice()[source]

A factory method that creates a Permissions with all “Voice” permissions from the official Discord UI set to True.

Changed in version 2.3: Added use_embedded_activities permission.

Changed in version 2.9: Added use_soundboard and use_external_sounds permissions.

Changed in version 2.10: Moved use_embedded_activities permission to apps.

classmethod stage()[source]

A factory method that creates a Permissions with all “Stage Channel” permissions from the official Discord UI set to True.

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 to True.

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 to True.

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 to True.

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 to True.

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() with view_channel with the following set to False:

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.

create_instant_invite

Returns True if the user can create instant invites.

Type:

bool

kick_members

Returns True if the user can kick users from the guild.

Type:

bool

ban_members

Returns True if a user can ban users from the guild.

Type:

bool

administrator

Returns True if a user is an administrator. This role overrides all other permissions.

This also bypasses all channel-specific overrides.

Type:

bool

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:

bool

manage_guild

Returns True if a user can edit guild properties.

Type:

bool

add_reactions

Returns True if a user can add reactions to messages.

Type:

bool

view_audit_log

Returns True if a user can view the guild’s audit log.

Type:

bool

priority_speaker

Returns True if a user can be more easily heard while talking.

Type:

bool

stream

Returns True if a user can stream in a voice channel.

Type:

bool

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 of view_channel.

Type:

bool

read_messages

An alias for view_channel.

Type:

bool

send_messages

Returns True if a user can send messages from all or specific text channels and create threads in forum/media channels.

Type:

bool

create_forum_threads

An alias for send_messages.

New in version 2.5.

Type:

bool

send_tts_messages

Returns True if a user can send TTS messages from all or specific text channels.

Type:

bool

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:

bool

Returns True if a user’s messages will automatically be embedded by Discord.

Type:

bool

attach_files

Returns True if a user can send files in their messages.

Type:

bool

read_message_history

Returns True if a user can read a text channel’s previous messages.

Type:

bool

mention_everyone

Returns True if a user’s @everyone or @here will mention everyone in the text channel.

Type:

bool

external_emojis

Returns True if a user can use emojis from other guilds.

Type:

bool

use_external_emojis

An alias for external_emojis.

New in version 1.3.

Type:

bool

view_guild_insights

Returns True if a user can view the guild’s insights.

New in version 1.3.

Type:

bool

connect

Returns True if a user can connect to a voice channel.

Type:

bool

speak

Returns True if a user can speak in a voice channel.

Type:

bool

mute_members

Returns True if a user can mute other users.

Type:

bool

deafen_members

Returns True if a user can deafen other users.

Type:

bool

move_members

Returns True if a user can move users between other voice channels.

Type:

bool

use_voice_activation

Returns True if a user can use voice activation in voice channels.

Type:

bool

change_nickname

Returns True if a user can change their nickname in the guild.

Type:

bool

manage_nicknames

Returns True if a user can change other user’s nickname in the guild.

Type:

bool

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:

bool

manage_permissions

An alias for manage_roles.

New in version 1.3.

Type:

bool

manage_webhooks

Returns True if a user can create, edit, or delete webhooks.

Type:

bool

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:

bool

manage_emojis

An alias for manage_guild_expressions.

Type:

bool

manage_emojis_and_stickers

An alias for manage_guild_expressions.

New in version 2.0.

Type:

bool

use_application_commands

Returns True if a user can use application commands.

New in version 2.6.

Type:

bool

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:

bool

request_to_speak

Returns True if a user can request to speak in a stage channel.

New in version 1.7.

Type:

bool

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:

bool

manage_threads

Returns True if a user can manage threads.

New in version 2.0.

Type:

bool

create_public_threads

Returns True if a user can create public threads.

New in version 2.0.

Type:

bool

create_private_threads

Returns True if a user can create private threads.

New in version 2.0.

Type:

bool

external_stickers

Returns True if a user can use stickers from other guilds.

New in version 2.0.

Type:

bool

use_external_stickers

An alias for external_stickers.

New in version 2.0.

Type:

bool

send_messages_in_threads

Returns True if a user can send messages in threads.

New in version 2.0.

Type:

bool

use_embedded_activities

Returns True if a user can use activities (applications with the embedded flag) in a voice channel.

New in version 2.6.

Type:

bool

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:

bool

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:

bool

view_creator_monetization_analytics

Returns True if a user can view role subscription insights.

New in version 2.9.

Type:

bool

use_soundboard

Returns True if a user can use the soundboard in voice channels.

New in version 2.9.

Type:

bool

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:

bool

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:

bool

use_external_sounds

Returns True if a user can use custom soundboard sounds from other guilds.

New in version 2.9.

Type:

bool

send_voice_messages

Returns True if a user can send voice messages.

New in version 2.9.

Type:

bool

send_polls

Returns True if a user can send polls.

New in version 2.10.

Type:

bool

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:

bool

PermissionOverwrite

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 to None and not False. Setting a value to False is explicitly denying that permission, while setting a value to True is explicitly allowing that permission.

The values supported by this are the same as Permissions with the added possibility of it being set to None.

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 or False.

Returns:

Indicates if the overwrite is empty.

Return type:

bool

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.