@effect/chat-discord 0.0.0 → 4.1.5
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,490 @@
|
|
|
1
|
+
import { InvalidRequest, TooLarge } from "effect/chat/ChatError";
|
|
2
|
+
import * as ChatInteraction from "effect/chat/ChatInteraction";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { codePoints, cut, messageLength } from "./length.js";
|
|
6
|
+
import * as Normalize from "./normalize.js";
|
|
7
|
+
/**
|
|
8
|
+
* The one character between an id and its value in a `custom_id`, for a
|
|
9
|
+
* button and for a modal's metadata. An id may not hold it, so the first one
|
|
10
|
+
* in a `custom_id` is the join.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export const join = "\u241F";
|
|
15
|
+
/** @internal */
|
|
16
|
+
export const limits = {
|
|
17
|
+
actionsPerMessage: 25,
|
|
18
|
+
actionDataLength: 99,
|
|
19
|
+
modalMetadataLength: 99,
|
|
20
|
+
modalFields: 5
|
|
21
|
+
};
|
|
22
|
+
/** Discord's limits on rows, a row's buttons, a modal's title and an input's label. */
|
|
23
|
+
const rowsPerMessage = 5;
|
|
24
|
+
const buttonsPerRow = 5;
|
|
25
|
+
const titleLength = 45;
|
|
26
|
+
const labelLength = 45;
|
|
27
|
+
/** Discord's interaction callback types. */
|
|
28
|
+
const DEFERRED_UPDATE_MESSAGE = 6;
|
|
29
|
+
const CHANNEL_MESSAGE_WITH_SOURCE = 4;
|
|
30
|
+
const DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5;
|
|
31
|
+
const MODAL = 9;
|
|
32
|
+
const EPHEMERAL = 1 << 6;
|
|
33
|
+
/** The ephemeral flag for a private answer, none otherwise. */
|
|
34
|
+
const visibilityFlags = visibility => visibility === "ephemeral" ? EPHEMERAL : 0;
|
|
35
|
+
/** `custom_id` for an id and an optional value. */
|
|
36
|
+
const customId = (id, value) => value === undefined ? id : id + join + value;
|
|
37
|
+
/** An id and its value from a `custom_id`, split at the first join. */
|
|
38
|
+
const splitCustomId = customId => {
|
|
39
|
+
const at = customId.indexOf(join);
|
|
40
|
+
return at === -1 ? {
|
|
41
|
+
id: customId
|
|
42
|
+
} : {
|
|
43
|
+
id: customId.slice(0, at),
|
|
44
|
+
value: customId.slice(at + 1)
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const buttonStyle = style => style === "primary" ? 1 : style === "danger" ? 4 : 2;
|
|
48
|
+
/**
|
|
49
|
+
* A message's elements as action rows, or why they can't go: five buttons to
|
|
50
|
+
* a row and a select alone in its row, in the order given, up to five rows.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export const rows = actions => {
|
|
55
|
+
if (actions.length > limits.actionsPerMessage) return new TooLarge({
|
|
56
|
+
detail: "too_many_actions"
|
|
57
|
+
});
|
|
58
|
+
const out = [];
|
|
59
|
+
let open;
|
|
60
|
+
for (const action of actions) {
|
|
61
|
+
if (action._tag === "Select") {
|
|
62
|
+
const id = codePoints(action.id);
|
|
63
|
+
if (action.options.some(option => id + codePoints(option.value) > limits.actionDataLength)) {
|
|
64
|
+
return new TooLarge({
|
|
65
|
+
detail: "action_data_too_long"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
open = undefined;
|
|
69
|
+
out.push({
|
|
70
|
+
type: 1,
|
|
71
|
+
components: [{
|
|
72
|
+
type: 3,
|
|
73
|
+
custom_id: action.id,
|
|
74
|
+
...(action.placeholder === undefined ? {} : {
|
|
75
|
+
placeholder: action.placeholder
|
|
76
|
+
}),
|
|
77
|
+
options: action.options.map(option => ({
|
|
78
|
+
label: option.label,
|
|
79
|
+
value: option.value,
|
|
80
|
+
...(option.value === action.selected ? {
|
|
81
|
+
default: true
|
|
82
|
+
} : {})
|
|
83
|
+
})),
|
|
84
|
+
min_values: 1,
|
|
85
|
+
max_values: 1
|
|
86
|
+
}]
|
|
87
|
+
});
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
let button;
|
|
91
|
+
if (action._tag === "LinkButton") {
|
|
92
|
+
button = {
|
|
93
|
+
type: 2,
|
|
94
|
+
style: 5,
|
|
95
|
+
label: action.label,
|
|
96
|
+
url: action.url
|
|
97
|
+
};
|
|
98
|
+
} else {
|
|
99
|
+
if (action.id.includes(join)) return new InvalidRequest({
|
|
100
|
+
detail: "invalid_action_id"
|
|
101
|
+
});
|
|
102
|
+
if (codePoints(action.id) + codePoints(action.value ?? "") > limits.actionDataLength) {
|
|
103
|
+
return new TooLarge({
|
|
104
|
+
detail: "action_data_too_long"
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
button = {
|
|
108
|
+
type: 2,
|
|
109
|
+
style: buttonStyle(action.style),
|
|
110
|
+
label: action.label,
|
|
111
|
+
custom_id: customId(action.id, action.value)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (open === undefined || open.length === buttonsPerRow) {
|
|
115
|
+
open = [button];
|
|
116
|
+
out.push({
|
|
117
|
+
type: 1,
|
|
118
|
+
components: open
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
open.push(button);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return out.length > rowsPerMessage ? new TooLarge({
|
|
125
|
+
detail: "too_many_actions"
|
|
126
|
+
}) : out;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Discord's Markdown escape for any ASCII punctuation, so a modal's text
|
|
130
|
+
* shows as written.
|
|
131
|
+
*/
|
|
132
|
+
const plain = text => text.replace(/[!-/:-@[-`{-~]/g, "\\$&");
|
|
133
|
+
/**
|
|
134
|
+
* The callback data that opens `modal`, or why it can't open. Inputs are
|
|
135
|
+
* Label components around a text input or a string select, and a `Text` is
|
|
136
|
+
* a text display. Discord has no submit label, so `submitLabel` is not sent.
|
|
137
|
+
*
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
export const modalData = modal => {
|
|
141
|
+
if (modal.id.includes(join)) return new InvalidRequest({
|
|
142
|
+
detail: "invalid_modal_id"
|
|
143
|
+
});
|
|
144
|
+
if (codePoints(modal.id) + codePoints(modal.metadata ?? "") > limits.modalMetadataLength) {
|
|
145
|
+
return new TooLarge({
|
|
146
|
+
detail: "modal_metadata_too_long"
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (modal.elements.length > limits.modalFields) return new TooLarge({
|
|
150
|
+
detail: "too_many_fields"
|
|
151
|
+
});
|
|
152
|
+
if (codePoints(modal.title) > titleLength) return new TooLarge({
|
|
153
|
+
detail: "title_too_long"
|
|
154
|
+
});
|
|
155
|
+
const components = [];
|
|
156
|
+
for (const element of modal.elements) {
|
|
157
|
+
if (element._tag === "Text") {
|
|
158
|
+
components.push({
|
|
159
|
+
type: 10,
|
|
160
|
+
content: plain(element.text)
|
|
161
|
+
});
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (codePoints(element.label) > labelLength) return new TooLarge({
|
|
165
|
+
detail: "label_too_long"
|
|
166
|
+
});
|
|
167
|
+
const required = element.optional !== true;
|
|
168
|
+
components.push({
|
|
169
|
+
type: 18,
|
|
170
|
+
label: element.label,
|
|
171
|
+
component: element._tag === "TextInput" ? {
|
|
172
|
+
type: 4,
|
|
173
|
+
custom_id: element.id,
|
|
174
|
+
style: element.multiline === true ? 2 : 1,
|
|
175
|
+
required,
|
|
176
|
+
...(element.placeholder === undefined ? {} : {
|
|
177
|
+
placeholder: element.placeholder
|
|
178
|
+
}),
|
|
179
|
+
...(element.initial === undefined ? {} : {
|
|
180
|
+
value: element.initial
|
|
181
|
+
}),
|
|
182
|
+
...(element.minLength === undefined ? {} : {
|
|
183
|
+
min_length: element.minLength
|
|
184
|
+
}),
|
|
185
|
+
...(element.maxLength === undefined ? {} : {
|
|
186
|
+
max_length: element.maxLength
|
|
187
|
+
})
|
|
188
|
+
} : {
|
|
189
|
+
type: 3,
|
|
190
|
+
custom_id: element.id,
|
|
191
|
+
required,
|
|
192
|
+
min_values: required ? 1 : 0,
|
|
193
|
+
max_values: 1,
|
|
194
|
+
...(element.placeholder === undefined ? {} : {
|
|
195
|
+
placeholder: element.placeholder
|
|
196
|
+
}),
|
|
197
|
+
options: element.options.map(option => ({
|
|
198
|
+
label: option.label,
|
|
199
|
+
value: option.value,
|
|
200
|
+
...(option.value === element.initial ? {
|
|
201
|
+
default: true
|
|
202
|
+
} : {})
|
|
203
|
+
}))
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
custom_id: customId(modal.id, modal.metadata),
|
|
209
|
+
title: modal.title,
|
|
210
|
+
components
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
/** @internal */
|
|
214
|
+
export const ackCallback = {
|
|
215
|
+
type: DEFERRED_UPDATE_MESSAGE
|
|
216
|
+
};
|
|
217
|
+
/** @internal */
|
|
218
|
+
export const modalCallback = data => ({
|
|
219
|
+
type: MODAL,
|
|
220
|
+
data
|
|
221
|
+
});
|
|
222
|
+
/**
|
|
223
|
+
* The answer to an `errors` reply: a private message listing each one, as
|
|
224
|
+
* plain text, cut to fit one message. The modal closes.
|
|
225
|
+
*
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
export const errorsCallback = errors => ({
|
|
229
|
+
type: CHANNEL_MESSAGE_WITH_SOURCE,
|
|
230
|
+
data: {
|
|
231
|
+
content: cut(Object.values(errors).map(message => "- " + plain(message)).join("\n"), messageLength),
|
|
232
|
+
allowed_mentions: {
|
|
233
|
+
parse: []
|
|
234
|
+
},
|
|
235
|
+
flags: EPHEMERAL
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
/**
|
|
239
|
+
* A message as an interaction's answer sends it: with the ephemeral flag
|
|
240
|
+
* when private.
|
|
241
|
+
*
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
export const withVisibility = (message, visibility) => ({
|
|
245
|
+
...message,
|
|
246
|
+
flags: message.flags | visibilityFlags(visibility)
|
|
247
|
+
});
|
|
248
|
+
/**
|
|
249
|
+
* The answer to a `respond` reply: the message a `post` sends, with the
|
|
250
|
+
* ephemeral flag when private.
|
|
251
|
+
*
|
|
252
|
+
* @internal
|
|
253
|
+
*/
|
|
254
|
+
export const respondCallback = (message, visibility) => ({
|
|
255
|
+
type: CHANNEL_MESSAGE_WITH_SOURCE,
|
|
256
|
+
data: withVisibility(message, visibility)
|
|
257
|
+
});
|
|
258
|
+
/**
|
|
259
|
+
* The answer to a `defer` reply. The visibility is fixed here and holds for
|
|
260
|
+
* the edit that follows.
|
|
261
|
+
*
|
|
262
|
+
* @internal
|
|
263
|
+
*/
|
|
264
|
+
export const deferCallback = visibility => ({
|
|
265
|
+
type: DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
|
266
|
+
...(visibility === "ephemeral" ? {
|
|
267
|
+
data: {
|
|
268
|
+
flags: EPHEMERAL
|
|
269
|
+
}
|
|
270
|
+
} : {})
|
|
271
|
+
});
|
|
272
|
+
// Inbound
|
|
273
|
+
const {
|
|
274
|
+
optional
|
|
275
|
+
} = Normalize;
|
|
276
|
+
const Input = /*#__PURE__*/Schema.Struct({
|
|
277
|
+
type: Schema.Number,
|
|
278
|
+
custom_id: /*#__PURE__*/optional(Schema.String),
|
|
279
|
+
value: /*#__PURE__*/optional(Schema.String),
|
|
280
|
+
values: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(Schema.String))
|
|
281
|
+
});
|
|
282
|
+
const ModalComponent = /*#__PURE__*/Schema.Struct({
|
|
283
|
+
type: Schema.Number,
|
|
284
|
+
component: /*#__PURE__*/optional(Input),
|
|
285
|
+
components: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(Input))
|
|
286
|
+
});
|
|
287
|
+
const CommandOption = /*#__PURE__*/Schema.Struct({
|
|
288
|
+
type: Schema.Number,
|
|
289
|
+
name: /*#__PURE__*/optional(Schema.String),
|
|
290
|
+
value: /*#__PURE__*/optional(Schema.Unknown)
|
|
291
|
+
});
|
|
292
|
+
const InteractionFields = /*#__PURE__*/Schema.Struct({
|
|
293
|
+
id: Schema.String,
|
|
294
|
+
application_id: /*#__PURE__*/optional(Schema.String),
|
|
295
|
+
type: Schema.Number,
|
|
296
|
+
token: Schema.String,
|
|
297
|
+
channel_id: /*#__PURE__*/optional(Schema.String),
|
|
298
|
+
member: /*#__PURE__*/optional(/*#__PURE__*/Schema.Struct({
|
|
299
|
+
user: /*#__PURE__*/optional(/*#__PURE__*/Schema.Struct({
|
|
300
|
+
id: Schema.String
|
|
301
|
+
}))
|
|
302
|
+
})),
|
|
303
|
+
user: /*#__PURE__*/optional(/*#__PURE__*/Schema.Struct({
|
|
304
|
+
id: Schema.String
|
|
305
|
+
})),
|
|
306
|
+
message: /*#__PURE__*/optional(/*#__PURE__*/Schema.Struct({
|
|
307
|
+
id: Schema.String,
|
|
308
|
+
channel_id: /*#__PURE__*/optional(Schema.String)
|
|
309
|
+
})),
|
|
310
|
+
data: /*#__PURE__*/Schema.Struct({
|
|
311
|
+
custom_id: /*#__PURE__*/optional(Schema.String),
|
|
312
|
+
component_type: /*#__PURE__*/optional(Schema.Number),
|
|
313
|
+
values: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(Schema.String)),
|
|
314
|
+
components: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(ModalComponent)),
|
|
315
|
+
name: /*#__PURE__*/optional(Schema.String),
|
|
316
|
+
type: /*#__PURE__*/optional(Schema.Number),
|
|
317
|
+
options: /*#__PURE__*/optional(/*#__PURE__*/Schema.Array(CommandOption))
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
const decodeFields = /*#__PURE__*/Schema.decodeUnknownOption(InteractionFields);
|
|
321
|
+
/** Discord's interaction types for a command, a component click and a modal submit. */
|
|
322
|
+
const APPLICATION_COMMAND = 2;
|
|
323
|
+
const MESSAGE_COMPONENT = 3;
|
|
324
|
+
const MODAL_SUBMIT = 5;
|
|
325
|
+
/** Discord's command type for a slash command, and its option type for a string. */
|
|
326
|
+
const CHAT_INPUT = 1;
|
|
327
|
+
const STRING = 3;
|
|
328
|
+
/**
|
|
329
|
+
* Credentials for answering an interaction.
|
|
330
|
+
*
|
|
331
|
+
* @internal
|
|
332
|
+
*/
|
|
333
|
+
export const answerTo = raw => Option.getOrUndefined(Option.map(decodeFields(raw), ({
|
|
334
|
+
id,
|
|
335
|
+
token
|
|
336
|
+
}) => ({
|
|
337
|
+
id,
|
|
338
|
+
token
|
|
339
|
+
})));
|
|
340
|
+
/**
|
|
341
|
+
* Credentials for editing a deferred command's response.
|
|
342
|
+
*
|
|
343
|
+
* @internal
|
|
344
|
+
*/
|
|
345
|
+
export const followUpTo = raw => Option.getOrUndefined(Option.flatMap(decodeFields(raw), ({
|
|
346
|
+
application_id,
|
|
347
|
+
id,
|
|
348
|
+
token
|
|
349
|
+
}) => typeof application_id === "string" && application_id !== "" ? Option.some({
|
|
350
|
+
id,
|
|
351
|
+
applicationId: application_id,
|
|
352
|
+
token
|
|
353
|
+
}) : Option.none()));
|
|
354
|
+
/**
|
|
355
|
+
* The text of a slash command's options: none, or one string. Undefined for
|
|
356
|
+
* anything else.
|
|
357
|
+
*/
|
|
358
|
+
const commandText = options => {
|
|
359
|
+
if (options === null || options === undefined || options.length === 0) return "";
|
|
360
|
+
const [option] = options;
|
|
361
|
+
return options.length === 1 && option.type === STRING && typeof option.value === "string" ? option.value : undefined;
|
|
362
|
+
};
|
|
363
|
+
/**
|
|
364
|
+
* The interaction a payload is, when it is a click on a button or string
|
|
365
|
+
* select, a submit of a modal, or a slash command with at most one string
|
|
366
|
+
* option. Anything else, a message or user command for one, is none.
|
|
367
|
+
*
|
|
368
|
+
* @internal
|
|
369
|
+
*/
|
|
370
|
+
export const normalize = raw => {
|
|
371
|
+
const decoded = decodeFields(raw);
|
|
372
|
+
if (Option.isNone(decoded)) return Option.none();
|
|
373
|
+
const fields = decoded.value;
|
|
374
|
+
const message = fields.message;
|
|
375
|
+
const userId = fields.member?.user?.id ?? fields.user?.id;
|
|
376
|
+
const channelId = message?.channel_id ?? fields.channel_id;
|
|
377
|
+
if (userId === undefined || channelId === null || channelId === undefined) return Option.none();
|
|
378
|
+
const {
|
|
379
|
+
data
|
|
380
|
+
} = fields;
|
|
381
|
+
if (fields.type === APPLICATION_COMMAND) {
|
|
382
|
+
const text = commandText(data.options);
|
|
383
|
+
// A missing command type is taken as a slash command, which is Discord's default.
|
|
384
|
+
return (data.type ?? CHAT_INPUT) !== CHAT_INPUT || typeof data.name !== "string" || data.name === "" || text === undefined ? Option.none() : Option.some(ChatInteraction.CommandInvoked.make({
|
|
385
|
+
id: data.name,
|
|
386
|
+
text,
|
|
387
|
+
thread: Normalize.thread(channelId),
|
|
388
|
+
userId,
|
|
389
|
+
raw: raw
|
|
390
|
+
}));
|
|
391
|
+
}
|
|
392
|
+
const customIdValue = data.custom_id;
|
|
393
|
+
if (customIdValue === null || customIdValue === undefined) return Option.none();
|
|
394
|
+
if (fields.type === MODAL_SUBMIT) return submitted(fields, customIdValue, channelId, userId, raw);
|
|
395
|
+
if (message === null || message === undefined) return Option.none();
|
|
396
|
+
const origin = {
|
|
397
|
+
thread: Normalize.thread(channelId),
|
|
398
|
+
messageId: message.id,
|
|
399
|
+
userId,
|
|
400
|
+
raw: raw
|
|
401
|
+
};
|
|
402
|
+
if (fields.type === MESSAGE_COMPONENT && data.component_type === 2) {
|
|
403
|
+
const {
|
|
404
|
+
id,
|
|
405
|
+
value
|
|
406
|
+
} = splitCustomId(customIdValue);
|
|
407
|
+
return Option.some(ChatInteraction.ButtonClicked.make({
|
|
408
|
+
id,
|
|
409
|
+
...(value === undefined ? {} : {
|
|
410
|
+
value
|
|
411
|
+
}),
|
|
412
|
+
...origin
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
415
|
+
if (fields.type === MESSAGE_COMPONENT && data.component_type === 3) {
|
|
416
|
+
const value = data.values?.[0];
|
|
417
|
+
return value === undefined ? Option.none() : Option.some(ChatInteraction.SelectChanged.make({
|
|
418
|
+
id: customIdValue,
|
|
419
|
+
value,
|
|
420
|
+
...origin
|
|
421
|
+
}));
|
|
422
|
+
}
|
|
423
|
+
return Option.none();
|
|
424
|
+
};
|
|
425
|
+
/** A modal's submit. One a command opened has no `message`, and no `messageId`. */
|
|
426
|
+
const submitted = (fields, customIdValue, channelId, userId, raw) => {
|
|
427
|
+
const values = {};
|
|
428
|
+
for (const component of fields.data.components ?? []) {
|
|
429
|
+
const inputs = component.component === null || component.component === undefined ? component.components ?? [] : [component.component];
|
|
430
|
+
for (const input of inputs) {
|
|
431
|
+
const value = input.value ?? input.values?.[0];
|
|
432
|
+
if (typeof input.custom_id === "string" && value !== null && value !== undefined && value !== "") {
|
|
433
|
+
// An own property, so an id such as `__proto__` keeps its answer.
|
|
434
|
+
Object.defineProperty(values, input.custom_id, {
|
|
435
|
+
value,
|
|
436
|
+
enumerable: true,
|
|
437
|
+
writable: true,
|
|
438
|
+
configurable: true
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const {
|
|
444
|
+
id,
|
|
445
|
+
value: metadata
|
|
446
|
+
} = splitCustomId(customIdValue);
|
|
447
|
+
const message = fields.message;
|
|
448
|
+
return Option.some(ChatInteraction.ModalSubmitted.make({
|
|
449
|
+
id,
|
|
450
|
+
...(metadata === undefined ? {} : {
|
|
451
|
+
metadata
|
|
452
|
+
}),
|
|
453
|
+
values,
|
|
454
|
+
thread: Normalize.thread(channelId),
|
|
455
|
+
...(message === null || message === undefined ? {} : {
|
|
456
|
+
messageId: message.id
|
|
457
|
+
}),
|
|
458
|
+
userId,
|
|
459
|
+
raw: raw
|
|
460
|
+
}));
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* The create payload of each command in `group`, in the group's order.
|
|
464
|
+
*
|
|
465
|
+
* @internal
|
|
466
|
+
*/
|
|
467
|
+
export const commandRequests = group => {
|
|
468
|
+
const out = [];
|
|
469
|
+
for (const definition of group.definitions.values()) {
|
|
470
|
+
if (definition.kind !== "command") continue;
|
|
471
|
+
const {
|
|
472
|
+
argument
|
|
473
|
+
} = definition;
|
|
474
|
+
out.push({
|
|
475
|
+
type: CHAT_INPUT,
|
|
476
|
+
name: definition.id,
|
|
477
|
+
description: definition.description,
|
|
478
|
+
...(argument === undefined ? {} : {
|
|
479
|
+
options: [{
|
|
480
|
+
type: STRING,
|
|
481
|
+
name: argument.name,
|
|
482
|
+
description: argument.description,
|
|
483
|
+
required: argument.required
|
|
484
|
+
}]
|
|
485
|
+
})
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
return out;
|
|
489
|
+
};
|
|
490
|
+
//# sourceMappingURL=interactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactions.js","names":[],"sources":["../../src/internal/interactions.ts"],"sourcesContent":[null],"mappings":"AAEA,SAAS,cAAc,EAAE,QAAQ,QAAQ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G;QAChC,OAAO,EAAE,CAAC;UACR,IAAI,EAAE,MAAM;UACZ,IAAI,EAAE,QAAQ,CAAC,IAAI;UACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;UACjC,QAAQ,EAAE,QAAQ,CAAC;SACpB;OACF;KACF,CAAC;EACJ;EACA,OAAO,GAAG;AACZ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"length.d.ts","sourceRoot":"","sources":["../../src/internal/length.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord's limit on `content`, in code points, inclusive.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export const messageLength = 2000;
|
|
7
|
+
/** The index past the code point at `i`: a surrogate pair is one, a lone surrogate one too. */
|
|
8
|
+
const next = (text, i) => text.codePointAt(i) > 0xffff ? i + 2 : i + 1;
|
|
9
|
+
/**
|
|
10
|
+
* Code points, which is what Discord counts: a recorded probe took 2,000
|
|
11
|
+
* astral emoji (4,000 UTF-16 units) and refused 1,999 letters and a flag.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export const codePoints = text => {
|
|
16
|
+
let count = 0;
|
|
17
|
+
for (let i = 0; i < text.length; i = next(text, i)) count++;
|
|
18
|
+
return count;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Cuts `text` to at most `max` code points.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export const cut = (text, max) => {
|
|
26
|
+
for (let i = 0, count = 0; i < text.length; i = next(text, i), count++) {
|
|
27
|
+
if (count === max) return text.slice(0, i);
|
|
28
|
+
}
|
|
29
|
+
return text;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"length.js","names":[],"sources":["../../src/internal/length.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;AAKA,OAAO,MAAM,aAAa,GAAG,IAAI;AAEjC;AACA,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,CAAS,KAAa,IAAI,CAAC,WAAW,CAAC,CAAC,CAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;AAE/F;;;;;;AAMA,OAAO,MAAM,UAAU,GAAI,IAAY,IAAY;EACjD,IAAI,KAAK,GAAG,CAAC;EACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE;EAC3D,OAAO,KAAK;AACd,CAAC;AAED;;;;;AAKA,OAAO,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,GAAW,KAAY;EACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;IACtE,IAAI,KAAK,KAAK,GAAG,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;EAC5C;EACA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentions.d.ts","sourceRoot":"","sources":["../../src/internal/mentions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** A mention token as Discord writes it in `content`. */
|
|
2
|
+
const tokenPattern = /<@!?(\d+)>|<@&(\d+)>|<#(\d+)>|@(everyone|here)/y;
|
|
3
|
+
const targetOf = match => {
|
|
4
|
+
const [, user, role, channel, broadcast] = match;
|
|
5
|
+
if (user !== undefined) return {
|
|
6
|
+
kind: "user",
|
|
7
|
+
id: user
|
|
8
|
+
};
|
|
9
|
+
if (role !== undefined) return {
|
|
10
|
+
kind: "role",
|
|
11
|
+
id: role
|
|
12
|
+
};
|
|
13
|
+
if (channel !== undefined) return {
|
|
14
|
+
kind: "channel",
|
|
15
|
+
id: channel
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
kind: "broadcast",
|
|
19
|
+
id: broadcast
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const tokenAt = (text, index) => {
|
|
23
|
+
tokenPattern.lastIndex = index;
|
|
24
|
+
return tokenPattern.exec(text);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Parses one token, `<@id>`, `<@!id>`, `<@&id>`, `<#id>`, `@everyone`
|
|
28
|
+
* or `@here`, as the whole of `slice`.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export const parseToken = slice => {
|
|
33
|
+
const match = tokenAt(slice, 0);
|
|
34
|
+
return match === null || match[0].length !== slice.length ? undefined : targetOf(match);
|
|
35
|
+
};
|
|
36
|
+
const isEscapable = char => char !== undefined && /[^0-9A-Za-z\s]/.test(char);
|
|
37
|
+
/** The index past the closing run of exactly `n` backticks, or -1. */
|
|
38
|
+
const closingRun = (text, from, n) => {
|
|
39
|
+
for (let i = from; i < text.length; i++) {
|
|
40
|
+
if (text[i] !== "`") continue;
|
|
41
|
+
let run = 1;
|
|
42
|
+
while (text[i + run] === "`") run++;
|
|
43
|
+
if (run === n && i > from) return i + run;
|
|
44
|
+
i += run - 1;
|
|
45
|
+
}
|
|
46
|
+
return -1;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The mention tokens in `content`, in order, skipping code blocks, inline
|
|
50
|
+
* code and tokens escaped with a backslash, as Discord's Markdown does.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export const tokens = text => {
|
|
55
|
+
const found = [];
|
|
56
|
+
let i = 0;
|
|
57
|
+
while (i < text.length) {
|
|
58
|
+
const char = text[i];
|
|
59
|
+
if (char === "\\" && isEscapable(text[i + 1])) {
|
|
60
|
+
i += 2;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (char === "`") {
|
|
64
|
+
let n = 1;
|
|
65
|
+
while (text[i + n] === "`") n++;
|
|
66
|
+
if (n >= 3) {
|
|
67
|
+
const end = text.indexOf("```", i + 3);
|
|
68
|
+
if (end !== -1) {
|
|
69
|
+
i = end + 3;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const end = closingRun(text, i + n, n);
|
|
74
|
+
i = end === -1 ? i + n : end;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (char === "<" || char === "@") {
|
|
78
|
+
const match = tokenAt(text, i);
|
|
79
|
+
if (match !== null) {
|
|
80
|
+
found.push({
|
|
81
|
+
...targetOf(match),
|
|
82
|
+
start: i,
|
|
83
|
+
end: i + match[0].length
|
|
84
|
+
});
|
|
85
|
+
i += match[0].length;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
i++;
|
|
90
|
+
}
|
|
91
|
+
return found;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=mentions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mentions.js","names":[],"sources":["../../src/internal/mentions.ts"],"sourcesContent":[null],"mappings":"AASA;AACA,MAAM,YAAY,GAAG,iDAAiD;AAEtE,MAAM,QAAQ,GAAI,KAAsB,IAAY;EAClD,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,KAAK;EAChD,IAAI,IAAI,KAAK,SAAS,EAAE,OAAO;IAAE,IAAI,EAAE,MAAM;IAAE,EAAE,EAAE;EAAI,CAAE;EACzD,IAAI,IAAI,KAAK,SAAS,EAAE,OAAO;IAAE,IAAI,EAAE,MAAM;IAAE,EAAE,EA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