Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4014 error when moving bot to another voice channel #5904

Closed
4 tasks done
TimK50 opened this issue Oct 6, 2020 · 15 comments
Closed
4 tasks done

4014 error when moving bot to another voice channel #5904

TimK50 opened this issue Oct 6, 2020 · 15 comments
Assignees
Labels
bug This is a bug with the library.

Comments

@TimK50
Copy link

TimK50 commented Oct 6, 2020

Summary

I'm trying to move bot to another voice channel after it connects. But it disconnects after moving with Gateway Intent Error 4014

Reproduction Steps

intents = discord.Intents.all()
bot = commands.Bot(command_prefix=def_prefix, intents=intents)
await ctx.author.voice.channel.connect()

then await ctx.guild.voice_client.move_to(another.voice.channel) or manual moving

then in log:

2020-10-06 17:40:19,780:DEBUG:discord.gateway: Keeping shard ID None voice websocket alive with timestamp 1601995219780.
2020-10-06 17:40:19,780:DEBUG:discord.gateway: Sending voice websocket frame: {'op': 3, 'd': 1601995219780}.
2020-10-06 17:40:19,789:DEBUG:discord.gateway: Voice websocket frame received: {'op': 6, 'd': 1601995219780}
2020-10-06 17:40:21,111:DEBUG:discord.gateway: Received WSMessage(type=<WSMsgType.CLOSE: 8>, data=4014, extra='Disconnected.')
2020-10-06 17:40:21,111:INFO:discord.voice_client: Disconnecting from voice normally, close code 4014.
2020-10-06 17:40:21,112:INFO:discord.voice_client: The voice handshake is being terminated for Channel ID 732706167028973769 (Guild ID 659036893870293022)

Expected Results

Bot not disconnects after moving and continue working (before.channel = smth, after.channel = smth)

Actual Results

Bot moves (before.channel = smth1, after.channel = smth2)
Bot disconnects (before.channel = smth2, after.channel = None)

Intents

intents = discord.Intents.all()

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.
  • I have provided the intents that my bot is using.

4014 | Disallowed intent(s)
You sent a disallowed intent for a Gateway Intent. You may have tried to specify an intent that you have not enabled or are not whitelisted for.

System Information

  • Python v3.8.2-final
  • discord.py v1.5.0-final
  • aiohttp v3.6.2
  • system info: Windows 10 10.0.19041
@TimK50 TimK50 added the bug This is a bug with the library. label Oct 6, 2020
@rafaelwastaken
Copy link

FYI you're looking at the wrong event code, 4014 for voice is Disconnected - Either the channel was deleted or you were kicked. Should not reconnect..

@TimK50
Copy link
Author

TimK50 commented Oct 6, 2020

FYI you're looking at the wrong event code, 4014 for voice is Disconnected - Either the channel was deleted or you were kicked. Should not reconnect..

But in log it recieved by discord.gateway, not by discord.voice

@pac-234
Copy link

pac-234 commented Oct 9, 2020

I have the exact same issue, here are my logs:

2020-10-09 08:27:10,102:DEBUG:discord.client: Dispatching event socket_response
2020-10-09 08:27:10,103:DEBUG:discord.client: Dispatching event voice_state_update
2020-10-09 08:27:10,105:DEBUG:discord.gateway: Updating our voice state to {'op': 4, 'd': {'guild_id': 102874787014956544, 'channel_id': 103888806519795712, 'self_mute': False, 'self_deaf': False}}.
2020-10-09 08:27:10,106:DEBUG:discord.client: Dispatching event socket_raw_send
2020-10-09 08:27:10,251:DEBUG:discord.client: Dispatching event socket_raw_receive
2020-10-09 08:27:10,252:DEBUG:discord.gateway: For Shard ID None: WebSocket Event: {'t': 'VOICE_STATE_UPDATE', 's': 11, 'op': 0, 'd': {'member': {'user': {'username': 'Metheros Bot', 'id': '293345489384898571', 'discriminator': '5834', 'bot': True, 'avatar': 'bc002bef23da9a121f3fb056a6a4af7c'}, 'roles': ['341596227269427210'], 'nick': 'Mebot', 'mute': False, 'joined_at': '2017-07-29T11:46:43.889000+00:00', 'hoisted_role': '341596227269427210', 'deaf': False}, 'user_id': '293345489384898571', 'suppress': False, 'session_id': 'ca8505b0d58d51a08b2d72bf64f1687d', 'self_video': False, 'self_mute': False, 'self_deaf': False, 'mute': False, 'guild_id': '102874787014956544', 'deaf': False, 'channel_id': '103888806519795712'}}
2020-10-09 08:27:10,253:DEBUG:discord.client: Dispatching event socket_response
2020-10-09 08:27:10,254:DEBUG:discord.client: Dispatching event voice_state_update
2020-10-09 08:27:10,255:DEBUG:discord.gateway: Received WSMessage(type=<WSMsgType.CLOSE: 8>, data=4014, extra='Disconnected.')
2020-10-09 08:27:10,256:INFO:discord.voice_client: Disconnecting from voice normally, close code 4014.

@EvieePy
Copy link
Contributor

EvieePy commented Oct 9, 2020

Cannot reproduce.

@rafaelwastaken
Copy link

This appears to happen only in guilds that have a different voice server for each voice channel

@TimK50
Copy link
Author

TimK50 commented Oct 10, 2020

This appears to happen only in guilds that have a different voice server for each voice channel

So how to deal with this problem?

@pac-234
Copy link

pac-234 commented Oct 11, 2020

This appears to happen only in guilds that have a different voice server for each voice channel

Interesting, how to check which Server a channel is on?

@MinnDevelopment
Copy link
Contributor

MinnDevelopment commented Oct 11, 2020

Discord will send a new VOICE_SERVER_UPDATE when the channel has a different voice server. It will close the old connection with a 4014 and the client needs to open a new connection when the server update arrives. The order of these events is not defined, from what I could tell.

To fix this the connection has to be re-established when a VOICE_SERVER_UPDATE with a different endpoint is received.

@xFranciB
Copy link

To fix this the connection has to be re-established when a VOICE_SERVER_UPDATE with a different endpoint is received.

I see what you mean @MinnDevelopment, but how do you do that? The endpoint servers are different on my main server, but then I tried the same thing on another server and it didn't leave on its own because the endpoint server were the same...
How do I set the same endpoint server for all voice channels? I don't think that's even possible.

@MinnDevelopment
Copy link
Contributor

How do I set the same endpoint server for all voice channels? I don't think that's even possible.

You don't. The library has to handle it.

@xFranciB
Copy link

You don't. The library has to handle it.

Soo... this is a bug and we just have to wait for a fix, right?

@pac-234
Copy link

pac-234 commented Oct 14, 2020

Thats how i understand it, but maybe we can get confirmation from somebody responsible?

@TimK50
Copy link
Author

TimK50 commented Oct 15, 2020

VoiceClient doesn't catch event to change voice server when moving bot. It works only with connect by method.

@cheez3d
Copy link

cheez3d commented Oct 15, 2020

VoiceClient doesn't catch event to change voice server when moving bot. It works only with connect by method.

Using a disconnect followed by a connect to the new voice channel instead of using move_to directly is a good workaround for now. The issue is that when you manually drag and drop the bot between 2 voice channels that are on different endpoint servers, it is equivalent to what move_to would do and the bot still disconnects.

@Rapptz Rapptz self-assigned this Oct 17, 2020
@Rapptz Rapptz closed this as completed Oct 18, 2020
Rapptz added a commit that referenced this issue Oct 18, 2020
Not overly proud of this implementation but this allows the library
to differentiate between a 4014 that means "move to another channel" or
"move nowhere". Sometimes the VOICE_STATE_UPDATE comes before the
actual websocket disconnect so special care had to be taken in that
case.

Fix #5904
@pac-234
Copy link

pac-234 commented Oct 20, 2020

thanks for the quick fix!

diceroll123 added a commit to diceroll123/discord.py that referenced this issue Dec 5, 2020
* Fix incorrect class reference in documentation

* Fix minor markdown typo in migrating.rst

* Support discord.com/invite URL in resolve_invite

* Fix TypeError on missing shard_id kwarg

* Escape masked URLs; Support quotes for as_needed

* Fix reconnecting loop due to failed handshake on region change

* Change PartialInviteGuild.icon_url_as to mimic Guild.icon_url_as

* Fix error raised when using the roles parameter.

* Add versionadded to VoiceClient latency and average_latency

* Update Message.system_content join strings to be up to date.

Fixes Rapptz#4211

* Fix Guild.by_category not showing empty categories.

* Fix a KeyError for channels with no category in Guild.by_category

* Fix various inconsistencies within the documentation (Rapptz#5067)

* [commands] Add a new exception class for command registration errors

* [tasks] Fix issue with default error handler in class context

* [commands] Raise TypeError when Optional is used with Greedy converter

* Add support for Discord templates

* Add support for integrations

* Add support for bulk editing role positions

* [bugs] stop resolving Object for template/invite; remove dupe methods

* Fix typo with voice_client documentation

* Documentation formatting

* Allow Webhook to be hashable and comparable

* Allow more methods to set an audit log reason

* Add a licence and encoding declaration to missing files

* Document raises for Converter.convert

* [docs] fix reference to `Guild` and document `utils.resolve_template`

* Fix TypeError when not specifying roles.

* Don't use a namedtuple for _Overwrites

Fix Rapptz#5109

* Fix detection of some JPEG images without JFIF or Exif info

Closes Rapptz#5143

* Add Guild.change_voice_state to control our voice state.

* Add double backticks for some parameter mentions in the documentation.

* Added exception documentation for Guild.create_voice_channel

* [commands] GroupView.get_command shouldn't raise errors for empty names

* Add gray alias for discord.Colour

* [commands] Add documentation for exceptions in Context.(re)invoke

* Fix typo in on_socket_raw_send documentation

* Add a changelog entry for v1.3.4

* Add documentation on bot_check_once

* Add revisions to check_once docs

* Rewrite of AutoShardedClient to prevent overlapping identify

This is experimental and I'm unsure if it actually works

* Add shard ID to keep alive logger messages

* Can't use %d in here

* Fix AttributeError on reconnection

* Rewrite gateway to use aiohttp instead of websockets

* Use a proper type for the event queue

* Fix voice websocket connections

* Fix READY not firing for multi-processed AutoShardedClient clusters

* Add before_identify_hook to have finer control over IDENTIFY syncing

* Make every shard maintain its own reconnect loop

Previously if a disconnect happened the client would get in a bad state
and certain shards would be double sending due to unhandled exceptions
raising back to Client.connect and causing all shards to be reconnected
again.

This new code overrides Client.connect to have more finer control and
allow each individual shard to maintain its own reconnect loop and then
serially request reconnection to ensure that IDENTIFYs are not
overlapping.

* Handle connection errors during reidentify flow.

* Add shard related connection and resume events.

These include:
* on_shard_resumed
* on_shard_connect
* on_shard_disconnect

* Handle Connection Reset by Peer connection errors.

This should work both on Windows and on Linux.

Apparently these types of blips are considered normal for Discord. So
rather than letting the reconnect logic handler expect these to be
catastrophic, it should handle it specially so it doesn't waste an
IDENTIFY for what ultimately should just be a small networking blip.

This also makes it less noisy for the end-user as these complaints
happen from time to time.

* If we're out of retries just raise the OSError

* Add a timeout for receiving websocket messages.

* Add guild_ready_timeout to control the timeout of GUILD_CREATE stream

This also fixes a timing issue where READY would take far too long to
load for big bot authors.

Closes Rapptz#4112

* Update message references in AutoShardedConnectionState

Fixes Rapptz#5133

* Use a subclass rather than monkey-patching for the websocket

* Propagate exceptions when an unhandled error happens

* Add an exposed way to extract shard-specific information.

Closes Rapptz#2654

* Fix AttributeError from internal queue being double underscore.

* Fix NameError with resolving codes with Template

* Specify where to get max_members in documentation

* Fix typo when creating a guild via template

* Terminate shard processing queue when a clean close is encountered.

Fix Rapptz#5180

* Optimize Channel.permissions_for by not creating temporary objects

This seemed to have shaved a few microseconds:
10.8 µs ± 79.6 ns per loop → 8.53 µs ± 48.1 ns per loop
12 µs ± 613 ns per loop → 8.72 µs ± 30.2 ns per loop

With 100K loops each

* Fix AttributeError when fetching reactions without cache

* Fix gramatical error in Client guild_subscriptions docs

* [tasks] Remove HTTPException as an exception to silently continue for

* Fix endpoint strings with :443 instead of :80

Fix Rapptz#5191
Close Rapptz#5188

* Propagate manual close codes to socket subclass

aiohttp seems to not set it during its state machine flow

* Require people to use templates when making an issue

* Fix NameError and AttributeError in Template and Integrations

* Be defensive in case Discord breaks something with WS URLs again

* [commands] Restart subcommand_passed chain on invoke

Fix Rapptz#5198

* [commands] Provide a way to retrieve time left for a cooldown

* [commands] implement HelpCommand.add/remove_check

* Add missing comma in template.py

* Fix a typo with webhook documentation

* Fixed a typo in message unpinning docs

* Add remaining user flags

* Add changelog for 1.4

* Version bump to 1.4

* Terminate connection if a close code couldn't be handled

* Fix error when trying to clear empty image/thumbnail in embeds

* Extend __path__ with pkgutil to allow editable extensions

* Add changelog for 1.4.1

* Version bump to 1.4.1

* Document on_error "special" behavior

* Add South Korea VoiceRegion

* update the docs on RawReactionActionEvent.member

* Fix letter to be consistent with the rest of the docs

* Fix hyperlink reference to PartialInviteChannel in Client

* Document merging behaviour of AllowedMentions in Messageable.send

* Fix bug with Guild.by_category not showing some channels

If categories come after a child channel in the dictionary mapping for
whatever reason, then the previous code would remove it from the
mapping and set it to []. This commit aims to fix this.

* Version bump for development purposes

* Fix issue with empty overwrites

Fixes Rapptz#5756.

* [commands] Use edited timestamp if provided for cooldown timing

* [tasks] Don't update _next_iteration on retry

* [commands] Added ColorConverter alias

* Don't call close() if we've already been closed in Client.run

* Added __eq__ to Message

* Add COMMUNITY to Guild.features

* Classmethods all and none for AllowedMentions

* [commands] Add subclasses of BadArgument for converters

* [commands] BadBooleanArgument -> BadBoolArgument

* [commands] add require_var_positional

* [docs] remove unresolved doc refs, fix attribute ref

* [commands] Update Bot.command() decorator docs

* Add fetch_message_fast using history endpoint

* Add discord.Colour classmethod dark_theme

* Fix Member.joined_at documentation

* [commands] Fix exception raised in Command invoke hooks.

* [commands] Correct command removing during cog injecting

* Fix comparison for overwrites when checking if a channel is synced

* Add logging to webhooks

Fixes Rapptz#5798

* Handle cloudflare bans on webhook requests

Fixes Rapptz#5221

* Guard uses of the keep alive thread in case they're None

Fixes Rapptz#5800

* Add a more concrete exception for 500 status codes.

Fixes Rapptz#5797

* [tasks] Lazily fetch event loop if one isn't provided

Fixes Rapptz#5808

* Remove caching from AutoShardedClient.shards

* Add missing permission in clone documentation

* Revert "Add fetch_message_fast using history endpoint"

This reverts commit a309088.

A rate limited was added to this method after 5 years defeating the
purpose of it.

* Completely update member references from message inner members.

Fixes Rapptz#5819

* Add labels to the issue templates

* Update issue template to redirect to discussions

* issue/PR templates: use h2 instead of h3

`h2` is the semantically correct heading here, as `h1` is for 
document titles and `h2` is for the top level headings within
a document. `h3` should be used for subheadings of `h2` headings.

* Add competing activity type

* Fix allowed_mentions when sending files

* Add bot.listen() suggestion to on_message faq

* Remove namedtuples to better future guard the library

* Use quotes when installing in the README

Other shells have a hard time with square brackets.

Closes Rapptz#5821

* Add support for message_reference on Message object

* Fix and add documentation

* Implement VoiceProtocol lower level hooks.

This allows changing the connect flow and taking control of it without
relying on internal events or tricks.

* Correct some protocol errors in v4 of voice gateway

* Fix issues with VoiceProtocol docstrsings.

* Properly handle disconnects in voice when force disconnected

* Add support for guild intents

* Handle gateway rate limits by using a rate limiter.

With the new chunking changes this will become necessary and we don't
want to disconnect from having too many outwards requests.

* Change unknown cache log warnings from WARNING -> DEBUG

* Add more close codes that can't be handled for reconnecting.

* Rewrite chunking to work with intents.

This slows down chunking significantly for bots in a large number of
guilds since it goes down from 75 guilds/request to 1 guild/request.
However the logic was rewritten to fire the chunking request
immediately after receiving the GUILD_CREATE rather than waiting for
all the guilds in the ready stream before doing it.

* Handle user updates within GUILD_MEMBER_UPDATE

* All guilds require chunking if opting into it

* Heartbeats bypass the rate limits for gateway

* Use a lock for the gateway rate limiter.

This will allow for higher concurrency in AutoSharded situations where
I can mostly "fire and forget" the chunk requests.

* Maximize concurrency when chunking on AutoSharded clients

* Speed up chunking for guilds with presence intent enabled

* Check for zombie connections through last received payload

The previous code would check zombie connections depending on whether
HEARTBEAT_ACK was received. Unfortunately when there's exceeding
backpressure the connection can terminate since the HEARTBEAT_ACK is
buffered very far away despite it being there, just not received yet.

* Maximize the amount of concurrency while chunking.

In order to reduce our amount of backpressure we need to limit the
amount of concurrent chunk requests we can have so the gateway buffer
has some time to breathe.

* Fix timeouts due to hitting the gateway rate limit

* Explicitly disable the members presence by default

* Add versionadded for intents enum

* Fix Client.request_offline_members no longer working

* Add Guild.chunk and deprecated Client.request_offline_members

* Don't cache members during guild start up if cache is disabled.

This is mainly a half-implemented commit. There are a few more places
where cache consistency is necessary. In the future there will
probably be a member cache policy enum that will be used and cache
consistency will be tackled in part of that larger refactoring.

* Raise if member intent is not enabled

* Allow finer grained control over the member cache.

* Intern status and overwrite strings

* Pass default intents if not explicitly given

* Add a special exception for required privileged intents

* Default MemberCacheFlags based on intents

* Some documentation fixes for MemberCacheFlags and Intents

* Fix up wording in MemberCacheFlags exception

* Disable voice cache in weird intent configurations.

* Fix presence intent docstring

* Mention potential Guild.member_count accuracy issues

* Add documentation for gateway intents

* Use /invites/ instead of /invite/

* Use delete_message_days instead of delete-message-days

* Add support for flag alias

* Fix typos in Intents documentation

* Add chunk_guilds_at_startup and deprecate fetch_offline_members

* More intent related documentation

* More intent documentation.

Mention that you can downgrade the library to revert. Also mention
that intents need to be updated in the code as well as the developer
portal.

* Fix typo in ValueError message

* Make Intent class creation more intuitive

* Fixed incorrectly named 'Intent' class in doc.

`Intent.members` -> `Intents.members`.

* Add Client.intents to query the current intents

Closes Rapptz#5854

* Update intents with small typo fixes

* 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.

* Add warning if guilds intent is disabled.

* Add changelog for v1.5.0

* Add changelog for v1.4.2

* Version bump to v1.5.0

* Some minor documentation fixes.

Make examples all mention where to put it for the unaware.

* Add intents to examples

* Add intents to event reference

* Update intent documentation to use defaults

* Add intents to the issue template

* Add note pointing to discord.AllowedMentions

* Fix typo in event reference

* Use Hashable mixin for Message

* logging.rst: Fix some typos and grammar errors

* Fix Colour.dark_theme docstring.

* Escape multi-line quotes properly

Fix Rapptz#5897

* Properly insert at the end if position is not found when moving.

Fixes Rapptz#5923

* Evict keys when they're set to None in PermissionOverwrite

Fixes Rapptz#5929

* Mark intent alias flags as actual aliases to skip them in __iter__

Fix Rapptz#5945

* Fix disconnect when trying to move to another voice channel.

Not overly proud of this implementation but this allows the library
to differentiate between a 4014 that means "move to another channel" or
"move nowhere". Sometimes the VOICE_STATE_UPDATE comes before the
actual websocket disconnect so special care had to be taken in that
case.

Fix Rapptz#5904

* Fix attribute errors when timing out during chunking start-up

* Add internal method to check if the websocket is currently ratelimited

* Ensure our own member is never evicted from the cache in any policy.

* [commands] Lazily fetch members in discord.Member converters

This makes commands taking members mostly work transparently without
much effort from the user.

* Load member from guild_member_update dispatch

* Allow concurrent calls to guild.chunk()

This allows people who write guild.chunk() calls in highly concurrent
places such as on_message or checks to not spam the gateway with an
actual request and instead waits for the pre-existing request to finish

* Fix error when querying members from the gateway.

I accidentally made this return True instead of the actual member list

* Add changelog for v1.5.1

* Version bump to v1.5.1

* Translation sync with crowdin

* Implement icon_rl_as and cover_image_url_as for AppInfo

* Raise ClientException when members intent is not enabled on guild.fetch_members

* [commands] Update MessageConverter link regex

Remove redundant parts of the MessageConverter regexes and support www

* Emphasize intents in the constructors of the examples

* Raise DiscordServerError for 503 Service Unavailable errors

* Properly document that categories throw 404's on create_invite.

* Add Colour.random factory method

* Clarify Colour.random RNG

* Bump version for development purposes

* Fix error with templates not having access to member cache flags.

This also changes the attribute from having an underscore

Fix Rapptz#5986

* Fix attribute error during rapid disconnects in VoiceClient.

Fix Rapptz#6039

* Clear the connected flag when potentially reconnecting the player

Fix Rapptz#5953

* Bump dependencies for 3.9 to work without build tools

Fix Rapptz#5984, Rapptz#5970

* Suppress the creation of a command window from ffmpeg on Windows

Fix Rapptz#6038

* Add sticker support

* Don't store a user cache if there's no member intent or cache is off

Without a cache or member intent the user cache can get out of date
with no events to update the underlying user in the member object.

Ref: Rapptz#6034

* Ensure member key is not overwritten by author key in MESSAGE_UPDATE

This also coerces the older message to take the member data from the
newer message so the types are not incompatible.

Fix Rapptz#5999

* Sticker implementation cleanup

* [commands] Fetch user if an ID is passed and cache lookup fails.

* Fix preview_asset key name in Sticker

* [commands] Allow setting description of cogs

* Implement role tags.

This comes with:

* The RoleTags class
* Role.is_premium_subscriber()
* Role.is_bot_managed()
* Role.is_integration()
* Guild.self_role
* Guild.premium_subscriber_role

* Add a way to check if the websocket is rate limited.

This is mainly for low level decision making for utilities that need
to know whether to fetch a member by HTTP or to query through the
websocket.

The library already does this trick in some places so it's only fair
that end users possess the same ability as well.

* Fix `discord.RoleTags` resolution

* Implement discord.Message.reply

* Code cleanup involving enums and message replies

* Allow MessageReference to be constructible by users

* Added MessageReference.resolved attribute to get replied to message

* Correct docstring missing ]

* Fix Message.to_reference from the MessageReference changes

* Change reply example to use replies

* Fix `UnboundLocalError` for editing `public_updates_channel`

* [chore] Remove redundant imports

This also removes the historical patch for NullHandler implemented in bbf1c54, as it has been available since Python 3.1.

* [bug] call super constructor for `CustomActivity` to fix `created_at`

* Fix Team.icon_url_as format argument default value

* Add reaction roles example

* Update documentation for rules/updates channels

* Add support for chunking AsyncIterator objects

* [commands] Cog unload failures are swallowed.

Fix Rapptz#6113

Co-authored-by: JohnyTheCarrot <[email protected]>
Co-authored-by: Tarek <[email protected]>
Co-authored-by: apple502j <[email protected]>
Co-authored-by: Anurag <[email protected]>
Co-authored-by: NCPlayz <[email protected]>
Co-authored-by: Jeffrey <[email protected]>
Co-authored-by: Tsumiki <[email protected]>
Co-authored-by: Rapptz <[email protected]>
Co-authored-by: Sebastian Law <[email protected]>
Co-authored-by: jack1142 <[email protected]>
Co-authored-by: Josh <[email protected]>
Co-authored-by: Skezza <[email protected]>
Co-authored-by: Znunu <[email protected]>
Co-authored-by: James <[email protected]>
Co-authored-by: James <[email protected]>
Co-authored-by: AXVin <[email protected]>
Co-authored-by: Jaime Garcia Jr <[email protected]>
Co-authored-by: Jaime Garcia Jr <[email protected]>
Co-authored-by: Riley S <[email protected]>
Co-authored-by: Tyler North <[email protected]>
Co-authored-by: Dan Hess <[email protected]>
Co-authored-by: Xua <[email protected]>
Co-authored-by: ELginas <[email protected]>
Co-authored-by: Bryan Forbes <[email protected]>
Co-authored-by: Vexs <[email protected]>
Co-authored-by: Patrick <[email protected]>
Co-authored-by: Zomatree <[email protected]>
Co-authored-by: sinus-x <[email protected]>
Co-authored-by: Nanofaux <[email protected]>
Co-authored-by: parafoxia <[email protected]>
Co-authored-by: alkatar21 <[email protected]>
Co-authored-by: Andres Torres <[email protected]>
Co-authored-by: Alex Nørgaard <[email protected]>
Co-authored-by: Saphielle Akiyama <[email protected]>
Co-authored-by: Simon Beal <[email protected]>
Co-authored-by: khazhyk <[email protected]>
Co-authored-by: Skye Im <[email protected]>
Co-authored-by: BluePhoenixGame <[email protected]>
Co-authored-by: rodovia <[email protected]>
Co-authored-by: Duck <[email protected]>
Co-authored-by: iomintz <[email protected]>
Co-authored-by: iDutchy <[email protected]>
Co-authored-by: PikalaxALT <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: Muhammad Hamza <[email protected]>
Co-authored-by: Nekokatt <[email protected]>
Co-authored-by: ChristopherJHart <[email protected]>
Co-authored-by: Eric Chan <[email protected]>
Co-authored-by: PythonCoderAS <[email protected]>
Co-authored-by: numbermaniac <[email protected]>
Co-authored-by: Florian Spieß <[email protected]>
Co-authored-by: Lukas <[email protected]>
Co-authored-by: Jonathan Feenstra <[email protected]>
Co-authored-by: Harmon <[email protected]>
Co-authored-by: webtax-gh <[email protected]>
Co-authored-by: Caio Alexandre <[email protected]>
Co-authored-by: SNVMK <[email protected]>
Co-authored-by: Kippiii <[email protected]>
Co-authored-by: RocketRace <[email protected]>
diceroll123 added a commit to diceroll123/discord.py that referenced this issue Dec 7, 2020
* Fix minor markdown typo in migrating.rst

* Support discord.com/invite URL in resolve_invite

* Fix TypeError on missing shard_id kwarg

* Escape masked URLs; Support quotes for as_needed

* Fix reconnecting loop due to failed handshake on region change

* Change PartialInviteGuild.icon_url_as to mimic Guild.icon_url_as

* Fix error raised when using the roles parameter.

* Add versionadded to VoiceClient latency and average_latency

* Update Message.system_content join strings to be up to date.

Fixes Rapptz#4211

* Fix Guild.by_category not showing empty categories.

* Fix a KeyError for channels with no category in Guild.by_category

* Fix various inconsistencies within the documentation (Rapptz#5067)

* [commands] Add a new exception class for command registration errors

* [tasks] Fix issue with default error handler in class context

* [commands] Raise TypeError when Optional is used with Greedy converter

* Add support for Discord templates

* Add support for integrations

* Add support for bulk editing role positions

* [bugs] stop resolving Object for template/invite; remove dupe methods

* Fix typo with voice_client documentation

* Documentation formatting

* Allow Webhook to be hashable and comparable

* Allow more methods to set an audit log reason

* Add a licence and encoding declaration to missing files

* Document raises for Converter.convert

* [docs] fix reference to `Guild` and document `utils.resolve_template`

* Fix TypeError when not specifying roles.

* Don't use a namedtuple for _Overwrites

Fix Rapptz#5109

* Fix detection of some JPEG images without JFIF or Exif info

Closes Rapptz#5143

* Add Guild.change_voice_state to control our voice state.

* Add double backticks for some parameter mentions in the documentation.

* Added exception documentation for Guild.create_voice_channel

* [commands] GroupView.get_command shouldn't raise errors for empty names

* Add gray alias for discord.Colour

* [commands] Add documentation for exceptions in Context.(re)invoke

* Fix typo in on_socket_raw_send documentation

* Add a changelog entry for v1.3.4

* Add documentation on bot_check_once

* Add revisions to check_once docs

* Rewrite of AutoShardedClient to prevent overlapping identify

This is experimental and I'm unsure if it actually works

* Add shard ID to keep alive logger messages

* Can't use %d in here

* Fix AttributeError on reconnection

* Rewrite gateway to use aiohttp instead of websockets

* Use a proper type for the event queue

* Fix voice websocket connections

* Fix READY not firing for multi-processed AutoShardedClient clusters

* Add before_identify_hook to have finer control over IDENTIFY syncing

* Make every shard maintain its own reconnect loop

Previously if a disconnect happened the client would get in a bad state
and certain shards would be double sending due to unhandled exceptions
raising back to Client.connect and causing all shards to be reconnected
again.

This new code overrides Client.connect to have more finer control and
allow each individual shard to maintain its own reconnect loop and then
serially request reconnection to ensure that IDENTIFYs are not
overlapping.

* Handle connection errors during reidentify flow.

* Add shard related connection and resume events.

These include:
* on_shard_resumed
* on_shard_connect
* on_shard_disconnect

* Handle Connection Reset by Peer connection errors.

This should work both on Windows and on Linux.

Apparently these types of blips are considered normal for Discord. So
rather than letting the reconnect logic handler expect these to be
catastrophic, it should handle it specially so it doesn't waste an
IDENTIFY for what ultimately should just be a small networking blip.

This also makes it less noisy for the end-user as these complaints
happen from time to time.

* If we're out of retries just raise the OSError

* Add a timeout for receiving websocket messages.

* Add guild_ready_timeout to control the timeout of GUILD_CREATE stream

This also fixes a timing issue where READY would take far too long to
load for big bot authors.

Closes Rapptz#4112

* Update message references in AutoShardedConnectionState

Fixes Rapptz#5133

* Use a subclass rather than monkey-patching for the websocket

* Propagate exceptions when an unhandled error happens

* Add an exposed way to extract shard-specific information.

Closes Rapptz#2654

* Fix AttributeError from internal queue being double underscore.

* Fix NameError with resolving codes with Template

* Specify where to get max_members in documentation

* Fix typo when creating a guild via template

* Terminate shard processing queue when a clean close is encountered.

Fix Rapptz#5180

* Optimize Channel.permissions_for by not creating temporary objects

This seemed to have shaved a few microseconds:
10.8 µs ± 79.6 ns per loop → 8.53 µs ± 48.1 ns per loop
12 µs ± 613 ns per loop → 8.72 µs ± 30.2 ns per loop

With 100K loops each

* Fix AttributeError when fetching reactions without cache

* Fix gramatical error in Client guild_subscriptions docs

* [tasks] Remove HTTPException as an exception to silently continue for

* Fix endpoint strings with :443 instead of :80

Fix Rapptz#5191
Close Rapptz#5188

* Propagate manual close codes to socket subclass

aiohttp seems to not set it during its state machine flow

* Require people to use templates when making an issue

* Fix NameError and AttributeError in Template and Integrations

* Be defensive in case Discord breaks something with WS URLs again

* [commands] Restart subcommand_passed chain on invoke

Fix Rapptz#5198

* [commands] Provide a way to retrieve time left for a cooldown

* [commands] implement HelpCommand.add/remove_check

* Add missing comma in template.py

* Fix a typo with webhook documentation

* Fixed a typo in message unpinning docs

* Add remaining user flags

* Add changelog for 1.4

* Version bump to 1.4

* Terminate connection if a close code couldn't be handled

* Fix error when trying to clear empty image/thumbnail in embeds

* Extend __path__ with pkgutil to allow editable extensions

* Add changelog for 1.4.1

* Version bump to 1.4.1

* Document on_error "special" behavior

* Add South Korea VoiceRegion

* update the docs on RawReactionActionEvent.member

* Fix letter to be consistent with the rest of the docs

* Fix hyperlink reference to PartialInviteChannel in Client

* Document merging behaviour of AllowedMentions in Messageable.send

* Fix bug with Guild.by_category not showing some channels

If categories come after a child channel in the dictionary mapping for
whatever reason, then the previous code would remove it from the
mapping and set it to []. This commit aims to fix this.

* Version bump for development purposes

* Fix issue with empty overwrites

Fixes Rapptz#5756.

* [commands] Use edited timestamp if provided for cooldown timing

* [tasks] Don't update _next_iteration on retry

* [commands] Added ColorConverter alias

* Don't call close() if we've already been closed in Client.run

* Added __eq__ to Message

* Add COMMUNITY to Guild.features

* Classmethods all and none for AllowedMentions

* [commands] Add subclasses of BadArgument for converters

* [commands] BadBooleanArgument -> BadBoolArgument

* [commands] add require_var_positional

* [docs] remove unresolved doc refs, fix attribute ref

* [commands] Update Bot.command() decorator docs

* Add fetch_message_fast using history endpoint

* Add discord.Colour classmethod dark_theme

* Fix Member.joined_at documentation

* [commands] Fix exception raised in Command invoke hooks.

* [commands] Correct command removing during cog injecting

* Fix comparison for overwrites when checking if a channel is synced

* Add logging to webhooks

Fixes Rapptz#5798

* Handle cloudflare bans on webhook requests

Fixes Rapptz#5221

* Guard uses of the keep alive thread in case they're None

Fixes Rapptz#5800

* Add a more concrete exception for 500 status codes.

Fixes Rapptz#5797

* [tasks] Lazily fetch event loop if one isn't provided

Fixes Rapptz#5808

* Remove caching from AutoShardedClient.shards

* Add missing permission in clone documentation

* Revert "Add fetch_message_fast using history endpoint"

This reverts commit a309088.

A rate limited was added to this method after 5 years defeating the
purpose of it.

* Completely update member references from message inner members.

Fixes Rapptz#5819

* Add labels to the issue templates

* Update issue template to redirect to discussions

* issue/PR templates: use h2 instead of h3

`h2` is the semantically correct heading here, as `h1` is for 
document titles and `h2` is for the top level headings within
a document. `h3` should be used for subheadings of `h2` headings.

* Add competing activity type

* Fix allowed_mentions when sending files

* Add bot.listen() suggestion to on_message faq

* Remove namedtuples to better future guard the library

* Use quotes when installing in the README

Other shells have a hard time with square brackets.

Closes Rapptz#5821

* Add support for message_reference on Message object

* Fix and add documentation

* Implement VoiceProtocol lower level hooks.

This allows changing the connect flow and taking control of it without
relying on internal events or tricks.

* Correct some protocol errors in v4 of voice gateway

* Fix issues with VoiceProtocol docstrsings.

* Properly handle disconnects in voice when force disconnected

* Add support for guild intents

* Handle gateway rate limits by using a rate limiter.

With the new chunking changes this will become necessary and we don't
want to disconnect from having too many outwards requests.

* Change unknown cache log warnings from WARNING -> DEBUG

* Add more close codes that can't be handled for reconnecting.

* Rewrite chunking to work with intents.

This slows down chunking significantly for bots in a large number of
guilds since it goes down from 75 guilds/request to 1 guild/request.
However the logic was rewritten to fire the chunking request
immediately after receiving the GUILD_CREATE rather than waiting for
all the guilds in the ready stream before doing it.

* Handle user updates within GUILD_MEMBER_UPDATE

* All guilds require chunking if opting into it

* Heartbeats bypass the rate limits for gateway

* Use a lock for the gateway rate limiter.

This will allow for higher concurrency in AutoSharded situations where
I can mostly "fire and forget" the chunk requests.

* Maximize concurrency when chunking on AutoSharded clients

* Speed up chunking for guilds with presence intent enabled

* Check for zombie connections through last received payload

The previous code would check zombie connections depending on whether
HEARTBEAT_ACK was received. Unfortunately when there's exceeding
backpressure the connection can terminate since the HEARTBEAT_ACK is
buffered very far away despite it being there, just not received yet.

* Maximize the amount of concurrency while chunking.

In order to reduce our amount of backpressure we need to limit the
amount of concurrent chunk requests we can have so the gateway buffer
has some time to breathe.

* Fix timeouts due to hitting the gateway rate limit

* Explicitly disable the members presence by default

* Add versionadded for intents enum

* Fix Client.request_offline_members no longer working

* Add Guild.chunk and deprecated Client.request_offline_members

* Don't cache members during guild start up if cache is disabled.

This is mainly a half-implemented commit. There are a few more places
where cache consistency is necessary. In the future there will
probably be a member cache policy enum that will be used and cache
consistency will be tackled in part of that larger refactoring.

* Raise if member intent is not enabled

* Allow finer grained control over the member cache.

* Intern status and overwrite strings

* Pass default intents if not explicitly given

* Add a special exception for required privileged intents

* Default MemberCacheFlags based on intents

* Some documentation fixes for MemberCacheFlags and Intents

* Fix up wording in MemberCacheFlags exception

* Disable voice cache in weird intent configurations.

* Fix presence intent docstring

* Mention potential Guild.member_count accuracy issues

* Add documentation for gateway intents

* Use /invites/ instead of /invite/

* Use delete_message_days instead of delete-message-days

* Add support for flag alias

* Fix typos in Intents documentation

* Add chunk_guilds_at_startup and deprecate fetch_offline_members

* More intent related documentation

* More intent documentation.

Mention that you can downgrade the library to revert. Also mention
that intents need to be updated in the code as well as the developer
portal.

* Fix typo in ValueError message

* Make Intent class creation more intuitive

* Fixed incorrectly named 'Intent' class in doc.

`Intent.members` -> `Intents.members`.

* Add Client.intents to query the current intents

Closes Rapptz#5854

* Update intents with small typo fixes

* 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.

* Add warning if guilds intent is disabled.

* Add changelog for v1.5.0

* Add changelog for v1.4.2

* Version bump to v1.5.0

* Some minor documentation fixes.

Make examples all mention where to put it for the unaware.

* Add intents to examples

* Add intents to event reference

* Update intent documentation to use defaults

* Add intents to the issue template

* Add note pointing to discord.AllowedMentions

* Fix typo in event reference

* Use Hashable mixin for Message

* logging.rst: Fix some typos and grammar errors

* Fix Colour.dark_theme docstring.

* Escape multi-line quotes properly

Fix Rapptz#5897

* Properly insert at the end if position is not found when moving.

Fixes Rapptz#5923

* Evict keys when they're set to None in PermissionOverwrite

Fixes Rapptz#5929

* Mark intent alias flags as actual aliases to skip them in __iter__

Fix Rapptz#5945

* Fix disconnect when trying to move to another voice channel.

Not overly proud of this implementation but this allows the library
to differentiate between a 4014 that means "move to another channel" or
"move nowhere". Sometimes the VOICE_STATE_UPDATE comes before the
actual websocket disconnect so special care had to be taken in that
case.

Fix Rapptz#5904

* Fix attribute errors when timing out during chunking start-up

* Add internal method to check if the websocket is currently ratelimited

* Ensure our own member is never evicted from the cache in any policy.

* [commands] Lazily fetch members in discord.Member converters

This makes commands taking members mostly work transparently without
much effort from the user.

* Load member from guild_member_update dispatch

* Allow concurrent calls to guild.chunk()

This allows people who write guild.chunk() calls in highly concurrent
places such as on_message or checks to not spam the gateway with an
actual request and instead waits for the pre-existing request to finish

* Fix error when querying members from the gateway.

I accidentally made this return True instead of the actual member list

* Add changelog for v1.5.1

* Version bump to v1.5.1

* Translation sync with crowdin

* Implement icon_rl_as and cover_image_url_as for AppInfo

* Raise ClientException when members intent is not enabled on guild.fetch_members

* [commands] Update MessageConverter link regex

Remove redundant parts of the MessageConverter regexes and support www

* Emphasize intents in the constructors of the examples

* Raise DiscordServerError for 503 Service Unavailable errors

* Properly document that categories throw 404's on create_invite.

* Add Colour.random factory method

* Clarify Colour.random RNG

* Bump version for development purposes

* Fix error with templates not having access to member cache flags.

This also changes the attribute from having an underscore

Fix Rapptz#5986

* Fix attribute error during rapid disconnects in VoiceClient.

Fix Rapptz#6039

* Clear the connected flag when potentially reconnecting the player

Fix Rapptz#5953

* Bump dependencies for 3.9 to work without build tools

Fix Rapptz#5984, Rapptz#5970

* Suppress the creation of a command window from ffmpeg on Windows

Fix Rapptz#6038

* Add sticker support

* Don't store a user cache if there's no member intent or cache is off

Without a cache or member intent the user cache can get out of date
with no events to update the underlying user in the member object.

Ref: Rapptz#6034

* Ensure member key is not overwritten by author key in MESSAGE_UPDATE

This also coerces the older message to take the member data from the
newer message so the types are not incompatible.

Fix Rapptz#5999

* Sticker implementation cleanup

* [commands] Fetch user if an ID is passed and cache lookup fails.

* Fix preview_asset key name in Sticker

* [commands] Allow setting description of cogs

* Implement role tags.

This comes with:

* The RoleTags class
* Role.is_premium_subscriber()
* Role.is_bot_managed()
* Role.is_integration()
* Guild.self_role
* Guild.premium_subscriber_role

* Add a way to check if the websocket is rate limited.

This is mainly for low level decision making for utilities that need
to know whether to fetch a member by HTTP or to query through the
websocket.

The library already does this trick in some places so it's only fair
that end users possess the same ability as well.

* Fix `discord.RoleTags` resolution

* Implement discord.Message.reply

* Code cleanup involving enums and message replies

* Allow MessageReference to be constructible by users

* Added MessageReference.resolved attribute to get replied to message

* Correct docstring missing ]

* Fix Message.to_reference from the MessageReference changes

* Change reply example to use replies

* Fix `UnboundLocalError` for editing `public_updates_channel`

* [chore] Remove redundant imports

This also removes the historical patch for NullHandler implemented in bbf1c54, as it has been available since Python 3.1.

* [bug] call super constructor for `CustomActivity` to fix `created_at`

* Fix Team.icon_url_as format argument default value

* Add reaction roles example

* Update documentation for rules/updates channels

* Add support for chunking AsyncIterator objects

* [commands] Cog unload failures are swallowed.

Fix Rapptz#6113

* Add created_at property to PartialEmoji

Also fixed docstring for PartialEmoji.url

Co-authored-by: Tarek <[email protected]>
Co-authored-by: apple502j <[email protected]>
Co-authored-by: Anurag <[email protected]>
Co-authored-by: NCPlayz <[email protected]>
Co-authored-by: Jeffrey <[email protected]>
Co-authored-by: Tsumiki <[email protected]>
Co-authored-by: Rapptz <[email protected]>
Co-authored-by: Sebastian Law <[email protected]>
Co-authored-by: jack1142 <[email protected]>
Co-authored-by: Josh <[email protected]>
Co-authored-by: Skezza <[email protected]>
Co-authored-by: Znunu <[email protected]>
Co-authored-by: James <[email protected]>
Co-authored-by: James <[email protected]>
Co-authored-by: AXVin <[email protected]>
Co-authored-by: Jaime Garcia Jr <[email protected]>
Co-authored-by: Jaime Garcia Jr <[email protected]>
Co-authored-by: Riley S <[email protected]>
Co-authored-by: Tyler North <[email protected]>
Co-authored-by: Dan Hess <[email protected]>
Co-authored-by: Xua <[email protected]>
Co-authored-by: ELginas <[email protected]>
Co-authored-by: Bryan Forbes <[email protected]>
Co-authored-by: Vexs <[email protected]>
Co-authored-by: Patrick <[email protected]>
Co-authored-by: Zomatree <[email protected]>
Co-authored-by: sinus-x <[email protected]>
Co-authored-by: Nanofaux <[email protected]>
Co-authored-by: parafoxia <[email protected]>
Co-authored-by: alkatar21 <[email protected]>
Co-authored-by: Andres Torres <[email protected]>
Co-authored-by: Alex Nørgaard <[email protected]>
Co-authored-by: Saphielle Akiyama <[email protected]>
Co-authored-by: Simon Beal <[email protected]>
Co-authored-by: khazhyk <[email protected]>
Co-authored-by: Skye Im <[email protected]>
Co-authored-by: BluePhoenixGame <[email protected]>
Co-authored-by: rodovia <[email protected]>
Co-authored-by: Duck <[email protected]>
Co-authored-by: iomintz <[email protected]>
Co-authored-by: iDutchy <[email protected]>
Co-authored-by: PikalaxALT <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: Muhammad Hamza <[email protected]>
Co-authored-by: Nekokatt <[email protected]>
Co-authored-by: ChristopherJHart <[email protected]>
Co-authored-by: Eric Chan <[email protected]>
Co-authored-by: PythonCoderAS <[email protected]>
Co-authored-by: numbermaniac <[email protected]>
Co-authored-by: Florian Spieß <[email protected]>
Co-authored-by: Lukas <[email protected]>
Co-authored-by: Jonathan Feenstra <[email protected]>
Co-authored-by: Harmon <[email protected]>
Co-authored-by: webtax-gh <[email protected]>
Co-authored-by: Caio Alexandre <[email protected]>
Co-authored-by: SNVMK <[email protected]>
Co-authored-by: Kippiii <[email protected]>
Co-authored-by: RocketRace <[email protected]>
yagomichalak pushed a commit to yagomichalak/discord.py that referenced this issue May 28, 2021
Not overly proud of this implementation but this allows the library
to differentiate between a 4014 that means "move to another channel" or
"move nowhere". Sometimes the VOICE_STATE_UPDATE comes before the
actual websocket disconnect so special care had to be taken in that
case.

Fix Rapptz#5904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a bug with the library.
Projects
None yet
Development

No branches or pull requests

8 participants