如何使用 slack API 设置 slack 上按钮的颜色

Nje*_*igi 4 node.js slack-api

除了默认的 3 之外,我正在尝试为松弛按钮设置其他样式:

- primary (green)
- danger (red)
- default (grey)
Run Code Online (Sandbox Code Playgroud)

例如,我想为按钮设置其他颜色orange

我知道可以通过指定十六进制代码来设置附件的自定义颜色。

有没有办法为松弛按钮指定自定义颜色?

这是我尝试过的:

{
    "text": "Please rate this trip.",
    "attachments": [
        {
            "callback_id": "rate_trip",
            "color": "#3AA3E3",
            "attachment_type": "default",
            "actions": [
                {
                    "name": "yes",
                    "text": "yes :thumbsup:",
                    "type": "button",
                    "value": "yes",
                    "style": "primary"
                },
                {
                    "name": "no",
                    "text": "no :thumbsdown:",
                    "type": "button",
                    "value": "no",
                    "style": "danger"
                },
   // I'd like to make the style for this to be orange but it defaults to grey.
                {
                    "name": "maybe",
                    "text": "maybe :neutral_face:",
                    "type": "button",
                    "value": "maybe",
                    "style": "#FFA500",
                    }
                }
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是此代码结果的屏幕截图。 ![样式按钮的示例屏幕截图

Eri*_*ken 5

不可以。Slack 不允许您对按钮使用自定义颜色。正如您所提到的,您只能使用“样式”(在style字段中)为按钮着色,并且仅限于default,primarydanger

请参阅此处以获取有关该主题的官方文档。