aboutsummaryrefslogtreecommitdiff
path: root/discord/webhook
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-05-01 09:21:39 -0400
committerRapptz <[email protected]>2021-05-01 09:21:39 -0400
commit02e21a890547ad87d19e1161792e7353266b409a (patch)
tree26061b812aa70126ce8bfe712541e2aab269aadc /discord/webhook
parentAdd typings for message related classes (diff)
downloaddiscord.py-02e21a890547ad87d19e1161792e7353266b409a.tar.xz
discord.py-02e21a890547ad87d19e1161792e7353266b409a.zip
Fix sending multipart data with SyncWebhook
Fixes #6825
Diffstat (limited to 'discord/webhook')
-rw-r--r--discord/webhook/sync.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/discord/webhook/sync.py b/discord/webhook/sync.py
index 23445317..eb79022c 100644
--- a/discord/webhook/sync.py
+++ b/discord/webhook/sync.py
@@ -127,6 +127,7 @@ class WebhookAdapter:
response: Optional[Response] = None
data: Optional[Union[Dict[str, Any], str]] = None
+ file_data: Optional[Dict[str, Any]] = None
method = route.method
url = route.url
webhook_id = route.webhook_id
@@ -137,13 +138,16 @@ class WebhookAdapter:
file.reset(seek=attempt)
if multipart:
- form_data: Dict[str, Any] = {}
+ file_data = {}
for p in multipart:
- form_data[p['name']] = (p['filename'], p['value'], p['content_type'])
- to_send = form_data
+ name = p['name']
+ if name == 'payload_json':
+ to_send = { 'payload_json': p['value'] }
+ else:
+ file_data[name] = (p['filename'], p['value'], p['content_type'])
try:
- with session.request(method, url, data=to_send, headers=headers, params=params) as response:
+ with session.request(method, url, data=to_send, files=file_data, headers=headers, params=params) as response:
log.debug(
'Webhook ID %s with %s %s has returned status code %s',
webhook_id,