首页 文章

Node-slack web api:chat.delete为所有 Channels 返回channel_not_found虽然channels.list返回所有 Channels

提问于
浏览
1

我一直在使用slack-node web api和botkit开发一个简单的聊天机器人,但是在使用chat.delete功能时遇到了一些麻烦 . 我可以正确列出我的所有 Channels ,查看他们的 Channels ID和名称,但是当我尝试使用chat.delete函数发送消息 Channels 时,它会返回“channel_not_found” .

我还尝试发送 Channels 名称,使用“常规”和我定位的实际 Channels 名称进行测试,两者都返回相同的错误 .

我的机器人正在使用管理员用户的令牌,这应该允许删除任何消息 . 我的机器人有聊天范围访问权限:写:机器人和聊天:写:用户也是 .

下面是我的代码片段 - 我也尝试过在其他地方删除直接从机器人发送的消息并得到相同的错误,所以我不相信它与权限有关 . 我已经查看了文档,并且对于我下面的内容似乎是正确的,但我可能会错过一篇文章 .

任何帮助表示赞赏!!

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) });
});

1 回答

相关问题