Browse Source

Add missing permissions and flags

pull/10109/head
dolfies 3 years ago
parent
commit
8e23a2a287
  1. 67
      discord/flags.py
  2. 39
      discord/permissions.py

67
discord/flags.py

@ -616,33 +616,77 @@ class ApplicationFlags(BaseFlags):
"""
@flag_value
def gateway_presence(self):
def presence(self):
""":class:`bool`: Returns ``True`` if the application is verified and is allowed to
receive presence information over the gateway.
"""
return 1 << 12
@alias_flag_value
def gateway_presence(self):
""":class:`bool`: Alias for :attr:`presence`."""
return 1 << 12
@flag_value
def gateway_presence_limited(self):
""":class:`bool`: Returns ``True`` if the application is allowed to receive limited
presence information over the gateway.
def presence_limited(self):
""":class:`bool`: Returns ``True`` if the application is allowed to receive
presence information over the gateway but is not whitelisted.
"""
return 1 << 13
@alias_flag_value
def gateway_presence_limited(self):
""":class:`bool`: Alias for :attr:`presence_limited`."""
return 1 << 13
@flag_value
def gateway_guild_members(self):
def guild_members(self):
""":class:`bool`: Returns ``True`` if the application is verified and is allowed to
receive full guild member lists.
"""
return 1 << 14
@alias_flag_value
def gateway_guild_members(self):
""":class:`bool`: Alias for :attr:`guild_members`."""
return 1 << 14
@flag_value
def gateway_guild_members_limited(self):
""":class:`bool`: Returns ``True`` if the application is allowed to receive limited
guild member lists.
def guild_members_limited(self):
""":class:`bool`: Returns ``True`` if the application is allowed to receive full
guild member lists but is not whitelisted.
"""
return 1 << 15
@alias_flag_value
def gateway_guild_members_limited(self):
""":class:`bool`: Alias for :attr:`guild_members_limited`."""
return 1 << 15
@flag_value
def message_content(self):
""":class:`bool`: Returns ``True`` if the application is verified and is allowed to
receive message content.
"""
return 1 << 18
@alias_flag_value
def gateway_message_content(self):
""":class:`bool`: Alias for :attr:`message_content`."""
return 1 << 18
@flag_value
def message_content_limited(self):
""":class:`bool`: Returns ``True`` if the application is allowed to receive full
message content but is not whitelisted.
"""
return 1 << 19
@alias_flag_value
def gateway_message_content_limited(self):
""":class:`bool`: Alias for :attr:`message_content`."""
return 1 << 19
@flag_value
def verification_pending_guild_limit(self):
""":class:`bool`: Returns ``True`` if the application is currently pending verification
@ -657,9 +701,14 @@ class ApplicationFlags(BaseFlags):
@flag_value
def embedded_first_party(self):
""":class:`bool`: Returns ``True`` if a first party application is emdedded within the Discord client."""
""":class:`bool`: Returns ``True`` if the embedded application is published by Discord."""
return 1 << 20
@flag_value
def embedded_released(self):
""":class:`bool`: Returns ``True`` if the embedded application is released."""
return 1 << 1
class GuildSubscriptionOptions:
r"""Controls the library's auto-subscribing feature.

39
discord/permissions.py

@ -147,7 +147,7 @@ class Permissions(BaseFlags):
"""A factory method that creates a :class:`Permissions` with all
permissions set to ``True``.
"""
return cls(0b111111111111111111111111111111111111111)
return cls(-1)
@classmethod
def all_channel(cls: Type[P]) -> P:
@ -194,8 +194,11 @@ class Permissions(BaseFlags):
"Membership" permissions from the official Discord UI set to ``True``.
.. versionadded:: 1.7
.. versionchanged:: 2.0
Added :attr:`moderate_members` permission.
"""
return cls(0b00001100000000000000000000000111)
return cls(0b10000000000001100000000000000000000000111)
@classmethod
def text(cls: Type[P]) -> P:
@ -215,8 +218,12 @@ class Permissions(BaseFlags):
@classmethod
def voice(cls: Type[P]) -> P:
"""A factory method that creates a :class:`Permissions` with all
"Voice" permissions from the official Discord UI set to ``True``."""
return cls(0b00000011111100000000001100000000)
"Voice" permissions from the official Discord UI set to ``True``.
.. versionchanged:: 2.0
Added :attr:`start_embedded_activities` permission.
"""
return cls(0b1000000000000011111100000000001100000000)
@classmethod
def stage(cls: Type[P]) -> P:
@ -551,13 +558,31 @@ class Permissions(BaseFlags):
"""
return 1 << 38
@flag_value
def start_embedded_activities(self) -> int:
""":class:`bool`: Returns ``True`` if a user can launch activities (applications with the :attr:`discord.ApplicationFlags.embedded` flag) in a voice channel.
.. versionadded:: 2.0
"""
return 1 << 39
@flag_value
def moderate_members(self) -> int:
""":class:`bool`: Returns ``True`` if a user can timeout users
(prevent them from sending or reacting to messages, and from connecting to voice/stage channels).
.. versionadded:: 2.0
"""
return 1 << 40
PO = TypeVar('PO', bound='PermissionOverwrite')
def _augment_from_permissions(cls):
cls.VALID_NAMES = set(Permissions.VALID_FLAGS)
aliases = set()
# make descriptors for all the valid names and aliases
# Make descriptors for all the valid names and aliases
for name, value in Permissions.__dict__.items():
if isinstance(value, permission_alias):
key = value.alias
@ -567,7 +592,7 @@ def _augment_from_permissions(cls):
else:
continue
# god bless Python
# God bless Python
def getter(self, x=key):
return self._values.get(x)
@ -664,6 +689,8 @@ class PermissionOverwrite:
send_messages_in_threads: Optional[bool]
external_stickers: Optional[bool]
use_external_stickers: Optional[bool]
start_embedded_activities: Optional[bool]
moderate_members: Optional[bool]
def __init__(self, **kwargs: Optional[bool]):
self._values: Dict[str, Optional[bool]] = {}

Loading…
Cancel
Save