松弛的WebAPI对话.unarchive失败,not_in_channel

问题描述

我的Slack应用正在监听channel_archived事件,因此它可以检查是否已存档了一个非常重要的Slack频道:

app.event('channel_archive',async ({ event,context }) => {  
    if (event.channel === redacted) {
        fns.textOutput(event.user,"Hello <@"+event.user+"> I noticed you archived the redacted channel. This channel is used by thousands of redacted for slack training.\n"+
        "I have un-archived it so no need to worry,just please be more careful about what you are archiving")
        unArchiveChannel()
    } 
});

所有这些都有效,它调用了unArchiveChannel()函数,该函数可以在此处看到:

async function unArchiveChannel() {
    try {
        const result = await app.client.conversations.unarchive({
        // Bot token
        token: process.env.SLACK_BOT_TOKEN,// Channel to unarchive
        channel: redacted,})
        console.log(result)
    }
    catch (error) {
        console.log(error)
    }
}

我的机器人令牌具有所有合适的范围:channel:manage,groups:write,im:write和mpim:write。我使用/invite @(my bots username)邀请它加入频道。但是,当我实际归档有问题的通道时,调用了我的函数,但它给了我not_in_channel错误,并且无法取消归档通道。错误未列出in the documentation,所以我迷路了。

解决方法

我联系了Slack的帮助中心,他们给我发了电子邮件,告诉我他们的文档中有错误。您不能使用漫游器令牌来授权sessions.unarchive方法。

,

我联系了Slack,他们写信给我添加了用户令牌范围:channels:write 因此,在OAuth URL中添加:&user_scope=channels:write

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...