From 1ebb52b13922bdc8600f398920594f5bddb1a035 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 28 Sep 2020 05:12:05 -0400 Subject: [PATCH 1/6] Guard GUILD_MEMBER_ADD/GUILD_MEMBER_REMOVE from errors If the guilds intent is disabled all guilds are unavailable. This means we don't receive a member_count attribute and cannot update it. --- discord/state.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/discord/state.py b/discord/state.py index aec723d4..fa6a9ff3 100644 --- a/discord/state.py +++ b/discord/state.py @@ -731,13 +731,22 @@ class ConnectionState: member = Member(guild=guild, data=data, state=self) if self._member_cache_flags.joined: guild._add_member(member) - guild._member_count += 1 + + try: + guild._member_count += 1 + except AttributeError: + pass + self.dispatch('member_join', member) def parse_guild_member_remove(self, data): guild = self._get_guild(int(data['guild_id'])) if guild is not None: - guild._member_count -= 1 + try: + guild._member_count -= 1 + except AttributeError: + pass + user_id = int(data['user']['id']) member = guild.get_member(user_id) if member is not None: From bf42cf72326a6fd6b64c697506be04c46acae26f Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 28 Sep 2020 05:39:13 -0400 Subject: [PATCH 2/6] Add warning if guilds intent is disabled. --- discord/state.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/discord/state.py b/discord/state.py index fa6a9ff3..82dbea68 100644 --- a/discord/state.py +++ b/discord/state.py @@ -139,6 +139,9 @@ class ConnectionState: else: intents = Intents.default() + if not intents.guilds: + log.warning('Guilds intent seems to be disabled. This may cause state related issues.') + try: chunk_guilds = options['fetch_offline_members'] except KeyError: From 821d833c11f32caf447f9ebabeea2c0b3ad0a2ec Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 28 Sep 2020 20:33:15 -0400 Subject: [PATCH 3/6] Add changelog for v1.5.0 --- docs/whats_new.rst | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/docs/whats_new.rst b/docs/whats_new.rst index 3cb60ffa..7a21df9a 100644 --- a/docs/whats_new.rst +++ b/docs/whats_new.rst @@ -11,6 +11,66 @@ Changelog This page keeps a detailed human friendly rendering of what's new and changed in specific versions. +.. _vp1p5p0: + +v1.5.0 +-------- + +This version came with forced breaking changes that Discord is requiring all bots to go through on October 7th. It is highly recommended to read the documentation on intents, :ref:`intents_primer`. + +API Changes +~~~~~~~~~~~~~ + +- Members and presences will no longer be retrieved due to an API change. See :ref:`privileged_intents` for more info. +- As a consequence, fetching offline members is disabled if the members intent is not enabled. + +New Features +~~~~~~~~~~~~~~ + +- Support for gateway intents, passed via ``intents`` in :class:`Client` using :class:`Intents`. +- Add :attr:`VoiceRegion.south_korea` (:issue:`5233`) +- Add support for ``__eq__`` for :class:`Message` (:issue:`5789`) +- Add :meth:`Colour.dark_theme` factory method (:issue:`1584`) +- Add :meth:`AllowedMentions.none` and :meth:`AllowedMentions.all` (:issue:`5785`) +- Add more concrete exceptions for 500 class errors under :class:`DiscordServerError` (:issue:`5797`) +- Implement :class:`VoiceProtocol` to better intersect the voice flow. +- Add :meth:`Guild.chunk` to fully chunk a guild. +- Add :class:`MemberCacheFlags` to better control member cache. See :ref:`intents_member_cache` for more info. +- Add support for :attr:`ActivityType.competing` (:issue:`5823`) + - This seems currently unused API wise. + +- Add support for message references, :attr:`Message.reference` (:issue:`5754`, :issue:`5832`) +- Add alias for :class:`ColourConverter` under ``ColorConverter`` (:issue:`5773`) +- Add alias for :attr:`PublicUserFlags.verified_bot_developer` under :attr:`PublicUserFlags.early_verified_bot_developer` (:issue:`5849`) +- |commands| Add support for ``require_var_positional`` for :class:`Command` (:issue:`5793`) + +Bug Fixes +~~~~~~~~~~ + +- Fix issue with :meth:`Guild.by_category` not showing certain channels. +- Fix :attr:`abc.GuildChannel.permissions_synced` always being ``False`` (:issue:`5772`) +- Fix handling of cloudflare bans on webhook related requests (:issue:`5221`) +- Fix cases where a keep-alive thread would ack despite already dying (:issue:`5800`) +- Fix cases where a :class:`Member` reference would be stale when cache is disabled in message events (:issue:`5819`) +- Fix ``allowed_mentions`` not being sent when sending a single file (:issue:`5835`) +- Fix ``overwrites`` being ignored in :meth:`abc.GuildChannel.edit` if ``{}`` is passed (:issue:`5756`, :issue:`5757`) +- |commands| Fix exceptions being raised improperly in command invoke hooks (:issue:`5799`) +- |commands| Fix commands not being properly ejected during errors in a cog injection (:issue:`5804`) +- |commands| Fix cooldown timing ignoring edited timestamps. +- |tasks| Fix tasks extending the next iteration on handled exceptions (:issue:`5762`, :issue:`5763`) + +Miscellaneous +~~~~~~~~~~~~~~~ + +- Webhook requests are now logged (:issue:`5798`) +- Remove caching layer from :attr:`AutoShardedClient.shards`. This was causing issues if queried before launching shards. +- Gateway rate limits are now handled. +- Warnings logged due to missed caches are now changed to DEBUG log level. +- Some strings are now explicitly interned to reduce memory usage. +- Usage of namedtuples has been reduced to avoid potential breaking changes in the future (:issue:`5834`) +- |commands| All :class:`BadArgument` exceptions from the built-in converters now raise concrete exceptions to better tell them apart (:issue:`5748`) +- |tasks| Lazily fetch the event loop to prevent surprises when changing event loop policy (:issue:`5808`) + .. _vp1p4p1: v1.4.1 From 1919267e5c8a2dcf3c0199ac8a05a221f1368ff8 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 28 Sep 2020 20:56:00 -0400 Subject: [PATCH 4/6] Add changelog for v1.4.2 --- docs/whats_new.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/whats_new.rst b/docs/whats_new.rst index 7a21df9a..571f0c47 100644 --- a/docs/whats_new.rst +++ b/docs/whats_new.rst @@ -71,6 +71,34 @@ Miscellaneous - |commands| All :class:`BadArgument` exceptions from the built-in converters now raise concrete exceptions to better tell them apart (:issue:`5748`) - |tasks| Lazily fetch the event loop to prevent surprises when changing event loop policy (:issue:`5808`) +.. _vp1p4p2: + +v1.4.2 +-------- + +This is a maintenance release with backports from :ref:`vp1p5p0`. + +Bug Fixes +~~~~~~~~~~~ + +- Fix issue with :meth:`Guild.by_category` not showing certain channels. +- Fix :attr:`abc.GuildChannel.permissions_synced` always being ``False`` (:issue:`5772`) +- Fix handling of cloudflare bans on webhook related requests (:issue:`5221`) +- Fix cases where a keep-alive thread would ack despite already dying (:issue:`5800`) +- Fix cases where a :class:`Member` reference would be stale when cache is disabled in message events (:issue:`5819`) +- Fix ``allowed_mentions`` not being sent when sending a single file (:issue:`5835`) +- Fix ``overwrites`` being ignored in :meth:`abc.GuildChannel.edit` if ``{}`` is passed (:issue:`5756`, :issue:`5757`) +- |commands| Fix exceptions being raised improperly in command invoke hooks (:issue:`5799`) +- |commands| Fix commands not being properly ejected during errors in a cog injection (:issue:`5804`) +- |commands| Fix cooldown timing ignoring edited timestamps. +- |tasks| Fix tasks extending the next iteration on handled exceptions (:issue:`5762`, :issue:`5763`) + +Miscellaneous +~~~~~~~~~~~~~~~ + +- Remove caching layer from :attr:`AutoShardedClient.shards`. This was causing issues if queried before launching shards. +- |tasks| Lazily fetch the event loop to prevent surprises when changing event loop policy (:issue:`5808`) + .. _vp1p4p1: v1.4.1 From 6d1bcf89da7b35b39e319544c2f4fd2a8e2e60c1 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 28 Sep 2020 20:57:10 -0400 Subject: [PATCH 5/6] Version bump to v1.5.0 --- discord/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord/__init__.py b/discord/__init__.py index c6b21593..985568a7 100644 --- a/discord/__init__.py +++ b/discord/__init__.py @@ -15,7 +15,7 @@ __title__ = 'discord' __author__ = 'Rapptz' __license__ = 'MIT' __copyright__ = 'Copyright 2015-2020 Rapptz' -__version__ = '1.5.0a' +__version__ = '1.5.0' __path__ = __import__('pkgutil').extend_path(__path__, __name__) @@ -61,7 +61,7 @@ from .team import * VersionInfo = namedtuple('VersionInfo', 'major minor micro releaselevel serial') -version_info = VersionInfo(major=1, minor=5, micro=0, releaselevel='alpha', serial=0) +version_info = VersionInfo(major=1, minor=5, micro=0, releaselevel='final', serial=0) try: from logging import NullHandler From 1518790c87ccbdda0093b9ae0bb66a47382b261f Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 28 Sep 2020 21:42:32 -0400 Subject: [PATCH 6/6] Some minor documentation fixes. Make examples all mention where to put it for the unaware. --- docs/intents.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/intents.rst b/docs/intents.rst index 17c43592..cda81380 100644 --- a/docs/intents.rst +++ b/docs/intents.rst @@ -25,6 +25,12 @@ For example, if you want a bot that functions without spammy events like presenc intents.typing = False intents.presences = False + # Somewhere else: + # client = discord.Client(intents=intents) + # or + # from discord.ext import commands + # bot = commands.Bot(command_prefix='!', intents=intents) + Note that this doesn't enable :attr:`Intents.members` since it's a privileged intent. Another example showing a bot that only deals with messages and guild information: @@ -36,6 +42,12 @@ Another example showing a bot that only deals with messages and guild informatio # If you also want reaction events enable the following: # intents.reactions = True + # Somewhere else: + # client = discord.Client(intents=intents) + # or + # from discord.ext import commands + # bot = commands.Bot(command_prefix='!', intents=intents) + .. _privileged_intents: Privileged Intents @@ -152,7 +164,7 @@ For example: # client = discord.Client(intents=intents) # or # from discord.ext import commands - # bot = commands.Bot(command_prefix="!", intents=intents) + # bot = commands.Bot(command_prefix='!', intents=intents) Why does ``on_ready`` take so long to fire? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -186,6 +198,6 @@ On Windows use ``py -3`` instead of ``python3``. .. warning:: - There is no date in which the old gateway will stop working so it is recommended to update your code instead. + There is no currently set date in which the old gateway will stop working so it is recommended to update your code instead. If you truly dislike the direction Discord is going with their API, you can contact them via `support `_