157 Commits

Author SHA1 Message Date
owocado
0a2faa6f5d
Fix default_avatar for team user and webhook 2024-08-28 15:34:33 -04:00
Alex Nørgaard
82d13e7b49
Add support for ClientUser editing banners 2024-03-14 18:10:17 -04:00
JDJG
8d3b56206b
Update ClientUser.edit docs for animated avatars 2024-02-07 19:38:18 -05:00
Andrin
e25b7ff3f8
Support for avatar decorations
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
Co-authored-by: owocado <24418520+owocado@users.noreply.github.com>
2024-01-26 20:12:07 -05:00
Rapptz
eedd7e3014 Add support for new pink default avatars 2023-06-07 22:12:47 -04:00
Rapptz
8d17aa23c9 Remove @ prefix from usernames
Discord seemed to have backtracked on this display
2023-05-19 20:59:19 -04:00
Rapptz
9ebc13e160 Only use @ prefix in __str__ if the user is migrated 2023-05-19 20:59:19 -04:00
Rapptz
b8310268b0 Fix default_avatar detection for migrated users 2023-05-19 20:59:19 -04:00
Rapptz
df01db3490 Initial support for pomelo migration 2023-05-19 20:59:19 -04:00
Rapptz
252ac38f92 Add fallback ClientUser.mutual_guilds property
Fixes #9387
2023-05-05 10:57:21 -04:00
AF-Sources
40db618d1e
Update documentation of User.avatar to be more clear 2023-01-14 08:02:44 -05:00
invalid-user
8eb2e19c41
Add more detailed description to accent_colour 2022-05-12 22:06:28 -04:00
Stocker
5aa696ccfa
Fix typing issues and improve typing completeness across the library
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
Co-authored-by: Josh <josh.ja.butt@gmail.com>
2022-03-13 23:52:10 -04:00
chromacoat dreamkey
095aaa9ad1
Change wording of InvalidArgument removal in docs 2022-03-11 23:25:43 -05:00
Josh
147948af9b
Use typing.Self throughout library 2022-03-01 07:53:24 -05:00
jack1142
f63eb5c30d
Fix avatar clearing in ClientUser.edit 2022-03-01 06:47:28 -05:00
Josh
2b69b5d545
Remove discord.InvalidArgument
This uses TypeError and ValueError instead.
2022-02-26 01:44:49 -05:00
Josh
3ce00abeae Fix some type-check errors 2022-02-22 03:59:58 -05:00
Rapptz
b389596f26 Fix typing of User._accent_colour 2022-02-17 09:20:08 -05:00
Rapptz
940bdb988a Revert "Move global user storage from WeakValueDictionary to dict"
This reverts commit cb2363f0fd819ce1a5c38b42cd403fcb8994be6f.

This lead to memory leaks due to insufficient tracking, assuming that
the members intent was enabled.
2022-02-17 07:26:10 -05:00
Rapptz
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
Rapptz
490bbffc93 Remove in-place edits and return fresh instances instead
Fixes #4098
2021-08-23 23:46:50 -04:00
Rapptz
b8898c7788 Fix user.py typings and reformat file 2021-08-22 07:38:07 -04:00
JustAnyone
91652e3b60
Add per-guild member avatar support
Fix #7054
2021-08-22 06:49:42 -04:00
Rapptz
63434fbfd9 Fix some type hints in user.py 2021-08-18 01:59:06 -04:00
thetimtoy
529fad6fec
Type-hint user.py 2021-08-18 00:37:33 -04:00
nickofolas
06a371e80a
Fix User.accent_color incorrect attribute access 2021-07-30 21:30:54 -04:00
Rapptz
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
Rapptz
9d25bb454b Fix recursive inheritance in BaseUser 2021-07-28 20:01:44 -04:00
Alex Nørgaard
b47133dfb2
Add BaseUser.banner for all subclasses to access new banners 2021-07-28 19:41:43 -04:00
Rapptz
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
Rapptz
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
Rapptz
6f3b8072d6 Rework User.edit to have proper typing 2021-06-29 22:05:29 -04:00
Rapptz
f7d551953b Remove extraneous __slots__ assignments 2021-06-28 23:36:20 -04:00
Nadir Chowdhury
757cfad38f
Type up **kwargs of various methods 2021-05-10 20:24:48 -04:00
Josh
8b2241916a
Typehint Widget 2021-05-09 23:22:12 -04:00
David
66b17f5afb
Clarify ClientUser.verified docs 2021-04-30 19:12:40 -04:00
Rapptz
1c64689807 Remove lingering User.avatar documentation 2021-04-19 05:35:33 -04:00
Steve C
86f10f6dd6
Add missing reprs to some objects
These are WidgetMember, BaseUser, and DeletedReferencedMessage
2021-04-17 18:56:08 -04:00
Rapptz
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
Rapptz
1209585de5 Remove User.permissions_in
This seemed to only cause confusion.
2021-04-11 22:21:36 -04:00
Rapptz
99fc950510 Use f-strings in more places that were missed. 2021-04-08 06:02:47 -04:00
Nadir Chowdhury
89456022cf
Add __all__ to remaining modules 2021-04-07 02:30:32 -04:00
Rapptz
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
Rapptz
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
Rapptz
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
Nadir Chowdhury
4d4c19f9b5
deprecate User.relationships 2021-03-28 18:39:15 -04:00
Alex Nørgaard
456a5dfa59
Update create_dm documentation to say it's a coroutine 2021-03-24 08:19:05 -04:00
Nadir Chowdhury
63ec23bac2
Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
Nadir Chowdhury
427e387a2f
Deprecate non-bot methods 2021-02-23 03:36:37 -05:00