MessagePayload
ClassOn this page
MessagePayload is a DiscordLua class representing a Discord resource. Obtain it from a manager, an event payload, or the constructor when one is documented below.
Constructor
MessagePayload.new(target, options) The class table is callable, so MessagePayload(target, options) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
target |
any |
required | Passed through to the implementation as written. |
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
local discord = require("discord")
local object = discord.MessagePayload({}, {})Properties
- Name
body- Type
any- Access
- readonly
- Description
- Instance field
MessagePayload.body. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this MessagePayload.
- Name
files- Type
any- Access
- readonly
- Description
- Instance field
MessagePayload.files. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this MessagePayload.
- Name
options- Type
any- Access
- readonly
- Description
- Instance field
MessagePayload.options. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this MessagePayload.
- Name
target- Type
any- Access
- readonly
- Description
- Instance field
MessagePayload.target. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this MessagePayload.
Methods
Create a new resource through REST and cache the result.
Signature
MessagePayload.create(target, options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
target |
any |
required | Passed through to the implementation as written. |
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
MessagePayload.create(target, {})MessagePayload:isInteraction()
#Predicate that returns whether this MessagePayload matches isInteraction. Use it to branch before calling type-specific methods.
Signature
MessagePayload:isInteraction() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:isInteraction()MessagePayload:isMessage()
#Predicate that returns whether this MessagePayload matches isMessage. Use it to branch before calling type-specific methods.
Signature
MessagePayload:isMessage() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:isMessage()MessagePayload:isMessageManager()
#Predicate that returns whether this MessagePayload matches isMessageManager. Use it to branch before calling type-specific methods.
Signature
MessagePayload:isMessageManager() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:isMessageManager()MessagePayload:isUser()
#Predicate that returns whether this MessagePayload matches isUser. Use it to branch before calling type-specific methods.
Signature
MessagePayload:isUser() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:isUser()MessagePayload:isWebhook()
#Predicate that returns whether this MessagePayload matches isWebhook. Use it to branch before calling type-specific methods.
Signature
MessagePayload:isWebhook() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:isWebhook()MessagePayload:makeContent()
#Performs make content on this MessagePayload. Call it from bot code when you need that operation on the current object.
Signature
MessagePayload:makeContent() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:makeContent()MessagePayload:resolveBody()
#Performs resolve body on this MessagePayload. Call it from bot code when you need that operation on the current object.
Signature
MessagePayload:resolveBody() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:resolveBody()MessagePayload:resolveFile()
#Performs resolve file on this MessagePayload. Call it from bot code when you need that operation on the current object.
Signature
MessagePayload:resolveFile(file) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
file |
any |
required | Passed through to the implementation as written. |
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:resolveFile(file)MessagePayload:resolveFiles()
#Performs resolve files on this MessagePayload. Call it from bot code when you need that operation on the current object.
Signature
MessagePayload:resolveFiles() Parameters
No parameters.
Returns
MessagePayload — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a MessagePayload
object:resolveFiles()Examples
local discord = require("discord")
local object = discord.MessagePayload({})Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment
Version: discord 1.2.4 · runtime 1.0.0