diff options
| author | Rapptz <[email protected]> | 2018-01-03 21:55:48 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2018-01-03 21:55:48 -0500 |
| commit | 30b5047b0edff9a3ed3b7a924a16761ccaa8e95b (patch) | |
| tree | 482ecfd53eb12ed93a0143a5bf102d16b3d48dcf | |
| parent | websupport is not actually a Sphinx extension apparently. (diff) | |
| download | discord.py-30b5047b0edff9a3ed3b7a924a16761ccaa8e95b.tar.xz discord.py-30b5047b0edff9a3ed3b7a924a16761ccaa8e95b.zip | |
Fix multipart sending for RequestsWebhookAdapter to work.
| -rw-r--r-- | discord/webhook.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/discord/webhook.py b/discord/webhook.py index 7db5095a..5702fa6e 100644 --- a/discord/webhook.py +++ b/discord/webhook.py @@ -147,7 +147,7 @@ class AsyncWebhookAdapter(WebhookAdapter): file = multipart.pop('file', None) data = aiohttp.FormData() if file: - data.add_field('file', file[0], filename=file[1], content_type=file[2]) + data.add_field('file', file[1], filename=file[0], content_type=file[2]) for key, value in multipart.items(): data.add_field(key, value) @@ -226,6 +226,9 @@ class RequestsWebhookAdapter(WebhookAdapter): headers['Content-Type'] = 'application/json' data = utils.to_json(payload) + if multipart is not None: + data = { 'payload_json': multipart.pop('payload_json') } + for tries in range(5): r = self.session.request(verb, url, headers=headers, data=data, files=multipart) r.encoding = 'utf-8' @@ -647,7 +650,7 @@ class Webhook: if file is not None: try: - to_pass = (file.open_file(), file.filename, 'application/octet-stream') + to_pass = (file.filename, file.open_file(), 'application/octet-stream') return self._adapter.execute_webhook(wait=wait, file=to_pass, payload=payload) finally: file.close() |