A user's or a guild's access to one of the app's SKUs — what a premium app checks before granting a perk.
Arrives with the ENTITLEMENT_CREATE, _UPDATE and _DELETE events and from
EDA.API.Entitlement. Discord's own advice is to grant perks on entitlements, not on
subscription status: see active?/1.
An entitlement is not deleted when it expires; ends_at passes instead. Deletion happens
on a refund, or when Discord or the app removes it.
Summary
Functions
Whether the entitlement grants access right now: not deleted, already started, not yet ended. A missing start or end date is no bound.
Converts a raw entitlement object into this struct.
Types
@type t() :: %EDA.Entitlement{ application_id: String.t() | nil, consumed: boolean() | nil, deleted: boolean(), ends_at: DateTime.t() | nil, guild_id: String.t() | nil, id: String.t() | nil, sku_id: String.t() | nil, starts_at: DateTime.t() | nil, type: type() | integer() | nil, user_id: String.t() | nil }
@type type() ::
:purchase
| :premium_subscription
| :developer_gift
| :test_mode_purchase
| :free_purchase
| :user_gift
| :premium_purchase
| :application_subscription
Functions
@spec active?(t(), DateTime.t()) :: boolean()
Whether the entitlement grants access right now: not deleted, already started, not yet ended. A missing start or end date is no bound.
iex> EDA.Entitlement.active?(%EDA.Entitlement{deleted: false})
true
iex> EDA.Entitlement.active?(%EDA.Entitlement{ends_at: ~U[2020-01-01 00:00:00Z]})
false
Converts a raw entitlement object into this struct.