gpt4 book ai didi

javascript - Node-slack web api : chat. delete 返回所有 channel 的 channel_not_found 尽管 channels.list 返回所有 channel

转载 作者:行者123 更新时间:2023-11-30 14:50:53 31 4
gpt4 key购买 nike

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

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

我的机器人正在使用管理员用户的 token ,它应该允许删除任何消息。我的机器人也可以访问 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

关于javascript - Node-slack web api : chat. delete 返回所有 channel 的 channel_not_found 尽管 channels.list 返回所有 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48119223/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com