Commit Graph

150 Commits

Author SHA1 Message Date
efec816de2 Make arguments positional only in 2 get methods
- Member.get_role
- Guild.get_member
2021-08-25 20:52:20 -04:00
848d752388 Change User.avatar to be Optional[Asset] instead of Asset
This change was needed to allow users to more easily check if an
uploaded avatar was set using `if user.avatar:` rather than the
admittedly clunky `if user.avatar != user.default_avatar.

The old behaviour with a fallback is still useful for actual display
purposes, so it has been moved over to the new `User.display_avatar`
attribute. This also has symmetry with the newly added
`Member.display_avatar` attribute.
2021-08-25 01:43:09 -04:00
490bbffc93 Remove in-place edits and return fresh instances instead
Fixes #4098
2021-08-23 23:46:50 -04:00
cff9ca0288 Fix typings for member HTTP methods 2021-08-23 23:44:20 -04:00
d7a4230007 Fix Member.guild_avatar docstring 2021-08-22 07:07:26 -04:00
49cf959784 Fix Member._avatar not updating in member update events 2021-08-22 06:54:38 -04:00
91652e3b60 Add per-guild member avatar support
Fix #7054
2021-08-22 06:49:42 -04:00
6c36df6c11 Add missing typehints for Member properties 2021-08-21 14:18:27 -04:00
745cf541ea Re-define Member properties inferred from User to support type-checking 2021-08-20 20:02:39 -04:00
6beef898c6 Rename instances of nitro to premium 2021-07-30 23:10:36 -04:00
ecf239d2a2 Fix user cache acting incorrectly with evictions
The first issue involved copied users which would lead to user updates
causing faster evictions of the cache than was expected.

The second issue involved users that weren't bound to an internal
lifetime eviction policy. These users would not get evicted.
For example, a user without mutual guilds or being part of the internal
cache in general (messages, DMs) would never end up being evicted for
some strange reason. To handle this case, store_user would get a
counterpart named create_user which would create a user without
potentially storing them in the cache. That way only users with a
bound lifetime within the library would be stored.
2021-07-29 01:43:23 -04:00
af8742a911 Use a specific tag type for member and user comparisons
The previous protocol based tag type caused significant overhead
(in the magnitude of seconds). Removing this should simplify object
creation by removing typing.Generic from the __mro__
2021-07-08 10:17:44 -04:00
1aeec34f84 Typehint Member and various typing fixes 2021-06-30 01:28:35 -04:00
a372aadb2d Rework Member.edit to not use kwargs for better typing 2021-06-29 21:54:24 -04:00
20dd632722 Fix Member.ban typing to include 0-day message deletes 2021-06-27 23:38:29 -04:00
1bf782fcb5 Add Member.get_role
Adds an efficient way to check if a member has a role by ID.

 This is done in a way consistent with the existing user API of the
 library.

 The more debated Member.has_role_id/has_role is intentionally not
 included for review at this time given the heavy bikeshedding of it.
2021-05-27 22:31:49 -04:00
5fa64e83e0 Fix issues with imports causing NameErrors 2021-05-12 20:24:28 -04:00
757cfad38f Type up **kwargs of various methods 2021-05-10 20:24:48 -04:00
e4513f70ad activities is no longer nullable 2021-04-17 18:56:51 -04:00
9eaf1e85e4 Rewrite Asset design
This is a breaking change.

This does the following transformations, assuming `asset` represents
an asset type.

Object.is_asset_animated() => Object.asset.is_animated()
Object.asset => Object.asset.key
Object.asset_url => Object.asset_url
Object.asset_url_as => Object.asset.replace(...)

Since the asset type now requires a key (or hash, if you will),
Emoji had to be flattened similar to how Attachment was done since
these assets are keyed solely ID.

Emoji.url (Asset) => Emoji.url (str)
Emoji.url_as => removed
Emoji.url.read => Emoji.read
Emoji.url.save => Emoji.save

This transformation was also done to PartialEmoji.
2021-04-16 11:27:23 -04:00
208b16ed1b Add note to member docs about Spotify limitation 2021-04-14 22:02:49 -04:00
1209585de5 Remove User.permissions_in
This seemed to only cause confusion.
2021-04-11 22:21:36 -04:00
7d79b4ba55 Remove Member related handling in PRESENCE_UPDATE 2021-04-11 00:57:59 -04:00
89456022cf Add __all__ to remaining modules 2021-04-07 02:30:32 -04:00
ff7094ce96 Convert datetimes to aware datetimes with UTC.
Naive datetimes will now be interpreted as local time throughout
the library.
2021-04-04 23:54:08 -04:00
9d39b135f4 Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
2021-04-04 07:03:53 -04:00
1b2688518e Implement StageChannel and related methods 2021-04-03 22:43:41 -04:00
d6501159e7 [docs] copy signature from overridden and inherited methods 2021-03-29 23:52:14 -04:00
a06d00f554 Make await text appear in async Member method docs 2021-03-24 08:22:50 -04:00
63ec23bac2 Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
d7b41e0a21 Fix User public flags not updating 2021-01-17 00:09:15 -05:00
69bdc3a184 Change copyright year to present 2021-01-15 05:28:11 -05:00
bbbda4ec00 Update add_roles docstring to mention role order. 2021-01-14 03:11:58 -05:00
93f102ca90 Add support for Member.pending boolean attribute 2020-12-18 21:02:22 -05:00
6b803acde4 [chore] Remove redundant imports
This also removes the historical patch for NullHandler implemented in bbf1c54, as it has been available since Python 3.1.
2020-11-28 03:16:49 -05:00
f2de794bde Intern status and overwrite strings 2020-09-23 03:21:20 -04:00
23ae084b8c Allow finer grained control over the member cache. 2020-09-23 03:21:20 -04:00
c261f7c4a3 Handle user updates within GUILD_MEMBER_UPDATE 2020-09-23 03:21:16 -04:00
93fa46713a Fix and add documentation 2020-09-23 03:19:35 -04:00
a183c4f752 Completely update member references from message inner members.
Fixes #5819
2020-09-17 02:45:53 -04:00
15f51113c3 Fix Member.joined_at documentation 2020-09-09 19:44:33 -04:00
c3bca7ec73 Documentation formatting 2020-06-30 23:32:00 -04:00
b4b953bfc6 Fix various inconsistencies within the documentation (#5067) 2020-06-28 03:45:58 -04:00
7bef78284f Removes the caching behavior of Member.roles
- fixes 4087
- This intentionally uses some internals in both Member.roles and
Member.top_role to retain as much performance as possible while
removing the cache
2020-06-04 23:38:11 -04:00
ab5f995d78 Add support for public user flags 2020-05-29 22:40:14 -04:00
6decfd1d1a Fix colour properties being displayed as methods in the documentation. 2020-05-03 15:40:13 -04:00
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