DiscordLua
discorddiscord
v1.2.9
Install

ComponentBuilder

Builder
On this page

ComponentBuilder is a fluent payload builder. Chain setters, then pass the builder to send, reply, or command registration.

builder Module 1.2.9 Source

Constructor

ComponentBuilder.new(data)

The class table is callable, so ComponentBuilder(data) is the same as .new.

NameTypeRequiredBehavior
data any required Passed through to the implementation as written.
lua
local discord = require("discord")
local object = discord.ComponentBuilder({})

Properties

ComponentBuilder.data

# readonly
Name
data
Type
any
Access
readonly
Description
Instance field ComponentBuilder.data. Read it after the object is constructed or wrapped from Gateway/REST data.
Availability
Populated from the Gateway/REST payload or constructor for this ComponentBuilder.

Methods

ComponentBuilder:clearId()

#

Performs clear id on this ComponentBuilder. Call it from bot code when you need that operation on the current object.

Signature

ComponentBuilder:clearId()

Parameters

No parameters.

Returns

ComponentBuilder — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ComponentBuilder
object:clearId()

ComponentBuilder:setId()

#

Set the Id field. Builders return this ComponentBuilder so setters can be chained.

Signature

ComponentBuilder:setId(id)

Parameters

NameTypeRequiredBehavior
id string required Snowflake id string.

Returns

ComponentBuilder — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ComponentBuilder
object:setId("123")

ComponentBuilder:toJSON()

#

Serialize this ComponentBuilder into a Lua table suitable for REST or debugging.

Signature

ComponentBuilder:toJSON()

Parameters

No parameters.

Returns

ComponentBuilder — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ComponentBuilder
object:toJSON()

Examples

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

ActionRowBuilder · AttachmentBuilder · BaseSelectMenuBuilder · ButtonBuilder · ChannelSelectMenuBuilder · CheckboxBuilder · ContainerBuilder · ContextMenuCommandBuilder

Version: discord 1.2.9 · runtime 1.0.0

Search Ctrl K Navigate Open Esc