最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

为什么CLIENT

运维笔记admin7浏览0评论

为什么CLIENT

为什么CLIENT

我只是开始开发松弛服务,我刚刚创建的松弛机器人的连接,但我已经面临着一个问题,即

无法读取的未定义的属性“RTM”

这是我的代码

const { RTMClient, CLIENT_EVENTS, RTM_EVENTS, RTM_MESSAGE_SUBTYPES } = require('@slack/client');

function handleOnAuthenticated(rtmStartData) {
    console.log(`logged in as ${rtmStartData.self.name} of team ${rtmStartData.self.team.name} but not et connected to channel`);
}

function addAuthenticatedHandler(rtm, handler) {
    rtm.on(CLIENT_EVENTS.RTM.AUTHENTICATED, handler);
}

module.exports.init = function slackClient(bot_token, logLevel) {
    rtm = new RTMClient(bot_token);
    addAuthenticatedHandler(rtm, handleOnAuthenticated);
    return rtm;
}

module.exports.addAuthenticatedHandler = addAuthenticatedHandler;

我不知道什么是确切的问题是,谁能告诉我,为什么发生这种情况。

回答如下:

该RTM_EVENTS字典是没有必要的,你只需要直接订阅事件名称为字符串。

兑换:

function addAuthenticatedHandler(rtm, handler) {
rtm.on(CLIENT_EVENTS.RTM.AUTHENTICATED, handler);
}

作为常量是V3.x的,已经从V4.x中删除

至:

function addAuthenticatedHandler(rtm, handler) {
rtm.on('authenticated', handler);
}

使用简单的字符串事件名称是V4.x中

migration guide

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论