diff options
| author | Rapptz <[email protected]> | 2018-02-13 05:41:10 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2018-02-13 05:41:10 -0500 |
| commit | 355eb08b25b5c46c4c061cf50594650738ac09cf (patch) | |
| tree | 81415bc9bf6ebbafb505443267940478ebb1494b | |
| parent | Fix websockets 4.0 support (diff) | |
| download | discord.py-355eb08b25b5c46c4c061cf50594650738ac09cf.tar.xz discord.py-355eb08b25b5c46c4c061cf50594650738ac09cf.zip | |
Add seek_begin keyword argument to Attachment.save
| -rw-r--r-- | discord/message.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/discord/message.py b/discord/message.py index 875defe6..aef1cb1a 100644 --- a/discord/message.py +++ b/discord/message.py @@ -72,7 +72,7 @@ class Attachment: self._http = state.http @asyncio.coroutine - def save(self, fp): + def save(self, fp, *, seek_begin=True): """|coro| Saves this attachment into a file-like object. @@ -83,6 +83,9 @@ class Attachment: The file-like object to save this attachment to or the filename to use. If a filename is passed then a file is created with that filename and used instead. + seek_begin: bool + Whether to seek to the beginning of the file after saving is + successfully done. Raises -------- @@ -102,7 +105,10 @@ class Attachment: with open(fp, 'wb') as f: return f.write(data) else: - return fp.write(data) + written = fp.write(data) + if seek_begin: + fp.seek(0) + return written class Message: """Represents a message from Discord. |