Commit Graph

137 Commits

Author SHA1 Message Date
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
b8898c7788 Fix user.py typings and reformat file 2021-08-22 07:38:07 -04:00
91652e3b60 Add per-guild member avatar support
Fix #7054
2021-08-22 06:49:42 -04:00
63434fbfd9 Fix some type hints in user.py 2021-08-18 01:59:06 -04:00
529fad6fec Type-hint user.py 2021-08-18 00:37:33 -04:00
06a371e80a Fix User.accent_color incorrect attribute access 2021-07-30 21:30:54 -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
9d25bb454b Fix recursive inheritance in BaseUser 2021-07-28 20:01:44 -04:00
b47133dfb2 Add BaseUser.banner for all subclasses to access new banners 2021-07-28 19:41:43 -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
cb2363f0fd Move global user storage from WeakValueDictionary to dict
Profiling showed that WeakValueDictionary caused rather significant
and noticeable slowdowns during startup. Since the only thing it was
used for was to automatically remove the key from the mapping when
the reference count reaches zero, the same could theoretically be
accomplished by using the __del__ special method. There is a chance
that this could lead to a memory leak since the __del__ method is not
always called, but the only instances of this happening are during
interpreter shutdown to my knowledge and at that point the mapping
is the least of my concern.
2021-07-07 20:19:17 -04:00
6f3b8072d6 Rework User.edit to have proper typing 2021-06-29 22:05:29 -04:00
f7d551953b Remove extraneous __slots__ assignments 2021-06-28 23:36:20 -04:00
757cfad38f Type up **kwargs of various methods 2021-05-10 20:24:48 -04:00
8b2241916a Typehint Widget 2021-05-09 23:22:12 -04:00
66b17f5afb Clarify ClientUser.verified docs 2021-04-30 19:12:40 -04:00
1c64689807 Remove lingering User.avatar documentation 2021-04-19 05:35:33 -04:00
86f10f6dd6 Add missing reprs to some objects
These are WidgetMember, BaseUser, and DeletedReferencedMessage
2021-04-17 18:56:08 -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
1209585de5 Remove User.permissions_in
This seemed to only cause confusion.
2021-04-11 22:21:36 -04:00
99fc950510 Use f-strings in more places that were missed. 2021-04-08 06:02:47 -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
54288879e2 Remove userbot functionality
This has a lot of legacy and cruft so there may be some stuff I've
missed but this first pass is enough to get a clear separation.
2021-04-04 10:15:30 -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
4d4c19f9b5 deprecate User.relationships 2021-03-28 18:39:15 -04:00
456a5dfa59 Update create_dm documentation to say it's a coroutine 2021-03-24 08:19:05 -04:00
63ec23bac2 Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
427e387a2f Deprecate non-bot methods 2021-02-23 03:36:37 -05:00
27c7fb6aed Add User.mutual_guilds 2021-02-20 19:29:19 -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
93fa46713a Fix and add documentation 2020-09-23 03:19:35 -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
010ce0519a Fix incorrect class reference in documentation 2020-06-04 23:38:57 -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
6f9793fe5e Fixes and improvements for v1.3 documentation
* Add missing versionadded strings for v1.3
* Add missing versionchanged string for Message.edit
* Consistently use versionadded for attributes
* Consistently use versionchanged for parameters
* Use versionchanged for Bot.is_owner
* Fix references in v1.3 changelog
* Improve grammar in v1.3 changelog
2020-01-22 23:55:05 -05:00
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
c92ca4ee07 Add Profile.system and Profile.team_user to query newer flags 2019-12-21 07:46:15 -05:00
2de90fbecf Add User.system and MessageFlags.urgent 2019-12-21 07:39:33 -05:00
b458cc7b7d Return 'username' instead of 'name' 2019-12-05 17:59:42 +01:00
bf9b9c5879 Adjust BASE urls to have no trailing slash (consistency) 2019-11-15 04:25:38 -05:00
f5ebf42e1f Return invites as https, various URL normalization 2019-11-15 04:25:38 -05:00
e713b86154 Added Optional to ClientUser.premium_type type hint 2019-11-15 04:23:15 -05:00
c7a1f5e6e9 Disambiguate and normalize documentation for non-bot only methods 2019-08-11 18:50:31 -04:00
de1a96b9f7 Fix: another capitalization issue in docstring 2019-07-18 18:06:42 -04:00
ae4989e474 Fix return type docstring for BaseUser.default_avatar 2019-07-18 18:06:26 -04:00