aboutsummaryrefslogtreecommitdiff
path: root/discord/state.py
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Fix crashing with wonky TYPING_START events.Rapptz2018-07-201-1/+1
| | | | Fixes #1439
* Store guild, unavailable tuple in ready as wellkhazhyk2018-06-301-1/+1
| | | | | | This should fix userbots. Fixes: 74380cd ("don't drop guild_available/join before ready")
* don't drop guild_available/join before readykhazhyk2018-06-291-5/+23
| | | | | | | large guilds that recieved GUILD_CREATE events prior to READY would never dispatch guild_available/join. This is inconsistent with smaller guilds and makes these events unreliable. Dispatch the "delayed" guilds after they've been chunked, prior to ready.
* Remove dead package references.Rapptz2018-06-101-1/+1
|
* Drop support for Python 3.4 and make minimum version 3.5.2.Rapptz2018-06-101-26/+21
|
* Remove emojis from cache if they're removed from a guild.Rapptz2018-05-191-0/+2
|
* Change raw events to use slotted data models instead of parameters.Rapptz2018-04-141-34/+38
| | | | | | | | | | This allows for internal changes in Discord to not cause a breaking change every time something changes. Also implements #1214 which adds guild_id to every event where applicable. This is a breaking change.
* Userbots do not have a DM cache cap limit.Rapptz2018-04-021-1/+1
|
* Split Game object to separate Activity subtypes for Rich Presences.Rapptz2018-03-051-4/+8
| | | | | | | | | | | This is a massive breaking change. * All references to "game" have been renamed to "activity" * Activity objects contain a majority of the rich presence information * Game and Streaming are subtypes for memory optimisation purposes for the more common cases. * Introduce a more specialised read-only type, Spotify, for the official Spotify integration to make it easier to use.
* Don't cache webhook users.Rapptz2018-02-241-1/+3
| | | | Fixes #1101
* Change PartialReactionEmoji to PartialEmoji, add a PartialEmojiConverterGorialis2018-01-061-4/+4
|
* Add category support.Rapptz2017-09-131-4/+4
| | | | | | | | | | | | | This adds: * CategoryChannel, which represents a category * Guild.by_category() which traverses the channels grouping by category * Guild.categories to get a list of categories * abc.GuildChannel.category to get the category a channel belongs to * sync_permissions keyword argument to abc.GuildChannel.edit to sync permissions with a pre-existing or new category * category keyword argument to abc.GuildChannel.edit to move a channel to a category
* Fix crashing for now when a category is created.Rapptz2017-09-081-0/+4
| | | | A full implementation will come later.
* Add heartbeat_timeout to the Client options.Rapptz2017-08-081-1/+1
| | | | | | | This setting configures how long before a timeout event is emitted internally and disconnects the websocket. Since some users were experiencing issues with the gateway not responding, this should help mitigate the issue for those with poor PCs.
* Accidentally left a print statement.Rapptz2017-07-051-1/+0
|
* Implement a LRU cache for private channels.Rapptz2017-07-041-4/+20
| | | | | | Another fix related to the discord issue[1]. [1]: https://github.com/hammerandchisel/discord-api-docs/issues/184
* Don't unnecessarily re-create private channels.Rapptz2017-07-041-3/+6
| | | | | | | | New API change[1] will make it so CHANNEL_CREATE will keep getting sent for private channels, so might as well avoid the overhead of constantly creating the channel if we can avoid it. [1]: https://github.com/hammerandchisel/discord-api-docs/issues/184
* Downgrade PartialReactionEmoji to str in non-raw reaction events.Rapptz2017-06-091-1/+4
|
* Defer logging formatting until the logger is actually called.Rapptz2017-06-091-1/+1
| | | | | This would cause unnecessary format calls even if you didn't have logging enabled.
* Implement "partial" message events.Rapptz2017-06-091-13/+52
| | | | | These are events that get triggered regardless of the state of the message cache. Useful for getting data from before the bot was booted.
* Don't expose Client.messagesRapptz2017-05-261-7/+7
| | | | | | | Not entirely sure why it was exposed in the first place. Most uses with it essentially boiled down to mis-usage when they meant to use the /messages endpoint (via Client.logs_from or Messageable.history) or complaining about the partial data woes that came from it.
* Don't dispatch on_voice_state_update when Member is not found.Rapptz2017-05-221-1/+3
|
* Allow setting a presence upon logging in.Rapptz2017-05-201-1/+16
|
* Split on_channel_pins_update as well.Rapptz2017-05-051-2/+16
|
* Rework some events to make more sense.Rapptz2017-05-051-9/+10
| | | | | | | | | | | | | | This is a breaking change. 1. Change on_guild_emojis_update to have 3 arguments. - The first parameter is now the guild object 2. Remove on_channel_create, on_channel_delete, and on_channel_update - They are now split into two. - on_guild_channel_[create|delete|update] - on_private_channel_[create|delete|update] 3. Change on_member_ban to allow User. - (member) -> (guild, user) - user can also be a Member