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:
@ -29,6 +29,7 @@ from typing import Any, Dict, List, Mapping, Optional, Protocol, TYPE_CHECKING,
|
||||
|
||||
from . import utils
|
||||
from .colour import Colour
|
||||
from .flags import AttachmentFlags, EmbedFlags
|
||||
|
||||
# fmt: off
|
||||
__all__ = (
|
||||
@ -76,6 +77,7 @@ if TYPE_CHECKING:
|
||||
proxy_url: Optional[str]
|
||||
height: Optional[int]
|
||||
width: Optional[int]
|
||||
flags: Optional[AttachmentFlags]
|
||||
|
||||
class _EmbedVideoProxy(Protocol):
|
||||
url: Optional[str]
|
||||
@ -146,6 +148,10 @@ class Embed:
|
||||
colour: Optional[Union[:class:`Colour`, :class:`int`]]
|
||||
The colour code of the embed. Aliased to ``color`` as well.
|
||||
This can be set during initialisation.
|
||||
flags: Optional[:class:`EmbedFlags`]
|
||||
The flags of this embed.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
"""
|
||||
|
||||
__slots__ = (
|
||||
@ -162,6 +168,7 @@ class Embed:
|
||||
'_author',
|
||||
'_fields',
|
||||
'description',
|
||||
'flags',
|
||||
)
|
||||
|
||||
def __init__(
|
||||
@ -181,6 +188,7 @@ class Embed:
|
||||
self.type: EmbedType = type
|
||||
self.url: Optional[str] = url
|
||||
self.description: Optional[str] = description
|
||||
self.flags: Optional[EmbedFlags] = None
|
||||
|
||||
if self.title is not None:
|
||||
self.title = str(self.title)
|
||||
@ -245,6 +253,11 @@ class Embed:
|
||||
else:
|
||||
setattr(self, '_' + attr, value)
|
||||
|
||||
try:
|
||||
self.flags = EmbedFlags._from_value(data['flags'])
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return self
|
||||
|
||||
def copy(self) -> Self:
|
||||
@ -399,11 +412,15 @@ class Embed:
|
||||
- ``proxy_url``
|
||||
- ``width``
|
||||
- ``height``
|
||||
- ``flags``
|
||||
|
||||
If the attribute has no value then ``None`` is returned.
|
||||
"""
|
||||
# Lying to the type checker for better developer UX.
|
||||
return EmbedProxy(getattr(self, '_image', {})) # type: ignore
|
||||
data = getattr(self, '_image', {})
|
||||
if 'flags' in data:
|
||||
data['flags'] = AttachmentFlags._from_value(data['flags'])
|
||||
return EmbedProxy(data) # type: ignore
|
||||
|
||||
def set_image(self, *, url: Optional[Any]) -> Self:
|
||||
"""Sets the image for the embed content.
|
||||
|
Reference in New Issue
Block a user