Sticker
Represents a Message
's sticker.
Attributes
bool
Whether the sticker is available.
None
, str
The sticker's description.
The sticker's format.
int
The guild's identifier to what the sticker is bound to. Defaults to 0
if the sticker is not bound to any guild.
int
The unique identifier number of the sticker.
str
The sticker's name.
int
The unique identifier number of the pack from the sticker is. Defaults to 0
if the sticker is not bound to any pack.
int
Value used to sort the stickers.
,
frozenset of
strTags 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
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.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
available |
| Whether the sticker is available. | ||
description |
| The sticker's description. | ||
name |
| The sticker's name. | ||
pack_id |
| The unique identifier number of the pack from the sticker is. | ||
sort_value |
| Value used to sort the stickers. | ||
sticker_format |
| The sticker's format. | ||
sticker_type |
| The sticker's type. | ||
tags | None | Tags of the sticker if applicable. | ||
user | The user who uploaded the sticker. |
Raises
TypeError
- A parameter's type is incorrect.
ValueError
- A parameter's value is incorrect.
()
copyCopies the sticker returning a partial one.
Returns
new : instance<type<self>>
(...)
copy_withCopies the sticker with the given fields.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
available |
| Whether the sticker is available. | ||
description |
| The sticker's description. | ||
name |
| The sticker's name. | ||
pack_id |
| The unique identifier number of the pack from the sticker is. | ||
sort_value |
| Value used to sort the stickers. | ||
sticker_format |
| The sticker's format. | ||
sticker_type |
| The sticker's type. | ||
tags | None | Tags of the sticker if applicable. | ||
user | The user who uploaded the sticker. |
Raises
TypeError
- A parameter's type is incorrect.
ValueError
- A parameter's value is incorrect.
(data)
from_dataCreates a new sticker from the given data.
Parameter | Type | Description |
---|---|---|
data |
| Sticker data. |
Returns
sticker : instance<cls>
(data)
from_partial_dataCreates a sticker from the given partial sticker data.
Parameter | Type | Description |
---|---|---|
data |
| Sticker data. |
Returns
sticker : instance<cls>
(tag)
has_tagReturns whether the sticker has the given tag.
Parameter | Type | Description |
---|---|---|
tag |
| The tag to check for. |
Returns
has_tag : bool
()
iter_tagsIterates over the tags of the sticker.
This method is an iterable generator.
Yields
tag : str
(sticker_id, ...)
precreatePrecreates 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.
Parameter | Type | Optional | Keyword only | Description |
---|---|---|---|---|
sticker_id |
| The sticker's identifier. | ||
**keyword_parameters | keyword parameters | Additional predefined attributes for the sticker. | ||
available |
| Whether the sticker is available. | ||
description |
| The sticker's description. | ||
guild |
| Alternative for | ||
guild_id |
| The sticker's guild's identifier. | ||
name |
| The sticker's name. | ||
pack |
| Alternative for | ||
pack_id |
| The unique identifier number of the pack from the sticker is. | ||
sort_value |
| Value used to sort the stickers. | ||
sticker_format |
| The sticker's format. | ||
sticker_type |
| The sticker's type. | ||
tags | None | Tags of the sticker if applicable. | ||
user | 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_dataConverts the sticker to a json serializable object.
Parameter | Type | Optional | Keyword only | Default | Description |
---|---|---|---|---|---|
defaults |
|
| Whether default values should be included as well. | ||
include_internals |
|
| Whether internal fields should be included as well. |
Returns
data : dict
of (str
, object
) items
()
to_partial_dataTries to convert the sticker to a json serializable dictionary representing a partial sticker.
Returns
data : dict
of (str
, object
)
(...)
url_asReturns the sticker's url.
This function is a shared method of Sticker
-s.
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
size |
|
| The preferred minimal size of the icon's url. | |
preview |
|
| Whether preview url should be generated. |
Returns
url : None
, str
Raises
ValueError
If size
was not passed as any of the expected values.
(sticker_id)
_create_emptyCreates an empty sticker with the given identifier.
Parameter | Type | Description |
---|---|---|
sticker_id |
| The sticker's identifier. |
Returns
self : instance<cls>
The created sticker.
(data)
_difference_update_attributesUpdates the sticker with the given data and returns the changed attributes in attribute-name
- old-value
relation.
Parameter | Type | Description |
---|---|---|
data |
| Sticker data. |
Returns
old_attributes : dict
of (str
, object
) items
All item in the returned dictionary is optional.
Keys | Values |
---|---|
available | bool |
description | None , str |
name | str |
sort_value | int |
tags | None or frozenset of str |
()
_get_hash_partialReturns a partial sticker's hash value.
Returns
hash_value : int
(other)
_is_equal_same_typeReturns whether the two stickers are equal. self
and other
must be the same type.
Parameter | Type | Description |
---|---|---|
other |
| The other sticker. |
Returns
is_equal : bool
(data)
_set_attributesSets the attributes of the sticker from the given data.
Parameter | Type | Description |
---|---|---|
data |
| Sticker data. |
(data)
_update_attributesUpdates the stickers with the given data.
Parameter | Type | Description |
---|---|---|
data |
| Sticker data. |
()
__eq__Returns whether the two stickers are equal.
(code)
__format__Formats the sticker in a format string.
Parameter | Type | Description |
---|---|---|
code |
| 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.