diff options
| author | Rapptz <[email protected]> | 2015-12-04 23:35:28 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-04 23:35:28 -0500 |
| commit | b87dfccfce3b23b1ac6d38fab2bdfb8618ebbef4 (patch) | |
| tree | a6b942016a133a39d1e63841ee847a5a4fa8ebf3 /discord/utils.py | |
| parent | Add enumerators instead of strings. (diff) | |
| download | discord.py-b87dfccfce3b23b1ac6d38fab2bdfb8618ebbef4.tar.xz discord.py-b87dfccfce3b23b1ac6d38fab2bdfb8618ebbef4.zip | |
Add server management commands.
Diffstat (limited to 'discord/utils.py')
| -rw-r--r-- | discord/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/discord/utils.py b/discord/utils.py index d2477696..ff035508 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -27,6 +27,7 @@ DEALINGS IN THE SOFTWARE. from re import split as re_split from .errors import HTTPException, Forbidden, NotFound, InvalidArgument import datetime +from base64 import b64encode import asyncio def parse_time(timestamp): @@ -81,6 +82,12 @@ def _get_mime_type_for_image(data): else: raise InvalidArgument('Unsupported image type given') +def _bytes_to_base64_data(data): + fmt = 'data:{mime};base64,{data}' + mime = _get_mime_type_for_image(data) + b64 = b64encode(data).decode('ascii') + return fmt.format(mime=mime, data=b64) + try: create_task = asyncio.ensure_future except AttributeError: |