Sticker

Represents a Message 's sticker.

Attributes

available : bool

Whether the sticker is available.

description : None, str

The sticker's description.

format : StickerFormat

The sticker's format.

guild_id : int

The guild's identifier to what the sticker is bound to. Defaults to 0 if the sticker is not bound to any guild.

id : int

The unique identifier number of the sticker.

name : str

The sticker's name.

pack_id : int

The unique identifier number of the pack from the sticker is. Defaults to 0 if the sticker is not bound to any pack.

sort_value : int

Value used to sort the stickers.

tags : None , frozenset of str

Tags of the sticker if applicable.

The sticker's type.

The user who uploaded the sticker. Defaults to ZEROUSER.

Properties

created_at

When the entity was created.

Returns

created_at : datetime

guild

Returns the sticker's guild if cached.

Returns

guild : Guild

partial

Returns whether the sticker is partial.

Returns

partial : bool

url

Returns the sticker's url.

This function is a shared method of property-s.

Returns

url : None, str

Methods

__new__(...)

Creates a partial sticker with the given fields.

ParameterTypeOptionalKeyword onlyDescription
available

bool

Whether the sticker is available.

description

None, str

The sticker's description.

name

str

The sticker's name.

pack_id

int, StickerPack

The unique identifier number of the pack from the sticker is.

sort_value

int

Value used to sort the stickers.

sticker_format

StickerFormat, int

The sticker's format.

sticker_type

StickerType, int

The sticker's type.

tags

None , iterable of str

Tags of the sticker if applicable.

user

ClientUserBase

The user who uploaded the sticker.

Raises

TypeError

  • A parameter's type is incorrect.

ValueError

  • A parameter's value is incorrect.

copy()

Copies the sticker returning a partial one.

Returns

new : instance<type<self>>

copy_with(...)

Copies the sticker with the given fields.

ParameterTypeOptionalKeyword onlyDescription
available

bool

Whether the sticker is available.

description

None, str

The sticker's description.

name

str

The sticker's name.

pack_id

int, StickerPack

The unique identifier number of the pack from the sticker is.

sort_value

int

Value used to sort the stickers.

sticker_format

StickerFormat, int

The sticker's format.

sticker_type

StickerType, int

The sticker's type.

tags

None , iterable of str

Tags of the sticker if applicable.

user

ClientUserBase

The user who uploaded the sticker.

Raises

TypeError

  • A parameter's type is incorrect.

ValueError

  • A parameter's value is incorrect.

from_data(data)

Creates a new sticker from the given data.

ParameterTypeDescription
data

dict of (str, object) items

Sticker data.

Returns

sticker : instance<cls>

from_partial_data(data)

Creates a sticker from the given partial sticker data.

ParameterTypeDescription
data

dict of (str, object) items

Sticker data.

Returns

sticker : instance<cls>

has_tag(tag)

Returns whether the sticker has the given tag.

ParameterTypeDescription
tag

str

The tag to check for.

Returns

has_tag : bool

iter_tags()

Iterates over the tags of the sticker.

This method is an iterable generator.

Yields

tag : str

precreate(sticker_id, ...)

Precreates the sticker by creating a partial one with the given parameters. When the sticker is loaded the precreated one will be picked up. If an already existing sticker would be precreated, returns that instead and updates that only, if that is partial.

ParameterTypeOptionalKeyword onlyDescription
sticker_id

int

The sticker's identifier.

**keyword_parameters

keyword parameters

Additional predefined attributes for the sticker.

available

bool

Whether the sticker is available.

description

None, str

The sticker's description.

guild

Guild, int

Alternative for guild_id.

guild_id

Guild, int

The sticker's guild's identifier.

name

str

The sticker's name.

pack

int, StickerPack

Alternative for pack_id.

pack_id

int, StickerPack

The unique identifier number of the pack from the sticker is.

sort_value

int

Value used to sort the stickers.

sticker_format

StickerFormat, int

The sticker's format.

sticker_type

StickerType, int

The sticker's type.

tags

None , iterable of str

Tags of the sticker if applicable.

user

ClientUserBase

The user who uploaded the sticker.

Returns

self : instance<cls>

Raises

TypeError

  • Extra parameter(s) given.
  • A parameter's type is incorrect.

ValueError

  • A parameter's value is incorrect.

to_data(...)

Converts the sticker to a json serializable object.

ParameterTypeOptionalKeyword onlyDefaultDescription
defaults

bool

False

Whether default values should be included as well.

include_internals

bool

False

Whether internal fields should be included as well.

Returns

data : dict of (str, object) items

to_partial_data()

Tries to convert the sticker to a json serializable dictionary representing a partial sticker.

Returns

data : dict of (str, object)

url_as(...)

Returns the sticker's url.

This function is a shared method of Sticker-s.

ParameterTypeOptionalDefaultDescription
size

None, int

None

The preferred minimal size of the icon's url.

preview

bool

False

Whether preview url should be generated.

Returns

url : None, str

Raises

ValueError

If size was not passed as any of the expected values.

_create_empty(sticker_id)

Creates an empty sticker with the given identifier.

ParameterTypeDescription
sticker_id

int

The sticker's identifier.

Returns

self : instance<cls>

The created sticker.

_difference_update_attributes(data)

Updates the sticker with the given data and returns the changed attributes in attribute-name- old-value relation.

ParameterTypeDescription
data

dict of (str, object) items

Sticker data.

Returns

old_attributes : dict of (str, object) items

All item in the returned dictionary is optional.

KeysValues
availablebool
descriptionNone, str
namestr
sort_valueint
tagsNone or frozenset of str

_get_hash_partial()

Returns a partial sticker's hash value.

Returns

hash_value : int

_is_equal_same_type(other)

Returns whether the two stickers are equal. self and other must be the same type.

ParameterTypeDescription
other

instance<type<self>>

The other sticker.

Returns

is_equal : bool

_set_attributes(data)

Sets the attributes of the sticker from the given data.

ParameterTypeDescription
data

dict of (str, object) items

Sticker data.

_update_attributes(data)

Updates the stickers with the given data.

ParameterTypeDescription
data

dict of (str, object) items

Sticker data.

__eq__()

Returns whether the two stickers are equal.

__format__(code)

Formats the sticker in a format string.

ParameterTypeDescription
code

str

The option on based the result will be formatted.

Returns

sticker : str

Raises

ValueError

Unknown format code.

Examples

>>> from hata import Sticker, now_as_id
>>> sticker = Sticker.precreate(now_as_id(), name = 'nice')
>>> sticker
<Sticker id = 712359434843586560, name = 'nice'>
>>> # no code returns the sticker's name.
>>> f'{sticker}'
'nice'
>>> # 'c' stands for created at.
>>> f'{sticker:c}'
'2020.05.19-17:42:04'

__ge__()

Returns whether self is greater or equal to other.

__getattr__()

Drops a rich attribute error.

__gt__()

Returns whether self is greater than other.

__hash__()

Returns the sticker's hash.

__le__()

Returns whether self is less or equal to other.

__lt__()

Returns whether self is less than other.

__ne__()

Returns whether the two stickers are not equal.

__repr__()

Returns the sticker's representation.