IconType

Represents a Discord icon's type.

Attributes

details : IconDetailsBase

Additional details describing the icon type.

name : str

The name of the icon type.

value : int

The identifier value the icon type.

Class Attributes

DEFAULT_NAME : str = 'Undefined'

The default name of the icon types.

INSTANCES : dict of (int, IconType) items

Stores the predefined IconType-s. These can be accessed with their value as key.

VALUE_TYPE : type = int

The icon types' values' type.

Every predefined icon type can be accessed as class attribute as well:

Class attribute nameNameValuePrefixDefault postfixAllowed Postfixes
nonenone0''''None
staticstatic1'''png''jpg', 'jpeg', 'png', 'webp'
animatedanimated2'a_''gif''jpg', 'jpeg', 'png', 'webp', 'gif'
animated_apnganimated apng3'a_''png''png'

Properties

allowed_postfixes

base_64_data

Returns the icon's data in base 64 encoding.

Returns

data : None, str

data

default_postfix

media_type

prefix

Methods

__init__(value, name, prefix, default_postfix, allowed_postfixes)

Creates a new icon type with the given parameters and stores it at the type's .INSTANCES.

ParameterTypeDescription
value

str

The unique identifier of the icon type.

name

str

The icon type's name

prefix

str

Prefix used when building an url with the icon.

default_postfix

str

Default postfix used when building an url with the icon.

allowed_postfixes

None, frozenset of str

The allowed postfixes.

allows_postfix(postfix)

Returns whether the icon type allows the given postfix.

ParameterTypeDescription
postfix

str

The postfix to check.

Returns

allows_postfix : bool

can_create_url()

Returns whether it is possible to create url with the icon.

Returns

can_create_url : bool

from_data(data, ...)

Creates a custom icon type holding actual raw data.

ParameterTypeOptionalDefaultDescription
data

bytes-like

The icon's raw data.

name

str

icon

The icon's name.

Returns

self : instance<cls>

Raises

TypeError

  • If data is not bytes-like.

get(value)

Returns the value's representation. If the value is already preinstanced, returns that, else creates a new object.

ParameterTypeDescription
value

None, .VALUE_TYPE

The value to get it's representation.

Returns

obj_ : PreinstancedBase

get_alternative_icon_type_for(prefix)

Tries to get the alternative icon type for the given prefix. If fails returns None.

ParameterTypeDescription
prefix

str

Icon prefix.

Returns

alternative_icon_type : None, IconType

register_alternative_icon_type(alternative_icon_type)

Registers an alternative icon type under this one.

ParameterTypeDescription
alternative_icon_type

IconType

The icon type to register.

_from_value(value)

Creates a new preinstanced object from the given value.

ParameterTypeDescription
value

.VALUE_TYPE

The value what has no representation yet.

Returns

self : PreinstancedBase

The created object.

__bool__()

Returns whether the icon's type is set.

__eq__()

Returns whether self's value equals to the other object's.

__ge__()

Returns whether self's value is greater or equal to the other object's.

__getattr__()

Drops a rich attribute error.

__gt__()

Returns whether self's value is greater than the other object's.

__hash__()

Returns the hash of the preinstanced object.

__le__()

Returns whether self's value is less or equal to the other object's.

__lt__()

Returns whether self's value is less than the other object's.

__ne__()

Returns whether self's not equals to the other object's.

__repr__()

Returns the icon detail's representation.