Node-slack web api:chat.delete returns channel_not_found 对于所有频道,尽管 channels.list returns 所有频道

Node-slack web api: chat.delete returns channel_not_found for all channels although channels.list returns all channels

我一直在使用 slack-node web api 和 botkit 开发一个简单的聊天机器人,但在使用 chat.delete 功能时遇到了一些问题。我能够正确列出我所有的频道,看到他们的频道 ID 和名称,但是当我尝试使用 chat.delete 功能沿着消息频道发送时,它 returns "channel_not_found" .

我也尝试发送频道名称,使用 "general" 和我定位的实际频道名称进行测试,这两个 return 同样的错误。

我的机器人正在使用管理员用户的令牌,它应该允许删除任何消息。我的机器人也可以访问 chat:write:bot 和 chat:write:user。

下面是我的代码片段 - 我也在其他地方尝试过删除直接从机器人发送的消息并得到同样的错误,所以我认为这与权限无关。我查看了文档,用法似乎对我下面的内容是正确的,但我可能遗漏了一部分。

controller.on('ambient', function(bot, message) {

      web.channels.list().then((res) => {
        console.log(res); // this prints out all of the channels
        // listed channels show a match for the channel ID given in message.channel
      });

      // this call returns an error "error: Response not OK:  channel_not_found"
      web.chat.delete(message.channel, message.ts).then((res) => {

         console.log(res + " was deleted bc it was not tagged");

      }).catch((err) => { console.log(err) });
});

文档对此有点混乱,但官方@slack/client库的chat.delete方法采用不同顺序的参数:

您需要将代码更改为:

web.chat.delete(message.ts, message.chanel).then(...)

看这里: https://slackapi.github.io/node-slack-sdk/reference/ChatFacet#ChatFacet+delete