Browse Source

Allow passing multiple embeds in InteractionResponse.edit_message

pull/6974/head
Rapptz 4 years ago
parent
commit
fc64ffdabd
  1. 18
      discord/interactions.py

18
discord/interactions.py

@ -315,6 +315,7 @@ class InteractionResponse:
*, *,
content: Optional[Any] = MISSING, content: Optional[Any] = MISSING,
embed: Optional[Embed] = MISSING, embed: Optional[Embed] = MISSING,
embeds: List[Embed] = MISSING,
attachments: List[Attachment] = MISSING, attachments: List[Attachment] = MISSING,
view: Optional[View] = MISSING, view: Optional[View] = MISSING,
) -> None: ) -> None:
@ -327,8 +328,11 @@ class InteractionResponse:
----------- -----------
content: Optional[:class:`str`] content: Optional[:class:`str`]
The new content to replace the message with. ``None`` removes the content. 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`] 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`] attachments: List[:class:`Attachment`]
A list of attachments to keep in the message. If ``[]`` is passed A list of attachments to keep in the message. If ``[]`` is passed
then all attachments are removed. then all attachments are removed.
@ -340,6 +344,8 @@ class InteractionResponse:
------- -------
HTTPException HTTPException
Editing the message failed. Editing the message failed.
TypeError
You specified both ``embed`` and ``embeds``.
""" """
if self._responded: if self._responded:
return return
@ -356,11 +362,17 @@ class InteractionResponse:
else: else:
payload['content'] = str(content) 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 not MISSING:
if embed is None: if embed is None:
payload['embed'] = None embeds = []
else: 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: if attachments is not MISSING:
payload['attachments'] = [a.to_dict() for a in attachments] payload['attachments'] = [a.to_dict() for a in attachments]

Loading…
Cancel
Save