Browse Source

Remove embeds :(

pull/10109/head
dolfies 4 years ago
parent
commit
16ad1a176c
  1. 39
      discord/abc.py
  2. 17
      discord/http.py
  3. 40
      discord/message.py

39
discord/abc.py

@ -78,7 +78,6 @@ if TYPE_CHECKING:
from .guild import Guild
from .member import Member
from .channel import CategoryChannel
from .embeds import Embed
from .message import Message, MessageReference, PartialMessage
from .channel import DMChannel, GroupChannel, PartialMessageable, TextChannel, VocalGuildChannel
from .threads import Thread
@ -1171,7 +1170,6 @@ class Messageable:
content: Optional[str] = ...,
*,
tts: bool = ...,
embed: Embed = ...,
file: File = ...,
stickers: Sequence[Union[GuildSticker, StickerItem]] = ...,
delete_after: float = ...,
@ -1188,7 +1186,6 @@ class Messageable:
content: Optional[str] = ...,
*,
tts: bool = ...,
embed: Embed = ...,
files: List[File] = ...,
stickers: Sequence[Union[GuildSticker, StickerItem]] = ...,
delete_after: float = ...,
@ -1205,7 +1202,6 @@ class Messageable:
content: Optional[str] = ...,
*,
tts: bool = ...,
embeds: List[Embed] = ...,
file: File = ...,
stickers: Sequence[Union[GuildSticker, StickerItem]] = ...,
delete_after: float = ...,
@ -1222,7 +1218,6 @@ class Messageable:
content: Optional[str] = ...,
*,
tts: bool = ...,
embeds: List[Embed] = ...,
files: List[File] = ...,
stickers: Sequence[Union[GuildSticker, StickerItem]] = ...,
delete_after: float = ...,
@ -1238,8 +1233,6 @@ class Messageable:
content=None,
*,
tts=False,
embed=None,
embeds=None,
file=None,
files=None,
stickers=None,
@ -1254,27 +1247,19 @@ class Messageable:
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through ``str(content)``.
If the content is set to ``None`` (the default), then the ``embed`` parameter must
be provided.
If the content is set to ``None`` (the default), then a sticker or file must be sent.
To upload a single file, the ``file`` parameter should be used with a
single :class:`~discord.File` object. To upload multiple files, the ``files``
parameter should be used with a :class:`list` of :class:`~discord.File` objects.
**Specifying both parameters will lead to an exception**.
To upload a single embed, the ``embed`` parameter should be used with a
single :class:`~discord.Embed` object. To upload multiple embeds, the ``embeds``
parameter should be used with a :class:`list` of :class:`~discord.Embed` objects.
**Specifying both parameters will lead to an exception**.
Parameters
------------
content: Optional[:class:`str`]
The content of the message to send.
tts: :class:`bool`
Indicates if the message should be sent using text-to-speech.
embed: :class:`~discord.Embed`
The rich embed for the content.
file: :class:`~discord.File`
The file to upload.
files: List[:class:`~discord.File`]
@ -1308,10 +1293,6 @@ class Messageable:
If set, overrides the :attr:`~discord.AllowedMentions.replied_user` attribute of ``allowed_mentions``.
.. versionadded:: 1.6
embeds: List[:class:`~discord.Embed`]
A list of embeds to upload. Must be a maximum of 10.
.. versionadded:: 2.0
stickers: Sequence[Union[:class:`~discord.GuildSticker`, :class:`~discord.StickerItem`]]
A list of stickers to upload. Must be a maximum of 3.
@ -1326,7 +1307,6 @@ class Messageable:
~discord.InvalidArgument
The ``files`` list is not of the appropriate size,
you specified both ``file`` and ``files``,
or you specified both ``embed`` and ``embeds``,
or the ``reference`` object is not a :class:`~discord.Message`,
:class:`~discord.MessageReference` or :class:`~discord.PartialMessage`.
@ -1340,17 +1320,6 @@ class Messageable:
state = self._state
content = str(content) if content is not None else None
if embed is not None and embeds is not None:
raise InvalidArgument('Cannot pass both embed and embeds')
if embed is not None:
embed = embed.to_dict()
elif embeds is not None:
if len(embeds) > 10:
raise InvalidArgument('embeds parameter must be a list of up to 10 elements')
embeds = [embed.to_dict() for embed in embeds]
if stickers is not None:
stickers = [sticker.id for sticker in stickers]
@ -1389,8 +1358,6 @@ class Messageable:
allowed_mentions=allowed_mentions,
content=content,
tts=tts,
embed=embed,
embeds=embeds,
nonce=nonce,
message_reference=reference,
stickers=stickers,
@ -1410,8 +1377,6 @@ class Messageable:
files=files,
content=content,
tts=tts,
embed=embed,
embeds=embeds,
nonce=nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,
@ -1425,8 +1390,6 @@ class Messageable:
channel.id,
content,
tts=tts,
embed=embed,
embeds=embeds,
nonce=nonce,
allowed_mentions=allowed_mentions,
message_reference=reference,

17
discord/http.py

@ -65,7 +65,6 @@ if TYPE_CHECKING:
audit_log,
channel,
emoji,
embed,
guild,
integration,
invite,
@ -510,8 +509,6 @@ class HTTPClient:
content: Optional[str],
*,
tts: bool = False,
embed: Optional[embed.Embed] = None,
embeds: Optional[List[embed.Embed]] = None,
nonce: Optional[Snowflake] = None,
allowed_mentions: Optional[message.AllowedMentions] = None,
message_reference: Optional[message.MessageReference] = None,
@ -521,10 +518,6 @@ class HTTPClient:
payload: Dict[str, Any] = {'tts': tts}
if content:
payload['content'] = content
if embed:
payload['embeds'] = [embed]
if embeds:
payload['embeds'] = embeds
if nonce:
payload['nonce'] = nonce
if allowed_mentions:
@ -546,8 +539,6 @@ class HTTPClient:
files: Sequence[File],
content: Optional[str] = None,
tts: bool = False,
embed: Optional[embed.Embed] = None,
embeds: Optional[Iterable[Optional[embed.Embed]]] = None,
nonce: Optional[Snowflake] = None,
allowed_mentions: Optional[message.AllowedMentions] = None,
message_reference: Optional[message.MessageReference] = None,
@ -558,10 +549,6 @@ class HTTPClient:
if content:
payload['content'] = content
if embed:
payload['embeds'] = [embed]
if embeds:
payload['embeds'] = embeds
if nonce:
payload['nonce'] = nonce
if allowed_mentions:
@ -598,8 +585,6 @@ class HTTPClient:
files: Sequence[File],
content: Optional[str] = None,
tts: bool = False,
embed: Optional[embed.Embed] = None,
embeds: Optional[List[embed.Embed]] = None,
nonce: Optional[Snowflake] = None,
allowed_mentions: Optional[message.AllowedMentions] = None,
message_reference: Optional[message.MessageReference] = None,
@ -610,8 +595,6 @@ class HTTPClient:
files=files,
content=content,
tts=tts,
embed=embed,
embeds=embeds,
nonce=nonce,
allowed_mentions=allowed_mentions,
message_reference=message_reference,

40
discord/message.py

@ -1207,7 +1207,6 @@ class Message(Hashable):
self,
*,
content: Optional[str] = ...,
embed: Optional[Embed] = ...,
attachments: List[Attachment] = ...,
suppress: bool = ...,
delete_after: Optional[float] = ...,
@ -1220,7 +1219,6 @@ class Message(Hashable):
self,
*,
content: Optional[str] = ...,
embeds: List[Embed] = ...,
attachments: List[Attachment] = ...,
suppress: bool = ...,
delete_after: Optional[float] = ...,
@ -1231,8 +1229,6 @@ class Message(Hashable):
async def edit(
self,
content: Optional[str] = MISSING,
embed: Optional[Embed] = MISSING,
embeds: List[Embed] = MISSING,
attachments: List[Attachment] = MISSING,
suppress: bool = MISSING,
delete_after: Optional[float] = None,
@ -1252,14 +1248,6 @@ class Message(Hashable):
content: Optional[:class:`str`]
The new content to replace the message with.
Could be ``None`` to remove the content.
embed: Optional[:class:`Embed`]
The new embed to replace the original with.
Could be ``None`` to remove the embed.
embeds: List[:class:`Embed`]
The new embeds to replace the original with. Must be a maximum of 10.
To remove all embeds ``[]`` should be passed.
.. versionadded:: 2.0
attachments: List[:class:`Attachment`]
A list of attachments to keep in the message. If ``[]`` is passed
then all attachments are removed.
@ -1288,9 +1276,7 @@ class Message(Hashable):
Editing the message failed.
Forbidden
Tried to suppress a message without permissions or
edited a message's content or embed that isn't yours.
~discord.InvalidArgument
You specified both ``embed`` and ``embeds``
edit a message that isn't yours.
"""
payload: Dict[str, Any] = {}
@ -1300,17 +1286,6 @@ class Message(Hashable):
else:
payload['content'] = None
if embed is not MISSING and embeds is not MISSING:
raise InvalidArgument('cannot pass both embed and embeds parameter to edit()')
if embed is not MISSING:
if embed is None:
payload['embeds'] = []
else:
payload['embeds'] = [embed.to_dict()]
elif embeds is not MISSING:
payload['embeds'] = [e.to_dict() for e in embeds]
if suppress is not MISSING:
flags = MessageFlags._from_value(self.flags.value)
flags.suppress_embeds = suppress
@ -1837,9 +1812,6 @@ class PartialMessage(Hashable):
content: Optional[:class:`str`]
The new content to replace the message with.
Could be ``None`` to remove the content.
embed: Optional[:class:`Embed`]
The new embed to replace the original with.
Could be ``None`` to remove the embed.
suppress: :class:`bool`
Whether to suppress embeds for the message. This removes
all the embeds if set to ``True``. If set to ``False``
@ -1865,7 +1837,7 @@ class PartialMessage(Hashable):
Editing the message failed.
Forbidden
Tried to suppress a message without permissions or
edited a message's content or embed that isn't yours.
edit a message that isn't yours.
Returns
---------
@ -1881,14 +1853,6 @@ class PartialMessage(Hashable):
if content is not None:
fields['content'] = str(content)
try:
embed = fields['embed']
except KeyError:
pass
else:
if embed is not None:
fields['embed'] = embed.to_dict()
try:
suppress: bool = fields.pop('suppress')
except KeyError:

Loading…
Cancel
Save