63 Commits

Author SHA1 Message Date
Rapptz
fec459e755 Document Server.large 2016-06-12 23:46:12 -04:00
Rapptz
c97e5a17e6 Update positions when a role is added or removed. 2016-06-01 21:06:04 -04:00
Rapptz
5016f12079 Add Role.server attribute.
This breaks events that expected a server parameter for the role events.
2016-06-01 19:27:48 -04:00
Rapptz
85806ef1d6 Handle nicknames in Server.get_member_named 2016-04-29 08:20:16 -04:00
Khazhismel Kumykov
0e91ef79ef Fix handling of unavailable servers in READY 2016-04-04 23:45:05 -04:00
Rapptz
1a202bb6eb Add Server.get_member_named to help with name + discriminator lookups. 2016-04-01 05:59:58 -04:00
Rapptz
0ad1cb95a3 Server.icon_url uses API url instead of the CDN. 2016-03-25 19:13:06 -04:00
Rapptz
f437ffe44e Add created_at properties for Server and User. 2016-03-06 03:47:25 -05:00
Rapptz
e2ed8b1476 Remove Server.me from __slots__ since it is a property now. 2016-03-05 20:58:25 -05:00
Rapptz
4584c68f0c Remove request_offline option. 2016-02-14 21:49:34 -05:00
Rapptz
841e584ee9 Update owner references when we get a chunk. 2016-02-14 20:00:50 -05:00
Rapptz
4768d950c5 Offline members are now added by default automatically.
This commit adds support for GUILD_MEMBERS_CHUNK which had to be done
due to forced large_threshold requirements in the library.
2016-02-14 19:24:26 -05:00
Rapptz
7b135725bc Add Server.member_count property for actual member count.
This will always work regardless of chunking or not.
2016-02-13 22:08:13 -05:00
Rapptz
e67f580350 Remove unneeded owner_id assignment. 2016-01-18 05:21:13 -05:00
Rapptz
178d43e24f Support upcoming guild ownership transfership change.
Thanks to Jake.
2016-01-18 05:17:06 -05:00
Rapptz
4ea015067f Handle cases where people put False-like values for game presences. 2016-01-11 19:50:13 -05:00
Rapptz
8974dffc4e Change internal update functions to have a leading underscore. 2016-01-11 14:44:13 -05:00
Rapptz
93e3c360a7 Fix conflicts with __slots__ and the new properties under Server. 2016-01-08 15:31:06 -05:00
Rapptz
a1a47c6f38 Document the breaking change with the new dictionary storage change.
Since the only things dict views support are iteration we should
advise people who want the old behaviour to change it to a list.
2016-01-08 14:04:58 -05:00
Steven Berler
777b5a09e2 document public get_ methods and make others private 2016-01-08 13:24:56 -05:00
Steven Berler
10b0b62f50 performance improvements
Replaced server member lists, channel lists, and private channel lists
with dicts. This allows O(1) lookups and removes (previously it would be
an O(N) operation to lookup or remove). I did pretty extensive testing
and benchmarking to compare the performance of using lists vs using
dicts. Iterating through lists to find an item is only faster in the
average case for extremely small lists (less than 3 items). For 100
items, using a dict is about 10 times faster on average (and about 100
times faster for 1000 items). The overhead in dicts is in memory usage
and initial creation time. Creating and populating a dict is about 2 to
3 times slower than creating and appending items to a list. However this
cost is still tiny.  For 1000 items this equates to about a 70
microsecond difference (on an i7 CPU) for populating the entire dict.
The memory overhead for a dict (compared to a list) is about 25-60 KB
per 1000 items (can vary depending on dict resizing).

Originally I wanted to use OrderedDicts to presereve order, but in my
testing OrderedDicts have about 6x the memory overhead compared to
normal dicts.
2016-01-08 13:24:55 -05:00
Rapptz
6ddfbc4b36 Add missing roles attribute to Server.__slots__ 2016-01-07 00:57:04 -05:00
Rapptz
89a418a388 Add __slots__ for missing classes that didn't have it. 2016-01-06 23:40:20 -05:00
Rapptz
c1583dd7d6 Unavailable guilds get added to cache. 2016-01-06 12:57:09 -05:00
Rapptz
db4cc791dd Update license of files to 2016. 2016-01-04 22:28:29 -05:00
Khazhismel
0aa46e6def Add game data class, replace game_id. 2015-12-23 21:28:18 -05:00
Rapptz
49d78c69c7 All update related events now pass in the previous state. 2015-12-17 06:05:35 -05:00
Rapptz
51d91c2a82 Most data classes now support hashing. 2015-12-17 00:32:54 -05:00
Rapptz
4f66d41ca3 Add Server.me attribute to access the Member version of Client.user. 2015-12-16 23:35:05 -05:00
Rapptz
de1c74a399 Make more things into properties.
A lot of the expensive getters were transformed into cached properties
instead. A lot of things that were properties were transformed into
properties as well.
2015-12-16 22:03:16 -05:00
Rapptz
9137d92f67 All data classes now support !=, == and str(obj). 2015-12-13 22:53:48 -05:00
Rapptz
ab46afee1d Changed functions that return a constant value into properties. 2015-12-13 20:05:58 -05:00
Rapptz
80b32e769e Handle GUILD_UPDATE 2015-12-06 03:09:55 -05:00
Rapptz
79bdf2a721 Add enumerators instead of strings.
Changes channel type, status and server region into 3.4 enums.
2015-12-04 22:13:17 -05:00
Rapptz
38e83f0999 "An array" -> "A list" for documentation purposes. 2015-11-28 19:51:32 -05:00
Rapptz
70c7a79719 Remove afk_channel_id and replace it with afk_channel. 2015-11-28 19:28:31 -05:00
Rapptz
df3cb831a9 Member.roles array now has the default role as the first element. 2015-11-28 19:26:25 -05:00
Rapptz
e10b6c767b Move server parsing code from Client to Server. 2015-11-28 19:17:50 -05:00
Hla
83a5449fc5 icon_url and get_default_channel in Server 2015-11-16 17:07:51 -05:00
Rapptz
a0073c734e Split data classes into more files. 2015-10-27 16:23:20 -04:00
Rapptz
5efddaf35d Support unavailable servers. 2015-10-24 05:10:58 -04:00
Rapptz
2813652995 Fix bug with member voice state update. 2015-10-17 05:27:10 -04:00
Rapptz
a9fd4fc4e3 Better detection for the @everyone role. 2015-10-17 04:13:15 -04:00
Rapptz
c4f7664bd9 Only remove if the user is actually in the voice channel. 2015-10-16 20:11:29 -04:00
Rapptz
be14fd1dcc Add Channel.voice_members
This allows you to see which members are currently in a voice
channel.
2015-10-16 15:52:11 -04:00
Rapptz
411b477a02 Separate colour tuple into its own class.
Also enumerate all the constant colours that Discord currently
supports.
2015-10-16 07:48:50 -04:00
Rapptz
ab2512785b Handle VOICE_STATE_UPDATE websocket events.
This adds a lot of new attributes into the Member class
such as giving a voice_channel that the user is currently connected
to. Initially there was a plan to have a voice_members attribute
in the Channel class but this proved to be difficult when it came to
actually removing users from the voice channel as the response would
return channel_id as null.

Fixes #16.
2015-10-15 01:37:55 -04:00
Rapptz
4ff7d22edd Handle GUILD_ROLE_UPDATE websocket events. 2015-10-15 01:37:55 -04:00
Rasmus Karlsson
75670fa0a2 Fixed get_default_role in Server attempting to access the wrong roles. 2015-10-15 01:37:52 -04:00
Rapptz
608384dd4f Parse role colour and other new role attributes.
New attributes include hoist, position, and of course colour. An
alias is in place for British and American spellings (i.e. color).
2015-10-13 05:39:58 -04:00