@hardlydifficult/chat 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -45
- package/dist/Channel.d.ts +24 -13
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +99 -46
- package/dist/Channel.js.map +1 -1
- package/dist/ChatClient.d.ts +2 -2
- package/dist/ChatClient.d.ts.map +1 -1
- package/dist/ChatClient.js +5 -1
- package/dist/ChatClient.js.map +1 -1
- package/dist/Message.d.ts +91 -6
- package/dist/Message.d.ts.map +1 -1
- package/dist/Message.js +138 -9
- package/dist/Message.js.map +1 -1
- package/dist/discord/DiscordChatClient.d.ts +19 -3
- package/dist/discord/DiscordChatClient.d.ts.map +1 -1
- package/dist/discord/DiscordChatClient.js +79 -15
- package/dist/discord/DiscordChatClient.js.map +1 -1
- package/dist/discord/index.d.ts +1 -1
- package/dist/discord/index.d.ts.map +1 -1
- package/dist/discord/index.js +5 -1
- package/dist/discord/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/dist/outputters/discord.d.ts +19 -0
- package/dist/outputters/discord.d.ts.map +1 -0
- package/dist/outputters/discord.js +64 -0
- package/dist/outputters/discord.js.map +1 -0
- package/dist/outputters/index.d.ts +4 -0
- package/dist/outputters/index.d.ts.map +1 -0
- package/dist/outputters/index.js +8 -0
- package/dist/outputters/index.js.map +1 -0
- package/dist/outputters/slack.d.ts +24 -0
- package/dist/outputters/slack.d.ts.map +1 -0
- package/dist/outputters/slack.js +149 -0
- package/dist/outputters/slack.js.map +1 -0
- package/dist/slack/SlackChatClient.d.ts +12 -2
- package/dist/slack/SlackChatClient.d.ts.map +1 -1
- package/dist/slack/SlackChatClient.js +54 -8
- package/dist/slack/SlackChatClient.js.map +1 -1
- package/dist/slack/index.d.ts +1 -1
- package/dist/slack/index.d.ts.map +1 -1
- package/dist/slack/index.js +5 -1
- package/dist/slack/index.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -0
- package/package.json +5 -2
package/dist/Message.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import type { MessageData, Platform } from './types
|
|
1
|
+
import type { MessageData, MessageContent, Platform, ReactionCallback } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Interface for the platform-specific reaction adder
|
|
4
4
|
*/
|
|
5
5
|
export interface ReactionAdder {
|
|
6
6
|
addReaction(messageId: string, channelId: string, emoji: string): Promise<void>;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Interface for message operations (reactions, updates, deletes, replies)
|
|
10
|
+
*/
|
|
11
|
+
export interface MessageOperations extends ReactionAdder {
|
|
12
|
+
updateMessage(messageId: string, channelId: string, content: MessageContent): Promise<void>;
|
|
13
|
+
deleteMessage(messageId: string, channelId: string): Promise<void>;
|
|
14
|
+
postReply(channelId: string, threadTs: string, content: MessageContent): Promise<MessageData>;
|
|
15
|
+
subscribeToReactions(messageId: string, callback: ReactionCallback): () => void;
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* Represents a posted message with chainable reaction methods
|
|
10
19
|
*/
|
|
@@ -12,9 +21,10 @@ export declare class Message {
|
|
|
12
21
|
readonly id: string;
|
|
13
22
|
readonly channelId: string;
|
|
14
23
|
readonly platform: Platform;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
protected pendingReactions: Promise<void>;
|
|
25
|
+
protected operations: MessageOperations;
|
|
26
|
+
protected reactionUnsubscribers: (() => void)[];
|
|
27
|
+
constructor(data: MessageData, operations: MessageOperations);
|
|
18
28
|
/**
|
|
19
29
|
* Add multiple emoji reactions to this message
|
|
20
30
|
* @param emojis - Array of emojis to add
|
|
@@ -22,8 +32,83 @@ export declare class Message {
|
|
|
22
32
|
*/
|
|
23
33
|
addReactions(emojis: string[]): this;
|
|
24
34
|
/**
|
|
25
|
-
*
|
|
35
|
+
* Listen for reactions on this message
|
|
36
|
+
* @param callback - Function called when users add reactions to this message
|
|
37
|
+
* @returns this for chaining
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* await channel
|
|
42
|
+
* .postMessage("Vote: (1) Pizza, (2) Burgers, (3) Salad")
|
|
43
|
+
* .addReactions(["1️⃣", "2️⃣", "3️⃣"])
|
|
44
|
+
* .onReaction((event) => {
|
|
45
|
+
* console.log(`${event.user.username} voted ${event.emoji}`);
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
onReaction(callback: ReactionCallback): this;
|
|
50
|
+
/**
|
|
51
|
+
* Stop listening for reactions on this message
|
|
52
|
+
*/
|
|
53
|
+
offReaction(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Post a reply in this message's thread
|
|
56
|
+
* @param content - Reply content (string or Document)
|
|
57
|
+
* @returns ReplyMessage that can be awaited to handle success/failure
|
|
58
|
+
*/
|
|
59
|
+
postReply(content: MessageContent): ReplyMessage;
|
|
60
|
+
/**
|
|
61
|
+
* Update this message's content
|
|
62
|
+
* @param content - New content (string or Document)
|
|
63
|
+
*/
|
|
64
|
+
update(content: MessageContent): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Delete this message
|
|
67
|
+
*/
|
|
68
|
+
delete(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Wait for all pending reactions to complete.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const msg = await channel.postMessage('Vote!');
|
|
75
|
+
* msg.addReactions(['👍', '👎']);
|
|
76
|
+
* await msg.waitForReactions();
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
waitForReactions(): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A reply message that is still being posted.
|
|
83
|
+
* Use `.wait()` to await completion and handle errors.
|
|
84
|
+
*/
|
|
85
|
+
export declare class ReplyMessage extends Message {
|
|
86
|
+
private replyPromise;
|
|
87
|
+
private deferredReactionCallbacks;
|
|
88
|
+
constructor(replyPromise: Promise<MessageData>, operations: MessageOperations, platform: Platform);
|
|
89
|
+
/**
|
|
90
|
+
* Override addReactions to wait for reply to complete first
|
|
91
|
+
*/
|
|
92
|
+
addReactions(emojis: string[]): this;
|
|
93
|
+
/**
|
|
94
|
+
* Override onReaction to defer subscription until reply completes
|
|
95
|
+
*/
|
|
96
|
+
onReaction(callback: ReactionCallback): this;
|
|
97
|
+
/**
|
|
98
|
+
* Wait for reply to complete.
|
|
99
|
+
* Throws if the reply fails - allows callers to handle errors.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const reply = msg.postReply('text');
|
|
104
|
+
* await reply.wait(); // throws if reply fails
|
|
105
|
+
* console.log(reply.id); // now available
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
wait(): Promise<this>;
|
|
109
|
+
/**
|
|
110
|
+
* Wait for reply and all pending reactions to complete.
|
|
26
111
|
*/
|
|
27
|
-
|
|
112
|
+
waitForReactions(): Promise<void>;
|
|
28
113
|
}
|
|
29
114
|
//# sourceMappingURL=Message.d.ts.map
|
package/dist/Message.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAA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WAAW,IAAI,IAAI;IAOnB;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY;IAKhD;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B;;;;;;;;;OASG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,yBAAyB,CAA0B;gBAGzD,YAAY,EAAE,OAAO,CAAC,WAAW,CAAC,EAClC,UAAU,EAAE,iBAAiB,EAC7B,QAAQ,EAAE,QAAQ;IAwBpB;;OAEG;IACM,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAY7C;;OAEG;IACM,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAKrD;;;;;;;;;;OAUG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B;;OAEG;IACY,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAIjD"}
|
package/dist/Message.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplyMessage = exports.Message = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Represents a posted message with chainable reaction methods
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
class Message {
|
|
5
8
|
id;
|
|
6
9
|
channelId;
|
|
7
10
|
platform;
|
|
8
11
|
pendingReactions = Promise.resolve();
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
operations;
|
|
13
|
+
reactionUnsubscribers = [];
|
|
14
|
+
constructor(data, operations) {
|
|
11
15
|
this.id = data.id;
|
|
12
16
|
this.channelId = data.channelId;
|
|
13
17
|
this.platform = data.platform;
|
|
14
|
-
this.
|
|
18
|
+
this.operations = operations;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* Add multiple emoji reactions to this message
|
|
@@ -20,19 +24,144 @@ export class Message {
|
|
|
20
24
|
*/
|
|
21
25
|
addReactions(emojis) {
|
|
22
26
|
for (const emoji of emojis) {
|
|
23
|
-
this.pendingReactions = this.pendingReactions.then(() => this.
|
|
27
|
+
this.pendingReactions = this.pendingReactions.then(() => this.operations.addReaction(this.id, this.channelId, emoji));
|
|
24
28
|
}
|
|
25
29
|
return this;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
|
-
*
|
|
32
|
+
* Listen for reactions on this message
|
|
33
|
+
* @param callback - Function called when users add reactions to this message
|
|
34
|
+
* @returns this for chaining
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* await channel
|
|
39
|
+
* .postMessage("Vote: (1) Pizza, (2) Burgers, (3) Salad")
|
|
40
|
+
* .addReactions(["1️⃣", "2️⃣", "3️⃣"])
|
|
41
|
+
* .onReaction((event) => {
|
|
42
|
+
* console.log(`${event.user.username} voted ${event.emoji}`);
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
onReaction(callback) {
|
|
47
|
+
const unsubscribe = this.operations.subscribeToReactions(this.id, callback);
|
|
48
|
+
this.reactionUnsubscribers.push(unsubscribe);
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Stop listening for reactions on this message
|
|
53
|
+
*/
|
|
54
|
+
offReaction() {
|
|
55
|
+
for (const unsub of this.reactionUnsubscribers) {
|
|
56
|
+
unsub();
|
|
57
|
+
}
|
|
58
|
+
this.reactionUnsubscribers = [];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Post a reply in this message's thread
|
|
62
|
+
* @param content - Reply content (string or Document)
|
|
63
|
+
* @returns ReplyMessage that can be awaited to handle success/failure
|
|
64
|
+
*/
|
|
65
|
+
postReply(content) {
|
|
66
|
+
const replyPromise = this.operations.postReply(this.channelId, this.id, content);
|
|
67
|
+
return new ReplyMessage(replyPromise, this.operations, this.platform);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Update this message's content
|
|
71
|
+
* @param content - New content (string or Document)
|
|
72
|
+
*/
|
|
73
|
+
async update(content) {
|
|
74
|
+
await this.operations.updateMessage(this.id, this.channelId, content);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Delete this message
|
|
29
78
|
*/
|
|
30
|
-
async
|
|
79
|
+
async delete() {
|
|
80
|
+
await this.operations.deleteMessage(this.id, this.channelId);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Wait for all pending reactions to complete.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const msg = await channel.postMessage('Vote!');
|
|
88
|
+
* msg.addReactions(['👍', '👎']);
|
|
89
|
+
* await msg.waitForReactions();
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
async waitForReactions() {
|
|
31
93
|
await this.pendingReactions;
|
|
32
|
-
|
|
33
|
-
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.Message = Message;
|
|
97
|
+
/**
|
|
98
|
+
* A reply message that is still being posted.
|
|
99
|
+
* Use `.wait()` to await completion and handle errors.
|
|
100
|
+
*/
|
|
101
|
+
class ReplyMessage extends Message {
|
|
102
|
+
replyPromise;
|
|
103
|
+
deferredReactionCallbacks = [];
|
|
104
|
+
constructor(replyPromise, operations, platform) {
|
|
105
|
+
// Initialize with placeholder data
|
|
106
|
+
super({ id: '', channelId: '', platform }, operations);
|
|
107
|
+
this.replyPromise = replyPromise;
|
|
108
|
+
// Update our data when the reply completes and subscribe any deferred listeners
|
|
109
|
+
this.replyPromise
|
|
110
|
+
.then((data) => {
|
|
111
|
+
Object.defineProperty(this, 'id', { value: data.id });
|
|
112
|
+
Object.defineProperty(this, 'channelId', { value: data.channelId });
|
|
113
|
+
Object.defineProperty(this, 'platform', { value: data.platform });
|
|
114
|
+
// Subscribe deferred reaction callbacks now that we have the message ID
|
|
115
|
+
for (const callback of this.deferredReactionCallbacks) {
|
|
116
|
+
const unsubscribe = this.operations.subscribeToReactions(data.id, callback);
|
|
117
|
+
this.reactionUnsubscribers.push(unsubscribe);
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
.catch(() => {
|
|
121
|
+
// Errors handled via wait()
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Override addReactions to wait for reply to complete first
|
|
126
|
+
*/
|
|
127
|
+
addReactions(emojis) {
|
|
128
|
+
// Chain reactions after the reply completes, capturing current pendingReactions
|
|
129
|
+
const currentPendingReactions = this.pendingReactions;
|
|
130
|
+
this.pendingReactions = this.replyPromise.then(() => currentPendingReactions);
|
|
131
|
+
for (const emoji of emojis) {
|
|
132
|
+
this.pendingReactions = this.pendingReactions.then(() => this.operations.addReaction(this.id, this.channelId, emoji));
|
|
34
133
|
}
|
|
35
134
|
return this;
|
|
36
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Override onReaction to defer subscription until reply completes
|
|
138
|
+
*/
|
|
139
|
+
onReaction(callback) {
|
|
140
|
+
this.deferredReactionCallbacks.push(callback);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Wait for reply to complete.
|
|
145
|
+
* Throws if the reply fails - allows callers to handle errors.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const reply = msg.postReply('text');
|
|
150
|
+
* await reply.wait(); // throws if reply fails
|
|
151
|
+
* console.log(reply.id); // now available
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
async wait() {
|
|
155
|
+
await this.replyPromise;
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Wait for reply and all pending reactions to complete.
|
|
160
|
+
*/
|
|
161
|
+
async waitForReactions() {
|
|
162
|
+
await this.replyPromise;
|
|
163
|
+
await this.pendingReactions;
|
|
164
|
+
}
|
|
37
165
|
}
|
|
166
|
+
exports.ReplyMessage = ReplyMessage;
|
|
38
167
|
//# sourceMappingURL=Message.js.map
|
package/dist/Message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":";;;AAmBA;;GAEG;AACH,MAAa,OAAO;IACF,EAAE,CAAS;IACX,SAAS,CAAS;IAClB,QAAQ,CAAW;IAEzB,gBAAgB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IACpD,UAAU,CAAoB;IAC9B,qBAAqB,GAAmB,EAAE,CAAC;IAErD,YAAY,IAAiB,EAAE,UAA6B;QAC1D,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,MAAgB;QAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,CACtD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAA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AAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,CACtD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACM,UAAU,CAAC,QAA0B;QAC5C,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,YAAY,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACM,KAAK,CAAC,gBAAgB;QAC7B,MAAM,IAAI,CAAC,YAAY,CAAC;QACxB,MAAM,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;CACF;AA7ED,oCA6EC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChatClient } from '../ChatClient.js';
|
|
2
2
|
import { Channel, type ChannelOperations } from '../Channel.js';
|
|
3
|
-
import type { DiscordConfig, ReactionCallback,
|
|
3
|
+
import type { DiscordConfig, MessageData, ReactionCallback, MessageContent } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Discord chat client implementation using discord.js
|
|
6
6
|
*/
|
|
@@ -27,10 +27,26 @@ export declare class DiscordChatClient extends ChatClient implements ChannelOper
|
|
|
27
27
|
/**
|
|
28
28
|
* Post a message to a Discord channel
|
|
29
29
|
* @param channelId - Channel to post to
|
|
30
|
-
* @param
|
|
30
|
+
* @param content - Message content (string or Document)
|
|
31
|
+
* @param options - Optional options including threadTs for replies
|
|
31
32
|
* @returns Message data with ID
|
|
32
33
|
*/
|
|
33
|
-
postMessage(channelId: string,
|
|
34
|
+
postMessage(channelId: string, content: MessageContent, options?: {
|
|
35
|
+
threadTs?: string;
|
|
36
|
+
}): Promise<MessageData>;
|
|
37
|
+
/**
|
|
38
|
+
* Update a message in a Discord channel
|
|
39
|
+
* @param messageId - ID of the message to update
|
|
40
|
+
* @param channelId - Channel containing the message
|
|
41
|
+
* @param content - New message content (string or Document)
|
|
42
|
+
*/
|
|
43
|
+
updateMessage(messageId: string, channelId: string, content: MessageContent): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Delete a message from a Discord channel
|
|
46
|
+
* @param messageId - ID of the message to delete
|
|
47
|
+
* @param channelId - Channel containing the message
|
|
48
|
+
*/
|
|
49
|
+
deleteMessage(messageId: string, channelId: string): Promise<void>;
|
|
34
50
|
/**
|
|
35
51
|
* Add a reaction to a message
|
|
36
52
|
* @param messageId - Message to react to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscordChatClient.d.ts","sourceRoot":"","sources":["../../src/discord/DiscordChatClient.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,
|
|
1
|
+
{"version":3,"file":"DiscordChatClient.d.ts","sourceRoot":"","sources":["../../src/discord/DiscordChatClient.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,gBAAgB,EAGhB,cAAc,EACf,MAAM,aAAa,CAAC;AAIrB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAW,YAAW,iBAAiB;IAC5E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAA4C;IACrE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,aAAa;IAgBjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA+C7B;;;;OAIG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYlD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC;;;;;;OAMG;IACG,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9B,OAAO,CAAC,WAAW,CAAC;IA6CvB;;;;;OAKG;IACG,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;OAIG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE;;;;;OAKG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrF;;;;;OAKG;IACH,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI;CAkBhF"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscordChatClient = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
const ChatClient_js_1 = require("../ChatClient.js");
|
|
6
|
+
const Channel_js_1 = require("../Channel.js");
|
|
7
|
+
const discord_js_2 = require("../outputters/discord.js");
|
|
8
|
+
const utils_js_1 = require("../utils.js");
|
|
4
9
|
/**
|
|
5
10
|
* Discord chat client implementation using discord.js
|
|
6
11
|
*/
|
|
7
|
-
|
|
12
|
+
class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
8
13
|
client;
|
|
9
14
|
reactionListeners = new Map();
|
|
10
15
|
token;
|
|
@@ -13,11 +18,11 @@ export class DiscordChatClient extends ChatClient {
|
|
|
13
18
|
super(config);
|
|
14
19
|
this.token = config.token ?? process.env.DISCORD_TOKEN ?? '';
|
|
15
20
|
this.guildId = config.guildId ?? process.env.DISCORD_GUILD_ID ?? '';
|
|
16
|
-
this.client = new Client({
|
|
21
|
+
this.client = new discord_js_1.Client({
|
|
17
22
|
intents: [
|
|
18
|
-
GatewayIntentBits.Guilds,
|
|
19
|
-
GatewayIntentBits.GuildMessages,
|
|
20
|
-
GatewayIntentBits.GuildMessageReactions,
|
|
23
|
+
discord_js_1.GatewayIntentBits.Guilds,
|
|
24
|
+
discord_js_1.GatewayIntentBits.GuildMessages,
|
|
25
|
+
discord_js_1.GatewayIntentBits.GuildMessageReactions,
|
|
21
26
|
],
|
|
22
27
|
});
|
|
23
28
|
this.setupReactionListener();
|
|
@@ -70,10 +75,10 @@ export class DiscordChatClient extends ChatClient {
|
|
|
70
75
|
async connect(channelId) {
|
|
71
76
|
await this.client.login(this.token);
|
|
72
77
|
const discordChannel = await this.client.channels.fetch(channelId);
|
|
73
|
-
if (!discordChannel || !(discordChannel instanceof TextChannel)) {
|
|
78
|
+
if (!discordChannel || !(discordChannel instanceof discord_js_1.TextChannel)) {
|
|
74
79
|
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
75
80
|
}
|
|
76
|
-
return new Channel(channelId, 'discord', this);
|
|
81
|
+
return new Channel_js_1.Channel(channelId, 'discord', this);
|
|
77
82
|
}
|
|
78
83
|
/**
|
|
79
84
|
* Disconnect from Discord
|
|
@@ -85,21 +90,79 @@ export class DiscordChatClient extends ChatClient {
|
|
|
85
90
|
/**
|
|
86
91
|
* Post a message to a Discord channel
|
|
87
92
|
* @param channelId - Channel to post to
|
|
88
|
-
* @param
|
|
93
|
+
* @param content - Message content (string or Document)
|
|
94
|
+
* @param options - Optional options including threadTs for replies
|
|
89
95
|
* @returns Message data with ID
|
|
90
96
|
*/
|
|
91
|
-
async postMessage(channelId,
|
|
97
|
+
async postMessage(channelId, content, options) {
|
|
92
98
|
const channel = await this.client.channels.fetch(channelId);
|
|
93
|
-
if (!channel || !(channel instanceof TextChannel)) {
|
|
99
|
+
if (!channel || !(channel instanceof discord_js_1.TextChannel)) {
|
|
94
100
|
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
95
101
|
}
|
|
96
|
-
|
|
102
|
+
let messageOptions;
|
|
103
|
+
if ((0, utils_js_1.isDocument)(content)) {
|
|
104
|
+
const embed = (0, discord_js_2.toDiscordEmbed)(content.getBlocks());
|
|
105
|
+
// Check if embed has any content - Discord rejects empty embeds
|
|
106
|
+
const hasEmbedContent = embed.title !== undefined ||
|
|
107
|
+
embed.description !== undefined ||
|
|
108
|
+
embed.footer !== undefined ||
|
|
109
|
+
embed.image !== undefined;
|
|
110
|
+
if (hasEmbedContent) {
|
|
111
|
+
messageOptions = { embeds: [embed] };
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Fallback to empty content for documents with no visible blocks
|
|
115
|
+
messageOptions = { content: '\u200B' };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
messageOptions = { content };
|
|
120
|
+
}
|
|
121
|
+
// If threadTs is provided (non-empty), use it as a reply reference
|
|
122
|
+
if (options?.threadTs !== undefined && options.threadTs !== '') {
|
|
123
|
+
messageOptions.messageReference = { messageId: options.threadTs };
|
|
124
|
+
}
|
|
125
|
+
const message = await channel.send(messageOptions);
|
|
97
126
|
return {
|
|
98
127
|
id: message.id,
|
|
99
128
|
channelId: channelId,
|
|
100
129
|
platform: 'discord',
|
|
101
130
|
};
|
|
102
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Update a message in a Discord channel
|
|
134
|
+
* @param messageId - ID of the message to update
|
|
135
|
+
* @param channelId - Channel containing the message
|
|
136
|
+
* @param content - New message content (string or Document)
|
|
137
|
+
*/
|
|
138
|
+
async updateMessage(messageId, channelId, content) {
|
|
139
|
+
const channel = await this.client.channels.fetch(channelId);
|
|
140
|
+
if (!channel || !(channel instanceof discord_js_1.TextChannel)) {
|
|
141
|
+
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
142
|
+
}
|
|
143
|
+
const message = await channel.messages.fetch(messageId);
|
|
144
|
+
if ((0, utils_js_1.isDocument)(content)) {
|
|
145
|
+
const embed = (0, discord_js_2.toDiscordEmbed)(content.getBlocks());
|
|
146
|
+
await message.edit({ embeds: [embed] });
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Clear embeds when switching to text
|
|
150
|
+
await message.edit({ content, embeds: [] });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Delete a message from a Discord channel
|
|
155
|
+
* @param messageId - ID of the message to delete
|
|
156
|
+
* @param channelId - Channel containing the message
|
|
157
|
+
*/
|
|
158
|
+
async deleteMessage(messageId, channelId) {
|
|
159
|
+
const channel = await this.client.channels.fetch(channelId);
|
|
160
|
+
if (!channel || !(channel instanceof discord_js_1.TextChannel)) {
|
|
161
|
+
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
162
|
+
}
|
|
163
|
+
const message = await channel.messages.fetch(messageId);
|
|
164
|
+
await message.delete();
|
|
165
|
+
}
|
|
103
166
|
/**
|
|
104
167
|
* Add a reaction to a message
|
|
105
168
|
* @param messageId - Message to react to
|
|
@@ -108,7 +171,7 @@ export class DiscordChatClient extends ChatClient {
|
|
|
108
171
|
*/
|
|
109
172
|
async addReaction(messageId, channelId, emoji) {
|
|
110
173
|
const channel = await this.client.channels.fetch(channelId);
|
|
111
|
-
if (!channel || !(channel instanceof TextChannel)) {
|
|
174
|
+
if (!channel || !(channel instanceof discord_js_1.TextChannel)) {
|
|
112
175
|
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
113
176
|
}
|
|
114
177
|
const message = await channel.messages.fetch(messageId);
|
|
@@ -137,4 +200,5 @@ export class DiscordChatClient extends ChatClient {
|
|
|
137
200
|
};
|
|
138
201
|
}
|
|
139
202
|
}
|
|
203
|
+
exports.DiscordChatClient = DiscordChatClient;
|
|
140
204
|
//# sourceMappingURL=DiscordChatClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscordChatClient.js","sourceRoot":"","sources":["../../src/discord/DiscordChatClient.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"DiscordChatClient.js","sourceRoot":"","sources":["../../src/discord/DiscordChatClient.ts"],"names":[],"mappings":";;;AAAA,2CAQoB;AACpB,oDAA8C;AAC9C,8CAAgE;AAShE,yDAA6E;AAC7E,0CAAyC;AAEzC;;GAEG;AACH,MAAa,iBAAkB,SAAQ,0BAAU;IACvC,MAAM,CAAS;IACf,iBAAiB,GAAG,IAAI,GAAG,EAAiC,CAAC;IACpD,KAAK,CAAS;IACd,OAAO,CAAS;IAEjC,YAAY,MAAqB;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;QAEpE,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAM,CAAC;YACvB,OAAO,EAAE;gBACP,8BAAiB,CAAC,MAAM;gBACxB,8BAAiB,CAAC,aAAa;gBAC/B,8BAAiB,CAAC,qBAAqB;aACxC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACK,qBAAqB;QAC3B,I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AG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxD,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,SAAiB,EAAE,QAA0B;QAChE,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,mCAAmC,SAAS,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAExB,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3B,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBACzB,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF;AA5OD,8CA4OC"}
|
package/dist/discord/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DiscordChatClient } from './DiscordChatClient
|
|
1
|
+
export { DiscordChatClient } from './DiscordChatClient';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discord/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discord/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/discord/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiscordChatClient = void 0;
|
|
4
|
+
var DiscordChatClient_1 = require("./DiscordChatClient");
|
|
5
|
+
Object.defineProperty(exports, "DiscordChatClient", { enumerable: true, get: function () { return DiscordChatClient_1.DiscordChatClient; } });
|
|
2
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/discord/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/discord/index.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { type User, type DiscordConfig, type SlackConfig, type ChatConfig, type Platform, type ReactionEvent, type ReactionCallback, } from './types
|
|
2
|
-
export { ChatClient } from './ChatClient
|
|
3
|
-
export { Channel } from './Channel
|
|
4
|
-
export { Message } from './Message
|
|
5
|
-
export { DiscordChatClient } from './discord/index
|
|
6
|
-
export { SlackChatClient } from './slack/index
|
|
7
|
-
import type { ChatConfig } from './types
|
|
8
|
-
import { ChatClient } from './ChatClient
|
|
1
|
+
export { type User, type DiscordConfig, type SlackConfig, type ChatConfig, type Platform, type ReactionEvent, type ReactionCallback, type MessageContent, type PostMessageOptions, Document, doc, } from './types';
|
|
2
|
+
export { ChatClient } from './ChatClient';
|
|
3
|
+
export { Channel, type ChannelOperations } from './Channel';
|
|
4
|
+
export { Message, ReplyMessage, type MessageOperations } from './Message';
|
|
5
|
+
export { DiscordChatClient } from './discord/index';
|
|
6
|
+
export { SlackChatClient } from './slack/index';
|
|
7
|
+
import type { ChatConfig } from './types';
|
|
8
|
+
import { ChatClient } from './ChatClient';
|
|
9
9
|
/**
|
|
10
10
|
* Factory function to create a chat client based on config type
|
|
11
11
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,QAAQ,EACR,GAAG,GACJ,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAS/D"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlackChatClient = exports.DiscordChatClient = exports.ReplyMessage = exports.Message = exports.Channel = exports.ChatClient = exports.doc = exports.Document = void 0;
|
|
4
|
+
exports.createChatClient = createChatClient;
|
|
5
|
+
// Types and utilities
|
|
6
|
+
var types_1 = require("./types");
|
|
7
|
+
Object.defineProperty(exports, "Document", { enumerable: true, get: function () { return types_1.Document; } });
|
|
8
|
+
Object.defineProperty(exports, "doc", { enumerable: true, get: function () { return types_1.doc; } });
|
|
1
9
|
// Core classes
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
10
|
+
var ChatClient_1 = require("./ChatClient");
|
|
11
|
+
Object.defineProperty(exports, "ChatClient", { enumerable: true, get: function () { return ChatClient_1.ChatClient; } });
|
|
12
|
+
var Channel_1 = require("./Channel");
|
|
13
|
+
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return Channel_1.Channel; } });
|
|
14
|
+
var Message_1 = require("./Message");
|
|
15
|
+
Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return Message_1.Message; } });
|
|
16
|
+
Object.defineProperty(exports, "ReplyMessage", { enumerable: true, get: function () { return Message_1.ReplyMessage; } });
|
|
5
17
|
// Platform implementations
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
var index_1 = require("./discord/index");
|
|
19
|
+
Object.defineProperty(exports, "DiscordChatClient", { enumerable: true, get: function () { return index_1.DiscordChatClient; } });
|
|
20
|
+
var index_2 = require("./slack/index");
|
|
21
|
+
Object.defineProperty(exports, "SlackChatClient", { enumerable: true, get: function () { return index_2.SlackChatClient; } });
|
|
22
|
+
const index_3 = require("./discord/index");
|
|
23
|
+
const index_4 = require("./slack/index");
|
|
10
24
|
/**
|
|
11
25
|
* Factory function to create a chat client based on config type
|
|
12
26
|
*
|
|
@@ -27,12 +41,12 @@ import { SlackChatClient } from './slack/index.js';
|
|
|
27
41
|
* });
|
|
28
42
|
* ```
|
|
29
43
|
*/
|
|
30
|
-
|
|
44
|
+
function createChatClient(config) {
|
|
31
45
|
switch (config.type) {
|
|
32
46
|
case 'discord':
|
|
33
|
-
return new DiscordChatClient(config);
|
|
47
|
+
return new index_3.DiscordChatClient(config);
|
|
34
48
|
case 'slack':
|
|
35
|
-
return new SlackChatClient(config);
|
|
49
|
+
return new index_4.SlackChatClient(config);
|
|
36
50
|
default:
|
|
37
51
|
throw new Error(`Unknown chat platform: ${config.type}`);
|
|
38
52
|
}
|