@abyss-project/runtime 3.10.0 → 3.12.0
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/.prettierrc +5 -5
- package/README.md +88 -88
- package/dist/discord/discord.types.d.ts +35 -2
- package/dist/discord/discord.types.js +10 -1
- package/dist/discord/discord.types.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/surface.test.ts +7 -0
- package/src/discord/__tests__/discord-event-input.test.ts +18 -0
- package/src/discord/discord.types.ts +738 -694
package/.prettierrc
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"singleQuote": true,
|
|
3
|
-
"trailingComma": "all",
|
|
4
|
-
"printWidth": 100
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"singleQuote": true,
|
|
3
|
+
"trailingComma": "all",
|
|
4
|
+
"printWidth": 100
|
|
5
|
+
}
|
package/README.md
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
# @abyss-project/runtime
|
|
2
|
-
|
|
3
|
-
Abyss automation core: definitions, interpreter, execution protocol `abyss-runtime.v2` and
|
|
4
|
-
execution cost.
|
|
5
|
-
|
|
6
|
-
The package root (`@abyss-project/runtime`) is browser-compatible. Node-only code (the
|
|
7
|
-
`CodeRunnerSession` WebSocket client) lives under `@abyss-project/runtime/server`.
|
|
8
|
-
`@abyss-project/runtime/engine` exports `ENGINE_SOURCE`, the interpreter bundled into one
|
|
9
|
-
self-contained script for the code runner's isolate.
|
|
10
|
-
|
|
11
|
-
## Host globals
|
|
12
|
-
|
|
13
|
-
`ExecuteMessage.globals` gives the client code read-only globals: each top-level key becomes a
|
|
14
|
-
frozen global. Two keys are conventional: `secrets` (`{{ secrets.NAME }}` / `secrets.NAME`, masked
|
|
15
|
-
by the host) and `config` (`Record<string, string>`, the non-secret per-environment variables:
|
|
16
|
-
`{{ config.NAME }}` / `config.NAME`, not masked). A name the host did not send is `undefined`.
|
|
17
|
-
The host sends the names `collectGlobalReferences(definition, 'config')` finds.
|
|
18
|
-
|
|
19
|
-
## Discord helpers
|
|
20
|
-
|
|
21
|
-
A host that grants the `DiscordCapability` names (`discord.reply`, `discord.update`,
|
|
22
|
-
`discord.showModal`, `discord.followUp`, `discord.sendMessage`, `discord.editMessage`,
|
|
23
|
-
`discord.deleteMessage`, `discord.addRole`, `discord.removeRole`, `discord.sendDirectMessage`,
|
|
24
|
-
`discord.getMember`, `discord.getGuildRoles`, `discord.getChannel`, `discord.getGuild`) lets the
|
|
25
|
-
client code call `abyss.discord.<name>(...)`. Every helper always exists; one whose capability the
|
|
26
|
-
function does not declare rejects with an error naming the action to declare:
|
|
27
|
-
|
|
28
|
-
- `reply(message)`, `update(message)`, `followUp(message)`, `showModal({ customId, title, fields })`
|
|
29
|
-
- `sendMessage(channelId, message)`, `editMessage(channelId, messageId, message)`,
|
|
30
|
-
`deleteMessage(channelId, messageId)`, `sendDirectMessage(userId, message)`
|
|
31
|
-
- `addRole(guildId, userId, roleId)`, `removeRole(guildId, userId, roleId)`
|
|
32
|
-
- reads: `getMember(guildId, userId)` (a `DiscordMember`, or `null` when the user is not in the
|
|
33
|
-
server), `getGuildRoles(guildId)` (`DiscordRole[]`), `getChannel(channelId)` (`DiscordChannel`),
|
|
34
|
-
`getGuild(guildId)` (`DiscordGuild`). The shapes are Discord's in camelCase; permissions are
|
|
35
|
-
decimal strings, since they exceed 2^53.
|
|
36
|
-
|
|
37
|
-
`reply`, `update`, `showModal` and `followUp` need an interaction: in an execution no interaction
|
|
38
|
-
started (a task, a delayed run) the host rejects them with `NO_INTERACTION`.
|
|
39
|
-
|
|
40
|
-
`message` is a `DiscordMessage` (`{ content?, embeds?, components?, ephemeral?, allowedMentions? }`).
|
|
41
|
-
By default a message pings the users it mentions and nobody else: `@everyone`, `@here` and roles
|
|
42
|
-
stay plain text. `allowedMentions` (`DiscordAllowedMentions`: `parse` of `DiscordMentionType`
|
|
43
|
-
values, `users`, `roles`, `repliedUser`) replaces that default. The `args` of
|
|
44
|
-
each host `call` are the types `Discord*Args` (a `DiscordMessage` itself for `reply`, `update`,
|
|
45
|
-
`followUp`). A host failing a call with the message `<DiscordErrorCode>: <detail>` (or the bare
|
|
46
|
-
code) makes the helper throw an `Error` named `DiscordError` with `code` and `message` set; any
|
|
47
|
-
other failure is thrown unchanged. `DiscordInteractionInput` types the `input` of a function
|
|
48
|
-
triggered by a Discord interaction; `DiscordEventInput` (`kind: 'DISCORD_EVENT'`, `event`, `guildId`, `receivedAt`, `firedAt`, `attempt`, `data`) types the `input` of one triggered by a Gateway event (`DiscordEventType`), and `isDiscordEventInput` tells it from the other inputs.
|
|
49
|
-
|
|
50
|
-
## Schedule helpers
|
|
51
|
-
|
|
52
|
-
A host that grants the `ScheduleCapability` names (`schedule.after`, `schedule.at`,
|
|
53
|
-
`schedule.cancel`) lets the client code schedule a delayed run of a named task. Every helper always
|
|
54
|
-
exists; one whose capability the function does not declare rejects with an error naming the action
|
|
55
|
-
to declare:
|
|
56
|
-
|
|
57
|
-
- `after(seconds, taskName, payload?, { key? })` and `at(isoDate, taskName, payload?, { key? })`
|
|
58
|
-
(`isoDate` an ISO 8601 string, or a `Date`) resolve to a `ScheduleResult` (`{ id, deduplicated }`).
|
|
59
|
-
While a run with the same `key` is pending, scheduling again returns its `id` with
|
|
60
|
-
`deduplicated: true`.
|
|
61
|
-
- `cancel(idOrKey)` resolves to a `ScheduleCancelResult` (`{ cancelled }`).
|
|
62
|
-
|
|
63
|
-
The `args` of each host `call` are `ScheduleAfterArgs`, `ScheduleAtArgs` and `ScheduleCancelArgs`
|
|
64
|
-
(`payload` and `key` left out when not given). A host failing a call with the message
|
|
65
|
-
`<ScheduleErrorCode>: <detail>` (or the bare code) makes the helper throw an `Error` named
|
|
66
|
-
`ScheduleError` with `code` and `message` set; any other failure is thrown unchanged.
|
|
67
|
-
`ScheduledRunInput` (`{ kind, task: { id, name }, scheduledFor, firedAt, attempt, payload? }`, `kind`
|
|
68
|
-
a `ScheduledRunKind`: `SCHEDULE` for a cron tick, `DELAYED` for a delayed run) types the `input` of a
|
|
69
|
-
function started by a task.
|
|
70
|
-
|
|
71
|
-
## Installation
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
npm install @abyss-project/runtime
|
|
75
|
-
# or
|
|
76
|
-
pnpm add @abyss-project/runtime
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Liens
|
|
80
|
-
|
|
81
|
-
- **Documentation** : [https://docs.abyss-project.fr](https://docs.abyss-project.fr)
|
|
82
|
-
- **NPM** : [@abyss-project/runtime](https://www.npmjs.com/package/@abyss-project/runtime)
|
|
83
|
-
- **Application Abyss** : [app.abyss-project.fr](https://app.abyss-project.fr)
|
|
84
|
-
- **Statut des services** : [status.abyss-project.fr](https://status.abyss-project.fr)
|
|
85
|
-
|
|
86
|
-
## Support
|
|
87
|
-
|
|
88
|
-
Pour toute demande, ouvrir un ticket depuis [l'application Abyss](https://app.abyss-project.fr/dashboard/account/tickets/create).
|
|
1
|
+
# @abyss-project/runtime
|
|
2
|
+
|
|
3
|
+
Abyss automation core: definitions, interpreter, execution protocol `abyss-runtime.v2` and
|
|
4
|
+
execution cost.
|
|
5
|
+
|
|
6
|
+
The package root (`@abyss-project/runtime`) is browser-compatible. Node-only code (the
|
|
7
|
+
`CodeRunnerSession` WebSocket client) lives under `@abyss-project/runtime/server`.
|
|
8
|
+
`@abyss-project/runtime/engine` exports `ENGINE_SOURCE`, the interpreter bundled into one
|
|
9
|
+
self-contained script for the code runner's isolate.
|
|
10
|
+
|
|
11
|
+
## Host globals
|
|
12
|
+
|
|
13
|
+
`ExecuteMessage.globals` gives the client code read-only globals: each top-level key becomes a
|
|
14
|
+
frozen global. Two keys are conventional: `secrets` (`{{ secrets.NAME }}` / `secrets.NAME`, masked
|
|
15
|
+
by the host) and `config` (`Record<string, string>`, the non-secret per-environment variables:
|
|
16
|
+
`{{ config.NAME }}` / `config.NAME`, not masked). A name the host did not send is `undefined`.
|
|
17
|
+
The host sends the names `collectGlobalReferences(definition, 'config')` finds.
|
|
18
|
+
|
|
19
|
+
## Discord helpers
|
|
20
|
+
|
|
21
|
+
A host that grants the `DiscordCapability` names (`discord.reply`, `discord.update`,
|
|
22
|
+
`discord.showModal`, `discord.followUp`, `discord.sendMessage`, `discord.editMessage`,
|
|
23
|
+
`discord.deleteMessage`, `discord.addRole`, `discord.removeRole`, `discord.sendDirectMessage`,
|
|
24
|
+
`discord.getMember`, `discord.getGuildRoles`, `discord.getChannel`, `discord.getGuild`) lets the
|
|
25
|
+
client code call `abyss.discord.<name>(...)`. Every helper always exists; one whose capability the
|
|
26
|
+
function does not declare rejects with an error naming the action to declare:
|
|
27
|
+
|
|
28
|
+
- `reply(message)`, `update(message)`, `followUp(message)`, `showModal({ customId, title, fields })`
|
|
29
|
+
- `sendMessage(channelId, message)`, `editMessage(channelId, messageId, message)`,
|
|
30
|
+
`deleteMessage(channelId, messageId)`, `sendDirectMessage(userId, message)`
|
|
31
|
+
- `addRole(guildId, userId, roleId)`, `removeRole(guildId, userId, roleId)`
|
|
32
|
+
- reads: `getMember(guildId, userId)` (a `DiscordMember`, or `null` when the user is not in the
|
|
33
|
+
server), `getGuildRoles(guildId)` (`DiscordRole[]`), `getChannel(channelId)` (`DiscordChannel`),
|
|
34
|
+
`getGuild(guildId)` (`DiscordGuild`). The shapes are Discord's in camelCase; permissions are
|
|
35
|
+
decimal strings, since they exceed 2^53.
|
|
36
|
+
|
|
37
|
+
`reply`, `update`, `showModal` and `followUp` need an interaction: in an execution no interaction
|
|
38
|
+
started (a task, a delayed run) the host rejects them with `NO_INTERACTION`.
|
|
39
|
+
|
|
40
|
+
`message` is a `DiscordMessage` (`{ content?, embeds?, components?, ephemeral?, allowedMentions? }`).
|
|
41
|
+
By default a message pings the users it mentions and nobody else: `@everyone`, `@here` and roles
|
|
42
|
+
stay plain text. `allowedMentions` (`DiscordAllowedMentions`: `parse` of `DiscordMentionType`
|
|
43
|
+
values, `users`, `roles`, `repliedUser`) replaces that default. The `args` of
|
|
44
|
+
each host `call` are the types `Discord*Args` (a `DiscordMessage` itself for `reply`, `update`,
|
|
45
|
+
`followUp`). A host failing a call with the message `<DiscordErrorCode>: <detail>` (or the bare
|
|
46
|
+
code) makes the helper throw an `Error` named `DiscordError` with `code` and `message` set; any
|
|
47
|
+
other failure is thrown unchanged. `DiscordInteractionInput` types the `input` of a function
|
|
48
|
+
triggered by a Discord interaction; `DiscordEventInput` (`kind: 'DISCORD_EVENT'`, `event`, `guildId`, `receivedAt`, `firedAt`, `attempt`, `data`) types the `input` of one triggered by a Gateway event (`DiscordEventType`), and `isDiscordEventInput` tells it from the other inputs.
|
|
49
|
+
|
|
50
|
+
## Schedule helpers
|
|
51
|
+
|
|
52
|
+
A host that grants the `ScheduleCapability` names (`schedule.after`, `schedule.at`,
|
|
53
|
+
`schedule.cancel`) lets the client code schedule a delayed run of a named task. Every helper always
|
|
54
|
+
exists; one whose capability the function does not declare rejects with an error naming the action
|
|
55
|
+
to declare:
|
|
56
|
+
|
|
57
|
+
- `after(seconds, taskName, payload?, { key? })` and `at(isoDate, taskName, payload?, { key? })`
|
|
58
|
+
(`isoDate` an ISO 8601 string, or a `Date`) resolve to a `ScheduleResult` (`{ id, deduplicated }`).
|
|
59
|
+
While a run with the same `key` is pending, scheduling again returns its `id` with
|
|
60
|
+
`deduplicated: true`.
|
|
61
|
+
- `cancel(idOrKey)` resolves to a `ScheduleCancelResult` (`{ cancelled }`).
|
|
62
|
+
|
|
63
|
+
The `args` of each host `call` are `ScheduleAfterArgs`, `ScheduleAtArgs` and `ScheduleCancelArgs`
|
|
64
|
+
(`payload` and `key` left out when not given). A host failing a call with the message
|
|
65
|
+
`<ScheduleErrorCode>: <detail>` (or the bare code) makes the helper throw an `Error` named
|
|
66
|
+
`ScheduleError` with `code` and `message` set; any other failure is thrown unchanged.
|
|
67
|
+
`ScheduledRunInput` (`{ kind, task: { id, name }, scheduledFor, firedAt, attempt, payload? }`, `kind`
|
|
68
|
+
a `ScheduledRunKind`: `SCHEDULE` for a cron tick, `DELAYED` for a delayed run) types the `input` of a
|
|
69
|
+
function started by a task.
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install @abyss-project/runtime
|
|
75
|
+
# or
|
|
76
|
+
pnpm add @abyss-project/runtime
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Liens
|
|
80
|
+
|
|
81
|
+
- **Documentation** : [https://docs.abyss-project.fr](https://docs.abyss-project.fr)
|
|
82
|
+
- **NPM** : [@abyss-project/runtime](https://www.npmjs.com/package/@abyss-project/runtime)
|
|
83
|
+
- **Application Abyss** : [app.abyss-project.fr](https://app.abyss-project.fr)
|
|
84
|
+
- **Statut des services** : [status.abyss-project.fr](https://status.abyss-project.fr)
|
|
85
|
+
|
|
86
|
+
## Support
|
|
87
|
+
|
|
88
|
+
Pour toute demande, ouvrir un ticket depuis [l'application Abyss](https://app.abyss-project.fr/dashboard/account/tickets/create).
|
|
@@ -59,6 +59,7 @@ export declare const DISCORD_CAPABILITY_LIMITS: {
|
|
|
59
59
|
export declare enum DiscordErrorCode {
|
|
60
60
|
MODAL_TOO_LATE = "MODAL_TOO_LATE",
|
|
61
61
|
INTERACTION_ALREADY_ANSWERED = "INTERACTION_ALREADY_ANSWERED",
|
|
62
|
+
DISCORD_FILE_TOO_LARGE = "DISCORD_FILE_TOO_LARGE",
|
|
62
63
|
DISCORD_TOKEN_INVALID = "DISCORD_TOKEN_INVALID",
|
|
63
64
|
DISCORD_FORBIDDEN = "DISCORD_FORBIDDEN",
|
|
64
65
|
DISCORD_NOT_FOUND = "DISCORD_NOT_FOUND",
|
|
@@ -326,6 +327,11 @@ export declare enum DiscordInteractionKind {
|
|
|
326
327
|
COMPONENT = "COMPONENT",
|
|
327
328
|
MODAL = "MODAL"
|
|
328
329
|
}
|
|
330
|
+
export declare enum DiscordCommandType {
|
|
331
|
+
CHAT_INPUT = "CHAT_INPUT",
|
|
332
|
+
USER = "USER",
|
|
333
|
+
MESSAGE = "MESSAGE"
|
|
334
|
+
}
|
|
329
335
|
export declare enum DiscordInteractionType {
|
|
330
336
|
PING = 1,
|
|
331
337
|
APPLICATION_COMMAND = 2,
|
|
@@ -362,11 +368,29 @@ export interface DiscordResolved {
|
|
|
362
368
|
roles?: Record<string, DiscordRole>;
|
|
363
369
|
channels?: Record<string, DiscordChannel>;
|
|
364
370
|
attachments?: Record<string, DiscordAttachment>;
|
|
371
|
+
messages?: Record<string, DiscordResolvedMessage>;
|
|
372
|
+
}
|
|
373
|
+
export interface DiscordResolvedMessage {
|
|
374
|
+
id: string;
|
|
375
|
+
channelId: string;
|
|
376
|
+
author: {
|
|
377
|
+
id: string;
|
|
378
|
+
username: string;
|
|
379
|
+
globalName: string | null;
|
|
380
|
+
bot: boolean;
|
|
381
|
+
};
|
|
382
|
+
content: string;
|
|
383
|
+
attachments: DiscordAttachment[];
|
|
384
|
+
createdAt: string;
|
|
365
385
|
}
|
|
366
386
|
export interface DiscordInteractionInput {
|
|
367
387
|
kind: DiscordInteractionKind;
|
|
368
388
|
command?: {
|
|
369
389
|
name: string;
|
|
390
|
+
type: DiscordCommandType;
|
|
391
|
+
subcommandGroup?: string;
|
|
392
|
+
subcommand?: string;
|
|
393
|
+
targetId?: string;
|
|
370
394
|
options: Record<string, string | number | boolean>;
|
|
371
395
|
resolved?: DiscordResolved;
|
|
372
396
|
focused?: {
|
|
@@ -406,7 +430,9 @@ export declare enum DiscordEventType {
|
|
|
406
430
|
GUILD_MEMBER_ADD = "GUILD_MEMBER_ADD",
|
|
407
431
|
GUILD_MEMBER_REMOVE = "GUILD_MEMBER_REMOVE",
|
|
408
432
|
MESSAGE_CREATE = "MESSAGE_CREATE",
|
|
409
|
-
MESSAGE_REACTION_ADD = "MESSAGE_REACTION_ADD"
|
|
433
|
+
MESSAGE_REACTION_ADD = "MESSAGE_REACTION_ADD",
|
|
434
|
+
MESSAGE_POLL_VOTE_ADD = "MESSAGE_POLL_VOTE_ADD",
|
|
435
|
+
MESSAGE_POLL_VOTE_REMOVE = "MESSAGE_POLL_VOTE_REMOVE"
|
|
410
436
|
}
|
|
411
437
|
export interface DiscordMemberAddData {
|
|
412
438
|
user: {
|
|
@@ -462,6 +488,12 @@ export interface DiscordReactionAddData {
|
|
|
462
488
|
animated: boolean;
|
|
463
489
|
};
|
|
464
490
|
}
|
|
491
|
+
export interface DiscordPollVoteData {
|
|
492
|
+
userId: string;
|
|
493
|
+
channelId: string;
|
|
494
|
+
messageId: string;
|
|
495
|
+
answerId: number;
|
|
496
|
+
}
|
|
465
497
|
export declare const DISCORD_EVENT_INPUT_KIND = "DISCORD_EVENT";
|
|
466
498
|
export interface DiscordEventInput {
|
|
467
499
|
kind: typeof DISCORD_EVENT_INPUT_KIND;
|
|
@@ -477,6 +509,7 @@ export interface DiscordEventInput {
|
|
|
477
509
|
receivedAt: string;
|
|
478
510
|
firedAt: string;
|
|
479
511
|
attempt: number;
|
|
480
|
-
|
|
512
|
+
replayOf?: string;
|
|
513
|
+
data: DiscordMemberAddData | DiscordMemberRemoveData | DiscordMessageCreateData | DiscordReactionAddData | DiscordPollVoteData;
|
|
481
514
|
}
|
|
482
515
|
export declare const isDiscordEventInput: (value: unknown) => value is DiscordEventInput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDiscordEventInput = exports.DISCORD_EVENT_INPUT_KIND = exports.DiscordEventType = exports.EPHEMERAL_FLAG = exports.DiscordCallbackType = exports.DiscordInteractionType = exports.DiscordInteractionKind = exports.DiscordPermissionTargetType = exports.DiscordChannelType = exports.DiscordModalFieldStyle = exports.DiscordMentionType = exports.DiscordErrorCode = exports.DISCORD_CAPABILITY_LIMITS = exports.REFLEX_ATTACHMENT_DEFAULT_MAX_BYTES = exports.REFLEX_ATTACHMENT_MAX_BYTES_BOUND = exports.DISCORD_MESSAGE_MAX_FILES_BYTES = exports.DISCORD_MESSAGE_MAX_FILES = exports.DISCORD_AUTOCOMPLETE_MAX_CHOICES = exports.DiscordCapability = void 0;
|
|
3
|
+
exports.isDiscordEventInput = exports.DISCORD_EVENT_INPUT_KIND = exports.DiscordEventType = exports.EPHEMERAL_FLAG = exports.DiscordCallbackType = exports.DiscordInteractionType = exports.DiscordCommandType = exports.DiscordInteractionKind = exports.DiscordPermissionTargetType = exports.DiscordChannelType = exports.DiscordModalFieldStyle = exports.DiscordMentionType = exports.DiscordErrorCode = exports.DISCORD_CAPABILITY_LIMITS = exports.REFLEX_ATTACHMENT_DEFAULT_MAX_BYTES = exports.REFLEX_ATTACHMENT_MAX_BYTES_BOUND = exports.DISCORD_MESSAGE_MAX_FILES_BYTES = exports.DISCORD_MESSAGE_MAX_FILES = exports.DISCORD_AUTOCOMPLETE_MAX_CHOICES = exports.DiscordCapability = void 0;
|
|
4
4
|
var DiscordCapability;
|
|
5
5
|
(function (DiscordCapability) {
|
|
6
6
|
DiscordCapability["REPLY"] = "discord.reply";
|
|
@@ -63,6 +63,7 @@ var DiscordErrorCode;
|
|
|
63
63
|
(function (DiscordErrorCode) {
|
|
64
64
|
DiscordErrorCode["MODAL_TOO_LATE"] = "MODAL_TOO_LATE";
|
|
65
65
|
DiscordErrorCode["INTERACTION_ALREADY_ANSWERED"] = "INTERACTION_ALREADY_ANSWERED";
|
|
66
|
+
DiscordErrorCode["DISCORD_FILE_TOO_LARGE"] = "DISCORD_FILE_TOO_LARGE";
|
|
66
67
|
DiscordErrorCode["DISCORD_TOKEN_INVALID"] = "DISCORD_TOKEN_INVALID";
|
|
67
68
|
DiscordErrorCode["DISCORD_FORBIDDEN"] = "DISCORD_FORBIDDEN";
|
|
68
69
|
DiscordErrorCode["DISCORD_NOT_FOUND"] = "DISCORD_NOT_FOUND";
|
|
@@ -100,6 +101,12 @@ var DiscordInteractionKind;
|
|
|
100
101
|
DiscordInteractionKind["COMPONENT"] = "COMPONENT";
|
|
101
102
|
DiscordInteractionKind["MODAL"] = "MODAL";
|
|
102
103
|
})(DiscordInteractionKind || (exports.DiscordInteractionKind = DiscordInteractionKind = {}));
|
|
104
|
+
var DiscordCommandType;
|
|
105
|
+
(function (DiscordCommandType) {
|
|
106
|
+
DiscordCommandType["CHAT_INPUT"] = "CHAT_INPUT";
|
|
107
|
+
DiscordCommandType["USER"] = "USER";
|
|
108
|
+
DiscordCommandType["MESSAGE"] = "MESSAGE";
|
|
109
|
+
})(DiscordCommandType || (exports.DiscordCommandType = DiscordCommandType = {}));
|
|
103
110
|
var DiscordInteractionType;
|
|
104
111
|
(function (DiscordInteractionType) {
|
|
105
112
|
DiscordInteractionType[DiscordInteractionType["PING"] = 1] = "PING";
|
|
@@ -125,6 +132,8 @@ var DiscordEventType;
|
|
|
125
132
|
DiscordEventType["GUILD_MEMBER_REMOVE"] = "GUILD_MEMBER_REMOVE";
|
|
126
133
|
DiscordEventType["MESSAGE_CREATE"] = "MESSAGE_CREATE";
|
|
127
134
|
DiscordEventType["MESSAGE_REACTION_ADD"] = "MESSAGE_REACTION_ADD";
|
|
135
|
+
DiscordEventType["MESSAGE_POLL_VOTE_ADD"] = "MESSAGE_POLL_VOTE_ADD";
|
|
136
|
+
DiscordEventType["MESSAGE_POLL_VOTE_REMOVE"] = "MESSAGE_POLL_VOTE_REMOVE";
|
|
128
137
|
})(DiscordEventType || (exports.DiscordEventType = DiscordEventType = {}));
|
|
129
138
|
exports.DISCORD_EVENT_INPUT_KIND = 'DISCORD_EVENT';
|
|
130
139
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discord.types.js","sourceRoot":"","sources":["../../src/discord/discord.types.ts"],"names":[],"mappings":";;;AAOA,IAAY,iBA+DX;AA/DD,WAAY,iBAAiB;IAE3B,4CAAuB,CAAA;IAEvB,8CAAyB,CAAA;IAEzB,qDAAgC,CAAA;IAEhC,mDAA8B,CAAA;IAE9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CHARS,
|
|
8
9
|
MAX_PROGRESS_OUTPUT_BYTES,
|
|
@@ -66,10 +67,16 @@ describe('public surface of the package root', () => {
|
|
|
66
67
|
'GUILD_MEMBER_REMOVE',
|
|
67
68
|
'MESSAGE_CREATE',
|
|
68
69
|
'MESSAGE_REACTION_ADD',
|
|
70
|
+
'MESSAGE_POLL_VOTE_ADD',
|
|
71
|
+
'MESSAGE_POLL_VOTE_REMOVE',
|
|
69
72
|
]);
|
|
70
73
|
expect(typeof isDiscordEventInput).toBe('function');
|
|
71
74
|
});
|
|
72
75
|
|
|
76
|
+
it('exports the application command types, slash command and the two context menus', () => {
|
|
77
|
+
expect(Object.values(DiscordCommandType)).toEqual(['CHAT_INPUT', 'USER', 'MESSAGE']);
|
|
78
|
+
});
|
|
79
|
+
|
|
73
80
|
it('exports the step output bounds of the execution protocol (64 KB whole, 4 KB preview)', () => {
|
|
74
81
|
expect(MAX_PROGRESS_OUTPUT_BYTES).toBe(65_536);
|
|
75
82
|
expect(MAX_PROGRESS_OUTPUT_CHARS).toBe(4_096);
|
|
@@ -30,6 +30,18 @@ const DATA_BY_TYPE: Record<DiscordEventType, DiscordEventInput['data']> = {
|
|
|
30
30
|
member: { roles: [] },
|
|
31
31
|
emoji: { id: null, name: '👍', animated: false },
|
|
32
32
|
},
|
|
33
|
+
[DiscordEventType.MESSAGE_POLL_VOTE_ADD]: {
|
|
34
|
+
userId: 'u1',
|
|
35
|
+
channelId: 'c1',
|
|
36
|
+
messageId: 'm1',
|
|
37
|
+
answerId: 2,
|
|
38
|
+
},
|
|
39
|
+
[DiscordEventType.MESSAGE_POLL_VOTE_REMOVE]: {
|
|
40
|
+
userId: 'u1',
|
|
41
|
+
channelId: 'c1',
|
|
42
|
+
messageId: 'm1',
|
|
43
|
+
answerId: 2,
|
|
44
|
+
},
|
|
33
45
|
};
|
|
34
46
|
|
|
35
47
|
const inputOf = (type: DiscordEventType): DiscordEventInput => ({
|
|
@@ -47,6 +59,12 @@ describe('isDiscordEventInput', () => {
|
|
|
47
59
|
expect(isDiscordEventInput(inputOf(type))).toBe(true);
|
|
48
60
|
});
|
|
49
61
|
|
|
62
|
+
it('is true for a replay, which names the live run it replays', () => {
|
|
63
|
+
expect(
|
|
64
|
+
isDiscordEventInput({ ...inputOf(DiscordEventType.MESSAGE_POLL_VOTE_ADD), replayOf: 'r1' }),
|
|
65
|
+
).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
50
68
|
it('is false for an interaction input', () => {
|
|
51
69
|
expect(
|
|
52
70
|
isDiscordEventInput({
|