curious.dataclasses.permissions

Wrappers for Permission objects.

This class uses some automatic generation to create the objects.

Functions

build_permissions_class([name]) Builds the permissions class automagically.

Classes

Overwrite(allow, …) Represents a permission overwrite.
Permissions(value, **kwargs) Represents the permissions a user can have.
curious.dataclasses.permissions.build_permissions_class(name='Permissions')[source]

Builds the permissions class automagically. This should *not* be used by normal user code - it is designed for internal usage by curious.

Parameters:name (str) – The name of the class.
Return type:type
Returns:A new type representing the permissions class.
class curious.dataclasses.permissions.Permissions(value: int = 0, **kwargs)

Bases: object

Represents the permissions a user can have. This type is automatically generated based upon a set of constant permission bits.

Every permission is accessible via a property getter and setter. The raw permissions value is accessible via bitfield.

Creates a new Permissions object.

Parameters:value (int) – The bitfield value of the permissions object.
_get_bit(bit)

Gets a bit from the internal bitfield of the permissions.

Return type:bool
add_reactions
Return type:bool
Returns:If this member has the add_reactions permission (bit 6).
administrator
Return type:bool
Returns:If this member has the administrator permission (bit 3).
classmethod all()
Returns:A new Permissions object with all permissions.
attach_files
Return type:bool
Returns:If this member has the attach_files permission (bit 15).
ban_members
Return type:bool
Returns:If this member has the ban_members permission (bit 2).
change_nickname
Return type:bool
Returns:If this member has the change_nickname permission (bit 26).
create_instant_invite
Return type:bool
Returns:If this member has the create_instant_invite permission (bit 0).
Return type:bool
Returns:If this member has the embed_links permission (bit 14).
kick_members
Return type:bool
Returns:If this member has the kick_members permission (bit 1).
manage_channels
Return type:bool
Returns:If this member has the manage_channels permission (bit 4).
manage_emojis
Return type:bool
Returns:If this member has the manage_emojis permission (bit 30).
manage_messages
Return type:bool
Returns:If this member has the manage_messages permission (bit 13).
manage_nicknames
Return type:bool
Returns:If this member has the manage_nicknames permission (bit 27).
manage_roles
Return type:bool
Returns:If this member has the manage_roles permission (bit 28).
manage_server
Return type:bool
Returns:If this member has the manage_server permission (bit 5).
manage_webhooks
Return type:bool
Returns:If this member has the manage_webhooks permission (bit 29).
mention_everyone
Return type:bool
Returns:If this member has the mention_everyone permission (bit 17).
classmethod none()
Returns:A new permissions object with no permissions.
raise_for_permission(permission)

Raises PermissionsError if this permission does not have the required bit.

Return type:None
read_message_history
Return type:bool
Returns:If this member has the read_message_history permission (bit 16).
read_messages
Return type:bool
Returns:If this member has the read_messages permission (bit 10).
send_messages
Return type:bool
Returns:If this member has the send_messages permission (bit 11).
send_tts_messages
Return type:bool
Returns:If this member has the send_tts_messages permission (bit 12).
use_external_emojis
Return type:bool
Returns:If this member has the use_external_emojis permission (bit 18).
view_audit_log
Return type:bool
Returns:If this member has the view_audit_log permission (bit 7).
voice_connect
Return type:bool
Returns:If this member has the voice_connect permission (bit 20).
voice_deafen_members
Return type:bool
Returns:If this member has the voice_deafen_members permission (bit 23).
voice_move_members
Return type:bool
Returns:If this member has the voice_move_members permission (bit 24).
voice_mute_members
Return type:bool
Returns:If this member has the voice_mute_members permission (bit 22).
voice_speak
Return type:bool
Returns:If this member has the voice_speak permission (bit 21).
voice_use_voice_activation
Return type:bool
Returns:If this member has the voice_use_voice_activation permission (bit 25).
class curious.dataclasses.permissions.Overwrite(allow: typing.Union[int, curious.dataclasses.permissions.Permissions], deny: typing.Union[int, curious.dataclasses.permissions.Permissions], obb: typing.Union[curious.dataclasses.member.Member, curious.dataclasses.role.Role, NoneType] = None, channel_id: int = None)[source]

Bases: object

Represents a permission overwrite.

This has all properties that the base Permissions object, but it takes into accounts the overwrites for the channels. It is always recommended to use this over the server permissions, as it will fall back to the default permissions for the role if it can’t find specific overwrites.

The overwrite has a permission marked as True if the object has a) an overwrite on the channel OR b) the object has that permission and no overwrite. The overwrite is marked as False if the object has a) an overwrite on the channel OR b) the object does not have that permission and no overwrite/a deny overwrite.

You can set an attribute to None to clear the overwrite, True to set an allow overwrite, and False to set a deny overwrite.

Parameters:
channel
Return type:Optional[Channel]
Returns:The Channel this overwrite represents.