DiscordLua
discorddiscord
v1.2.4
Install

MessagePayload

Class
On 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.

class Module 1.2.4 Source

Constructor

MessagePayload.new(target, options)

The class table is callable, so MessagePayload(target, options) is the same as .new.

NameTypeRequiredBehavior
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.
lua
local discord = require("discord")
local object = discord.MessagePayload({}, {})

Properties

MessagePayload.body

# readonly
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.

MessagePayload.files

# readonly
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.

MessagePayload.options

# readonly
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.

MessagePayload.target

# readonly
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

MessagePayload.create()

# static

Create a new resource through REST and cache the result.

Signature

MessagePayload.create(target, options)

Parameters

NameTypeRequiredBehavior
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

lua
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

lua
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

lua
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

lua
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

lua
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

lua
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

lua
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

lua
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

NameTypeRequiredBehavior
file any required Passed through to the implementation as written.

Returns

MessagePayload — the same instance, for chaining.

Example

lua
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

lua
local discord = require("discord")
-- object is a MessagePayload
object:resolveFiles()

Examples

lua
local discord = require("discord")
local object = discord.MessagePayload({})

ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc