diff --git a/package.json b/package.json index a91bd16..f651c6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rec0-bot", - "version": "2.3.1", + "version": "2.4.1", "description": "A bot for revolution of comm :)", "main": "index.js", "scripts": { diff --git a/src/environment/environment.dev.ts b/src/environment/environment.dev.ts index f04427d..a774602 100644 --- a/src/environment/environment.dev.ts +++ b/src/environment/environment.dev.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import { Environment } from '../interface/environment.interface'; export const environmentDev: Environment = { - version: '2.3.1', + version: '2.4.1', isProduction: false, slack: { token: { diff --git a/src/environment/environment.prod.ts b/src/environment/environment.prod.ts index 7601a1c..bf12e94 100644 --- a/src/environment/environment.prod.ts +++ b/src/environment/environment.prod.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import { Environment } from '../interface/environment.interface'; export const environmentProd: Environment = { - version: '2.3.1', + version: '2.4.1', isProduction: true, slack: { token: { diff --git a/src/service/connector/slack-connector.service.ts b/src/service/connector/slack-connector.service.ts index 7d5ab12..214aaf0 100644 --- a/src/service/connector/slack-connector.service.ts +++ b/src/service/connector/slack-connector.service.ts @@ -6,7 +6,7 @@ import { Connector } from '../../interface/connector.interface'; export class SlackConnectorService extends EventEmitter implements Connector { private sockClient: SocketModeClient; private webClient: WebClient; - private _ready: Promise | undefined; + private _ready: Promise | undefined; private botUserId = ''; @@ -24,13 +24,13 @@ export class SlackConnectorService extends EventEmitter implements Connector { async init() { this._ready = new Promise(async (resolve, reject) => { - const result = await this.sockClient.start(); - if (result.ok) { + try { + await this.sockClient.start(); this.subscribeEvents(); this.botUserId = await this.getBotUserId(false); - resolve(result); - } else { - reject(result); + resolve(); + } catch (e) { + reject(e); } }); await this._ready; @@ -116,7 +116,12 @@ export class SlackConnectorService extends EventEmitter implements Connector { private subscribeEvents() { this.SUBSCRIBE_EVENTS.forEach((ev) => this.sockClient.on(ev, async ({event, body, ack}) => { - await ack(); + if (ack) { + await ack(); + } + if (!event) { + return; + } const value = event; if (ev === 'message') { // Add some properties