diff --git a/README.rst b/README.rst index 34737d59..aa926618 100644 --- a/README.rst +++ b/README.rst @@ -20,11 +20,13 @@ Custom Features - ``Guild.icon_url`` and ``User.avatar_url`` return the string in stead of Asset. use icon/avatar url_as to get the Asset - Merged in ext-colors (https://github.com/MGardne8/DiscordPyColours) - Using Rapptz/discord.py/tree/neo-docs for documentation -- Adding support for ``hex()`` to ``discord.Color`` +- Added support for ``hex()`` to ``discord.Color`` - Added ``Client.embed_color`` / ``Bot.embed_color`` - Added ``Client.set_embed_color`` / ``Bot.set_embed_color`` - Added ``TextChannel.can_send`` - Added ``Intents.from_list`` +- Added support for ``int()`` to ``discord.User``, ``discord.Member``, ``discord.Emoji``, ``discord.Role``, ``discord.Guild``, ``discord.Message``, ``discord.TextChannel``, ``discord.VoiceChannel``, ``discord.CategoryChannel``, ``discord.Attachment`` and ``discord.Message``. This will return their id +- Added support for ``str()`` to ``discord.Message``. This will return the message content Key Features ------------- diff --git a/discord/abc.py b/discord/abc.py index 0ac87d13..e721033a 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -206,6 +206,9 @@ class GuildChannel: def __str__(self): return self.name + def __int__(self): + return self.id + @property def _sorting_bucket(self): raise NotImplementedError diff --git a/discord/emoji.py b/discord/emoji.py index 5feb1c90..b724e2f7 100644 --- a/discord/emoji.py +++ b/discord/emoji.py @@ -112,6 +112,9 @@ class Emoji(_EmojiTag): return ''.format(self) return "<:{0.name}:{0.id}>".format(self) + def __int__(self): + return self.id + def __repr__(self): return ''.format(self) diff --git a/discord/guild.py b/discord/guild.py index becba235..af45c45e 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -207,6 +207,9 @@ class Guild(Hashable): def __str__(self): return self.name + def __int__(self): + return self.id + def __repr__(self): attrs = ( 'id', 'name', 'shard_id', 'chunked' diff --git a/discord/message.py b/discord/message.py index 9e61e6b5..12675975 100644 --- a/discord/message.py +++ b/discord/message.py @@ -84,6 +84,9 @@ class Attachment: """:class:`bool`: Whether this attachment contains a spoiler.""" return self.filename.startswith('SPOILER_') + def __int__(self): + return self.id + def __repr__(self): return ''.format(self) @@ -388,6 +391,9 @@ class Message: def __str__(self): return self.content + def __int__(self): + return self.id + def __repr__(self): return ''.format(self) diff --git a/discord/role.py b/discord/role.py index 882f346e..09a42599 100644 --- a/discord/role.py +++ b/discord/role.py @@ -99,6 +99,9 @@ class Role(Hashable): def __str__(self): return self.name + def __int__(self): + return self.id + def __repr__(self): return ''.format(self) diff --git a/discord/user.py b/discord/user.py index 135eb7e9..8726abaf 100644 --- a/discord/user.py +++ b/discord/user.py @@ -92,6 +92,9 @@ class BaseUser(_BaseUser): def __str__(self): return '{0.name}#{0.discriminator}'.format(self) + def __int__(self): + return self.id + def __eq__(self, other): return isinstance(other, _BaseUser) and other.id == self.id diff --git a/docs/index.rst b/docs/index.rst index 3b3d0da5..21d0c421 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -30,6 +30,7 @@ Custom Features - Added ``Client.set_embed_color`` / ``Bot.set_embed_color`` - Added ``TextChannel.can_send`` - Added ``Intents.from_list`` +- Added support for ``int()`` to ``discord.User``, ``discord.Member``, ``discord.Emoji``, ``discord.Role``, ``discord.Guild``, ``discord.Message``, ``discord.TextChannel``, ``discord.VoiceChannel``, ``discord.CategoryChannel``, ``discord.Attachment`` and ``discord.Message``. This will return their id - Added support for ``str()`` to ``discord.Message``. This will return the message content Features