【发布时间】:2018-11-28 12:31:20
【问题描述】:
我对使用节点 js 的 slack api 集成非常陌生。我正在尝试获取频道历史记录。即使我尝试使用 chat.postMessage。但它每次都给我抛出以下错误:
{ Error: An API error occurred: channel_not_found
at platformErrorFromResult (..\node_modules\@slack\client\dist\WebClient.js:747:42)
at __await.makeRequest.then (..\node_modules\@slack\client\dist\WebClient.js:464:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
code: 'slackclient_platform_error',
data:
{ ok: false,
error: 'channel_not_found',
scopes:
[ 'identify',
'bot',
'commands',
'channels:history',
'chat:write:user',
'chat:write:bot' ],
acceptedScopes: [ 'channels:history' ]*** } }
这是我的代码sn-p,
const { WebClient } = require('@slack/client');
const token = "OAuth Access Token"; // passing OAuth Access Token
const web = new WebClient(token);
web.channels.history({ channel: appID})
.then((res) => {
console.log('Message sent: ', res.ts);
})
.catch(console.error);
有人可以帮我这里缺少什么吗?
- 什么时候应该使用“Bot User OAuth Access Token”和“OAuth Access Token”?
- 什么是频道 ID?
- APP ID 是否称为频道 ID?
提前致谢
【问题讨论】:
-
你不应该设置
token之前在const web = new WebClient(token);中使用它 -
@Dragonthoughts,谢谢,虽然添加错误。我已正确编辑问题
标签: node.js slack slack-api slack-commands