diff --git a/discord/message.py b/discord/message.py index a34ba7119..c681d33e7 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 ''.format(self) + def __str__(self): + return self.url or '' + async def save(self, fp, *, seek_begin=True, use_cached=False): """|coro|