Skip to content

Commit 731eda1

Browse files
docs(emoji): misc documentation fixes for app emojis (#1388)
Signed-off-by: vi <8530778+shiftinv@users.noreply.github.com> Signed-off-by: arielle <me@arielle.codes> Co-authored-by: arielle <me@arielle.codes>
1 parent 0306a61 commit 731eda1

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

changelog/1223.feature.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Add support to :class:`.Emoji` to represent application emojis.
2-
New methods on :class:`Client`: :meth:`Client.fetch_application_emoji`, :meth:`Client.fetch_application_emojis` and :meth:`Client.create_application_emoji`.
3-
New attributes on :class:`.Emoji`: :attr:`Emoji.application_id`, :attr:`Emoji.is_guild_emoji` and :attr:`Emoji.is_app_emoji`.
1+
Add support to :class:`.Emoji` to represent application-owned emojis.
2+
- New methods on :class:`Client`: :meth:`Client.fetch_application_emoji`, :meth:`Client.fetch_application_emojis` and :meth:`Client.create_application_emoji`.
3+
- New attributes on :class:`.Emoji`: :attr:`Emoji.application_id`, :attr:`Emoji.is_guild_emoji` and :attr:`Emoji.is_app_emoji`.

changelog/1388.feature.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add support to :class:`.Emoji` to represent application-owned emojis.
2+
- New methods on :class:`Client`: :meth:`Client.fetch_application_emoji`, :meth:`Client.fetch_application_emojis` and :meth:`Client.create_application_emoji`.
3+
- New attributes on :class:`.Emoji`: :attr:`Emoji.application_id`, :attr:`Emoji.is_guild_emoji` and :attr:`Emoji.is_app_emoji`.

disnake/client.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,8 +2439,8 @@ async def fetch_application_emoji(self, emoji_id: int) -> Emoji:
24392439
------
24402440
NotFound
24412441
The app emoji couldn't be found.
2442-
Forbidden
2443-
You are not allowed to get the app emoji.
2442+
HTTPException
2443+
An error occurred fetching the app emoji.
24442444
24452445
Returns
24462446
-------
@@ -2469,10 +2469,8 @@ async def create_application_emoji(self, *, name: str, image: AssetBytes) -> Emo
24692469
------
24702470
NotFound
24712471
The ``image`` asset couldn't be found.
2472-
Forbidden
2473-
You are not allowed to create app emojis.
24742472
HTTPException
2475-
An error occurred creating an app emoji.
2473+
An error occurred creating the app emoji.
24762474
TypeError
24772475
The ``image`` asset is a lottie sticker (see :func:`Sticker.read <disnake.Sticker.read>`).
24782476
ValueError
@@ -2496,10 +2494,8 @@ async def fetch_application_emojis(self) -> List[Emoji]:
24962494
24972495
Raises
24982496
------
2499-
NotFound
2500-
The app emojis for this application ID couldn't be found.
2501-
Forbidden
2502-
You are not allowed to get app emojis.
2497+
HTTPException
2498+
An error occurred fetching the app emojis.
25032499
25042500
Returns
25052501
-------

disnake/emoji.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Emoji(_EmojiTag, AssetMixin):
5454
5555
.. versionchanged:: |vnext|
5656
57-
This class can now represents app emojis. Use :attr:`Emoji.is_app_emoji` to check for this.
57+
This class can now represent app emojis. Use :attr:`Emoji.is_app_emoji` to check for this.
5858
To check if this is a guild emoji, use :attr:`Emoji.is_guild_emoji`.
5959
6060
Attributes
@@ -74,9 +74,12 @@ class Emoji(_EmojiTag, AssetMixin):
7474
available: :class:`bool`
7575
Whether the emoji is available for use.
7676
user: Optional[:class:`User`]
77-
The user that created this emoji. This can only be retrieved using
78-
:meth:`Guild.fetch_emoji`/:meth:`Guild.fetch_emojis` while
77+
The user that created this emoji. If this is a guild emoji, this can only be retrieved
78+
using :meth:`Guild.fetch_emoji`/:meth:`Guild.fetch_emojis` while
7979
having the :attr:`~Permissions.manage_guild_expressions` permission.
80+
81+
If this is an app emoji, this is the team member that uploaded the emoji,
82+
or the bot user if created using :meth:`Client.create_application_emoji`.
8083
"""
8184

8285
__slots__: Tuple[str, ...] = (
@@ -184,7 +187,8 @@ def guild(self) -> Optional[Guild]:
184187

185188
@property
186189
def application_id(self) -> Optional[int]:
187-
"""Optional[:class:`int`]: The ID of the application which owns this emoji.
190+
"""Optional[:class:`int`]: The ID of the application which owns this emoji,
191+
if this is an app emoji.
188192
189193
.. versionadded:: |vnext|
190194
"""
@@ -194,15 +198,15 @@ def application_id(self) -> Optional[int]:
194198

195199
@property
196200
def is_guild_emoji(self) -> bool:
197-
""":class:`bool`: Whether this is a guild emoji.
201+
""":class:`bool`: Whether this emoji is a guild emoji.
198202
199203
.. versionadded:: |vnext|
200204
"""
201205
return self.guild_id is not None
202206

203207
@property
204208
def is_app_emoji(self) -> bool:
205-
""":class:`bool`: Whether this is an application emoji.
209+
""":class:`bool`: Whether this emoji is an application emoji.
206210
207211
.. versionadded:: |vnext|
208212
"""
@@ -228,16 +232,18 @@ def is_usable(self) -> bool:
228232
async def delete(self, *, reason: Optional[str] = None) -> None:
229233
"""|coro|
230234
231-
Deletes the custom emoji.
235+
Deletes the emoji.
232236
233-
You must have :attr:`~Permissions.manage_guild_expressions` permission to
234-
do this.
237+
If this is not an app emoji, you must have
238+
:attr:`~Permissions.manage_guild_expressions` permission to do this.
235239
236240
Parameters
237241
----------
238242
reason: Optional[:class:`str`]
239243
The reason for deleting this emoji. Shows up on the audit log.
240244
245+
Only applies to emojis that belong to a :class:`.Guild`.
246+
241247
Raises
242248
------
243249
Forbidden
@@ -251,7 +257,10 @@ async def delete(self, *, reason: Optional[str] = None) -> None:
251257
if self.guild is None:
252258
if self.application_id is None:
253259
# should never happen
254-
msg = f"guild and application_id are both None when attempting to delete emoji with ID {self.id} This may be a library bug! Open an issue on GitHub."
260+
msg = (
261+
f"guild_id and application_id are both None when attempting to delete emoji with ID {self.id}."
262+
" This may be a library bug! Open an issue on GitHub."
263+
)
255264
raise InvalidData(msg)
256265

257266
return await self._state.http.delete_app_emoji(self.application_id, self.id)
@@ -262,10 +271,10 @@ async def edit(
262271
) -> Emoji:
263272
"""|coro|
264273
265-
Edits the custom emoji.
274+
Edits the emoji.
266275
267-
You must have :attr:`~Permissions.manage_guild_expressions` permission to
268-
do this.
276+
If this emoji is a guild emoji, you must have
277+
:attr:`~Permissions.manage_guild_expressions` permission to do this.
269278
270279
.. versionchanged:: 2.0
271280
The newly updated emoji is returned.
@@ -280,9 +289,13 @@ async def edit(
280289
An emoji cannot have both subscription roles (see :attr:`RoleTags.integration_id`) and
281290
non-subscription roles, and emojis can't be converted between premium and non-premium
282291
after creation.
292+
293+
Only applies to emojis that belong to a :class:`.Guild`.
283294
reason: Optional[:class:`str`]
284295
The reason for editing this emoji. Shows up on the audit log.
285296
297+
Only applies to emojis that belong to a :class:`.Guild`.
298+
286299
Raises
287300
------
288301
Forbidden
@@ -306,7 +319,10 @@ async def edit(
306319
if self.guild is None:
307320
if self.application_id is None:
308321
# should never happen
309-
msg = f"guild and application_id are both None when attempting to edit emoji with ID {self.id} This may be a library bug! Open an issue on GitHub."
322+
msg = (
323+
f"guild_id and application_id are both None when attempting to edit emoji with ID {self.id}."
324+
" This may be a library bug! Open an issue on GitHub."
325+
)
310326
raise InvalidData(msg)
311327

312328
data = await self._state.http.edit_app_emoji(self.application_id, self.id, name)

0 commit comments

Comments
 (0)