component
To create a new component builder do (this is a chained builder)
local component = component_builder.new()
All component builder methods
method
type
description
CustomId
string
Title
string
Only used for modals
AddComponent
table
Type
string | number
Lets you set the type
Style
string | number
Lets you set the style
Label
string
Required
boolean
MinValue
number
Only used for select menus
MaxValue
number
Only used for select menus
Placeholder
string
only used for modals
Build
none
Builds the component
Options
table
For select menus only
Url
string
This only used for the "Link" type in a button. Aswell a button with the type "Link" cannot have a custom_id.
Examples
Modal
local modal = component_builder.new()
:CustomId("modal_id")
:Title("Enter Info")
:AddComponent(
component_builder.new()
:Type("Action Row")
:AddComponent(
component_builder.new()
:Type("Text Input")
:CustomId("example_input")
:Style(modal_types.SHORT)
:Label("Password")
:Required(true)
)
)
:Build();
send_modal(interaction_id, interaction_token, modal, function(info)
end)
Button
local button = component_builder.new()
:Type("Action Row")
:AddComponent(
component_builder.new()
:Type("Button")
:Style("Primary")
:Label("Test")
:CustomId("test_id")
)
:Build();
send_raw(channel_id, { components = {button} })
Select menu
local select_menu = component_builder.new()
:Type("Action Row")
:AddComponent(
component_builder.new()
:Type("Select Menu")
:MinValue(1)
:MaxValue(1)
:CustomId("test_id")
:Placeholder("Test")
:Options({
option_builder.new()
:Label("Hi")
:Value("two")
:Description("test description")
:Build()
})
)
:Build();
send_raw(channel_id, { components = {select_menu} })
Last updated