send_components

Let's you send a message with only components and add a handler(s) to the given in components


Example

local example_component = {{
    type = components["Action Row"],
    components = {{
        type = components["Button"],
        style = styles["Primary"],
        label = "Test",
        custom_id = "test_id"
    }}
}}

local example_handler = {
    -- test_id is the custom_id from the button
    ["test_id"] = function(info)
        local interaction_token = info.interaction_token
        local interaction_id = info.interaction_id
        
        update_message(interaction_token, interaction_id, {
            content = "I was pressed",
            components = {}, -- remove the components
        }
    end 
}

send_components(channel_id, example_component, example_handler)

Last updated