From 8731e1f15a3671aa882cfd346eaedf0c730a8845 Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Sat, 6 Aug 2022 19:01:47 -0400 Subject: [PATCH] Improve sticker creation checks (#1546) * Make sticker description required * Actually fix sticker descriptions * Fix docs * Clarify docs Co-authored-by: Lala Sabathil --- discord/guild.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/discord/guild.py b/discord/guild.py index 301bb1db5f..c64c912919 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -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` @@ -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: