165 Commits

Author SHA1 Message Date
Florian Spieß
6910943703
Fix udp discovery not using 74 byte layout 2023-03-01 18:11:06 -05:00
Rapptz
8aaeb6acfa Parse gateway URL as an actual URL using yarl
Discord has changed the URL format to make it infeasible to edit it
using basic string interpolation.
2022-09-17 22:51:23 -04:00
Rapptz
3802780f77 Change a lot of logging INFO calls to be less verbose
Some of the logs were only useful for debug scenarios, so they have
been downgraded to DEBUG. Others were in INFO but supposed to be in
WARNING so those were upgraded.
2022-08-15 10:21:36 -04:00
Rapptz
7da2048d1a Add support for resume_gateway_url 2022-08-10 22:47:27 -04:00
Bryan Forbes
d707019348
Bump Pyright to 1.1.265, fix type errors, and remove unnecessary ignores 2022-08-04 22:46:02 -04:00
Rapptz
922e52b6df Update IDENTIFY payload to match new format 2022-06-17 20:56:44 -04:00
Rapptz
66881ba458 Remove gateway trace information
This was unused anyway
2022-06-13 01:06:15 -04:00
Lilly Rose Berner
2dbf14bb72
Separately delay ready event for each shard 2022-04-25 02:01:46 -04:00
Rapptz
c582940401 Remove ancient IDENTIFY key that is no longer used 2022-04-05 05:22:00 -04:00
Kellen
0f18d93e47
Remove unused imports 2022-04-02 04:58:39 -04:00
jack1142
5ffa3e85de
Update comments after # type: ignore to be compatible with PEP 484 2022-03-27 22:26:34 -04:00
Rapptz
6d75d2e937 Fix unnecessary type ignores in gateway 2022-03-16 01:19:45 -04:00
Stocker
5aa696ccfa
Fix typing issues and improve typing completeness across the library
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
Co-authored-by: Josh <josh.ja.butt@gmail.com>
2022-03-13 23:52:10 -04:00
Rapptz
58ad146a4e Remove window re-assignment in gateway rate limiter
This was a hold over from the old cooldown implementation.
2022-03-13 12:09:07 -04:00
Rapptz
0c690bc949 Fix audio not sending
Fixes #7531
2022-03-08 01:18:32 -05:00
Predä
32f131566f
Update gateway version docstring in DiscordWebSocket 2022-02-27 21:18:41 -05:00
Josh
2b69b5d545
Remove discord.InvalidArgument
This uses TypeError and ValueError instead.
2022-02-26 01:44:49 -05:00
Rapptz
8d52ddaff6 Fix remaining type errors in main package
This doesn't fix the type errors in the ext packages though.
2022-02-22 04:19:46 -05:00
Josh
c8064ba6f2 Type-hint gateway 2022-02-22 03:59:58 -05:00
Rapptz
88b520b5ab Reformat code using black
Segments where readability was hampered were fixed by appropriate
format skipping directives. New code should hopefully be black
compatible. The moment they remove the -S option is probably the moment
I stop using black though.
2022-02-20 08:04:58 -05:00
Rapptz
78598d59d7 Change on_socket_raw_receive to dispatch right before JSON conversion 2021-08-25 01:26:37 -04:00
Rapptz
4a72201617 Make json conversion functions private 2021-08-22 02:35:58 -04:00
Rapptz
ea2d972666 Make global log variable in modules private 2021-08-22 02:33:51 -04:00
Rapptz
035d110837 Fix debug event toggle not triggering for raw receive 2021-08-01 02:42:11 -04:00
Rapptz
b640493300 Add enable_debug_events parameter to enable expensive debug events
This should allow less dispatching during heavy gateway event streams.
2021-07-31 20:35:28 -04:00
Rapptz
e2250d402e Add on_socket_event_type event 2021-07-31 20:12:40 -04:00
Aaron Hennessey
15eb3d2e5d
Remove afk parameter from change_presence 2021-07-21 02:45:57 -04:00
Rapptz
88d825a803 Allow use of orjson instead of json
The difference in speed seems negligible at start up, which is when
most time is taken for actually parsing JSON. I could potentially be
missing something but profiling didn't point to any discernable
difference.
2021-07-07 20:19:17 -04:00
Imayhaveborkedit
ac061c31fb
Fix default hook signature
Since the hook function can be both bound and unbound
the bound signature needs to accept an extra argument
2021-05-25 02:22:21 -04:00
Imayhaveborkedit
8e08bd6af2
Add vws message hook 2021-05-23 03:42:07 -04:00
Rapptz
81b259ab36 Fix sending arrays with nulls in them when changing presences 2021-05-16 07:15:53 -04:00
apple502j
dea92a69dc
Remove support for guild subscriptions 2021-04-14 00:47:46 -04:00
Rapptz
d85805ab6d First pass at supporting v8 API 2021-04-11 00:39:13 -04:00
Rapptz
54288879e2 Remove userbot functionality
This has a lot of legacy and cruft so there may be some stuff I've
missed but this first pass is enough to get a clear separation.
2021-04-04 10:15:30 -04:00
Rapptz
9d39b135f4 Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
2021-04-04 07:03:53 -04:00
Nadir Chowdhury
63ec23bac2
Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
Riley Shaw
fafc3d9185
Fix ZeroDivisionError in DiscordVoiceWebSocket.average_latency 2021-02-18 06:53:08 -05:00
Nihaal Sangha
69bdc3a184
Change copyright year to present 2021-01-15 05:28:11 -05:00
Rapptz
5c868ed871 Fix SyntaxError from PR implementing presences in member querying 2021-01-01 09:37:47 -05:00
Nadir Chowdhury
59c11e71a2
Implement presences for Guild.query_members 2020-12-31 13:50:22 -05:00
Rapptz
2509ca6a82 Add internal method to check if the websocket is currently ratelimited 2020-10-17 22:51:29 -04:00
Rapptz
21ed9f61d2 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 #5904
2020-10-17 22:01:57 -04:00
Rapptz
6bae52f4bb 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.
2020-09-23 03:21:18 -04:00
Rapptz
af8fc32329 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.
2020-09-23 03:21:17 -04:00
Rapptz
5fe998ac19 Heartbeats bypass the rate limits for gateway 2020-09-23 03:21:17 -04:00
Rapptz
930761e058 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.
2020-09-23 03:21:16 -04:00
Rapptz
ec7b8edcc2 Add more close codes that can't be handled for reconnecting. 2020-09-23 03:21:16 -04:00
Rapptz
e7db9cfdf7 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.
2020-09-23 03:21:15 -04:00
Rapptz
a6381dcf77 Add support for guild intents 2020-09-23 03:21:15 -04:00
Rapptz
e3922e24d9 Correct some protocol errors in v4 of voice gateway 2020-09-23 03:20:35 -04:00