aboutsummaryrefslogtreecommitdiff
path: root/discord/state.py
Commit message (Collapse)AuthorAgeFilesLines
* Bump waiting time of GUILD_CREATE stream by number of shards waited.Rapptz2020-01-281-2/+3
| | | | | 2 seconds might be too short and cause it to finish waiting while other shards are still IDENTIFYing.
* Bump copyright year to 2020Rapptz2020-01-191-1/+1
| | | | Closes #2510
* Add support for clearing a specific reaction.Rapptz2020-01-171-0/+17
| | | | Closes #2440
* Add support for on_invite_create and on_invite_deleteRapptz2020-01-171-0/+9
|
* Expose _ActivityTag as BaseActivity to easily refer to.Rapptz2020-01-141-3/+3
|
* Rewrite on_ready delay to actually make sense and prevent heavy sleepRapptz2020-01-141-7/+15
|
* Fix issue with `shard_ready` not dispatching when not fetching offlineNCPlayz2020-01-141-12/+6
|
* Add `RawReactionActionEvent.member`NCPlayz2019-12-171-1/+9
|
* Fix all deprecation warnings for 3.8Rapptz2019-11-201-6/+6
|
* Fix regression with references being overwritten from the cache.Rapptz2019-11-201-1/+3
| | | | | | | A proper fix for this would be to just request presence information as well since the chunk request would probably be more up to date than the current cache. However this delta requires a little bit more work and will be done later.
* Move PartialEmoji over to a new namespace to avoid circular importsRapptz2019-11-201-1/+2
|
* Manually trigger GC in cases of large deallocations.Rapptz2019-11-181-0/+10
|
* animation field in reaction objects are not consistently availableRapptz2019-11-151-7/+7
|
* Actually add things to the message cache.Rapptz2019-08-271-2/+2
|
* Fix _get_message returning the message cache.Lorenzo2019-08-271-1/+1
|
* Allow disabling the message cache with max_messages=NoneRapptz2019-08-271-7/+15
| | | | | | This also changes the default to 1000 instead of 5000 since it can take some time for small bots to cycle through the default and they make up the majority of it.
* Add RawReactionActionEvent.event_type attribute.Rapptz2019-08-111-2/+2
| | | | This helps differentiate between reaction removal or addition.
* Proper boolean check for caching members.Rapptz2019-07-151-1/+1
|
* Add Guild.query_members to fetch members from the gateway.Rapptz2019-07-151-7/+43
|
* Allow complete disabling of the member cache.Rapptz2019-07-111-1/+4
|
* Add support for guild subscriptions.Rapptz2019-07-101-0/+1
|
* Fix regression with unresolved channels due to reordering.Rapptz2019-06-291-3/+5
| | | | | | Channels are meant to fallback to Object if the message is out of order. Somewhere along the commit line this got removed despite the issue still existing.
* Publicly expose a type property for all channels.Rapptz2019-06-091-1/+1
| | | | Fix #2185
* Replace Enum with an internal one for significant speed improvements.Rapptz2019-06-091-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has been a massive pain point for me personally due to the poor design of the Enum class leading to the common use cases used in the library being significantly slow. Since this Enum is not public facing in terms of *creation*, I can only implement the APIs that are used when *accessing* them. This Enum is a drop-in replacement to the pre-existing enum.Enum class except it comes with significant speed-ups. Since this is a lot to go over, I will let the numbers speak for themselves: In [4]: %timeit enums.try_enum(enums.Status, 'offline') 263 ns ± 34.3 ns per loop (7 runs, 1000000 loops each) In [5]: %timeit NeoStatus.try_value('offline') 134 ns ± 0.859 ns per loop (7 runs, 10000000 loops each) In [6]: %timeit enums.Status.offline 116 ns ± 0.378 ns per loop (7 runs, 10000000 loops each) In [7]: %timeit NeoStatus.offline 31.6 ns ± 0.327 ns per loop (7 runs, 10000000 loops each) In [8]: %timeit enums.Status.offline.value 382 ns ± 15.2 ns per loop (7 runs, 1000000 loops each) In [9]: %timeit NeoStatus.offline.value 65.5 ns ± 0.953 ns per loop (7 runs, 10000000 loops each) In [10]: %timeit str(enums.Status.offline) 630 ns ± 14.8 ns per loop (7 runs, 1000000 loops each) In [11]: %timeit str(NeoStatus.offline) 253 ns ± 3.53 ns per loop (7 runs, 1000000 loops each) In [12]: %timeit enums.Status('offline') 697 ns ± 8.42 ns per loop (7 runs, 1000000 loops each) In [13]: %timeit NeoStatus('offline') 182 ns ± 1.83 ns per loop (7 runs, 10000000 loops each)
* Improve performance of parsing MESSAGE_UPDATE and MESSAGE_CREATE eventsRapptz2019-06-071-9/+1
| | | | | | | | Embed edits are no longer special cased in the dispatch code, which could lead to on_message_edit being called more often than it used to be called. I am not sure on the general impact on that being removed. Fixes #2195
* Use a dict instead of getattr for parsing events.Rapptz2019-05-291-0/+6
| | | | | | | | | | | Probably not a significant difference but might as well use it here. The basic idea is to cache the getattr calls instead of repeatedly doing it (since they're around 105ns on my machine). The dictionary lookup is about 41ns on my machine. The next step in speeding up library code some more should be in the parser bodies themselves but that's a problem to tackle another day.
* Add cached_message to on_raw_message_edit eventVexs2019-05-091-1/+4
| | | | Also add documentation for this behavior
* Fix USER_UPDATE changes not triggering for member instances.Rapptz2019-04-281-6/+8
| | | | Also add a ClientUser.locale attribute.
* Fix long-standing issue with user updates not dispatching properly.Rapptz2019-04-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | This fix is long coming. For a long time due to the addition of a global user cache, the on_member_update event would only have the updated user in the very first dispatch due to a quirk in the reference only being updated once. In order to fix this issue two things had to change: 1. There had to be a new event, `on_user_update` to complement the equivalent member event. 2. Unnecessary copies of User had to be removed to compensate for the performance hit from the diffing. While doing these two fixes I also re-evaluated some more unnecessary copies done during the PRESENCE_UPDATE to add member case while fetch_offline_members=False is set or due to chunking issues. The number of copies was brought down from 2 to 1, discounting the original Member creation. Unsure on the benefits of this one, however. N.B: this doesn't change the pre-existing behaviour of on_member_update
* GUILD_MEMBER_UPDATE no longer does actual user updates.Rapptz2019-04-081-1/+1
| | | | | This had been delegated to PRESENCE_UPDATE a long time ago, unfortunately.
* Redesign bulk delete eventsVexs2019-04-061-7/+8
| | | | | | | | | Change `parse_message_delete_bulk` to not dispatch individual `message_delete` events, and instead `bulk_message_delete`. Also make `raw_bulk_message` delete and `raw_message_delete` have message objects attached. Fixes #1807
* Redesign asset retrieval in the library.NCPlayz2019-04-061-2/+2
| | | | | | | | | | | Most assets now return a new class named `Asset`. This allows for the assets to be consistently saved via a `save` method instead of special casing for `Attachment`. `AppInfo` is no longer a namedtuple it is a fully documented dataclass, as well as having the state attached to it. Fixes #1997
* Get cached message in reverse order for improved performance.Rapptz2019-03-231-1/+1
| | | | Most embed-only edits happen for the newest message.
* Add TextChannel.last_message_id and TextChannel.last_messageRapptz2019-03-201-0/+2
|
* Expose Embed.from_data as Embed.from_dictRapptz2019-03-131-1/+1
| | | | This is a breaking change.
* Log unknown channel warning in WEBHOOK_UPDATECraftSpider2019-02-181-2/+3
|
* Add guild_integrations_update eventCraftSpider2019-02-181-0/+7
|
* Bumped copyright years to 2019.Dante Dam2019-01-281-1/+1
|
* [lint] Fix import orderHornwitser2018-11-241-8/+10
| | | | | Reorder imports to be consistenly grouped by standard library, third party library, and local modules in that order thoughout the library.
* [lint] Replace equality comparisons to singletonsHornwitser2018-11-241-8/+8
| | | | | | | | Restrict the values accepted by comparisons with booleans to be actual booleans. Minor breaking of undocumented behaviour in permissions; the value to set bits to must be booleans (as indicated by the type error thrown).
* [lint] Rename exception variables to excHornwitser2018-11-241-2/+2
| | | | | Use the more explicit (and common) exc instead of e as the variable holding the exception in except handlers.
* Optimise tight loops in DiscordGateway.received_messageRapptz2018-09-241-1/+12
| | | | | | * type(x) is y is faster than isinstance(x, y) * Re-arrange if-statements for common statements * Drop handler getattr for most events that don't use it
* Optimise some member and user related routines.Rapptz2018-09-241-1/+1
| | | | | | | * Skip user update if possible * Drop copy.copy in favour of manual copy Credit to Hornwitser for these findings.
* Change internal role storage in Guild to a dict instead of a list.Rapptz2018-09-241-4/+3
| | | | | | | | | | | | | | | | This adds the following APIs: * Guild.get_role This removes the following APIs: * Guild.role_hierarchy To compensate for the removed APIs, Guild.roles is now a sorted list based on hierarchy. The first element will always be the @everyone role. This speeds up access at the cost of some memory, theoretically.
* Fix webhook_update from code reviewJeremy Zhang2018-09-151-2/+3
|
* Simple parser for WEBHOOKS_UPDATEJeremy Zhang2018-09-151-0/+4
|
* Ensure large guilds are properly appended to the ready state guild listBryan Forbes2018-08-281-1/+1
|
* [lint] Fix incorrect and inconsistent whitespaceHornwitser2018-08-221-2/+2
| | | | Adjust whitespace to be consistent with the rest of the library.
* [lint] Remove unused variablesHornwitser2018-08-221-2/+2
| | | | Left over from various refactoring and rewrites.
* [lint] Remove unused importsHornwitser2018-08-221-1/+0
| | | | Left over from various refactoring and rewrites.