slack-go / slack

Slack API in Go, originally by @nlopes; Maintainers needed, contact @parsley42
https://pkg.go.dev/github.com/slack-go/slack
BSD 2-Clause "Simplified" License
4.6k stars 1.11k forks source link

Not possible to set initial value of RichTextInputBlockElement due to wrong type #1276

Open matcornic opened 2 months ago

matcornic commented 2 months ago

Hello maintainers,

First, thanks a lot for this lib, it's very useful for us. I encountered a bug: I can't set an initial value for the RichTextInputBlockElement due the type being a string and not a Rich text object

What happened

I tried to use this code, which is compiling on :

    elem := slack.NewRichTextInputBlockElement(nil, "test")
    elem.InitialValue = "test"
    elemInput := slack.NewInputBlock("", slack.NewTextBlockObject("plain_text", "Test:", false, false), nil, elemInput)

But got an invalid_block error on Slack while checking the generated json on the Block kit builder

https://app.slack.com/block-kit-builder/T02F6HSJU2H#%7B%22blocks%22:%5B%7B%22type%22:%22header%22,%22text%22:%7B%22type%22:%22plain_text%22,%22text%22:%22Test%22%7D%7D,%7B%22type%22:%22input%22,%22label%22:%7B%22type%22:%22plain_text%22,%22text%22:%22RulTestes:%22%7D,%22element%22:%7B%22type%22:%22rich_text_input%22,%22action_id%22:%22test%22,%22initial_value%22:%22test%22%7D%7D%5D%7D

image

Seeing the documentation, it expects a Rich text object https://api.slack.com/reference/block-kit/block-elements#rich_text_input

Versions