Entitlement

Represent that a user or guild has access to a premium offer.

Attributes

application_id : int

The entitlement's owner application's identifier.

consumed : bool

Whether the entitlement is already consumed. Not applicable for subscriptions.

deleted : bool

Whether the entitlement is deleted.

ends_at : None | DateTime

When the entitlement ends.

guild_id : int

The guild's identifier that was granted access to the stock keeping unit.

id : int

The unique identifier number of the entitlement.

sku_id : int

The stock keeping unit's identifier the this entitlement grants access to.

starts_at : None | DateTime

When the entitlement starts.

subscription_id : int

The subscription's identifier the entitlement is part of.

The entitlement's type.

user_id : int

The user's identifier that was granted access to the stock keeping unit.

Notes

Entitlement instances are weakreferable.

Properties

created_at

When the entity was created.

Returns

created_at : datetime

owner_id

Returns the entitlement's owner's identifier. It is either its .guild_id or .user_id.

Returns

owner_id : int

owner_type

Returns the entitlement's owner type.

Returns

owner_type : EntitlementOwnerType

partial

Returns whether the entity is partial.

Returns

partial : bool

Methods

__new__(...)

Creates a new partial entitlement.

ParameterTypeOptionalKeyword onlyDescription
guild_id

int, Guild

The guild's identifier that was granted access to the stock keeping unit.

sku_id

int, SKU

The stock keeping unit's identifier the this entitlement grants access to.

user_id

int, ClientUserBase

The user's identifier that was granted access to the stock keeping unit.

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

copy()

Copies the entitlement.

Returns

new : instance<type<self>>

copy_with(...)

Copies the entitlement with the given fields.

ParameterTypeOptionalKeyword onlyDescription
guild_id

int, Guild

The guild's identifier that was granted access to the stock keeping unit.

sku_id

int, SKU

The stock keeping unit's identifier the this entitlement grants access to.

user_id

int, ClientUserBase

The user's identifier that was granted access to the stock keeping unit.

Returns

new : instance<type<self>>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

from_data(data)

Creates a new entitlement.

ParameterTypeDescription
data

dict<str, object>

Entitlement data.

Returns

new : instance<cls>

from_data_is_created(data)

Creates a new entitlement

ParameterTypeDescription
data

dict<str, object>

Entitlement data.

Returns

new : instance<cls> is_created : bool

precreate(entitlement_id, ...)

Creates an entitlement instance.

ParameterTypeOptionalKeyword onlyDescription
entitlement_id

int

The entitlement's identifier.

**keyword_parameters

Keyword parameters

Additional keyword parameters.

application

int, Application

Alternative for application_id.

application_id

int, Application

The entitlement's owner application's identifier.

consumed

bool

Whether the entitlement is already consumed.

deleted

bool

Whether the entitlement is deleted.

ends_at

None, DateTime

When the entitlement ends.

entitlement_type

EntitlementType, int

The entitlement's type.

guild

int, Guild

Alternative for guild_id.

guild_id

int, Guild

The guild's identifier that was granted access to the stock keeping unit.

sku

int, SKU

Alternative for sku_id.

sku_id

int, SKU

The stock keeping unit's identifier the this entitlement grants access to.

starts_at

None, DateTime

When the entitlement starts.

subscription

int

Alternative for subscription_id.

subscription_id

int

The subscription's identifier the entitlement is part of.

user

int, ClientUserBase

Alternative for user_id.

user_id

int, ClientUserBase

The user's identifier that was granted access to the stock keeping unit.

Returns

self : instance<cls>

Raises

TypeError

  • If a parameter's type is incorrect.

ValueError

  • If a parameter's value is incorrect.

to_data(...)

Converts the entitlement into a json serializable object.

ParameterTypeOptionalKeyword onlyDefaultDescription
defaults

bool

False

Whether default field values should be included.

include_internals

bool

False

Whether internal fields should be included.

Returns

data : dict of (str, object) items

_create_empty(entitlement_id)

Creates a new entitlement instance with it's attribute set to their default values.

ParameterTypeDescription
entitlement_id

int

The entitlement's identifier.

Returns

self : instance<cls>

_difference_update_attributes(data)

Updates the attributes of the entitlement and returns the changed ones within an attribute-name- old-value relation.

ParameterTypeDescription
data

dict<str, object>

Entitlement data.

Returns

old_attributes : dict of (str, object) items

The updated attributes.

The returned dictionary might contain the following items:

KeyValue
consumedbool
deletedbool
ends_atNone, DateTime
starts_atNone, DateTime

_get_hash_partial()

Calculates the entitlement's hash based on their fields.

This method is called by .__hash__ if the channel has no .id set.

Returns

hash_value : int

_is_equal_same_type(other)

Returns whether self is equal to other. Other must be same type as self.

ParameterTypeDescription
other

instance<type<self>>

The other instance.

Returns

is_equal : bool

_set_attributes(data)

Sets the entitlement's attributes from the given data. (Except .id.)

ParameterTypeDescription
data

dict<str, object>

Entitlement data.

_update_attributes(data)

Updates the entitlement by overwriting it's old attributes.

ParameterTypeDescription
data

dict<str, object>

Entitlement data.

__eq__()

Returns whether the two entitlements are equal.

__ge__()

Whether this entity's id is greater or equal than the other's.

__getattr__()

Drops a rich attribute error.

__gt__()

Whether this entity's id is greater than the other's.

__hash__()

Returns the hash value of the entitlement.

__le__()

Whether this entity's id is less or equal than the other's.

__lt__()

Whether this entity's id is less than the other's.

__ne__()

Returns whether the two entitlements are not equal.

__repr__()

Returns the entitlement's representation.