node.js - 如何使用 slack API 为 slack 上的按钮设置颜色

标签 node.js slack-api

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

- primary (green)
- danger (red)
- default (grey)

我想为按钮设置其他颜色,例如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",
                    }
                }
            ]
        }
    ]
}

这是此代码结果的屏幕截图。 ![Sample Screenshot of Styled Buttons

最佳答案

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

参见 here有关此主题的官方文档。

关于node.js - 如何使用 slack API 为 slack 上的按钮设置颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55417667/

相关文章:

node.js - 使用 Axios Node.js 请求 oAuth2 token - 使用 'request' 但不适用于 Axios

javascript - 在新的 Promise() 构造函数中使用 async/await 是一种反模式吗?

perl - 从 SVN 集成自定义 Slack 中显示的消息

python - 如何在 slack.client 中提及用户

php - 尝试使用 Laravel 5.8 向我的 slack 发送通知时出错

php - 消息格式化,使用 PHP 通过 Slack API 发送按钮

node.js - npm 启动后有没有办法在终端中获取用户输入?

node.js - Google Cloud 上的 GCS 功能比本地主机慢

python - 创建一个 SimpleHTTPServer 以使用 python 代码作为 API

python - 无法在Python中获取 'channel_list'