Commit Graph

281 Commits

Author SHA1 Message Date
e57617e157 Add support for delete_message_seconds ban argument 2022-08-28 02:06:57 -04:00
8dd186cf1e Fix cache eviction for ratelimit objects 2022-08-17 08:39:39 -04:00
f1ec0919f6 Remove stack info from ratelimit logs 2022-08-10 22:55:27 -04:00
87c9c95bb8 Use persistent dictionary for ratelimit information
This should prevent ratelimit information from being cleared too early.
In order to prevent the dictionary from growing to large expired keys
are deleted once they've been deleted.

At present I'm unsure if this change would cause too much CPU pressure.
2022-08-05 23:19:16 -04:00
a01dad283f Add extraneous debug logging to sub ratelimits being detected 2022-07-19 01:36:18 -04:00
76402b00f9 Allow configuring the maximum ratelimit timeout before erroring
This is useful for cases where a rate limit is known to be
extraordinarily high, but you still want to handle the error.
This is common with routes such as emoji creation.
2022-07-19 01:36:18 -04:00
85ea418776 Special case message deletion sub rate limits 2022-07-19 00:07:28 -04:00
c17eb31328 Rewrite rate limit handling to use X-Ratelimit-Bucket and a semaphore
This should increase throughput of the number of requests that can be
made at once, while simultaneously following the new standard practice
of using the rate limit bucket header.

This is an accumulation of a lot of months of work between a few people
and it has been tested extensively. From the testing it seems to work
fine, but I'm not sure if it's the best way to do it.

This changeset does not currently take into consideration sub
rate limits yet, but the foundation is there via Route.metadata. In the
future, this metadata will be filled in with the known sub rate limit
implementation to allow them to have separate keys in the rate limit
mapping.

Co-authored-by: Josh <josh.ja.butt@gmail.com>
2022-07-19 00:07:28 -04:00
2067819b75 Fix some minor typing errors 2022-07-17 21:40:05 -04:00
5426d19dc7 Implement AutoMod 2022-06-27 00:47:52 -04:00
85495a910c Add extra details to rate limit logs
- Include the rate limit bucket for webhooks
- Enable `stack_info` for the 429 warning.
2022-06-16 18:52:37 -04:00
3aa55ba1ed Implement Application Command Permissions models 2022-06-07 01:35:33 -04:00
e543abd950 Add support for new thread_name parameter in Webhook.send 2022-05-31 18:25:26 -04:00
f24f34e3f1 Remove unused internal bot_token attribute 2022-05-28 23:48:02 -04:00
e2d0193531 Implement WelcomeScreen 2022-05-21 21:26:06 -04:00
2bb7ed2092 Retry on 524 status code 2022-05-21 21:22:20 -04:00
93e1ff5f07 Change aiohttp object construction to no longer take loop objects 2022-05-20 15:08:38 -04:00
1df3ed861c Fix broken HTTPClient.recreate code to actually clear session 2022-05-05 11:42:50 -04:00
7f210c90f4 Return a named tuple with message from ForumChannel.create_thread 2022-05-01 19:32:11 -04:00
06df0d7931 Address latest breaking change in creating forum posts 2022-04-29 12:39:12 -04:00
6265723a35 Add support for archive duration in Guild.create_text_channel 2022-04-11 17:21:08 -04:00
a8b26b9257 Allow pinning a thread using Thread.edit 2022-04-06 23:21:17 -04:00
23f6876492 Add initial support for forum channels
Closes #7652
2022-04-06 23:02:58 -04:00
d600436378 [types] Use PEP-655 style Required/NotRequired types 2022-04-02 01:46:10 -04:00
9acf1db076 Support ban endpoint pagination 2022-04-01 00:09:02 -04:00
4fd2d5fdfd Remove redundant imports and variables 2022-03-29 02:50:34 -04:00
77ec49782a Add http_trace option in Client to trace the library's HTTP requests 2022-03-18 08:02:53 -04:00
8d86ee3fe3 Fix mention_author suppressing all mentions 2022-03-18 01:52:11 -04:00
e01d4a31eb Replace invariant container types with wider types where applicable 2022-03-17 07:26:01 -04:00
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
9c61e10a55 Move all async object creation to a proper initialisation point
This should make it so no object is created with another loop
2022-03-13 08:33:25 -04:00
8d4f08a5e7 Fix AutoShardedClient to work with the new asyncio loop machinery
Fix #7675
2022-03-13 08:05:44 -04:00
93af158b0c Refactor loop code to allow usage of asyncio.run 2022-03-13 04:54:14 -04:00
ba2763a4a1 Add private hook for changing the API version
This is mainly a temporary, undocumented, stop gap for bots that are
screwed over from waiting for Discord to grant them the message content
intent.
2022-03-07 18:23:12 -05:00
0330282c5f Create a default TCPConnector with no limit
The default implementation only allows for 100 concurrent connections
and during heavy sharding (>=100 shards) this can end up freezing
shards.
2022-03-07 01:19:37 -05:00
e15415413b Add missing parameters to certain methods
- slowmode_delay and reason in Message.create_thread
- slowmode_delay in TextChannel.create_thread
- reason in Guild.edit_widget
2022-03-06 23:00:50 -05:00
8360e4af8d Add premium_progress_bar_enabled attribute on Guild 2022-03-06 03:17:28 -05:00
fa901afa3a Add replied_user key when no allowed_mentions is passed in 2022-03-05 23:39:06 -05:00
e69428a841 Add with_counts support for Client.fetch_guild
Co-authored-by: Stocker <44980366+StockerMC@users.noreply.github.com>
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
2022-03-05 22:09:19 -05:00
147948af9b Use typing.Self throughout library 2022-03-01 07:53:24 -05:00
3c6279b947 Implement Guild Scheduled Events 2022-03-01 01:00:04 -05:00
2b69b5d545 Remove discord.InvalidArgument
This uses TypeError and ValueError instead.
2022-02-26 01:44:49 -05:00
e13997f35e Remove region parameters from HTTPClient 2022-02-25 10:44:37 -05:00
285069de08 Fix types in guild.py 2022-02-22 04:00:46 -05:00
c8064ba6f2 Type-hint gateway 2022-02-22 03:59:58 -05:00
30e7a2e937 Fix a few more type errors 2022-02-21 23:31:18 -05:00
c7c6d74d8d Fix type errors in the abc module 2022-02-21 22:38:36 -05:00
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
dede5539ee Add support for editing message attachments 2022-02-19 22:02:53 -05:00
e14153ddcb Fix nonce being sent even when not specified 2022-02-18 23:15:46 -05:00