diff options
| author | JohnyTheCarrot <[email protected]> | 2020-04-12 21:08:39 +0200 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2020-05-29 22:40:14 -0400 |
| commit | ab5f995d78c12005cae7cf51c174656207e0e134 (patch) | |
| tree | bb0f36c4c3e755246ce21a2c45d1b2f695fc6ce2 /discord/flags.py | |
| parent | Document that sleep_until considers naive datetimes as UTC. (diff) | |
| download | discord.py-ab5f995d78c12005cae7cf51c174656207e0e134.tar.xz discord.py-ab5f995d78c12005cae7cf51c174656207e0e134.zip | |
Add support for public user flags
Diffstat (limited to 'discord/flags.py')
| -rw-r--r-- | discord/flags.py | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/discord/flags.py b/discord/flags.py index ff0c10c1..448bced2 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -24,9 +24,12 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from .enums import UserFlags + __all__ = ( 'SystemChannelFlags', 'MessageFlags', + 'PublicUserFlags' ) class flag_value: @@ -230,3 +233,97 @@ class MessageFlags(BaseFlags): An urgent message is one sent by Discord Trust and Safety. """ return 16 + +@fill_with_flags() +class PublicUserFlags(BaseFlags): + r"""Wraps up the Discord User Public flags. + + .. container:: operations + + .. describe:: x == y + + Checks if two PublicUserFlags are equal. + .. describe:: x != y + + Checks if two PublicUserFlags are not equal. + + .. versionadded:: 1.4 + + Attributes + ----------- + value: :class:`int` + The raw value. This value is a bit array field of a 53-bit integer + representing the currently available flags. You should query + flags via the properties rather than using this raw value. + """ + + __slots__ = () + + @flag_value + def staff(self): + """:class:`bool`: Returns ``True`` if the user is a Discord Employee.""" + return UserFlags.staff.value + + @flag_value + def partner(self): + """:class:`bool`: Returns ``True`` if the user is a Discord Partner.""" + return UserFlags.partner.value + + @flag_value + def hypesquad(self): + """:class:`bool`: Returns ``True`` if the user is a HypeSquad Events member.""" + return UserFlags.hypesquad.value + + @flag_value + def bug_hunter(self): + """:class:`bool`: Returns ``True`` if the user is a Bug Hunter""" + return UserFlags.bug_hunter.value + + @flag_value + def hypesquad_bravery(self): + """:class:`bool`: Returns ``True`` if the user is a HypeSquad Bravery member.""" + return UserFlags.hypesquad_bravery.value + + @flag_value + def hypesquad_brilliance(self): + """:class:`bool`: Returns ``True`` if the user is a HypeSquad Brilliance member.""" + return UserFlags.hypesquad_brilliance.value + + @flag_value + def hypesquad_balance(self): + """:class:`bool`: Returns ``True`` if the user is a HypeSquad Balance member.""" + return UserFlags.hypesquad_balance.value + + @flag_value + def early_supporter(self): + """:class:`bool`: Returns ``True`` if the user is an Early Supporter.""" + return UserFlags.early_supporter.value + + @flag_value + def team_user(self): + """:class:`bool`: Returns ``True`` if the user is a Team User.""" + return UserFlags.team_user.value + + @flag_value + def system(self): + """:class:`bool`: Returns ``True`` if the user is a system user (i.e. represents Discord officially).""" + return UserFlags.system.value + + @flag_value + def bug_hunter_level_2(self): + """:class:`bool`: Returns ``True`` if the user is a Bug Hunter Level 2""" + return UserFlags.bug_hunter_level_2.value + + @flag_value + def verified_bot(self): + """:class:`bool`: Returns ``True`` if the user is a Verified Bot.""" + return UserFlags.verified_bot.value + + @flag_value + def verified_bot_developer(self): + """:class:`bool`: Returns ``True`` if the user is a Verified Bot Developer.""" + return UserFlags.verified_bot_developer.value + + def all(self): + """List[:class:`UserFlags`]: Returns all public flags the user has.""" + return [public_flag for public_flag in UserFlags if self._has_flag(public_flag.value)] |