Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve sticker creation checks #1546

Merged
merged 8 commits into from
Aug 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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