Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented attachments in Webhook.edit_message and WebhookMessage.edit #712

Merged
merged 3 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ async def edit_original_message(
embed: Optional[Embed] = MISSING,
file: File = MISSING,
files: List[File] = MISSING,
attachments: List[Attachment] = MISSING,
view: Optional[View] = MISSING,
allowed_mentions: Optional[AllowedMentions] = None,
delete_after: Optional[float] = None,
Expand Down Expand Up @@ -306,6 +307,9 @@ async def edit_original_message(
files: List[:class:`File`]
A list of files to send with the content. This cannot be mixed with the
``file`` parameter.
attachments: List[:class:`Attachment`]
A list of attachments to keep in the message. If ``[]`` is passed
then all attachments are removed.
allowed_mentions: :class:`AllowedMentions`
Controls the mentions being processed in this message.
See :meth:`.abc.Messageable.send` for more information.
Expand Down Expand Up @@ -339,6 +343,7 @@ async def edit_original_message(
content=content,
file=file,
files=files,
attachments=attachments,
embed=embed,
embeds=embeds,
view=view,
Expand Down
18 changes: 17 additions & 1 deletion discord/webhook/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from .. import utils
from ..object import Object
from ..errors import InvalidArgument, HTTPException, Forbidden, NotFound, DiscordServerError
from ..message import Message
from ..message import Attachment, Message
from ..enums import try_enum, WebhookType
from ..user import BaseUser, User
from ..asset import Asset
Expand Down Expand Up @@ -468,6 +468,7 @@ def handle_message_parameters(
ephemeral: bool = False,
file: File = MISSING,
files: List[File] = MISSING,
attachments: List[Attachment] = MISSING,
embed: Optional[Embed] = MISSING,
embeds: List[Embed] = MISSING,
view: Optional[View] = MISSING,
Expand Down Expand Up @@ -497,6 +498,9 @@ def handle_message_parameters(
else:
payload['content'] = None

if attachments is not MISSING:
payload['attachments'] = [a.to_dict() for a in attachments]

if view is not MISSING:
if view is not None:
payload['components'] = view.to_components()
Expand Down Expand Up @@ -683,6 +687,7 @@ async def edit(
embed: Optional[Embed] = MISSING,
file: File = MISSING,
files: List[File] = MISSING,
attachments: List[Attachment] = MISSING,
view: Optional[View] = MISSING,
allowed_mentions: Optional[AllowedMentions] = None,
) -> WebhookMessage:
Expand Down Expand Up @@ -712,6 +717,11 @@ async def edit(
A list of files to send with the content. This cannot be mixed with the
``file`` parameter.

.. versionadded:: 2.0
attachments: List[:class:`Attachment`]
A list of attachments to keep in the message. If ``[]`` is passed
then all attachments are removed.

.. versionadded:: 2.0
allowed_mentions: :class:`AllowedMentions`
Controls the mentions being processed in this message.
Expand Down Expand Up @@ -753,6 +763,7 @@ async def edit(
embed=embed,
file=file,
files=files,
attachments=attachments,
view=view,
allowed_mentions=allowed_mentions,
thread=thread
Expand Down Expand Up @@ -1527,6 +1538,7 @@ async def edit_message(
embed: Optional[Embed] = MISSING,
file: File = MISSING,
files: List[File] = MISSING,
attachments: List[Attachment] = MISSING,
view: Optional[View] = MISSING,
allowed_mentions: Optional[AllowedMentions] = None,
thread: Optional[Snowflake] = MISSING
Expand Down Expand Up @@ -1554,6 +1566,9 @@ async def edit_message(
embed: Optional[:class:`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.
file: :class:`File`
The file to upload. This cannot be mixed with ``files`` parameter.

Expand Down Expand Up @@ -1609,6 +1624,7 @@ async def edit_message(
content=content,
file=file,
files=files,
attachments=attachments,
embed=embed,
embeds=embeds,
view=view,
Expand Down