mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-06 09:56:09 +00:00
Add support for embed flags and update attachment flags
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
This commit is contained in:
@ -63,6 +63,7 @@ __all__ = (
|
||||
'RoleFlags',
|
||||
'AppInstallationType',
|
||||
'SKUFlags',
|
||||
'EmbedFlags',
|
||||
)
|
||||
|
||||
BF = TypeVar('BF', bound='BaseFlags')
|
||||
@ -2173,6 +2174,30 @@ class AttachmentFlags(BaseFlags):
|
||||
""":class:`bool`: Returns ``True`` if the attachment has been edited using the remix feature."""
|
||||
return 1 << 2
|
||||
|
||||
@flag_value
|
||||
def spoiler(self):
|
||||
""":class:`bool`: Returns ``True`` if the attachment was marked as a spoiler.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
"""
|
||||
return 1 << 3
|
||||
|
||||
@flag_value
|
||||
def contains_explicit_media(self):
|
||||
""":class:`bool`: Returns ``True`` if the attachment was flagged as sensitive content.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
"""
|
||||
return 1 << 4
|
||||
|
||||
@flag_value
|
||||
def animated(self):
|
||||
""":class:`bool`: Returns ``True`` if the attachment is an animated image.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
"""
|
||||
return 1 << 5
|
||||
|
||||
|
||||
@fill_with_flags()
|
||||
class RoleFlags(BaseFlags):
|
||||
@ -2308,3 +2333,67 @@ class SKUFlags(BaseFlags):
|
||||
def user_subscription(self):
|
||||
""":class:`bool`: Returns ``True`` if the SKU is a user subscription."""
|
||||
return 1 << 8
|
||||
|
||||
|
||||
@fill_with_flags()
|
||||
class EmbedFlags(BaseFlags):
|
||||
r"""Wraps up the Discord Embed flags
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
.. container:: operations
|
||||
|
||||
.. describe:: x == y
|
||||
|
||||
Checks if two EmbedFlags are equal.
|
||||
|
||||
.. describe:: x != y
|
||||
|
||||
Checks if two EmbedFlags are not equal.
|
||||
|
||||
.. describe:: x | y, x |= y
|
||||
|
||||
Returns an EmbedFlags instance with all enabled flags from
|
||||
both x and y.
|
||||
|
||||
.. describe:: x ^ y, x ^= y
|
||||
|
||||
Returns an EmbedFlags instance with only flags enabled on
|
||||
only one of x or y, not on both.
|
||||
|
||||
.. describe:: ~x
|
||||
|
||||
Returns an EmbedFlags instance with all flags inverted from x.
|
||||
|
||||
.. describe:: hash(x)
|
||||
|
||||
Returns 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.
|
||||
|
||||
.. describe:: bool(b)
|
||||
|
||||
Returns whether any flag is set to ``True``.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
value: :class:`int`
|
||||
The raw value. You should query flags via the properties
|
||||
rather than using this raw value.
|
||||
"""
|
||||
|
||||
@flag_value
|
||||
def contains_explicit_media(self):
|
||||
""":class:`bool`: Returns ``True`` if the embed was flagged as sensitive content."""
|
||||
return 1 << 4
|
||||
|
||||
@flag_value
|
||||
def content_inventory_entry(self):
|
||||
""":class:`bool`: Returns ``True`` if the embed is a reply to an activity card, and is no
|
||||
longer displayed.
|
||||
"""
|
||||
return 1 << 5
|
||||
|
Reference in New Issue
Block a user