From 984cbacf593aea347b85e007be62cb5f4433e34f Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Thu, 26 Dec 2024 18:40:40 -0600 Subject: [PATCH 1/4] fix: Fixed Attachment Metadata Being Set Incorrectly In Interaction Responses --- CHANGELOG.md | 2 ++ discord/webhook/async_.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a0edc608..fbcb3730fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,8 @@ These changes are available on the `master` branch, but have not yet been releas apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650)) - Fixed type annotations of cached properties. ([#2635](https://github.com/Pycord-Development/pycord/issues/2635)) +- Fixed attachment metadata being set incorrectly in interaction responses causing it to + be ignored. ([#2679](https://github.com/Pycord-Development/pycord/pull/2679)) ### Changed diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 23b6386a7d..85c80bd600 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -522,7 +522,7 @@ def create_interaction_response( "content_type": "application/octet-stream", } ) - payload["attachments"] = attachments + payload["data"]["attachments"] = attachments form[0]["value"] = utils._to_json(payload) route = Route( From fb09d53fd819317988457ec09679b5b7b58c7da7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Dec 2024 17:08:44 +0000 Subject: [PATCH 2/4] style(pre-commit): auto fixes from pre-commit.com hooks --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a8738b9a..20de3cbf21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,8 +67,9 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed an error when responding non-ephemerally with a `Paginator` to an ephemerally deferred interaction. ([#2661](https://github.com/Pycord-Development/pycord/pull/2661)) -- Fixed attachment metadata being set incorrectly in interaction responses causing the metadata to - be ignored by Discord. ([#2679](https://github.com/Pycord-Development/pycord/pull/2679)) +- Fixed attachment metadata being set incorrectly in interaction responses causing the + metadata to be ignored by Discord. + ([#2679](https://github.com/Pycord-Development/pycord/pull/2679)) ### Changed From 75b7ef0391dcf21e9c24bcfc491b3945041e7974 Mon Sep 17 00:00:00 2001 From: Ice Wolfy Date: Sat, 28 Dec 2024 13:12:46 -0600 Subject: [PATCH 3/4] fix: Ensure Payload Data Exists --- discord/webhook/async_.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 85c80bd600..5db1653faa 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -503,6 +503,8 @@ def create_interaction_response( if data is not None: payload["data"] = data + else: + payload["data"] = {} form = [{"name": "payload_json"}] attachments = [] files = files or [] @@ -522,7 +524,8 @@ def create_interaction_response( "content_type": "application/octet-stream", } ) - payload["data"]["attachments"] = attachments + if attachments: + payload["data"]["attachments"] = attachments form[0]["value"] = utils._to_json(payload) route = Route( From 88503b7e1d05a7025d8dd290cceb33cdab5e8f86 Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:07:52 +0300 Subject: [PATCH 4/4] chore: use inline if Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- discord/webhook/async_.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 58f759ee52..4b87a7e0f3 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -502,10 +502,7 @@ def create_interaction_response( "type": type, } - if data is not None: - payload["data"] = data - else: - payload["data"] = {} + payload["data"] = data if data is not None else {} form = [{"name": "payload_json"}] attachments = [] files = files or []