aboutsummaryrefslogtreecommitdiff
path: root/discord/message.py
diff options
context:
space:
mode:
Diffstat (limited to 'discord/message.py')
-rw-r--r--discord/message.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/discord/message.py b/discord/message.py
index a34ba711..c681d33e 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -68,9 +68,30 @@ def convert_emoji_reaction(emoji):
raise InvalidArgument('emoji argument must be str, Emoji, or Reaction not {.__class__.__name__}.'.format(emoji))
-class Attachment:
+class Attachment(Hashable):
"""Represents an attachment from Discord.
+ .. container:: operations
+
+ .. describe:: str(x)
+
+ Returns the URL of the attachment.
+
+ .. describe:: x == y
+
+ Checks if the attachment is equal to another attachment.
+
+ .. describe:: x != y
+
+ Checks if the attachment is not equal to another attachment.
+
+ .. describe:: hash(x)
+
+ Returns the hash of the attachment.
+
+ .. versionchanged:: 1.7
+ Attachment can now be casted to :class:`str` and is hashable.
+
Attributes
------------
id: :class:`int`
@@ -111,6 +132,9 @@ class Attachment:
def __repr__(self):
return '<Attachment id={0.id} filename={0.filename!r} url={0.url!r}>'.format(self)
+ def __str__(self):
+ return self.url or ''
+
async def save(self, fp, *, seek_begin=True, use_cached=False):
"""|coro|