aboutsummaryrefslogtreecommitdiff
path: root/discord/file.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2018-12-14 19:09:25 -0500
committerRapptz <[email protected]>2018-12-14 19:09:25 -0500
commit93d576a65bce7a8ea13dc87331ef5c7c224e9770 (patch)
treec5bbc1a2c886d2d03ebb5ffc22e6b718239e270b /discord/file.py
parentUpdate Message.mention_everyone docs to include @here (diff)
downloaddiscord.py-93d576a65bce7a8ea13dc87331ef5c7c224e9770.tar.xz
discord.py-93d576a65bce7a8ea13dc87331ef5c7c224e9770.zip
Add support for spoiler attachments.
Diffstat (limited to 'discord/file.py')
-rw-r--r--discord/file.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/discord/file.py b/discord/file.py
index f56de713..2351d3fb 100644
--- a/discord/file.py
+++ b/discord/file.py
@@ -48,11 +48,13 @@ class File:
The filename to display when uploading to Discord.
If this is not given then it defaults to ``fp.name`` or if ``fp`` is
a string then the ``filename`` will default to the string given.
+ spoiler: :class:`bool`
+ Whether the attachment is a spoiler.
"""
__slots__ = ('fp', 'filename', '_true_fp')
- def __init__(self, fp, filename=None):
+ def __init__(self, fp, filename=None, *, spoiler=False):
self.fp = fp
self._true_fp = None
@@ -64,6 +66,9 @@ class File:
else:
self.filename = filename
+ if spoiler and not self.filename.startswith('SPOILER_'):
+ self.filename = 'SPOILER_' + self.filename
+
def open_file(self):
fp = self.fp
if isinstance(fp, str):