aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-08-25 09:07:30 -0400
committerRapptz <[email protected]>2017-08-25 09:07:30 -0400
commit94e2c0e66100d672faac9dc430daa0569e7d3250 (patch)
tree263322755ab36199a96c1870fcc9ba4f3421c6f2 /docs
parentRename webhook parameters to payload to avoid shadowing. (diff)
downloaddiscord.py-94e2c0e66100d672faac9dc430daa0569e7d3250.tar.xz
discord.py-94e2c0e66100d672faac9dc430daa0569e7d3250.zip
Add upload from URL to the FAQ.
Diffstat (limited to 'docs')
-rw-r--r--docs/faq.rst15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/faq.rst b/docs/faq.rst
index 8b73357f..bc01eabe 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -134,6 +134,21 @@ To upload multiple files, you can use the ``files`` keyword argument instead of
]
await channel.send(files=my_files)
+If you want to upload something from a URL, you will have to use an HTTP request using ``aiohttp``
+and then pass an ``io.BytesIO`` instance to :class:`File` like so:
+
+.. code-block:: python3
+
+ import io
+ import aiohttp
+
+ async with aiohttp.ClientSession() as session:
+ async with session.get(my_url) as resp:
+ if resp.status != 200:
+ return await channel.send('Could not download file...')
+ data = io.BytesIO(await resp.read())
+ await channel.send(file=discord.File(data, 'cool_image.png'))
+
How can I add a reaction to a message?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~