refactor: Adjust send a message to channel to use slack client

This commit is contained in:
Faruk AYDIN
2022-09-01 23:19:53 +03:00
parent 26eee1bb63
commit e0f055a375
5 changed files with 52 additions and 20 deletions

View File

@@ -1,21 +1,18 @@
import { WebClient } from '@slack/web-api';
import { IJSONObject } from '@automatisch/types';
import SlackClient from '../client';
export default class SendMessageToChannel {
client: WebClient;
parameters: IJSONObject;
client: SlackClient;
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
this.client = new WebClient(connectionData.accessToken as string);
this.parameters = parameters;
constructor(client: SlackClient) {
this.client = client;
}
async run() {
const result = await this.client.chat.postMessage({
channel: this.parameters.channel as string,
text: this.parameters.message as string,
});
const channelId = this.client.step.parameters.channel as string;
const text = this.client.step.parameters.message as string;
return result;
const message = await this.client.postMessageToChannel.run(channelId, text);
return message;
}
}