Commit Graph

104 Commits

Author SHA1 Message Date
02397306b2 Drop superfluous zero in version related changes in the documentation 2020-01-21 03:47:56 -05:00
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
42a084028c Expose _ActivityTag as BaseActivity to easily refer to. 2020-01-14 20:56:00 -05:00
de5caf59d6 Cache member.roles access to avoid surprising performance traps
Without the cache, repeated access could be accidentally quadratic or
worse.
2020-01-06 22:13:35 -05:00
f1118273f5 Fix Member.mentioned_in returning True if in separate guilds 2020-01-06 00:30:04 -05:00
99b61f973f Added Optional to VoiceState.channel type 2019-11-15 04:23:15 -05:00
8240454555 Add self_stream property to VoiceState object. 2019-09-19 21:21:54 -04:00
562580a07f Use lower level Guild.owner_id for permission resolution. 2019-07-10 14:30:53 -04:00
91f1f430e1 Fix NameError in member upgrade code 2019-07-10 06:11:03 -04:00
bbc50c92d0 Add upgraded Member to Message.mentions in case of no cache. 2019-07-10 04:51:27 -04:00
5c1b239b47 Different method of upgrading user instances 2019-07-10 01:23:38 -04:00
2b4cf5dafc Set premium_since when copying and updating Member 2019-06-11 21:13:43 +02:00
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
2b27a7a9d5 Add Member.premium_since to denote member boost date. 2019-06-04 18:30:46 -04:00
3c387e9031 Use attrgetter to speed up Member attribute access by 2x. 2019-05-25 03:14:35 -04:00
4dee175d2a Add support for voice kicking. 2019-04-30 00:34:20 -04:00
f8999b63ae Fix long-standing issue with user updates not dispatching properly.
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
2019-04-08 07:45:04 -04:00
1a9726087a GUILD_MEMBER_UPDATE no longer does actual user updates.
This had been delegated to PRESENCE_UPDATE a long time ago,
unfortunately.
2019-04-08 06:34:28 -04:00
c9fd092476 Don't use an enum when unnecessary in Member._client_status 2019-04-08 04:06:01 -04:00
fb02191b80 Organise documentation 2019-03-19 08:24:42 -04:00
7240d170c1 Update Member.joined_at on MESSAGE_CREATE and document it can be None.
Fixes #1638
2019-02-27 06:23:08 -05:00
7ab47c223b Add self_video property to VoiceState 2019-02-18 03:48:26 -05:00
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
26bb6c6ddc Fix some lingering attribute setting issues. 2018-12-14 21:59:31 -05:00
c7396dc8ac Add support for mobile indicators and per-client statuses. 2018-12-14 20:57:21 -05:00
7fe4c999fb Actually drop copy.copy in Member
Remove the old and slow Member._copy implementation that was left over
by accident in 095f0ec.  Since it was defined later it overrode the new
implementation and rendered it moot.
2018-11-24 22:38:49 -05:00
e89e7dfe93 Add support for multiple activities 2018-11-24 22:36:52 -05:00
860d6a9ace Revert "Rework documentation to not duplicate inherited members."
This reverts commit 96981210b3.
2018-10-11 03:42:01 -04:00
96981210b3 Rework documentation to not duplicate inherited members.
This will probably be reverted in 1 week.
2018-10-03 05:45:30 -04:00
095f0ec2fc Optimise some member and user related routines.
* Skip user update if possible
* Drop copy.copy in favour of manual copy

Credit to Hornwitser for these findings.
2018-09-24 22:50:05 -04:00
95d8bb2e85 Change internal representation of roles in Member and Emoji.
Introduce a new internal type, SnowflakeList, which has better memory
footprint over a regular list or set of roles. It is suspected that
there will be a 9x reduction of memory for every Emoji instance and a
48 byte saving per Member instance. However, these savings will
probably only be evident on larger bots.

As a consequence of this change, Member.roles is now computed lazily.

Currently I am not sure if I want to do the initial sorting on the
SnowflakeList for Member, as this comes with a O(n log n) cost when
creating a Member for little purpose since SnowflakeList.has is not
overly relied on. If CPU time becomes an issue this might change.
2018-09-24 22:19:42 -04:00
3d03dbc451 Change internal role storage in Guild to a dict instead of a list.
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.
2018-09-24 21:08:48 -04:00
a4d1599ce9 Change docstrings to raw-strings 2018-09-14 22:55:27 -04:00
6d57ddf11b Correct Member.__hash__
Make Member.__hash__ just use whatever its User object's hash impl is.
2018-08-23 19:10:29 -06:00
c8b49d37be [lint] Fix incorrect and inconsistent whitespace
Adjust whitespace to be consistent with the rest of the library.
2018-08-22 21:43:53 -04:00
d58fc0ccee [lint] Remove unused imports
Left over from various refactoring and rewrites.
2018-08-22 21:43:50 -04:00
f25091efe1 Drop support for Python 3.4 and make minimum version 3.5.2. 2018-06-10 18:10:00 -04:00
f8f8f418f3 Split Game object to separate Activity subtypes for Rich Presences.
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.
2018-03-05 11:15:49 -05:00
3112e1c17e Add intersphinx 2018-01-06 17:23:59 -05:00
21fd94a449 Attempt to change how member functions are detected for Member objects 2017-09-04 20:03:50 -04:00
62df23633a Sort roles by hierarchy instead of by ID.
Fixes #741
2017-08-29 16:24:04 -04:00
7ee63a26f0 Fix docstring 2017-08-22 04:45:52 -04:00
84f38b166e Add atomic keyword argument for member role editing operations.
This affects:

* Member.add_roles
* Member.remove_roles

This is the main attempt of fixing long standing bugs like #56. Since
cache consistency is too hard to ask for due to eventual consistency
and this generally being one of the only main roadblocks that the
cache ruins, it's best to just implement it in terms of the atomic
endpoint instead.

Fixes #56
2017-08-21 10:40:33 -04:00
be1cffb7c3 Support for discord.Object in Member.remove_roles and Member.add_roles 2017-08-09 18:41:54 -04:00
723e392c95 Properly sort roles and discard everyone role in Member.colour. 2017-06-24 20:55:47 -04:00
f588876587 Use Python3Lexer instead of PythonLexer for pygments. 2017-05-22 07:21:23 -04:00
229c471106 More broken Channel references. 2017-05-20 08:48:04 -04:00
f4e01b3a92 Make supported operations stand out more than attributes. 2017-05-20 02:08:34 -04:00
8526995004 Minor speedup when doing comparisons.
Shred 2 getattr calls + 1 global lookup to 1 global lookup.
2017-05-18 05:15:06 -04:00
8e34a256a4 Fix User == Member comparisons. 2017-05-18 05:12:48 -04:00