Skip to content

Commit

Permalink
Improve sticker creation checks (#1546)
Browse files Browse the repository at this point in the history
* Make sticker description required

* Actually fix sticker descriptions

* Fix docs

* Clarify docs

Co-authored-by: Lala Sabathil <lala@pycord.dev>
  • Loading branch information
Middledot and Lulalaby authored Aug 6, 2022
1 parent 17af9d0 commit 8731e1f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2431,9 +2431,9 @@ async def create_sticker(
Parameters
-----------
name: :class:`str`
The sticker name. Must be at least 2 characters.
The sticker name. Must be 2 to 30 characters.
description: Optional[:class:`str`]
The sticker's description. Can be ``None``.
The sticker's description. If used, must be 2 to 100 characters.
emoji: :class:`str`
The name of a unicode emoji that represents the sticker's expression.
file: :class:`File`
Expand All @@ -2447,19 +2447,25 @@ async def create_sticker(
You are not allowed to create stickers.
HTTPException
An error occurred creating a sticker.
TypeError
The parameters for the sticker are not correctly formatted.
Returns
--------
:class:`GuildSticker`
The created sticker.
"""
if not (2 <= len(name) <= 30):
raise TypeError("\"name\" parameter must be 2 to 30 characters long.")

if description and not (2 <= len(description) <= 100):
raise TypeError("\"description\" parameter must be 2 to 200 characters long.")

payload = {
"name": name,
"description": description or ""
}

if description:
payload["description"] = description

try:
emoji = unicodedata.name(emoji)
except TypeError:
Expand Down

0 comments on commit 8731e1f

Please sign in to comment.