aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-05-27 21:07:28 -0400
committerRapptz <[email protected]>2021-05-27 21:07:28 -0400
commitfc64ffdabd7158f91f41347b23b01af7cce40d2a (patch)
tree1a271fd3808f916dc8963ebcfacc034cd8f2f2b5
parentAllow View to be instantiated without subclassing (diff)
downloaddiscord.py-fc64ffdabd7158f91f41347b23b01af7cce40d2a.tar.xz
discord.py-fc64ffdabd7158f91f41347b23b01af7cce40d2a.zip
Allow passing multiple embeds in InteractionResponse.edit_message
-rw-r--r--discord/interactions.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/discord/interactions.py b/discord/interactions.py
index dae85786..c68f7f86 100644
--- a/discord/interactions.py
+++ b/discord/interactions.py
@@ -315,6 +315,7 @@ class InteractionResponse:
*,
content: Optional[Any] = MISSING,
embed: Optional[Embed] = MISSING,
+ embeds: List[Embed] = MISSING,
attachments: List[Attachment] = MISSING,
view: Optional[View] = MISSING,
) -> None:
@@ -327,8 +328,11 @@ class InteractionResponse:
-----------
content: Optional[:class:`str`]
The new content to replace the message with. ``None`` removes the content.
+ embeds: List[:class:`Embed`]
+ A list of embeds to edit the message with.
embed: Optional[:class:`Embed`]
- The new embed to replace the embed with. ``None`` removes the embed.
+ The embed to edit the message with. ``None`` suppresses the embeds.
+ This should not be mixed with the ``embeds`` parameter.
attachments: List[:class:`Attachment`]
A list of attachments to keep in the message. If ``[]`` is passed
then all attachments are removed.
@@ -340,6 +344,8 @@ class InteractionResponse:
-------
HTTPException
Editing the message failed.
+ TypeError
+ You specified both ``embed`` and ``embeds``.
"""
if self._responded:
return
@@ -356,11 +362,17 @@ class InteractionResponse:
else:
payload['content'] = str(content)
+ if embed is not MISSING and embeds is not MISSING:
+ raise TypeError('cannot mix both embed and embeds keyword arguments')
+
if embed is not MISSING:
if embed is None:
- payload['embed'] = None
+ embeds = []
else:
- payload['embed'] = embed.to_dict()
+ embeds = [embed]
+
+ if embeds is not MISSING:
+ payload['embeds'] = [e.to_dict() for e in embeds]
if attachments is not MISSING:
payload['attachments'] = [a.to_dict() for a in attachments]