Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2568](https://github.com/Pycord-Development/pycord/pull/2500))
- Fixed the `guild` attribute of `Member`s recieved from a `UserCommand` being `None`.
([#2573](https://github.com/Pycord-Development/pycord/pull/2573))
- Fixed `Webhook.send` not including `Attachment` data.
([#2513](https://github.com/Pycord-Development/pycord/pull/2513))

## [2.6.0] - 2024-07-09

Expand Down
38 changes: 21 additions & 17 deletions discord/webhook/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,9 @@ def handle_message_parameters(
payload["embeds"] = [] if embed is None else [embed.to_dict()]
if content is not MISSING:
payload["content"] = str(content) if content is not None else None
_attachments = []
if attachments is not MISSING:
payload["attachments"] = [a.to_dict() for a in attachments]
_attachments = [a.to_dict() for a in attachments]

if view is not MISSING:
payload["components"] = view.to_components() if view is not None else []
Expand Down Expand Up @@ -674,32 +675,35 @@ def handle_message_parameters(
payload["allowed_mentions"] = previous_allowed_mentions.to_dict()

multipart = []
multipart_files = []
if file is not MISSING:
files = [file]

if files:
multipart.append({"name": "payload_json", "value": utils._to_json(payload)})
payload = None
if len(files) == 1:
file = files[0]
multipart.append(
for index, file in enumerate(files):
multipart_files.append(
{
"name": "file",
"name": f"files[{index}]",
"value": file.fp,
"filename": file.filename,
"content_type": "application/octet-stream",
}
)
else:
for index, file in enumerate(files):
multipart.append(
{
"name": f"file{index}",
"value": file.fp,
"filename": file.filename,
"content_type": "application/octet-stream",
}
)
_attachments.append(
{
"id": index,
"filename": file.filename,
"description": file.description,
}
)

if _attachments:
payload["attachments"] = _attachments

if multipart_files:
multipart.append({"name": "payload_json", "value": utils._to_json(payload)})
payload = None
multipart += multipart_files

return ExecuteWebhookParameters(payload=payload, multipart=multipart, files=files)

Expand Down