Entitlement
ClassOn this page
Entitlement is a DiscordLua class representing a Discord resource. Obtain it from a manager, an event payload, or the constructor when one is documented below.
Properties
- Name
applicationId- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.applicationId. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
client- Type
any- Access
- readonly
- Description
- Owning Client instance used for REST, cache, and event dispatch.
- Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
consumed- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.consumed. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
deleted- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.deleted. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
endsAt- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.endsAt. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
endsTimestamp- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.endsTimestamp. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
guildId- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.guildId. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
id- Type
any- Access
- readonly
- Description
- Snowflake id of this Entitlement.
- Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
raw- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.raw. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
skuId- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.skuId. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
startsAt- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.startsAt. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
startsTimestamp- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.startsTimestamp. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
type- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.type. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
- Name
userId- Type
any- Access
- readonly
- Description
- Instance field
Entitlement.userId. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Entitlement.
Methods
Entitlement:consume()
#Performs consume on this Entitlement. Call it from bot code when you need that operation on the current object.
Signature
Entitlement:consume(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:consume(function(err, result)
if err then error(err) end
end)Entitlement:fetch()
#Request a fresh copy of this resource from REST and update the cache.
Signature
Entitlement:fetch(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:fetch(function(err, result)
if err then error(err) end
end)Entitlement:fetchUser()
#Fetch User from REST and update the local cache when the request succeeds.
Signature
Entitlement:fetchUser(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:fetchUser(function(err, result)
if err then error(err) end
end)Entitlement:guild()
#Performs guild on this Entitlement. Call it from bot code when you need that operation on the current object.
Signature
Entitlement:guild() Parameters
No parameters.
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:guild()Entitlement:isActive()
#Predicate that returns whether this Entitlement matches isActive. Use it to branch before calling type-specific methods.
Signature
Entitlement:isActive() Parameters
No parameters.
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:isActive()Entitlement:isGuildSubscription()
#Predicate that returns whether this Entitlement matches isGuildSubscription. Use it to branch before calling type-specific methods.
Signature
Entitlement:isGuildSubscription() Parameters
No parameters.
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:isGuildSubscription()Entitlement:isTest()
#Predicate that returns whether this Entitlement matches isTest. Use it to branch before calling type-specific methods.
Signature
Entitlement:isTest() Parameters
No parameters.
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:isTest()Entitlement:isUserPurchase()
#Predicate that returns whether this Entitlement matches isUserPurchase. Use it to branch before calling type-specific methods.
Signature
Entitlement:isUserPurchase() Parameters
No parameters.
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:isUserPurchase()Entitlement:isUserSubscription()
#Predicate that returns whether this Entitlement matches isUserSubscription. Use it to branch before calling type-specific methods.
Signature
Entitlement:isUserSubscription() Parameters
No parameters.
Returns
Entitlement — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Entitlement
object:isUserSubscription()Entitlement:toJSON()
#Serialize this Entitlement into a Lua table suitable for REST or debugging.
Signature
Entitlement:toJSON() Parameters
No parameters.
Returns
any.
Example
local discord = require("discord")
-- object is a Entitlement
object:toJSON()Examples
Obtain this object from a manager, wrap helper, or event payload — it is not constructed directly in typical bot code.
Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment
Version: discord 1.2.4 · runtime 1.0.0