Commit Graph

81 Commits

Author SHA1 Message Date
df4b1c88df Move MissingApplicationID to top-level discord namespace 2024-08-31 08:51:56 -04:00
463b4bd570 Add support for application emojis
Co-authored-by: DA344 <108473820+DA-344@users.noreply.github.com>
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
2024-08-28 17:15:15 -04:00
ce06beeb6c Fix permissions-based docstrings to be more consistent 2022-09-17 14:07:39 -04:00
67066937c5 Add return type for __init__ and _from_data 2022-05-30 08:48:56 -04:00
5ffa3e85de Update comments after # type: ignore to be compatible with PEP 484 2022-03-27 22:26:34 -04:00
e01d4a31eb Replace invariant container types with wider types where applicable 2022-03-17 07:26:01 -04:00
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
a90e1824f4 Fix type of roles param in Emoji.edit's docstring 2022-03-01 07:41:33 -05:00
f5e087c5c3 Fix typing in emoji.py 2022-02-22 03:59:58 -05:00
88b520b5ab Reformat code using black
Segments where readability was hampered were fixed by appropriate
format skipping directives. New code should hopefully be black
compatible. The moment they remove the -S option is probably the moment
I stop using black though.
2022-02-20 08:04:58 -05:00
490bbffc93 Remove in-place edits and return fresh instances instead
Fixes #4098
2021-08-23 23:46:50 -04:00
47f2d04940 Allow passing Emoji in components 2021-06-02 05:30:42 -04:00
be5f4ae4ab Properly type hint attributes in Emoji 2021-06-02 05:30:42 -04:00
1bf7aadf94 Typehint emoji classes 2021-05-05 23:48:36 -04:00
fed259a83b Refactor save() and read() into AssetMixin 2021-04-17 00:56:38 -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
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
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
69bdc3a184 Change copyright year to present 2021-01-15 05:28:11 -05:00
3fea697ba5 Add versionadded string for Emoji.url_as 2020-12-17 22:21:45 -05:00
13bba3afc2 Add Emoji.url_as 2020-12-17 22:20:00 -05: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
15f0b000e1 Move PartialEmoji over to a new namespace to avoid circular imports 2019-11-20 00:50:19 -05:00
cb21159589 Document that PartialEmoji.name can be None 2019-11-18 20:00:06 -05: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
f273199d57 Refactor name kwarg for Emoji.edit() 2019-10-20 05:19:03 -04:00
3cef1e09f8 Add Emoji.is_usable() 2019-09-19 21:24:16 -04:00
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
8e80eee0d1 Add Emoji.available field 2019-06-04 18:30:46 -04:00
2cd6d771ec Make __repr__ slightly more detailed and add a few missing ones.
This includes raw events (which didn't have any) and a few other
types that were missing them. Upon review some more useful fields were
added to the repr output which would be more useful during debugging.
2019-05-26 02:32:47 -04:00
5473cec6ac Added note to Emoji.user 2019-05-13 22:12:33 -04:00
a62641bd65 Add back __repr__ that were deleted in the Asset redesign
The Asset PR (be227ebcf0) changed some namedtuple-deriving
classes to object-deriving classes, which meant that the free __repr__ provided by namedtuple
was removed
2019-05-13 20:29:08 -04:00
9248ff306c Use explicit __eq__ call to be consistent with other methods. 2019-04-06 20:18:10 -04:00
1d701f32b6 Add fetch custom emoji, all custom emojis; Add user property to Emoji 2019-04-06 19:19:47 -04:00
be227ebcf0 Redesign asset retrieval in the library.
Most assets now return a new class named `Asset`. This allows for the
assets to be consistently saved via a `save` method instead of special
casing for `Attachment`.

`AppInfo` is no longer a namedtuple it is a fully documented dataclass,
as well as having the state attached to it.

Fixes #1997
2019-04-06 19:12:50 -04:00
72b6b67cf4 Add back PartialEmoji.__hash__ that was deleted due to __eq__. 2019-03-20 22:54:53 -04:00
fb02191b80 Organise documentation 2019-03-19 08:24:42 -04:00
bbc4460c38 Fix Emoji.__hash__ being None.
When a type defines __eq__, Python removes its __hash__ function.

Fixes #1933
2019-02-26 08:44:25 -05:00
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
ce3ede1551 Implement PartialEmoji == Emoji (fixes #1627) 2019-01-28 22:22:48 -05:00
fed01c5e15 Remove outdated note about bot accounts.
They can now delete all emoji
2018-10-11 02:36:46 -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
5c24e69cf2 Fix up the Sphinx strings causing warnings. 2018-09-15 09:54:00 -04:00
21309c2d72 Removed inaccurate note on emoji.py
In the docs, it says ``Note that bot accounts can only edit custom emojis they own.``

But after testing a bit. My bot was able to edit emojis in any guild that had the permissions `manage_roles`. Even if the bot didn't own the guild. Or was the original emoji uploader.

And I don't see any mentions of this in the API server or in the documentation. So I'm unsure how this ended up in here. It's possible I am misunderstanding the whole note. My bad if that's the case.
2018-09-14 22:55:28 -04:00
3ccbda928e Fix PartialEmoji._as_reaction() for emojis the bot can't see
If the bot has access to the emoji, you can pass anything for its name
and it will work fine. The name is only required to be correct when
adding a reaction where you do not have access to the emoji,
all other cases ignore the name.
2018-08-30 18:33:51 -04:00
d58fc0ccee [lint] Remove unused imports
Left over from various refactoring and rewrites.
2018-08-22 21:43:50 -04:00
0e6082c57d Implement roles kwarg for guild.create_custom_emoji and emoji.edit 2018-08-22 21:06:09 -04:00