Add support for member flags

This commit is contained in:
Soheab_
2023-01-25 17:12:31 +01:00
committed by GitHub
parent ee07f72906
commit c46f309c13
5 changed files with 126 additions and 15 deletions

View File

@ -42,6 +42,7 @@ __all__ = (
'ApplicationFlags',
'ChannelFlags',
'AutoModPresets',
'MemberFlags',
)
BF = TypeVar('BF', bound='BaseFlags')
@ -1646,3 +1647,77 @@ class AutoModPresets(ArrayFlags):
self = cls.__new__(cls)
self.value = self.DEFAULT_VALUE
return self
@fill_with_flags()
class MemberFlags(BaseFlags):
r"""Wraps up the Discord Guild Member flags
.. versionadded:: 2.2
.. container:: operations
.. describe:: x == y
Checks if two MemberFlags are equal.
.. describe:: x != y
Checks if two MemberFlags are not equal.
.. describe:: x | y, x |= y
Returns a MemberFlags instance with all enabled flags from
both x and y.
.. describe:: x & y, x &= y
Returns a MemberFlags instance with only flags enabled on
both x and y.
.. describe:: x ^ y, x ^= y
Returns a MemberFlags instance with only flags enabled on
only one of x or y, not on both.
.. describe:: ~x
Returns a MemberFlags instance with all flags inverted from x.
.. describe:: hash(x)
Return the flag's hash.
.. describe:: iter(x)
Returns an iterator of ``(name, value)`` pairs. This allows it
to be, for example, constructed as a dict or a list of pairs.
Note that aliases are not shown.
Attributes
-----------
value: :class:`int`
The raw value. You should query flags via the properties
rather than using this raw value.
"""
@flag_value
def did_rejoin(self):
""":class:`bool`: Returns ``True`` if the member left and rejoined the :attr:`~discord.Member.guild`."""
return 1 << 0
@flag_value
def completed_onboarding(self):
""":class:`bool`: Returns ``True`` if the member has completed onboarding."""
return 1 << 1
@flag_value
def bypasses_verification(self):
""":class:`bool`: Returns ``True`` if the member can bypass the guild verification requirements."""
return 1 << 2
@flag_value
def started_onboarding(self):
""":class:`bool`: Returns ``True`` if the member has started onboarding."""
return 1 << 3