Browse Source

Standardize Permission constants as padded binary u64

Should make it easier to know how and where to modify the bits
pull/9553/head
Rapptz 2 years ago
parent
commit
69dd6052e4
  1. 19
      discord/permissions.py

19
discord/permissions.py

@ -186,7 +186,8 @@ class Permissions(BaseFlags):
"""A factory method that creates a :class:`Permissions` with all
permissions set to ``True``.
"""
return cls(0b11111111111111111111111111111111111111111111111)
# Some of these are 0 because we don't want to set unnecessary bits
return cls(0b0000_0000_0000_0000_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111)
@classmethod
def _timeout_mask(cls) -> int:
@ -235,7 +236,7 @@ class Permissions(BaseFlags):
.. versionchanged:: 2.3
Added :attr:`use_soundboard`, :attr:`create_expressions` permissions.
"""
return cls(0b01000111110110110011111101111111111101010001)
return cls(0b0000_0000_0000_0000_0000_0100_0111_1101_1011_0011_1111_0111_1111_1111_0101_0001)
@classmethod
def general(cls) -> Self:
@ -251,7 +252,7 @@ class Permissions(BaseFlags):
.. versionchanged:: 2.3
Added :attr:`create_expressions` permission.
"""
return cls(0b10000000000001110000000010000000010010110000)
return cls(0b0000_0000_0000_0000_0000_1000_0000_0000_0111_0000_0000_1000_0000_0100_1011_0000)
@classmethod
def membership(cls) -> Self:
@ -260,7 +261,7 @@ class Permissions(BaseFlags):
.. versionadded:: 1.7
"""
return cls(0b10000000000001100000000000000000000000111)
return cls(0b0000_0000_0000_0000_0000_0001_0000_0000_0000_1100_0000_0000_0000_0000_0000_0111)
@classmethod
def text(cls) -> Self:
@ -278,13 +279,13 @@ class Permissions(BaseFlags):
.. versionchanged:: 2.3
Added :attr:`send_voice_messages` permission.
"""
return cls(0b10000000111110010000000000001111111100001000000)
return cls(0b0000_0000_0000_0000_0100_0000_0111_1100_1000_0000_0000_0111_1111_1000_0100_0000)
@classmethod
def voice(cls) -> Self:
"""A factory method that creates a :class:`Permissions` with all
"Voice" permissions from the official Discord UI set to ``True``."""
return cls(0b1001001000000000000011111100000000001100000000)
return cls(0b0000_0000_0000_0000_0010_0100_1000_0000_0000_0011_1111_0000_0000_0011_0000_0000)
@classmethod
def stage(cls) -> Self:
@ -309,7 +310,7 @@ class Permissions(BaseFlags):
.. versionchanged:: 2.0
Added :attr:`manage_channels` permission and removed :attr:`request_to_speak` permission.
"""
return cls(0b1010000000000000000010000)
return cls(0b0000_0000_0000_0000_0000_0000_0000_0000_0000_0001_0100_0000_0000_0000_0001_0000)
@classmethod
def elevated(cls) -> Self:
@ -330,7 +331,7 @@ class Permissions(BaseFlags):
.. versionadded:: 2.0
"""
return cls(0b10000010001110000000000000010000000111110)
return cls(0b0000_0000_0000_0000_0000_0001_0000_0100_0111_0000_0000_0000_0010_0000_0011_1110)
@classmethod
def events(cls) -> Self:
@ -339,7 +340,7 @@ class Permissions(BaseFlags):
.. versionadded:: 2.4
"""
return cls(0b100000000001000000000000000000000000000000000)
return cls(0b0000_0000_0000_0000_0001_0000_0000_0010_0000_0000_0000_0000_0000_0000_0000_0000)
@classmethod
def advanced(cls) -> Self:

Loading…
Cancel
Save