Entitlements¶
This section documents everything related to entitlements, which represent access to SKUs.
Discord Models¶
Entitlement¶
- class disnake.Entitlement[source]¶
Represents an entitlement.
This is usually retrieved using
Client.entitlements()
, fromInteraction.entitlements
when using interactions, or provided by events (e.g.on_entitlement_create()
).Note that some entitlements may have ended already; consider using
is_active()
to check whether a given entitlement is considered active at the current time, or useexclude_ended=True
when fetching entitlements usingClient.entitlements()
.You may create new entitlements for testing purposes using
Client.create_entitlement()
.- x == y
Checks if two
Entitlement
s are equal.
- x != y
Checks if two
Entitlement
s are not equal.
- hash(x)
Returns the entitlement’s hash.
New in version 2.10.
- type¶
The entitlement’s type.
- Type:
- user_id¶
The ID of the user that is granted access to the entitlement’s SKU.
See also
user
.- Type:
Optional[
int
]
- guild_id¶
The ID of the guild that is granted access to the entitlement’s SKU.
See also
guild
.- Type:
Optional[
int
]
- consumed¶
Whether the entitlement has been consumed. Only applies to consumable items, i.e. those associated with a
consumable
SKU.- Type:
- starts_at¶
The time at which the entitlement starts being active. Set to
None
when this is a test entitlement.- Type:
Optional[
datetime.datetime
]
- ends_at¶
The time at which the entitlement stops being active.
You can use
is_active()
to check whether this entitlement is still active.- Type:
Optional[
datetime.datetime
]
- property guild[source]¶
The guild that is granted access to this entitlement’s SKU, if applicable.
- Type:
Optional[
Guild
]
- property user[source]¶
The user that is granted access to this entitlement’s SKU, if applicable.
Requires the user to be cached. See also
user_id
.- Type:
Optional[
User
]
- is_active()[source]¶
Whether the entitlement is currently active, based on
starts_at
andends_at
.Always returns
True
for test entitlements.- Return type:
- await consume()[source]¶
This function is a coroutine.
Marks the entitlement as consumed.
This is only valid for consumable one-time entitlements; see
consumed
.- Raises:
NotFound – The entitlement does not exist.
HTTPException – Consuming the entitlement failed.
- await delete()[source]¶
This function is a coroutine.
Deletes the entitlement.
This is only valid for test entitlements; you cannot use this to delete entitlements that users purchased.
- Raises:
NotFound – The entitlement does not exist.
HTTPException – Deleting the entitlement failed.
Enumerations¶
EntitlementType¶
- class disnake.EntitlementType[source]¶
Represents the type of an entitlement.
New in version 2.10.
- purchase¶
Represents an entitlement purchased by a user.
Represents an entitlement for a Discord Nitro subscription.
- developer_gift¶
Represents an entitlement gifted by the application developer.
- test_mode_purchase¶
Represents an entitlement purchased by a developer in application test mode.
- free_purchase¶
Represents an entitlement granted when the SKU was free.
- user_gift¶
Represents an entitlement gifted by another user.
Represents an entitlement claimed by a user for free as a Discord Nitro subscriber.
- application_subscription¶
Represents an entitlement for an application subscription.