ComponentBuilder
BuilderOn this page
ComponentBuilder is a fluent payload builder. Chain setters, then pass the builder to send, reply, or command registration.
Constructor
ComponentBuilder.new(data) The class table is callable, so ComponentBuilder(data) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
data |
any |
required | Passed through to the implementation as written. |
local discord = require("discord")
local object = discord.ComponentBuilder({})Properties
- 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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
Returns
ComponentBuilder — the same instance, for chaining.
Example
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
local discord = require("discord")
-- object is a ComponentBuilder
object:toJSON()Examples
local discord = require("discord")
local object = discord.ComponentBuilder({})Related APIs
ActionRowBuilder · AttachmentBuilder · BaseSelectMenuBuilder · ButtonBuilder · ChannelSelectMenuBuilder · CheckboxBuilder · ContainerBuilder · ContextMenuCommandBuilder
Version: discord 1.2.9 · runtime 1.0.0