Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update permission class methods for v1.7 #6476

Merged
merged 5 commits into from Mar 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 53 additions & 11 deletions discord/permissions.py
Expand Up @@ -140,41 +140,83 @@ def none(cls):
@classmethod
def all(cls):
"""A factory method that creates a :class:`Permissions` with all
permissions set to ``True``."""
return cls(0b01111111111111111111111111111111)
permissions set to ``True``.

.. versionchanged:: 1.7
Added :attr:`use_slash_commands` permission."""
NicolasAlmerge marked this conversation as resolved.
Show resolved Hide resolved
return cls(0b11111111111111111111111111111111)

@classmethod
def all_channel(cls):
"""A :class:`Permissions` with all channel-specific permissions set to
``True`` and the guild-specific ones set to ``False``. The guild-specific
permissions are currently:

- manage_emojis
- view_audit_log
- view_guild_insights
- manage_guild
- change_nickname
- manage_nicknames
- kick_members
- ban_members
- administrator
- change_nickname
- manage_nicknames

.. versionchanged:: 1.7
Added :attr:`stream`, :attr:`priority_speaker` and :attr:`use_slash_commands` permissions.
"""
return cls(0b00110011111101111111110001010001)
return cls(0b10110011111101111111111101010001)

@classmethod
def general(cls):
"""A factory method that creates a :class:`Permissions` with all
"General" permissions from the official Discord UI set to ``True``."""
return cls(0b01111100000010000000000010111111)

"General" permissions from the official Discord UI set to ``True``.

.. versionchanged:: 1.7
Permission :attr:`read_messages` is now included in the general permissions, but
permissions :attr:`administrator`, :attr:`create_instant_invite`, :attr:`kick_members`,
:attr:`ban_members`, :attr:`change_nickname` and :attr:`manage_nicknames` are
no longer part of the general permissions.
"""
return cls(0b01110000000010000000010010110000)

@classmethod
def membership(cls):
"""A factory method that creates a :class:`Permissions` with all
"Membership" permissions from the official Discord UI set to ``True``.

Membership permissions include :attr:`create_instant_invite`, :attr:`kick_members`,
:attr:`ban_members`, :attr:`change_nickname` and :attr:`manage_nicknames`.

NicolasAlmerge marked this conversation as resolved.
Show resolved Hide resolved
.. versionadded:: 1.7
"""
return cls(0b00001100000000000000000000000111)

@classmethod
def text(cls):
"""A factory method that creates a :class:`Permissions` with all
"Text" permissions from the official Discord UI set to ``True``."""
return cls(0b00000000000001111111110001000000)
"Text" permissions from the official Discord UI set to ``True``.

.. versionchanged:: 1.7
Permission :attr:`read_messages` is no longer part of the text permissions. Added :attr:`use_slash_commands` permission.
NicolasAlmerge marked this conversation as resolved.
Show resolved Hide resolved
"""
return cls(0b10000000000001111111100001000000)

@classmethod
def voice(cls):
"""A factory method that creates a :class:`Permissions` with all
"Voice" permissions from the official Discord UI set to ``True``."""
return cls(0b00000011111100000000001100000000)

@classmethod
def advanced(cls):
"""A factory method that creates a :class:`Permissions` with all
"Advanced" permissions from the official Discord UI set to ``True``.

Advanced permissions only contain the :attr:`administrator` permission.
NicolasAlmerge marked this conversation as resolved.
Show resolved Hide resolved

.. versionadded: 1.7
"""
return cls(1 << 3)


def update(self, **kwargs):
Expand Down