@effect/chat-discord 0.0.0 → 4.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/AGENTS.md +434 -0
- package/CLAUDE.md +434 -0
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +52 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +7 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +163 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +111 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/40_sql/10_basics.ts +175 -0
- package/ai-docs/src/40_sql/index.md +6 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +118 -0
- package/ai-docs/src/51_http-server/20_testing.ts +100 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +107 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +21 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +37 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +80 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +183 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/52_graphql/10_basics.ts +117 -0
- package/ai-docs/src/52_graphql/20_testing.ts +45 -0
- package/ai-docs/src/52_graphql/30_batching.ts +118 -0
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
- package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
- package/ai-docs/src/52_graphql/index.md +6 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +162 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +28 -0
- package/dist/DiscordChat.d.ts +530 -0
- package/dist/DiscordChat.d.ts.map +1 -0
- package/dist/DiscordChat.js +574 -0
- package/dist/DiscordChat.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/adapter.d.ts +2 -0
- package/dist/internal/adapter.d.ts.map +1 -0
- package/dist/internal/adapter.js +492 -0
- package/dist/internal/adapter.js.map +1 -0
- package/dist/internal/errors.d.ts +2 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +236 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/interactions.d.ts +2 -0
- package/dist/internal/interactions.d.ts.map +1 -0
- package/dist/internal/interactions.js +490 -0
- package/dist/internal/interactions.js.map +1 -0
- package/dist/internal/length.d.ts +2 -0
- package/dist/internal/length.d.ts.map +1 -0
- package/dist/internal/length.js +31 -0
- package/dist/internal/length.js.map +1 -0
- package/dist/internal/mentions.d.ts +2 -0
- package/dist/internal/mentions.d.ts.map +1 -0
- package/dist/internal/mentions.js +93 -0
- package/dist/internal/mentions.js.map +1 -0
- package/dist/internal/normalize.d.ts +2 -0
- package/dist/internal/normalize.d.ts.map +1 -0
- package/dist/internal/normalize.js +322 -0
- package/dist/internal/normalize.js.map +1 -0
- package/dist/internal/options.d.ts +2 -0
- package/dist/internal/options.d.ts.map +1 -0
- package/dist/internal/options.js +25 -0
- package/dist/internal/options.js.map +1 -0
- package/package.json +63 -1
- package/src/DiscordChat.ts +703 -0
- package/src/index.ts +12 -0
- package/src/internal/adapter.ts +653 -0
- package/src/internal/errors.ts +184 -0
- package/src/internal/interactions.ts +451 -0
- package/src/internal/length.ts +33 -0
- package/src/internal/mentions.ts +101 -0
- package/src/internal/normalize.ts +363 -0
- package/src/internal/options.ts +29 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import * as ChatThread from "effect/chat/ChatThread";
|
|
2
|
+
import * as DateTime from "effect/DateTime";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Predicate from "effect/Predicate";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Mentions from "./mentions.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const platform = "discord";
|
|
9
|
+
/** @internal */
|
|
10
|
+
export const thread = channelId => ChatThread.make(platform, channelId);
|
|
11
|
+
/**
|
|
12
|
+
* The message types that are a message: `DEFAULT`, `REPLY`,
|
|
13
|
+
* `CHAT_INPUT_COMMAND` and `CONTEXT_MENU_COMMAND`. Inbound and history
|
|
14
|
+
* both read it, and a type Discord adds later stays out.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export const messageTypes = /*#__PURE__*/new Set([0, 19, 20, 23]);
|
|
19
|
+
/** @internal */
|
|
20
|
+
export const REPLY = 19;
|
|
21
|
+
/**
|
|
22
|
+
* The thread starter placeholder in a thread started from a message.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const THREAD_STARTER_MESSAGE = 21;
|
|
27
|
+
/**
|
|
28
|
+
* Discord's channel type as a `kind`: 10, 11 and 12 are threads, 1 and 3
|
|
29
|
+
* directs, everything else a channel, unknown types included.
|
|
30
|
+
*
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export const kindOf = channelType => channelType === 10 || channelType === 11 || channelType === 12 ? "thread" : channelType === 1 || channelType === 3 ? "direct" : "channel";
|
|
34
|
+
/** @internal */
|
|
35
|
+
export const isThreadType = channelType => kindOf(channelType) === "thread";
|
|
36
|
+
/**
|
|
37
|
+
* A field Discord may leave out or send as `null`.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export const optional = schema => Schema.optionalKey(Schema.NullOr(schema));
|
|
42
|
+
/** @internal */
|
|
43
|
+
export const UserFields = /*#__PURE__*/Schema.Struct({
|
|
44
|
+
id: Schema.String,
|
|
45
|
+
username: /*#__PURE__*/optional(Schema.String),
|
|
46
|
+
global_name: /*#__PURE__*/optional(Schema.String),
|
|
47
|
+
bot: /*#__PURE__*/optional(Schema.Boolean)
|
|
48
|
+
});
|
|
49
|
+
const MemberFields = /*#__PURE__*/Schema.Struct({
|
|
50
|
+
nick: /*#__PURE__*/optional(Schema.String),
|
|
51
|
+
roles: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(Schema.String))
|
|
52
|
+
});
|
|
53
|
+
const AttachmentFields = /*#__PURE__*/Schema.Struct({
|
|
54
|
+
id: Schema.String,
|
|
55
|
+
filename: /*#__PURE__*/optional(Schema.String),
|
|
56
|
+
content_type: /*#__PURE__*/optional(Schema.String),
|
|
57
|
+
size: /*#__PURE__*/optional(Schema.Int)
|
|
58
|
+
});
|
|
59
|
+
const ReferenceFields = /*#__PURE__*/Schema.Struct({
|
|
60
|
+
type: /*#__PURE__*/optional(Schema.Number),
|
|
61
|
+
message_id: /*#__PURE__*/optional(Schema.String),
|
|
62
|
+
channel_id: /*#__PURE__*/optional(Schema.String)
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* What the normaliser reads from a message.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export const MessageFields = /*#__PURE__*/Schema.Struct({
|
|
70
|
+
id: Schema.String,
|
|
71
|
+
channel_id: Schema.String,
|
|
72
|
+
type: Schema.Number,
|
|
73
|
+
content: /*#__PURE__*/optional(Schema.String),
|
|
74
|
+
timestamp: Schema.DateTimeUtcFromString,
|
|
75
|
+
author: UserFields,
|
|
76
|
+
webhook_id: /*#__PURE__*/optional(Schema.String),
|
|
77
|
+
guild_id: /*#__PURE__*/optional(Schema.String),
|
|
78
|
+
channel_type: /*#__PURE__*/optional(Schema.Number),
|
|
79
|
+
member: /*#__PURE__*/optional(MemberFields),
|
|
80
|
+
mentions: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(/*#__PURE__*/Schema.Struct({
|
|
81
|
+
id: Schema.String
|
|
82
|
+
}))),
|
|
83
|
+
mention_roles: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(Schema.String)),
|
|
84
|
+
mention_everyone: /*#__PURE__*/optional(Schema.Boolean),
|
|
85
|
+
attachments: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(AttachmentFields)),
|
|
86
|
+
message_reference: /*#__PURE__*/optional(ReferenceFields),
|
|
87
|
+
referenced_message: /*#__PURE__*/optional(/*#__PURE__*/Schema.Struct({
|
|
88
|
+
author: /*#__PURE__*/optional(/*#__PURE__*/Schema.Struct({
|
|
89
|
+
id: Schema.String
|
|
90
|
+
}))
|
|
91
|
+
}))
|
|
92
|
+
});
|
|
93
|
+
const ReactionFields = /*#__PURE__*/Schema.Struct({
|
|
94
|
+
user_id: Schema.String,
|
|
95
|
+
channel_id: Schema.String,
|
|
96
|
+
message_id: Schema.String,
|
|
97
|
+
guild_id: /*#__PURE__*/optional(Schema.String),
|
|
98
|
+
message_author_id: /*#__PURE__*/optional(Schema.String),
|
|
99
|
+
member: /*#__PURE__*/optional(MemberFields),
|
|
100
|
+
emoji: /*#__PURE__*/Schema.Struct({
|
|
101
|
+
id: /*#__PURE__*/optional(Schema.String),
|
|
102
|
+
name: /*#__PURE__*/optional(Schema.String)
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
const decodeMessage = /*#__PURE__*/Schema.decodeUnknownOption(MessageFields);
|
|
106
|
+
const decodeReaction = /*#__PURE__*/Schema.decodeUnknownOption(ReactionFields);
|
|
107
|
+
/** @internal */
|
|
108
|
+
export const decodeMessageFields = raw => Option.getOrUndefined(decodeMessage(raw));
|
|
109
|
+
/**
|
|
110
|
+
* An attachment's id: the message's id and the attachment's, since a download reads the message again.
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export const attachmentId = (messageId, id) => `${messageId}/${id}`;
|
|
115
|
+
/** @internal */
|
|
116
|
+
export const parseAttachmentId = id => {
|
|
117
|
+
const parts = id.split("/");
|
|
118
|
+
return parts.length === 2 && parts[0] !== "" && parts[1] !== "" ? {
|
|
119
|
+
messageId: parts[0],
|
|
120
|
+
attachmentId: parts[1]
|
|
121
|
+
} : undefined;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* The mentions in `content`: a token outside code that Discord says
|
|
125
|
+
* resolved, through `mentions` for a user, `mention_roles` for a role and
|
|
126
|
+
* `mention_everyone` for `@everyone` and `@here`. A channel token has no
|
|
127
|
+
* confirming field, so the token alone counts.
|
|
128
|
+
*/
|
|
129
|
+
const mentionsOf = (fields, text, botUserId) => {
|
|
130
|
+
const users = new Set((fields.mentions ?? []).map(user => user.id));
|
|
131
|
+
const roles = new Set(fields.mention_roles ?? []);
|
|
132
|
+
const everyone = fields.mention_everyone === true;
|
|
133
|
+
const found = [];
|
|
134
|
+
for (const token of Mentions.tokens(text)) {
|
|
135
|
+
const resolved = token.kind === "user" ? users.has(token.id) : token.kind === "role" ? roles.has(token.id) : token.kind === "broadcast" ? everyone : true;
|
|
136
|
+
if (!resolved) continue;
|
|
137
|
+
found.push({
|
|
138
|
+
kind: token.kind,
|
|
139
|
+
id: token.id,
|
|
140
|
+
start: token.start,
|
|
141
|
+
end: token.end,
|
|
142
|
+
isSelf: token.kind === "user" && token.id === botUserId
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return found;
|
|
146
|
+
};
|
|
147
|
+
/** @internal */
|
|
148
|
+
export const nonEmpty = value => value === null || value === undefined || value === "" ? undefined : value;
|
|
149
|
+
/**
|
|
150
|
+
* A message payload, from the gateway or REST, as a `ChatMessage`.
|
|
151
|
+
* `undefined` for a type that is not a message.
|
|
152
|
+
*
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
export const message = (raw, fields, context) => {
|
|
156
|
+
if (!messageTypes.has(fields.type)) return undefined;
|
|
157
|
+
const text = fields.content ?? "";
|
|
158
|
+
const webhook = nonEmpty(fields.webhook_id);
|
|
159
|
+
const name = webhook === undefined ? nonEmpty(fields.member?.nick) ?? nonEmpty(fields.author.global_name) ?? nonEmpty(fields.author.username) : nonEmpty(fields.author.username);
|
|
160
|
+
const reference = fields.message_reference;
|
|
161
|
+
const replyId = fields.type === REPLY && (reference?.type ?? 0) === 0 ? nonEmpty(reference?.message_id) : undefined;
|
|
162
|
+
const replyAuthor = fields.referenced_message?.author?.id;
|
|
163
|
+
const attachments = (fields.attachments ?? []).map(attachment => {
|
|
164
|
+
const name = nonEmpty(attachment.filename);
|
|
165
|
+
const contentType = nonEmpty(attachment.content_type);
|
|
166
|
+
return {
|
|
167
|
+
id: attachmentId(fields.id, attachment.id),
|
|
168
|
+
...(name === undefined ? {} : {
|
|
169
|
+
name
|
|
170
|
+
}),
|
|
171
|
+
...(contentType === undefined ? {} : {
|
|
172
|
+
contentType
|
|
173
|
+
}),
|
|
174
|
+
...(typeof attachment.size === "number" ? {
|
|
175
|
+
size: attachment.size
|
|
176
|
+
} : {})
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
id: fields.id,
|
|
181
|
+
thread: thread(fields.channel_id),
|
|
182
|
+
author: {
|
|
183
|
+
id: webhook ?? fields.author.id,
|
|
184
|
+
...(name === undefined ? {} : {
|
|
185
|
+
name
|
|
186
|
+
}),
|
|
187
|
+
isBot: webhook !== undefined || fields.author.bot === true,
|
|
188
|
+
isSelf: webhook === undefined && fields.author.id === context.botUserId
|
|
189
|
+
},
|
|
190
|
+
text,
|
|
191
|
+
mentions: mentionsOf(fields, text, context.botUserId),
|
|
192
|
+
...(replyId === undefined ? {} : {
|
|
193
|
+
replyTo: {
|
|
194
|
+
messageId: replyId,
|
|
195
|
+
...(replyAuthor === undefined ? {} : {
|
|
196
|
+
authorId: replyAuthor,
|
|
197
|
+
isSelf: replyAuthor === context.botUserId
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
attachments,
|
|
202
|
+
timestamp: fields.timestamp,
|
|
203
|
+
raw
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* A reaction's emoji: the Unicode emoji, or `custom:{name}` for a guild's own.
|
|
208
|
+
*
|
|
209
|
+
* @internal
|
|
210
|
+
*/
|
|
211
|
+
export const emojiOf = emoji => nonEmpty(emoji.id) === undefined ? nonEmpty(emoji.name) : `custom:${nonEmpty(emoji.name) ?? emoji.id}`;
|
|
212
|
+
const none = {
|
|
213
|
+
_tag: "Events",
|
|
214
|
+
events: []
|
|
215
|
+
};
|
|
216
|
+
const events = events => ({
|
|
217
|
+
_tag: "Events",
|
|
218
|
+
events
|
|
219
|
+
});
|
|
220
|
+
/** @internal */
|
|
221
|
+
export const normalize = (dispatch, context) => {
|
|
222
|
+
const raw = dispatch.d;
|
|
223
|
+
switch (dispatch.t) {
|
|
224
|
+
case "MESSAGE_CREATE":
|
|
225
|
+
{
|
|
226
|
+
const fields = decodeMessageFields(raw);
|
|
227
|
+
if (fields === undefined || !messageTypes.has(fields.type)) return none;
|
|
228
|
+
const channelType = fields.channel_type ?? context.channelType;
|
|
229
|
+
if (channelType === undefined) return {
|
|
230
|
+
_tag: "MissingChannelType",
|
|
231
|
+
channelId: fields.channel_id
|
|
232
|
+
};
|
|
233
|
+
const created = message(raw, fields, context);
|
|
234
|
+
return created === undefined ? none : events([{
|
|
235
|
+
_tag: "MessageCreated",
|
|
236
|
+
thread: created.thread,
|
|
237
|
+
kind: kindOf(channelType),
|
|
238
|
+
message: created,
|
|
239
|
+
raw
|
|
240
|
+
}]);
|
|
241
|
+
}
|
|
242
|
+
case "MESSAGE_REACTION_ADD":
|
|
243
|
+
case "MESSAGE_REACTION_REMOVE":
|
|
244
|
+
{
|
|
245
|
+
const fields = Option.getOrUndefined(decodeReaction(raw));
|
|
246
|
+
const emoji = fields === undefined ? undefined : emojiOf(fields.emoji);
|
|
247
|
+
if (fields === undefined || emoji === undefined) return none;
|
|
248
|
+
const authorId = nonEmpty(fields.message_author_id);
|
|
249
|
+
const reaction = {
|
|
250
|
+
thread: thread(fields.channel_id),
|
|
251
|
+
messageId: fields.message_id,
|
|
252
|
+
...(authorId === undefined ? {} : {
|
|
253
|
+
messageAuthorId: authorId
|
|
254
|
+
}),
|
|
255
|
+
userId: fields.user_id,
|
|
256
|
+
emoji,
|
|
257
|
+
raw
|
|
258
|
+
};
|
|
259
|
+
return events([dispatch.t === "MESSAGE_REACTION_ADD" ? {
|
|
260
|
+
_tag: "ReactionAdded",
|
|
261
|
+
...reaction
|
|
262
|
+
} : {
|
|
263
|
+
_tag: "ReactionRemoved",
|
|
264
|
+
...reaction
|
|
265
|
+
}]);
|
|
266
|
+
}
|
|
267
|
+
default:
|
|
268
|
+
return none;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
/** @internal */
|
|
272
|
+
export const guildIdOf = raw => Predicate.isObject(raw) && typeof raw.guild_id === "string" && raw.guild_id !== "" ? Option.some(raw.guild_id) : Option.none();
|
|
273
|
+
/** @internal */
|
|
274
|
+
export const memberOf = raw => Option.flatMap(guildIdOf(raw), guildId => {
|
|
275
|
+
const member = raw.member;
|
|
276
|
+
if (!Predicate.isObject(member)) return Option.none();
|
|
277
|
+
const roles = Array.isArray(member.roles) ? member.roles.filter(role => typeof role === "string") : [];
|
|
278
|
+
const nick = typeof member.nick === "string" && member.nick !== "" ? member.nick : undefined;
|
|
279
|
+
return Option.some({
|
|
280
|
+
guildId,
|
|
281
|
+
roles,
|
|
282
|
+
...(nick === undefined ? {} : {
|
|
283
|
+
nick
|
|
284
|
+
})
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
/** The start of Discord's snowflake clock, in Unix milliseconds. */
|
|
288
|
+
const discordEpoch = 1_420_070_400_000;
|
|
289
|
+
/**
|
|
290
|
+
* When a snowflake was made, in Unix milliseconds. Throws for an id that is
|
|
291
|
+
* not a number.
|
|
292
|
+
*
|
|
293
|
+
* @internal
|
|
294
|
+
*/
|
|
295
|
+
export const snowflakeMillis = id => Number(BigInt(id) >> BigInt(22)) + discordEpoch;
|
|
296
|
+
/**
|
|
297
|
+
* When a snowflake was made.
|
|
298
|
+
*
|
|
299
|
+
* @internal
|
|
300
|
+
*/
|
|
301
|
+
export const snowflakeTime = id => {
|
|
302
|
+
try {
|
|
303
|
+
return DateTime.makeUnsafe(snowflakeMillis(id));
|
|
304
|
+
} catch {
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Orders two snowflakes.
|
|
310
|
+
*
|
|
311
|
+
* @internal
|
|
312
|
+
*/
|
|
313
|
+
export const compareIds = (a, b) => {
|
|
314
|
+
try {
|
|
315
|
+
const x = BigInt(a);
|
|
316
|
+
const y = BigInt(b);
|
|
317
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
318
|
+
} catch {
|
|
319
|
+
return a.length !== b.length ? a.length - b.length : a < b ? -1 : a > b ? 1 : 0;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","names":[],"sources":["../../src/internal/normalize.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAO,KAAK,UAAU,MAAM,wBAAwB;AACpD,OAAO,KAAK,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,QAAQ,MAAM,eAAe;AAEzC;AACA,OAAO,MAAM,QAAQ,GAAG,SAAS;AAEjC;AACA,OAAO,MAAM,MAAM,GAAI,SAAiB,IAA4B,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;AAExG;;;;;;;AAOA,OAAO,MAAM,YAAY,gBAAwB,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAEzE;AACA,OAAO,MAAM,KAAK,GAAG,EAAE;AAEvB;;;;;AAKA,OAAO,MAAM,sBAAsB,GAAG,EAAE;AAExC;;;;;;AAMA,OAAO,MAAM,MAAM,GAAI,WAAmB,IACxC,WAAW,KAAK,EAAE,IAAI,WAAW,KAAK,EAAE,IAAI,WAAW,KAAK,EAAE,GAC1D,QAAQ,GACR,WAAW,KAAK,CAAC,IAAI,WAAW,KAAK,CAAC,GACtC,QAAQ,GACR,SAAS;AAEf;AACA,OAAO,MAAM,YAAY,GAAI,WAAmB,IAAc,MAAM,CAAC,WAAW,CAAC,KAAK,QAAQ;AAE9F;;;;;AAKA,OAAO,MAAM,Q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AO,MAAM,eAAe,GAAI,EAAU,IAAa,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY;AAEtG;;;;;AAKA,OAAO,MAAM,aAAa,GAAI,EAAU,IAA8B;EACpE,IAAI;IACF,OAAO,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;EACjD,CAAC,CAAC,MAAM;IACN,OAAO,SAAS;EAClB;AACF,CAAC;AAED;;;;;AAKA,OAAO,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,KAAY;EACzD,IAAI;IACF,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;EACnC,CAAC,CAAC,MAAM;IACN,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;EACjF;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/internal/options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export const CurrentPostOptions = /*#__PURE__*/Context.Reference("@effect/chat-discord/CurrentPostOptions", {
|
|
4
|
+
defaultValue: () => ({})
|
|
5
|
+
});
|
|
6
|
+
/** Discord's `SUPPRESS_EMBEDS` message flag. */
|
|
7
|
+
const SUPPRESS_EMBEDS = 1 << 2;
|
|
8
|
+
/**
|
|
9
|
+
* The `allowed_mentions` for a write: nobody, unless `notify` says otherwise.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export const allowedMentions = notify => ({
|
|
14
|
+
parse: notify?.everyone === true ? ["everyone"] : [],
|
|
15
|
+
users: notify?.users ?? [],
|
|
16
|
+
roles: notify?.roles ?? [],
|
|
17
|
+
replied_user: notify?.repliedUser === true
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* The flags for a write.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const flags = options => options.suppressEmbeds === false ? 0 : SUPPRESS_EMBEDS;
|
|
25
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","names":[],"sources":["../../src/internal/options.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB;AAGzC;AACA,OAAO,MAAM,kBAAkB,gBAAG,OAAO,CAAC,SAAS,CAAqB,yCAAyC,EAAE;EACjH,YAAY,EAAE,OAAO,EAAE;CACxB,CAAC;AAEF;AACA,MAAM,eAAe,GAAG,CAAC,IAAI,CAAC;AAE9B;;;;;AAKA,OAAO,MAAM,eAAe,GAAI,MAAoC,KAAM;EACxE,KAAK,EAAE,MAAM,EAAE,QAAQ,KAAK,IAAI,GAAG,CAAC,UAAmB,CAAC,GAAG,EAAE;EAC7D,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE;EAC1B,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE;EAC1B,YAAY,EAAE,MAAM,EAAE,WAAW,KAAK;CACvC,CAAC;AAEF;;;;;AAKA,OAAO,MAAM,KAAK,GAAI,OAA2B,IAAa,OAAO,CAAC,cAAc,KAAK,KAAK,GAAG,CAAC,GAAG,eAAe","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1 +1,63 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@effect/chat-discord",
|
|
3
|
+
"version": "4.1.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "The Discord adapter for effect/chat",
|
|
7
|
+
"homepage": "https://effect.website",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Effect-TS/effect.git",
|
|
11
|
+
"directory": "packages/chat/discord"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Effect-TS/effect/issues"
|
|
15
|
+
},
|
|
16
|
+
"tags": [
|
|
17
|
+
"typescript",
|
|
18
|
+
"chat",
|
|
19
|
+
"discord"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"typescript",
|
|
23
|
+
"chat",
|
|
24
|
+
"discord"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": [],
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./*": "./dist/*.js",
|
|
31
|
+
"./internal/*": null,
|
|
32
|
+
"./index": null,
|
|
33
|
+
"./*/index": null
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"src/**/*.ts",
|
|
37
|
+
"dist/**/*.js",
|
|
38
|
+
"dist/**/*.js.map",
|
|
39
|
+
"dist/**/*.d.ts",
|
|
40
|
+
"dist/**/*.d.ts.map",
|
|
41
|
+
"AGENTS.md",
|
|
42
|
+
"CLAUDE.md",
|
|
43
|
+
"ai-docs/**/*"
|
|
44
|
+
],
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"provenance": true
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"dfx": "^1.1.1",
|
|
51
|
+
"effect": "^4.1.6"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"dfx": "^1.1.1",
|
|
55
|
+
"effect": "^4.1.6"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"codegen": "effect-utils codegen",
|
|
59
|
+
"build": "tsc -b tsconfig.json && pnpm babel",
|
|
60
|
+
"babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
|
|
61
|
+
"check": "tsc -b tsconfig.json"
|
|
62
|
+
}
|
|
63
|
+
}
|