diff options
| author | Rapptz <[email protected]> | 2017-04-08 03:17:30 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-04-08 03:33:21 -0400 |
| commit | bf2066278e872a86da64ef4d4ce95dfaf8baf4e7 (patch) | |
| tree | 8fc0002844570de0929706731623aa109be5f533 /discord/http.py | |
| parent | Proper recursion when launching shards. (diff) | |
| download | discord.py-bf2066278e872a86da64ef4d4ce95dfaf8baf4e7.tar.xz discord.py-bf2066278e872a86da64ef4d4ce95dfaf8baf4e7.zip | |
Add support for multiple file attachments.
This is a breaking change. No longer does Messageable.send have a
filename keyword argument, instead this is all handled through the
discord.File model. To upload many files you must specify a list
of discord.File objects.
Diffstat (limited to 'discord/http.py')
| -rw-r--r-- | discord/http.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/discord/http.py b/discord/http.py index 9f43faad..e5d0c094 100644 --- a/discord/http.py +++ b/discord/http.py @@ -306,7 +306,7 @@ class HTTPClient: def send_typing(self, channel_id): return self.request(Route('POST', '/channels/{channel_id}/typing', channel_id=channel_id)) - def send_file(self, channel_id, buffer, *, filename=None, content=None, tts=False, embed=None): + def send_files(self, channel_id, *, files, content=None, tts=False, embed=None): r = Route('POST', '/channels/{channel_id}/messages', channel_id=channel_id) form = aiohttp.FormData() @@ -317,7 +317,12 @@ class HTTPClient: payload['embed'] = embed form.add_field('payload_json', utils.to_json(payload)) - form.add_field('file', buffer, filename=filename, content_type='application/octet-stream') + if len(files) == 1: + fp = files[0] + form.add_field('file', fp[0], filename=fp[1], content_type='application/octet-stream') + else: + for index, (buffer, filename) in enumerate(files): + form.add_field('file%s' % index, buffer, filename=filename, content_type='application/octet-stream') return self.request(r, data=form) |