@hardlydifficult/chat 1.1.4 → 1.1.6
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 +4 -6
- package/dist/Channel.d.ts +4 -5
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +8 -8
- package/dist/Channel.js.map +1 -1
- package/dist/ChatClient.d.ts +2 -2
- package/dist/ChatClient.d.ts.map +1 -1
- package/dist/Message.d.ts +11 -16
- package/dist/Message.d.ts.map +1 -1
- package/dist/Message.js +12 -12
- package/dist/Message.js.map +1 -1
- package/dist/discord/DiscordChatClient.d.ts +6 -6
- package/dist/discord/DiscordChatClient.d.ts.map +1 -1
- package/dist/discord/DiscordChatClient.js +43 -36
- package/dist/discord/DiscordChatClient.js.map +1 -1
- package/dist/discord/index.d.ts +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -12
- package/dist/index.js.map +1 -1
- package/dist/outputters/discord.d.ts +1 -1
- package/dist/outputters/discord.d.ts.map +1 -1
- package/dist/outputters/discord.js +14 -11
- package/dist/outputters/discord.js.map +1 -1
- package/dist/outputters/index.d.ts +2 -3
- package/dist/outputters/index.d.ts.map +1 -1
- package/dist/outputters/slack.d.ts +2 -2
- package/dist/outputters/slack.d.ts.map +1 -1
- package/dist/outputters/slack.js +29 -29
- package/dist/outputters/slack.js.map +1 -1
- package/dist/slack/SlackChatClient.d.ts +5 -5
- package/dist/slack/SlackChatClient.d.ts.map +1 -1
- package/dist/slack/SlackChatClient.js +47 -30
- package/dist/slack/SlackChatClient.js.map +1 -1
- package/dist/slack/index.d.ts +1 -1
- package/dist/types.d.ts +4 -28
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,14 +91,14 @@ channel.postMessage("Here's the scan report", {
|
|
|
91
91
|
const msg = await channel.postMessage("Hello");
|
|
92
92
|
|
|
93
93
|
await msg.update("Updated content");
|
|
94
|
+
msg.reply("Thread reply");
|
|
94
95
|
await msg.delete();
|
|
95
|
-
msg.postReply("Thread reply");
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
### Reactions
|
|
99
99
|
|
|
100
100
|
```typescript
|
|
101
|
-
await channel
|
|
101
|
+
const msg = await channel
|
|
102
102
|
.postMessage("Pick one")
|
|
103
103
|
.addReactions(["👍", "👎"])
|
|
104
104
|
.onReaction((event) => {
|
|
@@ -114,12 +114,10 @@ Create a thread from an existing message.
|
|
|
114
114
|
|
|
115
115
|
```typescript
|
|
116
116
|
const msg = await channel.postMessage("Starting a discussion");
|
|
117
|
-
const thread = await msg.startThread("Discussion Thread",
|
|
118
|
-
autoArchiveDuration: 1440, // minutes
|
|
119
|
-
});
|
|
117
|
+
const thread = await msg.startThread("Discussion Thread", 1440); // auto-archive in minutes
|
|
120
118
|
```
|
|
121
119
|
|
|
122
|
-
> **Slack note:** Slack threads are implicit — calling `startThread()` returns the message's timestamp as the thread ID. Post replies with `msg.
|
|
120
|
+
> **Slack note:** Slack threads are implicit — calling `startThread()` returns the message's timestamp as the thread ID. Post replies with `msg.reply()` to populate the thread.
|
|
123
121
|
|
|
124
122
|
## Typing Indicator
|
|
125
123
|
|
package/dist/Channel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Message } from "./Message";
|
|
2
|
+
import type { DisconnectCallback, ErrorCallback, FileAttachment, MessageCallback, MessageContent, MessageData, Platform, ReactionCallback, ThreadData } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Interface for platform-specific channel operations
|
|
5
5
|
*/
|
|
@@ -14,7 +14,7 @@ export interface ChannelOperations {
|
|
|
14
14
|
subscribeToReactions(channelId: string, callback: ReactionCallback): () => void;
|
|
15
15
|
subscribeToMessages(channelId: string, callback: MessageCallback): () => void;
|
|
16
16
|
sendTyping(channelId: string): Promise<void>;
|
|
17
|
-
startThread(messageId: string, channelId: string, name: string,
|
|
17
|
+
startThread(messageId: string, channelId: string, name: string, autoArchiveDuration?: number): Promise<ThreadData>;
|
|
18
18
|
bulkDelete(channelId: string, count: number): Promise<number>;
|
|
19
19
|
getThreads(channelId: string): Promise<ThreadData[]>;
|
|
20
20
|
onDisconnect(callback: DisconnectCallback): () => void;
|
|
@@ -33,11 +33,10 @@ export declare class Channel {
|
|
|
33
33
|
/**
|
|
34
34
|
* Post a message to this channel
|
|
35
35
|
* @param content - Message content (string or Document)
|
|
36
|
-
* @param options - Optional message options (e.g.,
|
|
36
|
+
* @param options - Optional message options (e.g., files for attachments)
|
|
37
37
|
* @returns Message object with chainable reaction methods
|
|
38
38
|
*/
|
|
39
39
|
postMessage(content: MessageContent, options?: {
|
|
40
|
-
threadTs?: string;
|
|
41
40
|
files?: FileAttachment[];
|
|
42
41
|
}): Message & PromiseLike<Message>;
|
|
43
42
|
/**
|
package/dist/Channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Channel.d.ts","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA0B,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE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AC,UAAU,CAAoB;IACtC,OAAO,CAAC,wBAAwB,CAA4C;IAC5E,OAAO,CAAC,uBAAuB,CAA6B;gBAEhD,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB;IAYzE;;;;;OAKG;IACH,WAAW,CACT,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,cAAc,EAAE,CAAA;KAAE,GACrC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAejC;;OAEG;YACW,YAAY;IAe1B;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAmBnC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiC/B;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,IAAI;IAIhD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;;;OAIG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhD;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAIzC;;OAEG;IACH,UAAU,IAAI,IAAI;CAOnB"}
|
package/dist/Channel.js
CHANGED
|
@@ -21,7 +21,7 @@ class Channel {
|
|
|
21
21
|
/**
|
|
22
22
|
* Post a message to this channel
|
|
23
23
|
* @param content - Message content (string or Document)
|
|
24
|
-
* @param options - Optional message options (e.g.,
|
|
24
|
+
* @param options - Optional message options (e.g., files for attachments)
|
|
25
25
|
* @returns Message object with chainable reaction methods
|
|
26
26
|
*/
|
|
27
27
|
postMessage(content, options) {
|
|
@@ -38,7 +38,7 @@ class Channel {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const promises = Array.from(callbacks).map((cb) => Promise.resolve(cb(event)).catch((err) => {
|
|
41
|
-
console.error(
|
|
41
|
+
console.error("Reaction callback error:", err);
|
|
42
42
|
}));
|
|
43
43
|
await Promise.all(promises);
|
|
44
44
|
}
|
|
@@ -68,9 +68,9 @@ class Channel {
|
|
|
68
68
|
addReaction: (messageId, channelId, emoji) => this.operations.addReaction(messageId, channelId, emoji),
|
|
69
69
|
updateMessage: (messageId, channelId, content) => this.operations.updateMessage(messageId, channelId, content),
|
|
70
70
|
deleteMessage: (messageId, channelId) => this.operations.deleteMessage(messageId, channelId),
|
|
71
|
-
|
|
71
|
+
reply: async (channelId, threadTs, content) => this.operations.postMessage(channelId, content, { threadTs }),
|
|
72
72
|
subscribeToReactions: (messageId, callback) => this.subscribeToMessageReactions(messageId, callback),
|
|
73
|
-
startThread: (messageId, channelId, name,
|
|
73
|
+
startThread: (messageId, channelId, name, autoArchiveDuration) => this.operations.startThread(messageId, channelId, name, autoArchiveDuration),
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -127,15 +127,15 @@ class PendingMessage extends Message_1.Message {
|
|
|
127
127
|
deferredReactionCallbacks = [];
|
|
128
128
|
constructor(postPromise, operations, platform) {
|
|
129
129
|
// Initialize with placeholder data using the correct platform
|
|
130
|
-
super({ id:
|
|
130
|
+
super({ id: "", channelId: "", platform }, operations);
|
|
131
131
|
this.postPromise = postPromise;
|
|
132
132
|
// Update our data when the post resolves and subscribe any deferred listeners
|
|
133
133
|
this.postPromise
|
|
134
134
|
.then((data) => {
|
|
135
135
|
// Update the readonly properties via Object.defineProperty
|
|
136
|
-
Object.defineProperty(this,
|
|
137
|
-
Object.defineProperty(this,
|
|
138
|
-
Object.defineProperty(this,
|
|
136
|
+
Object.defineProperty(this, "id", { value: data.id });
|
|
137
|
+
Object.defineProperty(this, "channelId", { value: data.channelId });
|
|
138
|
+
Object.defineProperty(this, "platform", { value: data.platform });
|
|
139
139
|
// Subscribe deferred reaction callbacks now that we have the message ID
|
|
140
140
|
for (const callback of this.deferredReactionCallbacks) {
|
|
141
141
|
const unsubscribe = this.operations.subscribeToReactions(data.id, callback);
|
package/dist/Channel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":";;;AAAA,uCAA4D;AAmD5D;;GAEG;AACH,MAAa,OAAO;IACF,EAAE,CAAS;IACX,QAAQ,CAAW;IAE3B,UAAU,CAAoB;IAC9B,wBAAwB,GAAG,IAAI,GAAG,EAAiC,CAAC;IACpE,uBAAuB,GAAwB,IAAI,CAAC;IAE5D,YAAY,EAAU,EAAE,QAAkB,EAAE,UAA6B;QACvE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,4EAA4E;QAC5E,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,CACjE,EAAE,EACF,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CACpC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,WAAW,CACT,OAAuB,EACvB,OAAsC;QAEtC,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAChD,IAAI,CAAC,EAAE,EACP,OAAO,EACP,OAAO,CACR,CAAC;QAEF,6DAA6D;QAC7D,OAAO,IAAI,cAAc,CACvB,cAAc,EACd,IAAI,CAAC,uBAAuB,EAAE,EAC9B,IAAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,YAAY,CACxB,KAAsC;QAEtC,MAAM,SAAS,GAAG,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACrE,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QACD,MAAM,QAAQ,GAAG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
import type {
|
|
1
|
+
import type { Channel } from "./Channel";
|
|
2
|
+
import type { ChatConfig } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Abstract base class for chat platform clients
|
|
5
5
|
* Provides a unified API for Discord and Slack
|
package/dist/ChatClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatClient.d.ts","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ChatClient.d.ts","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;GAGG;AACH,8BAAsB,UAAU;IAClB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU;gBAAlB,MAAM,EAAE,UAAU;IAEjD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAErD;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CACrC"}
|
package/dist/Message.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
* Interface for the platform-specific reaction adder
|
|
4
|
-
*/
|
|
5
|
-
export interface ReactionAdder {
|
|
6
|
-
addReaction(messageId: string, channelId: string, emoji: string): Promise<void>;
|
|
7
|
-
}
|
|
1
|
+
import type { MessageContent, MessageData, Platform, ReactionCallback, ThreadData } from "./types";
|
|
8
2
|
/**
|
|
9
3
|
* Interface for message operations (reactions, updates, deletes, replies)
|
|
10
4
|
*/
|
|
11
|
-
export interface MessageOperations
|
|
5
|
+
export interface MessageOperations {
|
|
6
|
+
addReaction(messageId: string, channelId: string, emoji: string): Promise<void>;
|
|
12
7
|
updateMessage(messageId: string, channelId: string, content: MessageContent): Promise<void>;
|
|
13
8
|
deleteMessage(messageId: string, channelId: string): Promise<void>;
|
|
14
|
-
|
|
9
|
+
reply(channelId: string, threadTs: string, content: MessageContent): Promise<MessageData>;
|
|
15
10
|
subscribeToReactions(messageId: string, callback: ReactionCallback): () => void;
|
|
16
|
-
startThread(messageId: string, channelId: string, name: string,
|
|
11
|
+
startThread(messageId: string, channelId: string, name: string, autoArchiveDuration?: number): Promise<ThreadData>;
|
|
17
12
|
}
|
|
18
13
|
/**
|
|
19
14
|
* Represents a posted message with chainable reaction methods
|
|
@@ -58,18 +53,18 @@ export declare class Message {
|
|
|
58
53
|
*/
|
|
59
54
|
offReaction(): void;
|
|
60
55
|
/**
|
|
61
|
-
*
|
|
56
|
+
* Reply in this message's thread
|
|
62
57
|
* @param content - Reply content (string or Document)
|
|
63
58
|
* @returns ReplyMessage that can be awaited to handle success/failure
|
|
64
59
|
*/
|
|
65
|
-
|
|
60
|
+
reply(content: MessageContent): Message & PromiseLike<Message>;
|
|
66
61
|
/**
|
|
67
62
|
* Create a thread from this message
|
|
68
63
|
* @param name - Thread name
|
|
69
|
-
* @param
|
|
70
|
-
* @returns
|
|
64
|
+
* @param autoArchiveDuration - Auto-archive duration in minutes (60, 1440, 4320, 10080)
|
|
65
|
+
* @returns Thread data
|
|
71
66
|
*/
|
|
72
|
-
startThread(name: string,
|
|
67
|
+
startThread(name: string, autoArchiveDuration?: number): Promise<ThreadData>;
|
|
73
68
|
/**
|
|
74
69
|
* Update this message's content
|
|
75
70
|
* @param content - New content (string or Document)
|
|
@@ -94,7 +89,7 @@ export declare class Message {
|
|
|
94
89
|
/**
|
|
95
90
|
* A reply message that is still being posted.
|
|
96
91
|
* Implements PromiseLike so it can be directly awaited:
|
|
97
|
-
* const reply = await msg.
|
|
92
|
+
* const reply = await msg.reply('text');
|
|
98
93
|
*/
|
|
99
94
|
export declare class ReplyMessage extends Message implements PromiseLike<Message> {
|
|
100
95
|
private replyPromise;
|
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,EACV,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../src/Message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,WAAW,CAAC,CAAC;IACxB,oBAAoB,CAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,gBAAgB,GACzB,MAAM,IAAI,CAAC;IACd,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,mBAAmB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,OAAO;IAClB,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEn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E,gBAAgB,GAAG,IAAI;IAKrD;;;OAGG;IACH,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,GAAG,KAAK,EACvC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EAC3E,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GAC1E,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAQ/B;;OAEG;IACY,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAIjD"}
|
package/dist/Message.js
CHANGED
|
@@ -67,22 +67,22 @@ class Message {
|
|
|
67
67
|
this.reactionUnsubscribers = [];
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Reply in this message's thread
|
|
71
71
|
* @param content - Reply content (string or Document)
|
|
72
72
|
* @returns ReplyMessage that can be awaited to handle success/failure
|
|
73
73
|
*/
|
|
74
|
-
|
|
75
|
-
const replyPromise = this.operations.
|
|
74
|
+
reply(content) {
|
|
75
|
+
const replyPromise = this.operations.reply(this.channelId, this.id, content);
|
|
76
76
|
return new ReplyMessage(replyPromise, this.operations, this.platform);
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Create a thread from this message
|
|
80
80
|
* @param name - Thread name
|
|
81
|
-
* @param
|
|
82
|
-
* @returns
|
|
81
|
+
* @param autoArchiveDuration - Auto-archive duration in minutes (60, 1440, 4320, 10080)
|
|
82
|
+
* @returns Thread data
|
|
83
83
|
*/
|
|
84
|
-
async startThread(name,
|
|
85
|
-
return this.operations.startThread(this.id, this.channelId, name,
|
|
84
|
+
async startThread(name, autoArchiveDuration) {
|
|
85
|
+
return this.operations.startThread(this.id, this.channelId, name, autoArchiveDuration);
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Update this message's content
|
|
@@ -115,21 +115,21 @@ exports.Message = Message;
|
|
|
115
115
|
/**
|
|
116
116
|
* A reply message that is still being posted.
|
|
117
117
|
* Implements PromiseLike so it can be directly awaited:
|
|
118
|
-
* const reply = await msg.
|
|
118
|
+
* const reply = await msg.reply('text');
|
|
119
119
|
*/
|
|
120
120
|
class ReplyMessage extends Message {
|
|
121
121
|
replyPromise;
|
|
122
122
|
deferredReactionCallbacks = [];
|
|
123
123
|
constructor(replyPromise, operations, platform) {
|
|
124
124
|
// Initialize with placeholder data
|
|
125
|
-
super({ id:
|
|
125
|
+
super({ id: "", channelId: "", platform }, operations);
|
|
126
126
|
this.replyPromise = replyPromise;
|
|
127
127
|
// Update our data when the reply completes and subscribe any deferred listeners
|
|
128
128
|
this.replyPromise
|
|
129
129
|
.then((data) => {
|
|
130
|
-
Object.defineProperty(this,
|
|
131
|
-
Object.defineProperty(this,
|
|
132
|
-
Object.defineProperty(this,
|
|
130
|
+
Object.defineProperty(this, "id", { value: data.id });
|
|
131
|
+
Object.defineProperty(this, "channelId", { value: data.channelId });
|
|
132
|
+
Object.defineProperty(this, "platform", { value: data.platform });
|
|
133
133
|
// Subscribe deferred reaction callbacks now that we have the message ID
|
|
134
134
|
for (const callback of this.deferredReactionCallbacks) {
|
|
135
135
|
const unsubscribe = this.operations.subscribeToReactions(data.id, callback);
|
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":";;;AAwCA;;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,CAA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AW,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;;;OAGG;IACH,IAAI,CACF,WAA2E,EAC3E,UAA2E;QAE3E,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YACjD,MAAM,IAAI,CAAC,gBAAgB,CAAC;YAC5B,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACM,KAAK,CAAC,gBAAgB;QAC7B,MAAM,IAAI,CAAC,YAAY,CAAC;QACxB,MAAM,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;CACF;AAjFD,oCAiFC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type { DiscordConfig,
|
|
1
|
+
import { Channel, type ChannelOperations } from "../Channel.js";
|
|
2
|
+
import { ChatClient } from "../ChatClient.js";
|
|
3
|
+
import type { DisconnectCallback, DiscordConfig, ErrorCallback, FileAttachment, MessageCallback, MessageContent, MessageData, ReactionCallback, ThreadData } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Discord chat client implementation using discord.js
|
|
6
6
|
*/
|
|
@@ -55,7 +55,7 @@ export declare class DiscordChatClient extends ChatClient implements ChannelOper
|
|
|
55
55
|
*/
|
|
56
56
|
updateMessage(messageId: string, channelId: string, content: MessageContent): Promise<void>;
|
|
57
57
|
/**
|
|
58
|
-
* Delete a message from a Discord channel
|
|
58
|
+
* Delete a message and its thread replies from a Discord channel
|
|
59
59
|
* @param messageId - ID of the message to delete
|
|
60
60
|
* @param channelId - Channel containing the message
|
|
61
61
|
*/
|
|
@@ -91,10 +91,10 @@ export declare class DiscordChatClient extends ChatClient implements ChannelOper
|
|
|
91
91
|
* @param messageId - Message to create thread from
|
|
92
92
|
* @param channelId - Channel containing the message
|
|
93
93
|
* @param name - Thread name
|
|
94
|
-
* @param
|
|
94
|
+
* @param autoArchiveDuration - Auto-archive duration in minutes (60, 1440, 4320, 10080)
|
|
95
95
|
* @returns Thread data
|
|
96
96
|
*/
|
|
97
|
-
startThread(messageId: string, channelId: string, name: string,
|
|
97
|
+
startThread(messageId: string, channelId: string, name: string, autoArchiveDuration?: number): Promise<ThreadData>;
|
|
98
98
|
/**
|
|
99
99
|
* Bulk delete messages in a Discord channel
|
|
100
100
|
* @param channelId - Channel to delete messages from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscordChatClient.d.ts","sourceRoot":"","sources":["../../src/discord/DiscordChatClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DiscordChatClient.d.ts","sourceRoot":"","sources":["../../src/discord/DiscordChatClient.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,WAAW,EAEX,gBAAgB,EAEhB,UAAU,EAEX,MAAM,aAAa,CAAC;AAGrB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAW,YAAW,iBAAiB;IAC5E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAA4C;IACrE,OAAO,CAAC,gBAAgB,CAA2C;IACnE,OAAO,CAAC,mBAAmB,CAAiC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EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWlD;;;;;;;OAOG;IACG,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,mBAAmB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,UAAU,CAAC;IA0BtB;;;;;OAKG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYnE;;;;OAIG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAyB1D;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAOtD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;CAM7C"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DiscordChatClient = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
|
-
const ChatClient_js_1 = require("../ChatClient.js");
|
|
6
5
|
const Channel_js_1 = require("../Channel.js");
|
|
6
|
+
const ChatClient_js_1 = require("../ChatClient.js");
|
|
7
7
|
const discord_js_2 = require("../outputters/discord.js");
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
9
|
/**
|
|
@@ -19,15 +19,13 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
19
19
|
guildId;
|
|
20
20
|
constructor(config) {
|
|
21
21
|
super(config);
|
|
22
|
-
this.token = config.token ?? process.env.DISCORD_TOKEN ??
|
|
23
|
-
this.guildId = config.guildId ?? process.env.DISCORD_GUILD_ID ??
|
|
22
|
+
this.token = config.token ?? process.env.DISCORD_TOKEN ?? "";
|
|
23
|
+
this.guildId = config.guildId ?? process.env.DISCORD_GUILD_ID ?? "";
|
|
24
24
|
const intents = [
|
|
25
25
|
discord_js_1.GatewayIntentBits.Guilds,
|
|
26
26
|
discord_js_1.GatewayIntentBits.GuildMessages,
|
|
27
27
|
discord_js_1.GatewayIntentBits.GuildMessageReactions,
|
|
28
|
-
|
|
29
|
-
// Enabled by default; set config.intents.messageContent = false to disable.
|
|
30
|
-
...(config.intents?.messageContent === false ? [] : [discord_js_1.GatewayIntentBits.MessageContent]),
|
|
28
|
+
discord_js_1.GatewayIntentBits.MessageContent,
|
|
31
29
|
];
|
|
32
30
|
this.client = new discord_js_1.Client({ intents });
|
|
33
31
|
this.setupReactionListener();
|
|
@@ -38,7 +36,7 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
38
36
|
* Set up the global reaction listener that routes events to channel-specific callbacks
|
|
39
37
|
*/
|
|
40
38
|
setupReactionListener() {
|
|
41
|
-
this.client.on(
|
|
39
|
+
this.client.on("messageReactionAdd", (reaction, user) => {
|
|
42
40
|
void (async () => {
|
|
43
41
|
// Handle partial reactions
|
|
44
42
|
if (reaction.partial) {
|
|
@@ -46,21 +44,24 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
46
44
|
await reaction.fetch();
|
|
47
45
|
}
|
|
48
46
|
catch (error) {
|
|
49
|
-
console.error(
|
|
47
|
+
console.error("Failed to fetch partial reaction:", error);
|
|
50
48
|
return;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
const channelId = reaction.message
|
|
51
|
+
const { channelId } = reaction.message;
|
|
54
52
|
const callbacks = this.reactionListeners.get(channelId);
|
|
55
53
|
if (!callbacks || callbacks.size === 0) {
|
|
56
54
|
return;
|
|
57
55
|
}
|
|
58
|
-
const reactionUser = {
|
|
56
|
+
const reactionUser = {
|
|
57
|
+
id: user.id,
|
|
58
|
+
username: user.username ?? undefined,
|
|
59
|
+
};
|
|
59
60
|
const event = {
|
|
60
|
-
emoji: reaction.emoji.name ?? reaction.emoji.id ??
|
|
61
|
+
emoji: reaction.emoji.name ?? reaction.emoji.id ?? "",
|
|
61
62
|
user: reactionUser,
|
|
62
63
|
messageId: reaction.message.id,
|
|
63
|
-
channelId
|
|
64
|
+
channelId,
|
|
64
65
|
timestamp: new Date(),
|
|
65
66
|
};
|
|
66
67
|
for (const callback of callbacks) {
|
|
@@ -68,7 +69,7 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
68
69
|
await callback(event);
|
|
69
70
|
}
|
|
70
71
|
catch (error) {
|
|
71
|
-
console.error(
|
|
72
|
+
console.error("Reaction callback error:", error);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
})();
|
|
@@ -78,24 +79,24 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
78
79
|
* Set up the global message listener that routes events to channel-specific callbacks
|
|
79
80
|
*/
|
|
80
81
|
setupMessageListener() {
|
|
81
|
-
this.client.on(
|
|
82
|
+
this.client.on("messageCreate", (message) => {
|
|
82
83
|
void (async () => {
|
|
83
84
|
// Ignore messages from the bot itself
|
|
84
85
|
if (message.author?.id === this.client.user?.id) {
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
const channelId = message
|
|
88
|
+
const { channelId } = message;
|
|
88
89
|
const callbacks = this.messageListeners.get(channelId);
|
|
89
90
|
if (!callbacks || callbacks.size === 0) {
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
const author = {
|
|
93
|
-
id: message.author?.id ??
|
|
94
|
+
id: message.author?.id ?? "",
|
|
94
95
|
username: message.author?.username ?? undefined,
|
|
95
96
|
};
|
|
96
97
|
const event = {
|
|
97
98
|
id: message.id,
|
|
98
|
-
content: message.content ??
|
|
99
|
+
content: message.content ?? "",
|
|
99
100
|
author,
|
|
100
101
|
channelId,
|
|
101
102
|
timestamp: message.createdAt,
|
|
@@ -105,7 +106,7 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
105
106
|
await callback(event);
|
|
106
107
|
}
|
|
107
108
|
catch (error) {
|
|
108
|
-
console.error(
|
|
109
|
+
console.error("Message callback error:", error);
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
})();
|
|
@@ -116,21 +117,21 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
116
117
|
* discord.js handles reconnection internally — these callbacks are for observability.
|
|
117
118
|
*/
|
|
118
119
|
setupConnectionResilience() {
|
|
119
|
-
this.client.on(
|
|
120
|
+
this.client.on("shardDisconnect", (_event, shardId) => {
|
|
120
121
|
const reason = `Shard ${String(shardId)} disconnected`;
|
|
121
122
|
for (const callback of this.disconnectCallbacks) {
|
|
122
123
|
void Promise.resolve(callback(reason)).catch((err) => {
|
|
123
|
-
console.error(
|
|
124
|
+
console.error("Disconnect callback error:", err);
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
127
|
});
|
|
127
|
-
this.client.on(
|
|
128
|
+
this.client.on("shardError", (error, shardId) => {
|
|
128
129
|
const wrappedError = error instanceof Error
|
|
129
130
|
? error
|
|
130
131
|
: new Error(`Shard ${String(shardId)} error: ${String(error)}`);
|
|
131
132
|
for (const callback of this.errorCallbacks) {
|
|
132
133
|
void Promise.resolve(callback(wrappedError)).catch((err) => {
|
|
133
|
-
console.error(
|
|
134
|
+
console.error("Error callback error:", err);
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
137
|
});
|
|
@@ -146,7 +147,7 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
146
147
|
if (!discordChannel || !(discordChannel instanceof discord_js_1.TextChannel)) {
|
|
147
148
|
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
148
149
|
}
|
|
149
|
-
return new Channel_js_1.Channel(channelId,
|
|
150
|
+
return new Channel_js_1.Channel(channelId, "discord", this);
|
|
150
151
|
}
|
|
151
152
|
/**
|
|
152
153
|
* Disconnect from Discord
|
|
@@ -183,25 +184,27 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
183
184
|
}
|
|
184
185
|
else {
|
|
185
186
|
// Fallback to empty content for documents with no visible blocks
|
|
186
|
-
messageOptions = { content:
|
|
187
|
+
messageOptions = { content: "\u200B" };
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
else {
|
|
190
191
|
messageOptions = { content };
|
|
191
192
|
}
|
|
192
193
|
// If threadTs is provided (non-empty), use it as a reply reference
|
|
193
|
-
if (options?.threadTs !== undefined && options.threadTs !==
|
|
194
|
+
if (options?.threadTs !== undefined && options.threadTs !== "") {
|
|
194
195
|
messageOptions.messageReference = { messageId: options.threadTs };
|
|
195
196
|
}
|
|
196
197
|
// Add file attachments
|
|
197
198
|
if (options?.files && options.files.length > 0) {
|
|
198
|
-
messageOptions.files = options.files.map((file) => new discord_js_1.AttachmentBuilder(typeof file.content ===
|
|
199
|
+
messageOptions.files = options.files.map((file) => new discord_js_1.AttachmentBuilder(typeof file.content === "string"
|
|
200
|
+
? Buffer.from(file.content)
|
|
201
|
+
: file.content, { name: file.name }));
|
|
199
202
|
}
|
|
200
203
|
const message = await channel.send(messageOptions);
|
|
201
204
|
return {
|
|
202
205
|
id: message.id,
|
|
203
|
-
channelId
|
|
204
|
-
platform:
|
|
206
|
+
channelId,
|
|
207
|
+
platform: "discord",
|
|
205
208
|
};
|
|
206
209
|
}
|
|
207
210
|
/**
|
|
@@ -226,7 +229,7 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
226
229
|
}
|
|
227
230
|
}
|
|
228
231
|
/**
|
|
229
|
-
* Delete a message from a Discord channel
|
|
232
|
+
* Delete a message and its thread replies from a Discord channel
|
|
230
233
|
* @param messageId - ID of the message to delete
|
|
231
234
|
* @param channelId - Channel containing the message
|
|
232
235
|
*/
|
|
@@ -236,6 +239,10 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
236
239
|
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
237
240
|
}
|
|
238
241
|
const message = await channel.messages.fetch(messageId);
|
|
242
|
+
// Delete the thread (and all its messages) if one exists
|
|
243
|
+
if (message.thread) {
|
|
244
|
+
await message.thread.delete();
|
|
245
|
+
}
|
|
239
246
|
await message.delete();
|
|
240
247
|
}
|
|
241
248
|
/**
|
|
@@ -312,10 +319,10 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
312
319
|
* @param messageId - Message to create thread from
|
|
313
320
|
* @param channelId - Channel containing the message
|
|
314
321
|
* @param name - Thread name
|
|
315
|
-
* @param
|
|
322
|
+
* @param autoArchiveDuration - Auto-archive duration in minutes (60, 1440, 4320, 10080)
|
|
316
323
|
* @returns Thread data
|
|
317
324
|
*/
|
|
318
|
-
async startThread(messageId, channelId, name,
|
|
325
|
+
async startThread(messageId, channelId, name, autoArchiveDuration) {
|
|
319
326
|
const channel = await this.client.channels.fetch(channelId);
|
|
320
327
|
if (!channel || !(channel instanceof discord_js_1.TextChannel)) {
|
|
321
328
|
throw new Error(`Channel ${channelId} not found or is not a text channel`);
|
|
@@ -323,12 +330,12 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
323
330
|
const message = await channel.messages.fetch(messageId);
|
|
324
331
|
const thread = await message.startThread({
|
|
325
332
|
name,
|
|
326
|
-
autoArchiveDuration:
|
|
333
|
+
autoArchiveDuration: autoArchiveDuration,
|
|
327
334
|
});
|
|
328
335
|
return {
|
|
329
336
|
id: thread.id,
|
|
330
|
-
channelId
|
|
331
|
-
platform:
|
|
337
|
+
channelId,
|
|
338
|
+
platform: "discord",
|
|
332
339
|
};
|
|
333
340
|
}
|
|
334
341
|
/**
|
|
@@ -359,12 +366,12 @@ class DiscordChatClient extends ChatClient_js_1.ChatClient {
|
|
|
359
366
|
// Fetch active threads
|
|
360
367
|
const activeThreads = await channel.threads.fetchActive();
|
|
361
368
|
for (const [threadId] of activeThreads.threads) {
|
|
362
|
-
threads.push({ id: threadId, channelId, platform:
|
|
369
|
+
threads.push({ id: threadId, channelId, platform: "discord" });
|
|
363
370
|
}
|
|
364
371
|
// Fetch archived threads
|
|
365
372
|
const archivedThreads = await channel.threads.fetchArchived();
|
|
366
373
|
for (const [threadId] of archivedThreads.threads) {
|
|
367
|
-
threads.push({ id: threadId, channelId, platform:
|
|
374
|
+
threads.push({ id: threadId, channelId, platform: "discord" });
|
|
368
375
|
}
|
|
369
376
|
return threads;
|
|
370
377
|
}
|