@neontechspace/fluxerly 1000.0.0-nightly.12
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/CHANGELOG.md +833 -0
- package/LICENSE +201 -0
- package/README.md +129 -0
- package/agents/AGENTS.md +195 -0
- package/dist/api/default/application.d.ts +34 -0
- package/dist/api/default/application.d.ts.map +1 -0
- package/dist/api/default/application.js +2 -0
- package/dist/api/default/application.js.map +1 -0
- package/dist/api/default/attachments.d.ts +89 -0
- package/dist/api/default/attachments.d.ts.map +1 -0
- package/dist/api/default/attachments.js +2 -0
- package/dist/api/default/attachments.js.map +1 -0
- package/dist/api/default/audit-logs.d.ts +48 -0
- package/dist/api/default/audit-logs.d.ts.map +1 -0
- package/dist/api/default/audit-logs.js +2 -0
- package/dist/api/default/audit-logs.js.map +1 -0
- package/dist/api/default/bot.d.ts +200 -0
- package/dist/api/default/bot.d.ts.map +1 -0
- package/dist/api/default/bot.js +309 -0
- package/dist/api/default/bot.js.map +1 -0
- package/dist/api/default/cache.d.ts +105 -0
- package/dist/api/default/cache.d.ts.map +1 -0
- package/dist/api/default/cache.js +2 -0
- package/dist/api/default/cache.js.map +1 -0
- package/dist/api/default/channels.d.ts +249 -0
- package/dist/api/default/channels.d.ts.map +1 -0
- package/dist/api/default/channels.js +2 -0
- package/dist/api/default/channels.js.map +1 -0
- package/dist/api/default/client.d.ts +528 -0
- package/dist/api/default/client.d.ts.map +1 -0
- package/dist/api/default/client.js +301 -0
- package/dist/api/default/client.js.map +1 -0
- package/dist/api/default/collectors.d.ts +76 -0
- package/dist/api/default/collectors.d.ts.map +1 -0
- package/dist/api/default/collectors.js +2 -0
- package/dist/api/default/collectors.js.map +1 -0
- package/dist/api/default/commands.d.ts +91 -0
- package/dist/api/default/commands.d.ts.map +1 -0
- package/dist/api/default/commands.js +92 -0
- package/dist/api/default/commands.js.map +1 -0
- package/dist/api/default/direct-messages.d.ts +111 -0
- package/dist/api/default/direct-messages.d.ts.map +1 -0
- package/dist/api/default/direct-messages.js +2 -0
- package/dist/api/default/direct-messages.js.map +1 -0
- package/dist/api/default/discovery.d.ts +76 -0
- package/dist/api/default/discovery.d.ts.map +1 -0
- package/dist/api/default/discovery.js +2 -0
- package/dist/api/default/discovery.js.map +1 -0
- package/dist/api/default/emojis.d.ts +88 -0
- package/dist/api/default/emojis.d.ts.map +1 -0
- package/dist/api/default/emojis.js +2 -0
- package/dist/api/default/emojis.js.map +1 -0
- package/dist/api/default/events.d.ts +127 -0
- package/dist/api/default/events.d.ts.map +1 -0
- package/dist/api/default/events.js +2 -0
- package/dist/api/default/events.js.map +1 -0
- package/dist/api/default/gateway.d.ts +62 -0
- package/dist/api/default/gateway.d.ts.map +1 -0
- package/dist/api/default/gateway.js +2 -0
- package/dist/api/default/gateway.js.map +1 -0
- package/dist/api/default/guards.d.ts +87 -0
- package/dist/api/default/guards.d.ts.map +1 -0
- package/dist/api/default/guards.js +78 -0
- package/dist/api/default/guards.js.map +1 -0
- package/dist/api/default/guilds.d.ts +230 -0
- package/dist/api/default/guilds.d.ts.map +1 -0
- package/dist/api/default/guilds.js +2 -0
- package/dist/api/default/guilds.js.map +1 -0
- package/dist/api/default/helpers.d.ts +79 -0
- package/dist/api/default/helpers.d.ts.map +1 -0
- package/dist/api/default/helpers.js +79 -0
- package/dist/api/default/helpers.js.map +1 -0
- package/dist/api/default/instance.d.ts +47 -0
- package/dist/api/default/instance.d.ts.map +1 -0
- package/dist/api/default/instance.js +2 -0
- package/dist/api/default/instance.js.map +1 -0
- package/dist/api/default/invites.d.ts +57 -0
- package/dist/api/default/invites.d.ts.map +1 -0
- package/dist/api/default/invites.js +2 -0
- package/dist/api/default/invites.js.map +1 -0
- package/dist/api/default/logging.d.ts +37 -0
- package/dist/api/default/logging.d.ts.map +1 -0
- package/dist/api/default/logging.js +2 -0
- package/dist/api/default/logging.js.map +1 -0
- package/dist/api/default/members.d.ts +442 -0
- package/dist/api/default/members.d.ts.map +1 -0
- package/dist/api/default/members.js +2 -0
- package/dist/api/default/members.js.map +1 -0
- package/dist/api/default/messages.d.ts +898 -0
- package/dist/api/default/messages.d.ts.map +1 -0
- package/dist/api/default/messages.js +2 -0
- package/dist/api/default/messages.js.map +1 -0
- package/dist/api/default/oauth.d.ts +168 -0
- package/dist/api/default/oauth.d.ts.map +1 -0
- package/dist/api/default/oauth.js +84 -0
- package/dist/api/default/oauth.js.map +1 -0
- package/dist/api/default/permissions.d.ts +44 -0
- package/dist/api/default/permissions.d.ts.map +1 -0
- package/dist/api/default/permissions.js +2 -0
- package/dist/api/default/permissions.js.map +1 -0
- package/dist/api/default/presence.d.ts +88 -0
- package/dist/api/default/presence.d.ts.map +1 -0
- package/dist/api/default/presence.js +2 -0
- package/dist/api/default/presence.js.map +1 -0
- package/dist/api/default/rest.d.ts +28 -0
- package/dist/api/default/rest.d.ts.map +1 -0
- package/dist/api/default/rest.js +2 -0
- package/dist/api/default/rest.js.map +1 -0
- package/dist/api/default/results.d.ts +31 -0
- package/dist/api/default/results.d.ts.map +1 -0
- package/dist/api/default/results.js +14 -0
- package/dist/api/default/results.js.map +1 -0
- package/dist/api/default/roles.d.ts +119 -0
- package/dist/api/default/roles.d.ts.map +1 -0
- package/dist/api/default/roles.js +2 -0
- package/dist/api/default/roles.js.map +1 -0
- package/dist/api/default/stickers.d.ts +92 -0
- package/dist/api/default/stickers.d.ts.map +1 -0
- package/dist/api/default/stickers.js +2 -0
- package/dist/api/default/stickers.js.map +1 -0
- package/dist/api/default/supervisor.d.ts +51 -0
- package/dist/api/default/supervisor.d.ts.map +1 -0
- package/dist/api/default/supervisor.js +53 -0
- package/dist/api/default/supervisor.js.map +1 -0
- package/dist/api/default/threads.d.ts +158 -0
- package/dist/api/default/threads.d.ts.map +1 -0
- package/dist/api/default/threads.js +2 -0
- package/dist/api/default/threads.js.map +1 -0
- package/dist/api/default/users.d.ts +73 -0
- package/dist/api/default/users.d.ts.map +1 -0
- package/dist/api/default/users.js +2 -0
- package/dist/api/default/users.js.map +1 -0
- package/dist/api/default/webhook-client.d.ts +149 -0
- package/dist/api/default/webhook-client.d.ts.map +1 -0
- package/dist/api/default/webhook-client.js +69 -0
- package/dist/api/default/webhook-client.js.map +1 -0
- package/dist/api/default/webhooks.d.ts +62 -0
- package/dist/api/default/webhooks.d.ts.map +1 -0
- package/dist/api/default/webhooks.js +2 -0
- package/dist/api/default/webhooks.js.map +1 -0
- package/dist/api/effect/application.d.ts +29 -0
- package/dist/api/effect/application.d.ts.map +1 -0
- package/dist/api/effect/application.js +2 -0
- package/dist/api/effect/application.js.map +1 -0
- package/dist/api/effect/attachments.d.ts +84 -0
- package/dist/api/effect/attachments.d.ts.map +1 -0
- package/dist/api/effect/attachments.js +2 -0
- package/dist/api/effect/attachments.js.map +1 -0
- package/dist/api/effect/audit-logs.d.ts +42 -0
- package/dist/api/effect/audit-logs.d.ts.map +1 -0
- package/dist/api/effect/audit-logs.js +2 -0
- package/dist/api/effect/audit-logs.js.map +1 -0
- package/dist/api/effect/bot.d.ts +233 -0
- package/dist/api/effect/bot.d.ts.map +1 -0
- package/dist/api/effect/bot.js +230 -0
- package/dist/api/effect/bot.js.map +1 -0
- package/dist/api/effect/cache.d.ts +103 -0
- package/dist/api/effect/cache.d.ts.map +1 -0
- package/dist/api/effect/cache.js +2 -0
- package/dist/api/effect/cache.js.map +1 -0
- package/dist/api/effect/channels.d.ts +231 -0
- package/dist/api/effect/channels.d.ts.map +1 -0
- package/dist/api/effect/channels.js +2 -0
- package/dist/api/effect/channels.js.map +1 -0
- package/dist/api/effect/client.d.ts +622 -0
- package/dist/api/effect/client.d.ts.map +1 -0
- package/dist/api/effect/client.js +191 -0
- package/dist/api/effect/client.js.map +1 -0
- package/dist/api/effect/collectors.d.ts +90 -0
- package/dist/api/effect/collectors.d.ts.map +1 -0
- package/dist/api/effect/collectors.js +2 -0
- package/dist/api/effect/collectors.js.map +1 -0
- package/dist/api/effect/commands.d.ts +86 -0
- package/dist/api/effect/commands.d.ts.map +1 -0
- package/dist/api/effect/commands.js +87 -0
- package/dist/api/effect/commands.js.map +1 -0
- package/dist/api/effect/direct-messages.d.ts +102 -0
- package/dist/api/effect/direct-messages.d.ts.map +1 -0
- package/dist/api/effect/direct-messages.js +2 -0
- package/dist/api/effect/direct-messages.js.map +1 -0
- package/dist/api/effect/discovery.d.ts +68 -0
- package/dist/api/effect/discovery.d.ts.map +1 -0
- package/dist/api/effect/discovery.js +2 -0
- package/dist/api/effect/discovery.js.map +1 -0
- package/dist/api/effect/emojis.d.ts +77 -0
- package/dist/api/effect/emojis.d.ts.map +1 -0
- package/dist/api/effect/emojis.js +2 -0
- package/dist/api/effect/emojis.js.map +1 -0
- package/dist/api/effect/events.d.ts +78 -0
- package/dist/api/effect/events.d.ts.map +1 -0
- package/dist/api/effect/events.js +12 -0
- package/dist/api/effect/events.js.map +1 -0
- package/dist/api/effect/failures.d.ts +14 -0
- package/dist/api/effect/failures.d.ts.map +1 -0
- package/dist/api/effect/failures.js +2 -0
- package/dist/api/effect/failures.js.map +1 -0
- package/dist/api/effect/gateway.d.ts +63 -0
- package/dist/api/effect/gateway.d.ts.map +1 -0
- package/dist/api/effect/gateway.js +2 -0
- package/dist/api/effect/gateway.js.map +1 -0
- package/dist/api/effect/guards.d.ts +91 -0
- package/dist/api/effect/guards.d.ts.map +1 -0
- package/dist/api/effect/guards.js +94 -0
- package/dist/api/effect/guards.js.map +1 -0
- package/dist/api/effect/guilds.d.ts +221 -0
- package/dist/api/effect/guilds.d.ts.map +1 -0
- package/dist/api/effect/guilds.js +2 -0
- package/dist/api/effect/guilds.js.map +1 -0
- package/dist/api/effect/helpers.d.ts +300 -0
- package/dist/api/effect/helpers.d.ts.map +1 -0
- package/dist/api/effect/helpers.js +156 -0
- package/dist/api/effect/helpers.js.map +1 -0
- package/dist/api/effect/hierarchy.d.ts +26 -0
- package/dist/api/effect/hierarchy.d.ts.map +1 -0
- package/dist/api/effect/hierarchy.js +26 -0
- package/dist/api/effect/hierarchy.js.map +1 -0
- package/dist/api/effect/instance.d.ts +46 -0
- package/dist/api/effect/instance.d.ts.map +1 -0
- package/dist/api/effect/instance.js +8 -0
- package/dist/api/effect/instance.js.map +1 -0
- package/dist/api/effect/invites.d.ts +49 -0
- package/dist/api/effect/invites.d.ts.map +1 -0
- package/dist/api/effect/invites.js +2 -0
- package/dist/api/effect/invites.js.map +1 -0
- package/dist/api/effect/logging.d.ts +37 -0
- package/dist/api/effect/logging.d.ts.map +1 -0
- package/dist/api/effect/logging.js +2 -0
- package/dist/api/effect/logging.js.map +1 -0
- package/dist/api/effect/members.d.ts +433 -0
- package/dist/api/effect/members.d.ts.map +1 -0
- package/dist/api/effect/members.js +2 -0
- package/dist/api/effect/members.js.map +1 -0
- package/dist/api/effect/messages.d.ts +877 -0
- package/dist/api/effect/messages.d.ts.map +1 -0
- package/dist/api/effect/messages.js +2 -0
- package/dist/api/effect/messages.js.map +1 -0
- package/dist/api/effect/oauth.d.ts +148 -0
- package/dist/api/effect/oauth.d.ts.map +1 -0
- package/dist/api/effect/oauth.js +51 -0
- package/dist/api/effect/oauth.js.map +1 -0
- package/dist/api/effect/permissions.d.ts +41 -0
- package/dist/api/effect/permissions.d.ts.map +1 -0
- package/dist/api/effect/permissions.js +2 -0
- package/dist/api/effect/permissions.js.map +1 -0
- package/dist/api/effect/presence.d.ts +83 -0
- package/dist/api/effect/presence.d.ts.map +1 -0
- package/dist/api/effect/presence.js +2 -0
- package/dist/api/effect/presence.js.map +1 -0
- package/dist/api/effect/rest.d.ts +27 -0
- package/dist/api/effect/rest.d.ts.map +1 -0
- package/dist/api/effect/rest.js +2 -0
- package/dist/api/effect/rest.js.map +1 -0
- package/dist/api/effect/roles.d.ts +104 -0
- package/dist/api/effect/roles.d.ts.map +1 -0
- package/dist/api/effect/roles.js +2 -0
- package/dist/api/effect/roles.js.map +1 -0
- package/dist/api/effect/service.d.ts +76 -0
- package/dist/api/effect/service.d.ts.map +1 -0
- package/dist/api/effect/service.js +79 -0
- package/dist/api/effect/service.js.map +1 -0
- package/dist/api/effect/stickers.d.ts +81 -0
- package/dist/api/effect/stickers.d.ts.map +1 -0
- package/dist/api/effect/stickers.js +2 -0
- package/dist/api/effect/stickers.js.map +1 -0
- package/dist/api/effect/supervisor.d.ts +56 -0
- package/dist/api/effect/supervisor.d.ts.map +1 -0
- package/dist/api/effect/supervisor.js +58 -0
- package/dist/api/effect/supervisor.js.map +1 -0
- package/dist/api/effect/threads.d.ts +154 -0
- package/dist/api/effect/threads.d.ts.map +1 -0
- package/dist/api/effect/threads.js +2 -0
- package/dist/api/effect/threads.js.map +1 -0
- package/dist/api/effect/users.d.ts +62 -0
- package/dist/api/effect/users.d.ts.map +1 -0
- package/dist/api/effect/users.js +2 -0
- package/dist/api/effect/users.js.map +1 -0
- package/dist/api/effect/webhook-client.d.ts +140 -0
- package/dist/api/effect/webhook-client.d.ts.map +1 -0
- package/dist/api/effect/webhook-client.js +50 -0
- package/dist/api/effect/webhook-client.js.map +1 -0
- package/dist/api/effect/webhooks.d.ts +54 -0
- package/dist/api/effect/webhooks.d.ts.map +1 -0
- package/dist/api/effect/webhooks.js +2 -0
- package/dist/api/effect/webhooks.js.map +1 -0
- package/dist/api-errors.d.ts +609 -0
- package/dist/api-errors.d.ts.map +1 -0
- package/dist/api-errors.js +589 -0
- package/dist/api-errors.js.map +1 -0
- package/dist/application.d.ts +85 -0
- package/dist/application.d.ts.map +1 -0
- package/dist/application.js +44 -0
- package/dist/application.js.map +1 -0
- package/dist/assets.d.ts +197 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +419 -0
- package/dist/assets.js.map +1 -0
- package/dist/attachments.d.ts +400 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +88 -0
- package/dist/attachments.js.map +1 -0
- package/dist/audit-logs.d.ts +292 -0
- package/dist/audit-logs.d.ts.map +1 -0
- package/dist/audit-logs.js +46 -0
- package/dist/audit-logs.js.map +1 -0
- package/dist/bot-runner.d.ts +69 -0
- package/dist/bot-runner.d.ts.map +1 -0
- package/dist/bot-runner.js +41 -0
- package/dist/bot-runner.js.map +1 -0
- package/dist/builders.d.ts +153 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/builders.js +326 -0
- package/dist/builders.js.map +1 -0
- package/dist/cache.d.ts +187 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +2 -0
- package/dist/cache.js.map +1 -0
- package/dist/channels.d.ts +903 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +125 -0
- package/dist/channels.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +65 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +645 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/collectors.d.ts +205 -0
- package/dist/collectors.d.ts.map +1 -0
- package/dist/collectors.js +71 -0
- package/dist/collectors.js.map +1 -0
- package/dist/colors.d.ts +55 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +40 -0
- package/dist/colors.js.map +1 -0
- package/dist/command-arguments.d.ts +353 -0
- package/dist/command-arguments.d.ts.map +1 -0
- package/dist/command-arguments.js +2 -0
- package/dist/command-arguments.js.map +1 -0
- package/dist/command-help.d.ts +54 -0
- package/dist/command-help.d.ts.map +1 -0
- package/dist/command-help.js +2 -0
- package/dist/command-help.js.map +1 -0
- package/dist/commands.d.ts +328 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +62 -0
- package/dist/commands.js.map +1 -0
- package/dist/counts.d.ts +124 -0
- package/dist/counts.d.ts.map +1 -0
- package/dist/counts.js +52 -0
- package/dist/counts.js.map +1 -0
- package/dist/default-commands.d.ts +400 -0
- package/dist/default-commands.d.ts.map +1 -0
- package/dist/default-commands.js +488 -0
- package/dist/default-commands.js.map +1 -0
- package/dist/default-supervisor.d.ts +111 -0
- package/dist/default-supervisor.d.ts.map +1 -0
- package/dist/default-supervisor.js +277 -0
- package/dist/default-supervisor.js.map +1 -0
- package/dist/discovery.d.ts +223 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +18 -0
- package/dist/discovery.js.map +1 -0
- package/dist/effect-testing.d.ts +388 -0
- package/dist/effect-testing.d.ts.map +1 -0
- package/dist/effect-testing.js +261 -0
- package/dist/effect-testing.js.map +1 -0
- package/dist/effect.d.ts +220 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +101 -0
- package/dist/effect.js.map +1 -0
- package/dist/embeds.d.ts +243 -0
- package/dist/embeds.d.ts.map +1 -0
- package/dist/embeds.js +2 -0
- package/dist/embeds.js.map +1 -0
- package/dist/error-tools.d.ts +101 -0
- package/dist/error-tools.d.ts.map +1 -0
- package/dist/error-tools.js +125 -0
- package/dist/error-tools.js.map +1 -0
- package/dist/errors.d.ts +386 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +440 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +798 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/expressions.d.ts +188 -0
- package/dist/expressions.d.ts.map +1 -0
- package/dist/expressions.js +2 -0
- package/dist/expressions.js.map +1 -0
- package/dist/failures.d.ts +53 -0
- package/dist/failures.d.ts.map +1 -0
- package/dist/failures.js +2 -0
- package/dist/failures.js.map +1 -0
- package/dist/gateway.d.ts +48 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +60 -0
- package/dist/gateway.js.map +1 -0
- package/dist/guilds.d.ts +923 -0
- package/dist/guilds.d.ts.map +1 -0
- package/dist/guilds.js +204 -0
- package/dist/guilds.js.map +1 -0
- package/dist/helpers.d.ts +423 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +434 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +228 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/input-validation.d.ts +51 -0
- package/dist/input-validation.d.ts.map +1 -0
- package/dist/input-validation.js +34 -0
- package/dist/input-validation.js.map +1 -0
- package/dist/instance.d.ts +101 -0
- package/dist/instance.d.ts.map +1 -0
- package/dist/instance.js +2 -0
- package/dist/instance.js.map +1 -0
- package/dist/internal/agents-section.d.ts +22 -0
- package/dist/internal/agents-section.d.ts.map +1 -0
- package/dist/internal/agents-section.js +101 -0
- package/dist/internal/agents-section.js.map +1 -0
- package/dist/internal/application.d.ts +16 -0
- package/dist/internal/application.d.ts.map +1 -0
- package/dist/internal/application.js +33 -0
- package/dist/internal/application.js.map +1 -0
- package/dist/internal/attachment-refresh.d.ts +18 -0
- package/dist/internal/attachment-refresh.d.ts.map +1 -0
- package/dist/internal/attachment-refresh.js +39 -0
- package/dist/internal/attachment-refresh.js.map +1 -0
- package/dist/internal/attachments.d.ts +45 -0
- package/dist/internal/attachments.d.ts.map +1 -0
- package/dist/internal/attachments.js +230 -0
- package/dist/internal/attachments.js.map +1 -0
- package/dist/internal/audit-logs.d.ts +13 -0
- package/dist/internal/audit-logs.d.ts.map +1 -0
- package/dist/internal/audit-logs.js +295 -0
- package/dist/internal/audit-logs.js.map +1 -0
- package/dist/internal/audit.d.ts +12 -0
- package/dist/internal/audit.d.ts.map +1 -0
- package/dist/internal/audit.js +22 -0
- package/dist/internal/audit.js.map +1 -0
- package/dist/internal/binding/default-adapters.d.ts +22 -0
- package/dist/internal/binding/default-adapters.d.ts.map +1 -0
- package/dist/internal/binding/default-adapters.js +304 -0
- package/dist/internal/binding/default-adapters.js.map +1 -0
- package/dist/internal/binding/default.d.ts +45 -0
- package/dist/internal/binding/default.d.ts.map +1 -0
- package/dist/internal/binding/default.js +86 -0
- package/dist/internal/binding/default.js.map +1 -0
- package/dist/internal/binding/execute.d.ts +51 -0
- package/dist/internal/binding/execute.d.ts.map +1 -0
- package/dist/internal/binding/execute.js +123 -0
- package/dist/internal/binding/execute.js.map +1 -0
- package/dist/internal/binding/native-adapters.d.ts +23 -0
- package/dist/internal/binding/native-adapters.d.ts.map +1 -0
- package/dist/internal/binding/native-adapters.js +90 -0
- package/dist/internal/binding/native-adapters.js.map +1 -0
- package/dist/internal/binding/native.d.ts +41 -0
- package/dist/internal/binding/native.d.ts.map +1 -0
- package/dist/internal/binding/native.js +34 -0
- package/dist/internal/binding/native.js.map +1 -0
- package/dist/internal/binding/operations.d.ts +361 -0
- package/dist/internal/binding/operations.d.ts.map +1 -0
- package/dist/internal/binding/operations.js +272 -0
- package/dist/internal/binding/operations.js.map +1 -0
- package/dist/internal/bot-runner.d.ts +65 -0
- package/dist/internal/bot-runner.d.ts.map +1 -0
- package/dist/internal/bot-runner.js +363 -0
- package/dist/internal/bot-runner.js.map +1 -0
- package/dist/internal/cache-changes.d.ts +43 -0
- package/dist/internal/cache-changes.d.ts.map +1 -0
- package/dist/internal/cache-changes.js +320 -0
- package/dist/internal/cache-changes.js.map +1 -0
- package/dist/internal/cache.d.ts +57 -0
- package/dist/internal/cache.d.ts.map +1 -0
- package/dist/internal/cache.js +318 -0
- package/dist/internal/cache.js.map +1 -0
- package/dist/internal/calls.d.ts +16 -0
- package/dist/internal/calls.d.ts.map +1 -0
- package/dist/internal/calls.js +108 -0
- package/dist/internal/calls.js.map +1 -0
- package/dist/internal/channel-cache.d.ts +69 -0
- package/dist/internal/channel-cache.d.ts.map +1 -0
- package/dist/internal/channel-cache.js +413 -0
- package/dist/internal/channel-cache.js.map +1 -0
- package/dist/internal/channel-decode.d.ts +44 -0
- package/dist/internal/channel-decode.d.ts.map +1 -0
- package/dist/internal/channel-decode.js +377 -0
- package/dist/internal/channel-decode.js.map +1 -0
- package/dist/internal/channels.d.ts +60 -0
- package/dist/internal/channels.d.ts.map +1 -0
- package/dist/internal/channels.js +605 -0
- package/dist/internal/channels.js.map +1 -0
- package/dist/internal/client/backoff.d.ts +42 -0
- package/dist/internal/client/backoff.d.ts.map +1 -0
- package/dist/internal/client/backoff.js +36 -0
- package/dist/internal/client/backoff.js.map +1 -0
- package/dist/internal/client/configuration-fields.d.ts +14 -0
- package/dist/internal/client/configuration-fields.d.ts.map +1 -0
- package/dist/internal/client/configuration-fields.js +11 -0
- package/dist/internal/client/configuration-fields.js.map +1 -0
- package/dist/internal/client/drain.d.ts +33 -0
- package/dist/internal/client/drain.d.ts.map +1 -0
- package/dist/internal/client/drain.js +109 -0
- package/dist/internal/client/drain.js.map +1 -0
- package/dist/internal/client/intake.d.ts +27 -0
- package/dist/internal/client/intake.d.ts.map +1 -0
- package/dist/internal/client/intake.js +198 -0
- package/dist/internal/client/intake.js.map +1 -0
- package/dist/internal/client/lifetime.d.ts +35 -0
- package/dist/internal/client/lifetime.d.ts.map +1 -0
- package/dist/internal/client/lifetime.js +109 -0
- package/dist/internal/client/lifetime.js.map +1 -0
- package/dist/internal/client/shard-loop.d.ts +93 -0
- package/dist/internal/client/shard-loop.d.ts.map +1 -0
- package/dist/internal/client/shard-loop.js +452 -0
- package/dist/internal/client/shard-loop.js.map +1 -0
- package/dist/internal/client-registry.d.ts +26 -0
- package/dist/internal/client-registry.d.ts.map +1 -0
- package/dist/internal/client-registry.js +11 -0
- package/dist/internal/client-registry.js.map +1 -0
- package/dist/internal/client.d.ts +189 -0
- package/dist/internal/client.d.ts.map +1 -0
- package/dist/internal/client.js +1935 -0
- package/dist/internal/client.js.map +1 -0
- package/dist/internal/clock.d.ts +9 -0
- package/dist/internal/clock.d.ts.map +1 -0
- package/dist/internal/clock.js +5 -0
- package/dist/internal/clock.js.map +1 -0
- package/dist/internal/code-catalogue.d.ts +712 -0
- package/dist/internal/code-catalogue.d.ts.map +1 -0
- package/dist/internal/code-catalogue.js +655 -0
- package/dist/internal/code-catalogue.js.map +1 -0
- package/dist/internal/collector.d.ts +34 -0
- package/dist/internal/collector.d.ts.map +1 -0
- package/dist/internal/collector.js +400 -0
- package/dist/internal/collector.js.map +1 -0
- package/dist/internal/command-arguments.d.ts +29 -0
- package/dist/internal/command-arguments.d.ts.map +1 -0
- package/dist/internal/command-arguments.js +484 -0
- package/dist/internal/command-arguments.js.map +1 -0
- package/dist/internal/command-guards.d.ts +57 -0
- package/dist/internal/command-guards.d.ts.map +1 -0
- package/dist/internal/command-guards.js +81 -0
- package/dist/internal/command-guards.js.map +1 -0
- package/dist/internal/command-help.d.ts +15 -0
- package/dist/internal/command-help.d.ts.map +1 -0
- package/dist/internal/command-help.js +121 -0
- package/dist/internal/command-help.js.map +1 -0
- package/dist/internal/commands.d.ts +212 -0
- package/dist/internal/commands.d.ts.map +1 -0
- package/dist/internal/commands.js +1004 -0
- package/dist/internal/commands.js.map +1 -0
- package/dist/internal/configuration.d.ts +86 -0
- package/dist/internal/configuration.d.ts.map +1 -0
- package/dist/internal/configuration.js +401 -0
- package/dist/internal/configuration.js.map +1 -0
- package/dist/internal/counts.d.ts +33 -0
- package/dist/internal/counts.d.ts.map +1 -0
- package/dist/internal/counts.js +348 -0
- package/dist/internal/counts.js.map +1 -0
- package/dist/internal/decode/primitives.d.ts +30 -0
- package/dist/internal/decode/primitives.d.ts.map +1 -0
- package/dist/internal/decode/primitives.js +56 -0
- package/dist/internal/decode/primitives.js.map +1 -0
- package/dist/internal/decode/timestamp.d.ts +13 -0
- package/dist/internal/decode/timestamp.d.ts.map +1 -0
- package/dist/internal/decode/timestamp.js +27 -0
- package/dist/internal/decode/timestamp.js.map +1 -0
- package/dist/internal/decode/trace.d.ts +11 -0
- package/dist/internal/decode/trace.d.ts.map +1 -0
- package/dist/internal/decode/trace.js +69 -0
- package/dist/internal/decode/trace.js.map +1 -0
- package/dist/internal/defects.d.ts +48 -0
- package/dist/internal/defects.d.ts.map +1 -0
- package/dist/internal/defects.js +100 -0
- package/dist/internal/defects.js.map +1 -0
- package/dist/internal/effect-failures.d.ts +12 -0
- package/dist/internal/effect-failures.d.ts.map +1 -0
- package/dist/internal/effect-failures.js +45 -0
- package/dist/internal/effect-failures.js.map +1 -0
- package/dist/internal/embeds.d.ts +12 -0
- package/dist/internal/embeds.d.ts.map +1 -0
- package/dist/internal/embeds.js +308 -0
- package/dist/internal/embeds.js.map +1 -0
- package/dist/internal/events.d.ts +156 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +1071 -0
- package/dist/internal/events.js.map +1 -0
- package/dist/internal/expiry-queue.d.ts +42 -0
- package/dist/internal/expiry-queue.d.ts.map +1 -0
- package/dist/internal/expiry-queue.js +138 -0
- package/dist/internal/expiry-queue.js.map +1 -0
- package/dist/internal/expressions.d.ts +35 -0
- package/dist/internal/expressions.d.ts.map +1 -0
- package/dist/internal/expressions.js +311 -0
- package/dist/internal/expressions.js.map +1 -0
- package/dist/internal/failures.d.ts +107 -0
- package/dist/internal/failures.d.ts.map +1 -0
- package/dist/internal/failures.js +416 -0
- package/dist/internal/failures.js.map +1 -0
- package/dist/internal/field-text.d.ts +10 -0
- package/dist/internal/field-text.d.ts.map +1 -0
- package/dist/internal/field-text.js +37 -0
- package/dist/internal/field-text.js.map +1 -0
- package/dist/internal/gateway/commands.d.ts +92 -0
- package/dist/internal/gateway/commands.d.ts.map +1 -0
- package/dist/internal/gateway/commands.js +223 -0
- package/dist/internal/gateway/commands.js.map +1 -0
- package/dist/internal/gateway/dispatch-table.d.ts +42 -0
- package/dist/internal/gateway/dispatch-table.d.ts.map +1 -0
- package/dist/internal/gateway/dispatch-table.js +288 -0
- package/dist/internal/gateway/dispatch-table.js.map +1 -0
- package/dist/internal/gateway/event-dispatches.d.ts +97 -0
- package/dist/internal/gateway/event-dispatches.d.ts.map +1 -0
- package/dist/internal/gateway/event-dispatches.js +172 -0
- package/dist/internal/gateway/event-dispatches.js.map +1 -0
- package/dist/internal/gateway/frames.d.ts +45 -0
- package/dist/internal/gateway/frames.d.ts.map +1 -0
- package/dist/internal/gateway/frames.js +121 -0
- package/dist/internal/gateway/frames.js.map +1 -0
- package/dist/internal/gateway/options.d.ts +24 -0
- package/dist/internal/gateway/options.d.ts.map +1 -0
- package/dist/internal/gateway/options.js +103 -0
- package/dist/internal/gateway/options.js.map +1 -0
- package/dist/internal/gateway/session.d.ts +104 -0
- package/dist/internal/gateway/session.d.ts.map +1 -0
- package/dist/internal/gateway/session.js +420 -0
- package/dist/internal/gateway/session.js.map +1 -0
- package/dist/internal/gateway-requests.d.ts +10 -0
- package/dist/internal/gateway-requests.d.ts.map +1 -0
- package/dist/internal/gateway-requests.js +26 -0
- package/dist/internal/gateway-requests.js.map +1 -0
- package/dist/internal/gateway.d.ts +19 -0
- package/dist/internal/gateway.d.ts.map +1 -0
- package/dist/internal/gateway.js +11 -0
- package/dist/internal/gateway.js.map +1 -0
- package/dist/internal/guild-cache.d.ts +69 -0
- package/dist/internal/guild-cache.d.ts.map +1 -0
- package/dist/internal/guild-cache.js +402 -0
- package/dist/internal/guild-cache.js.map +1 -0
- package/dist/internal/guild-discovery.d.ts +15 -0
- package/dist/internal/guild-discovery.d.ts.map +1 -0
- package/dist/internal/guild-discovery.js +258 -0
- package/dist/internal/guild-discovery.js.map +1 -0
- package/dist/internal/guild-lifecycle.d.ts +18 -0
- package/dist/internal/guild-lifecycle.d.ts.map +1 -0
- package/dist/internal/guild-lifecycle.js +119 -0
- package/dist/internal/guild-lifecycle.js.map +1 -0
- package/dist/internal/guild-settings.d.ts +11 -0
- package/dist/internal/guild-settings.d.ts.map +1 -0
- package/dist/internal/guild-settings.js +150 -0
- package/dist/internal/guild-settings.js.map +1 -0
- package/dist/internal/guilds.d.ts +94 -0
- package/dist/internal/guilds.d.ts.map +1 -0
- package/dist/internal/guilds.js +785 -0
- package/dist/internal/guilds.js.map +1 -0
- package/dist/internal/init-command.d.ts +54 -0
- package/dist/internal/init-command.d.ts.map +1 -0
- package/dist/internal/init-command.js +248 -0
- package/dist/internal/init-command.js.map +1 -0
- package/dist/internal/instance.d.ts +69 -0
- package/dist/internal/instance.d.ts.map +1 -0
- package/dist/internal/instance.js +455 -0
- package/dist/internal/instance.js.map +1 -0
- package/dist/internal/invalid-callback-return.d.ts +3 -0
- package/dist/internal/invalid-callback-return.d.ts.map +1 -0
- package/dist/internal/invalid-callback-return.js +26 -0
- package/dist/internal/invalid-callback-return.js.map +1 -0
- package/dist/internal/invites.d.ts +19 -0
- package/dist/internal/invites.d.ts.map +1 -0
- package/dist/internal/invites.js +182 -0
- package/dist/internal/invites.js.map +1 -0
- package/dist/internal/logging.d.ts +129 -0
- package/dist/internal/logging.d.ts.map +1 -0
- package/dist/internal/logging.js +868 -0
- package/dist/internal/logging.js.map +1 -0
- package/dist/internal/logical-scheduler.d.ts +27 -0
- package/dist/internal/logical-scheduler.d.ts.map +1 -0
- package/dist/internal/logical-scheduler.js +102 -0
- package/dist/internal/logical-scheduler.js.map +1 -0
- package/dist/internal/masking.d.ts +13 -0
- package/dist/internal/masking.d.ts.map +1 -0
- package/dist/internal/masking.js +235 -0
- package/dist/internal/masking.js.map +1 -0
- package/dist/internal/member-chunks.d.ts +96 -0
- package/dist/internal/member-chunks.d.ts.map +1 -0
- package/dist/internal/member-chunks.js +557 -0
- package/dist/internal/member-chunks.js.map +1 -0
- package/dist/internal/member-search-workflow.d.ts +19 -0
- package/dist/internal/member-search-workflow.d.ts.map +1 -0
- package/dist/internal/member-search-workflow.js +143 -0
- package/dist/internal/member-search-workflow.js.map +1 -0
- package/dist/internal/member-search.d.ts +20 -0
- package/dist/internal/member-search.d.ts.map +1 -0
- package/dist/internal/member-search.js +201 -0
- package/dist/internal/member-search.js.map +1 -0
- package/dist/internal/message-cleanup.d.ts +9 -0
- package/dist/internal/message-cleanup.d.ts.map +1 -0
- package/dist/internal/message-cleanup.js +368 -0
- package/dist/internal/message-cleanup.js.map +1 -0
- package/dist/internal/message-fields.d.ts +9 -0
- package/dist/internal/message-fields.d.ts.map +1 -0
- package/dist/internal/message-fields.js +55 -0
- package/dist/internal/message-fields.js.map +1 -0
- package/dist/internal/message-search-workflow.d.ts +14 -0
- package/dist/internal/message-search-workflow.d.ts.map +1 -0
- package/dist/internal/message-search-workflow.js +101 -0
- package/dist/internal/message-search-workflow.js.map +1 -0
- package/dist/internal/message-search.d.ts +19 -0
- package/dist/internal/message-search.d.ts.map +1 -0
- package/dist/internal/message-search.js +317 -0
- package/dist/internal/message-search.js.map +1 -0
- package/dist/internal/message.d.ts +34 -0
- package/dist/internal/message.d.ts.map +1 -0
- package/dist/internal/message.js +723 -0
- package/dist/internal/message.js.map +1 -0
- package/dist/internal/metrics.d.ts +16 -0
- package/dist/internal/metrics.d.ts.map +1 -0
- package/dist/internal/metrics.js +49 -0
- package/dist/internal/metrics.js.map +1 -0
- package/dist/internal/moderation.d.ts +20 -0
- package/dist/internal/moderation.d.ts.map +1 -0
- package/dist/internal/moderation.js +219 -0
- package/dist/internal/moderation.js.map +1 -0
- package/dist/internal/multipart.d.ts +10 -0
- package/dist/internal/multipart.d.ts.map +1 -0
- package/dist/internal/multipart.js +156 -0
- package/dist/internal/multipart.js.map +1 -0
- package/dist/internal/node-version.d.ts +10 -0
- package/dist/internal/node-version.d.ts.map +1 -0
- package/dist/internal/node-version.js +21 -0
- package/dist/internal/node-version.js.map +1 -0
- package/dist/internal/oauth.d.ts +29 -0
- package/dist/internal/oauth.d.ts.map +1 -0
- package/dist/internal/oauth.js +721 -0
- package/dist/internal/oauth.js.map +1 -0
- package/dist/internal/observer.d.ts +21 -0
- package/dist/internal/observer.d.ts.map +1 -0
- package/dist/internal/observer.js +48 -0
- package/dist/internal/observer.js.map +1 -0
- package/dist/internal/operation-signal.d.ts +9 -0
- package/dist/internal/operation-signal.d.ts.map +1 -0
- package/dist/internal/operation-signal.js +19 -0
- package/dist/internal/operation-signal.js.map +1 -0
- package/dist/internal/pagination.d.ts +67 -0
- package/dist/internal/pagination.d.ts.map +1 -0
- package/dist/internal/pagination.js +306 -0
- package/dist/internal/pagination.js.map +1 -0
- package/dist/internal/permission-requirements.d.ts +34 -0
- package/dist/internal/permission-requirements.d.ts.map +1 -0
- package/dist/internal/permission-requirements.js +204 -0
- package/dist/internal/permission-requirements.js.map +1 -0
- package/dist/internal/permissions.d.ts +28 -0
- package/dist/internal/permissions.d.ts.map +1 -0
- package/dist/internal/permissions.js +314 -0
- package/dist/internal/permissions.js.map +1 -0
- package/dist/internal/pins.d.ts +24 -0
- package/dist/internal/pins.d.ts.map +1 -0
- package/dist/internal/pins.js +83 -0
- package/dist/internal/pins.js.map +1 -0
- package/dist/internal/presence.d.ts +101 -0
- package/dist/internal/presence.d.ts.map +1 -0
- package/dist/internal/presence.js +581 -0
- package/dist/internal/presence.js.map +1 -0
- package/dist/internal/protocol/gateway.d.ts +116 -0
- package/dist/internal/protocol/gateway.d.ts.map +1 -0
- package/dist/internal/protocol/gateway.js +258 -0
- package/dist/internal/protocol/gateway.js.map +1 -0
- package/dist/internal/rate-limit-templates.d.ts +2 -0
- package/dist/internal/rate-limit-templates.d.ts.map +1 -0
- package/dist/internal/rate-limit-templates.js +132 -0
- package/dist/internal/rate-limit-templates.js.map +1 -0
- package/dist/internal/rate-limits.d.ts +32 -0
- package/dist/internal/rate-limits.d.ts.map +1 -0
- package/dist/internal/rate-limits.js +306 -0
- package/dist/internal/rate-limits.js.map +1 -0
- package/dist/internal/reaction-collector.d.ts +39 -0
- package/dist/internal/reaction-collector.d.ts.map +1 -0
- package/dist/internal/reaction-collector.js +441 -0
- package/dist/internal/reaction-collector.js.map +1 -0
- package/dist/internal/reaction-pages.d.ts +18 -0
- package/dist/internal/reaction-pages.d.ts.map +1 -0
- package/dist/internal/reaction-pages.js +213 -0
- package/dist/internal/reaction-pages.js.map +1 -0
- package/dist/internal/reactions.d.ts +30 -0
- package/dist/internal/reactions.d.ts.map +1 -0
- package/dist/internal/reactions.js +160 -0
- package/dist/internal/reactions.js.map +1 -0
- package/dist/internal/rejection-scope.d.ts +25 -0
- package/dist/internal/rejection-scope.d.ts.map +1 -0
- package/dist/internal/rejection-scope.js +103 -0
- package/dist/internal/rejection-scope.js.map +1 -0
- package/dist/internal/response-json.d.ts +12 -0
- package/dist/internal/response-json.d.ts.map +1 -0
- package/dist/internal/response-json.js +74 -0
- package/dist/internal/response-json.js.map +1 -0
- package/dist/internal/rest/admission.d.ts +77 -0
- package/dist/internal/rest/admission.d.ts.map +1 -0
- package/dist/internal/rest/admission.js +178 -0
- package/dist/internal/rest/admission.js.map +1 -0
- package/dist/internal/rest/attempt.d.ts +124 -0
- package/dist/internal/rest/attempt.d.ts.map +1 -0
- package/dist/internal/rest/attempt.js +410 -0
- package/dist/internal/rest/attempt.js.map +1 -0
- package/dist/internal/rest/classify.d.ts +93 -0
- package/dist/internal/rest/classify.d.ts.map +1 -0
- package/dist/internal/rest/classify.js +304 -0
- package/dist/internal/rest/classify.js.map +1 -0
- package/dist/internal/rest/download.d.ts +66 -0
- package/dist/internal/rest/download.d.ts.map +1 -0
- package/dist/internal/rest/download.js +552 -0
- package/dist/internal/rest/download.js.map +1 -0
- package/dist/internal/rest/options.d.ts +42 -0
- package/dist/internal/rest/options.d.ts.map +1 -0
- package/dist/internal/rest/options.js +99 -0
- package/dist/internal/rest/options.js.map +1 -0
- package/dist/internal/rest/owner.d.ts +154 -0
- package/dist/internal/rest/owner.d.ts.map +1 -0
- package/dist/internal/rest/owner.js +1292 -0
- package/dist/internal/rest/owner.js.map +1 -0
- package/dist/internal/rest/request.d.ts +31 -0
- package/dist/internal/rest/request.d.ts.map +1 -0
- package/dist/internal/rest/request.js +227 -0
- package/dist/internal/rest/request.js.map +1 -0
- package/dist/internal/rest.d.ts +10 -0
- package/dist/internal/rest.d.ts.map +1 -0
- package/dist/internal/rest.js +9 -0
- package/dist/internal/rest.js.map +1 -0
- package/dist/internal/retention-age.d.ts +11 -0
- package/dist/internal/retention-age.d.ts.map +1 -0
- package/dist/internal/retention-age.js +29 -0
- package/dist/internal/retention-age.js.map +1 -0
- package/dist/internal/role-hierarchy-workflow.d.ts +15 -0
- package/dist/internal/role-hierarchy-workflow.d.ts.map +1 -0
- package/dist/internal/role-hierarchy-workflow.js +122 -0
- package/dist/internal/role-hierarchy-workflow.js.map +1 -0
- package/dist/internal/role-hierarchy.d.ts +11 -0
- package/dist/internal/role-hierarchy.d.ts.map +1 -0
- package/dist/internal/role-hierarchy.js +87 -0
- package/dist/internal/role-hierarchy.js.map +1 -0
- package/dist/internal/scheduled-tasks.d.ts +46 -0
- package/dist/internal/scheduled-tasks.d.ts.map +1 -0
- package/dist/internal/scheduled-tasks.js +190 -0
- package/dist/internal/scheduled-tasks.js.map +1 -0
- package/dist/internal/sharding.d.ts +62 -0
- package/dist/internal/sharding.d.ts.map +1 -0
- package/dist/internal/sharding.js +205 -0
- package/dist/internal/sharding.js.map +1 -0
- package/dist/internal/starter-project.d.ts +27 -0
- package/dist/internal/starter-project.d.ts.map +1 -0
- package/dist/internal/starter-project.js +224 -0
- package/dist/internal/starter-project.js.map +1 -0
- package/dist/internal/suggest.d.ts +12 -0
- package/dist/internal/suggest.d.ts.map +1 -0
- package/dist/internal/suggest.js +51 -0
- package/dist/internal/suggest.js.map +1 -0
- package/dist/internal/supervisor.d.ts +95 -0
- package/dist/internal/supervisor.d.ts.map +1 -0
- package/dist/internal/supervisor.js +1829 -0
- package/dist/internal/supervisor.js.map +1 -0
- package/dist/internal/testing/discovery.d.ts +24 -0
- package/dist/internal/testing/discovery.d.ts.map +1 -0
- package/dist/internal/testing/discovery.js +22 -0
- package/dist/internal/testing/discovery.js.map +1 -0
- package/dist/internal/testing/errors.d.ts +43 -0
- package/dist/internal/testing/errors.d.ts.map +1 -0
- package/dist/internal/testing/errors.js +63 -0
- package/dist/internal/testing/errors.js.map +1 -0
- package/dist/internal/testing/fixtures.d.ts +477 -0
- package/dist/internal/testing/fixtures.d.ts.map +1 -0
- package/dist/internal/testing/fixtures.js +233 -0
- package/dist/internal/testing/fixtures.js.map +1 -0
- package/dist/internal/testing/gateway.d.ts +51 -0
- package/dist/internal/testing/gateway.d.ts.map +1 -0
- package/dist/internal/testing/gateway.js +265 -0
- package/dist/internal/testing/gateway.js.map +1 -0
- package/dist/internal/testing/harness.d.ts +60 -0
- package/dist/internal/testing/harness.d.ts.map +1 -0
- package/dist/internal/testing/harness.js +280 -0
- package/dist/internal/testing/harness.js.map +1 -0
- package/dist/internal/testing/http.d.ts +31 -0
- package/dist/internal/testing/http.d.ts.map +1 -0
- package/dist/internal/testing/http.js +347 -0
- package/dist/internal/testing/http.js.map +1 -0
- package/dist/internal/testing/types.d.ts +222 -0
- package/dist/internal/testing/types.d.ts.map +1 -0
- package/dist/internal/testing/types.js +2 -0
- package/dist/internal/testing/types.js.map +1 -0
- package/dist/internal/testing/wait.d.ts +16 -0
- package/dist/internal/testing/wait.d.ts.map +1 -0
- package/dist/internal/testing/wait.js +55 -0
- package/dist/internal/testing/wait.js.map +1 -0
- package/dist/internal/thread-events.d.ts +40 -0
- package/dist/internal/thread-events.d.ts.map +1 -0
- package/dist/internal/thread-events.js +121 -0
- package/dist/internal/thread-events.js.map +1 -0
- package/dist/internal/threads.d.ts +47 -0
- package/dist/internal/threads.d.ts.map +1 -0
- package/dist/internal/threads.js +587 -0
- package/dist/internal/threads.js.map +1 -0
- package/dist/internal/transfer-source.d.ts +29 -0
- package/dist/internal/transfer-source.d.ts.map +1 -0
- package/dist/internal/transfer-source.js +347 -0
- package/dist/internal/transfer-source.js.map +1 -0
- package/dist/internal/transport/http.d.ts +12 -0
- package/dist/internal/transport/http.d.ts.map +1 -0
- package/dist/internal/transport/http.js +44 -0
- package/dist/internal/transport/http.js.map +1 -0
- package/dist/internal/transport/index.d.ts +21 -0
- package/dist/internal/transport/index.d.ts.map +1 -0
- package/dist/internal/transport/index.js +15 -0
- package/dist/internal/transport/index.js.map +1 -0
- package/dist/internal/transport/socket.d.ts +51 -0
- package/dist/internal/transport/socket.d.ts.map +1 -0
- package/dist/internal/transport/socket.js +27 -0
- package/dist/internal/transport/socket.js.map +1 -0
- package/dist/internal/transport/user-agent.d.ts +7 -0
- package/dist/internal/transport/user-agent.d.ts.map +1 -0
- package/dist/internal/transport/user-agent.js +42 -0
- package/dist/internal/transport/user-agent.js.map +1 -0
- package/dist/internal/uploads.d.ts +23 -0
- package/dist/internal/uploads.d.ts.map +1 -0
- package/dist/internal/uploads.js +89 -0
- package/dist/internal/uploads.js.map +1 -0
- package/dist/internal/user-cache.d.ts +50 -0
- package/dist/internal/user-cache.d.ts.map +1 -0
- package/dist/internal/user-cache.js +273 -0
- package/dist/internal/user-cache.js.map +1 -0
- package/dist/internal/users.d.ts +41 -0
- package/dist/internal/users.d.ts.map +1 -0
- package/dist/internal/users.js +333 -0
- package/dist/internal/users.js.map +1 -0
- package/dist/internal/vanity-url.d.ts +11 -0
- package/dist/internal/vanity-url.d.ts.map +1 -0
- package/dist/internal/vanity-url.js +58 -0
- package/dist/internal/vanity-url.js.map +1 -0
- package/dist/internal/webhooks.d.ts +58 -0
- package/dist/internal/webhooks.d.ts.map +1 -0
- package/dist/internal/webhooks.js +490 -0
- package/dist/internal/webhooks.js.map +1 -0
- package/dist/invites.d.ts +86 -0
- package/dist/invites.d.ts.map +1 -0
- package/dist/invites.js +2 -0
- package/dist/invites.js.map +1 -0
- package/dist/logging.d.ts +228 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +2 -0
- package/dist/logging.js.map +1 -0
- package/dist/member-chunks.d.ts +145 -0
- package/dist/member-chunks.d.ts.map +1 -0
- package/dist/member-chunks.js +68 -0
- package/dist/member-chunks.js.map +1 -0
- package/dist/member-search.d.ts +140 -0
- package/dist/member-search.d.ts.map +1 -0
- package/dist/member-search.js +14 -0
- package/dist/member-search.js.map +1 -0
- package/dist/message-cleanup.d.ts +227 -0
- package/dist/message-cleanup.d.ts.map +1 -0
- package/dist/message-cleanup.js +101 -0
- package/dist/message-cleanup.js.map +1 -0
- package/dist/message-errors.d.ts +172 -0
- package/dist/message-errors.d.ts.map +1 -0
- package/dist/message-errors.js +173 -0
- package/dist/message-errors.js.map +1 -0
- package/dist/message-search.d.ts +201 -0
- package/dist/message-search.d.ts.map +1 -0
- package/dist/message-search.js +2 -0
- package/dist/message-search.js.map +1 -0
- package/dist/messages.d.ts +694 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +37 -0
- package/dist/messages.js.map +1 -0
- package/dist/native-commands.d.ts +451 -0
- package/dist/native-commands.d.ts.map +1 -0
- package/dist/native-commands.js +432 -0
- package/dist/native-commands.js.map +1 -0
- package/dist/native-supervisor.d.ts +125 -0
- package/dist/native-supervisor.d.ts.map +1 -0
- package/dist/native-supervisor.js +126 -0
- package/dist/native-supervisor.js.map +1 -0
- package/dist/oauth.d.ts +298 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +128 -0
- package/dist/oauth.js.map +1 -0
- package/dist/observer.d.ts +111 -0
- package/dist/observer.d.ts.map +1 -0
- package/dist/observer.js +2 -0
- package/dist/observer.js.map +1 -0
- package/dist/pagination.d.ts +117 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +61 -0
- package/dist/pagination.js.map +1 -0
- package/dist/permissions.d.ts +73 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +2 -0
- package/dist/permissions.js.map +1 -0
- package/dist/pins.d.ts +62 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +2 -0
- package/dist/pins.js.map +1 -0
- package/dist/presence.d.ts +84 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +46 -0
- package/dist/presence.js.map +1 -0
- package/dist/reaction-pages.d.ts +99 -0
- package/dist/reaction-pages.d.ts.map +1 -0
- package/dist/reaction-pages.js +2 -0
- package/dist/reaction-pages.js.map +1 -0
- package/dist/reactions.d.ts +118 -0
- package/dist/reactions.d.ts.map +1 -0
- package/dist/reactions.js +2 -0
- package/dist/reactions.js.map +1 -0
- package/dist/rest.d.ts +260 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +46 -0
- package/dist/rest.js.map +1 -0
- package/dist/role-hierarchy.d.ts +81 -0
- package/dist/role-hierarchy.d.ts.map +1 -0
- package/dist/role-hierarchy.js +53 -0
- package/dist/role-hierarchy.js.map +1 -0
- package/dist/sharding.d.ts +219 -0
- package/dist/sharding.d.ts.map +1 -0
- package/dist/sharding.js +86 -0
- package/dist/sharding.js.map +1 -0
- package/dist/supervisor.d.ts +392 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +101 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/testing.d.ts +258 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +202 -0
- package/dist/testing.js.map +1 -0
- package/dist/text.d.ts +38 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +46 -0
- package/dist/text.js.map +1 -0
- package/dist/threads.d.ts +258 -0
- package/dist/threads.d.ts.map +1 -0
- package/dist/threads.js +2 -0
- package/dist/threads.js.map +1 -0
- package/dist/users.d.ts +204 -0
- package/dist/users.d.ts.map +1 -0
- package/dist/users.js +44 -0
- package/dist/users.js.map +1 -0
- package/dist/webhooks.d.ts +423 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +68 -0
- package/dist/webhooks.js.map +1 -0
- package/esm-only.cjs +3 -0
- package/examples/starter/bot-effect.ts +17 -0
- package/examples/starter/bot.js +13 -0
- package/examples/starter/bot.ts +13 -0
- package/package.json +82 -0
- package/src/api/default/application.ts +40 -0
- package/src/api/default/attachments.ts +106 -0
- package/src/api/default/audit-logs.ts +58 -0
- package/src/api/default/bot.ts +586 -0
- package/src/api/default/cache.ts +106 -0
- package/src/api/default/channels.ts +317 -0
- package/src/api/default/client.ts +829 -0
- package/src/api/default/collectors.ts +81 -0
- package/src/api/default/commands.ts +92 -0
- package/src/api/default/direct-messages.ts +143 -0
- package/src/api/default/discovery.ts +103 -0
- package/src/api/default/emojis.ts +125 -0
- package/src/api/default/events.ts +144 -0
- package/src/api/default/gateway.ts +67 -0
- package/src/api/default/guards.ts +173 -0
- package/src/api/default/guilds.ts +271 -0
- package/src/api/default/helpers.ts +97 -0
- package/src/api/default/instance.ts +49 -0
- package/src/api/default/invites.ts +73 -0
- package/src/api/default/logging.ts +37 -0
- package/src/api/default/members.ts +550 -0
- package/src/api/default/messages.ts +1053 -0
- package/src/api/default/oauth.ts +293 -0
- package/src/api/default/permissions.ts +47 -0
- package/src/api/default/presence.ts +88 -0
- package/src/api/default/rest.ts +30 -0
- package/src/api/default/results.ts +44 -0
- package/src/api/default/roles.ts +154 -0
- package/src/api/default/stickers.ts +129 -0
- package/src/api/default/supervisor.ts +53 -0
- package/src/api/default/threads.ts +233 -0
- package/src/api/default/users.ts +82 -0
- package/src/api/default/webhook-client.ts +266 -0
- package/src/api/default/webhooks.ts +89 -0
- package/src/api/effect/application.ts +29 -0
- package/src/api/effect/attachments.ts +100 -0
- package/src/api/effect/audit-logs.ts +50 -0
- package/src/api/effect/bot.ts +546 -0
- package/src/api/effect/cache.ts +110 -0
- package/src/api/effect/channels.ts +293 -0
- package/src/api/effect/client.ts +792 -0
- package/src/api/effect/collectors.ts +103 -0
- package/src/api/effect/commands.ts +87 -0
- package/src/api/effect/direct-messages.ts +119 -0
- package/src/api/effect/discovery.ts +87 -0
- package/src/api/effect/emojis.ts +108 -0
- package/src/api/effect/events.ts +92 -0
- package/src/api/effect/failures.ts +14 -0
- package/src/api/effect/gateway.ts +63 -0
- package/src/api/effect/guards.ts +194 -0
- package/src/api/effect/guilds.ts +247 -0
- package/src/api/effect/helpers.ts +359 -0
- package/src/api/effect/hierarchy.ts +26 -0
- package/src/api/effect/instance.ts +50 -0
- package/src/api/effect/invites.ts +59 -0
- package/src/api/effect/logging.ts +37 -0
- package/src/api/effect/members.ts +521 -0
- package/src/api/effect/messages.ts +1003 -0
- package/src/api/effect/oauth.ts +208 -0
- package/src/api/effect/permissions.ts +44 -0
- package/src/api/effect/presence.ts +83 -0
- package/src/api/effect/rest.ts +27 -0
- package/src/api/effect/roles.ts +136 -0
- package/src/api/effect/service.ts +104 -0
- package/src/api/effect/stickers.ts +112 -0
- package/src/api/effect/supervisor.ts +58 -0
- package/src/api/effect/threads.ts +221 -0
- package/src/api/effect/users.ts +66 -0
- package/src/api/effect/webhook-client.ts +206 -0
- package/src/api/effect/webhooks.ts +75 -0
- package/src/api-errors.ts +985 -0
- package/src/application.ts +103 -0
- package/src/assets.ts +731 -0
- package/src/attachments.ts +469 -0
- package/src/audit-logs.ts +355 -0
- package/src/bot-runner.ts +91 -0
- package/src/builders.ts +390 -0
- package/src/cache.ts +190 -0
- package/src/channels.ts +1051 -0
- package/src/cli.ts +60 -0
- package/src/client.ts +663 -0
- package/src/collectors.ts +248 -0
- package/src/colors.ts +91 -0
- package/src/command-arguments.ts +432 -0
- package/src/command-help.ts +55 -0
- package/src/commands.ts +403 -0
- package/src/counts.ts +160 -0
- package/src/default-commands.ts +1147 -0
- package/src/default-supervisor.ts +484 -0
- package/src/discovery.ts +241 -0
- package/src/effect-testing.ts +603 -0
- package/src/effect.ts +751 -0
- package/src/embeds.ts +253 -0
- package/src/error-tools.ts +191 -0
- package/src/errors.ts +849 -0
- package/src/events.ts +830 -0
- package/src/expressions.ts +198 -0
- package/src/failures.ts +55 -0
- package/src/gateway.ts +86 -0
- package/src/guilds.ts +1108 -0
- package/src/helpers.ts +836 -0
- package/src/index.ts +796 -0
- package/src/input-validation.ts +94 -0
- package/src/instance.ts +111 -0
- package/src/internal/agents-section.ts +114 -0
- package/src/internal/application.ts +51 -0
- package/src/internal/attachment-refresh.ts +57 -0
- package/src/internal/attachments.ts +313 -0
- package/src/internal/audit-logs.ts +336 -0
- package/src/internal/audit.ts +33 -0
- package/src/internal/binding/default-adapters.ts +482 -0
- package/src/internal/binding/default.ts +155 -0
- package/src/internal/binding/execute.ts +221 -0
- package/src/internal/binding/native-adapters.ts +199 -0
- package/src/internal/binding/native.ts +72 -0
- package/src/internal/binding/operations.ts +1171 -0
- package/src/internal/bot-runner.ts +480 -0
- package/src/internal/cache-changes.ts +363 -0
- package/src/internal/cache.ts +323 -0
- package/src/internal/calls.ts +119 -0
- package/src/internal/channel-cache.ts +435 -0
- package/src/internal/channel-decode.ts +399 -0
- package/src/internal/channels.ts +874 -0
- package/src/internal/client/backoff.ts +69 -0
- package/src/internal/client/configuration-fields.ts +18 -0
- package/src/internal/client/drain.ts +150 -0
- package/src/internal/client/intake.ts +228 -0
- package/src/internal/client/lifetime.ts +165 -0
- package/src/internal/client/shard-loop.ts +586 -0
- package/src/internal/client-registry.ts +35 -0
- package/src/internal/client.ts +2448 -0
- package/src/internal/clock.ts +11 -0
- package/src/internal/code-catalogue.ts +739 -0
- package/src/internal/collector.ts +452 -0
- package/src/internal/command-arguments.ts +585 -0
- package/src/internal/command-guards.ts +96 -0
- package/src/internal/command-help.ts +156 -0
- package/src/internal/commands.ts +1319 -0
- package/src/internal/configuration.ts +529 -0
- package/src/internal/counts.ts +471 -0
- package/src/internal/decode/primitives.ts +67 -0
- package/src/internal/decode/timestamp.ts +29 -0
- package/src/internal/decode/trace.ts +65 -0
- package/src/internal/defects.ts +115 -0
- package/src/internal/effect-failures.ts +65 -0
- package/src/internal/embeds.ts +355 -0
- package/src/internal/events.ts +1345 -0
- package/src/internal/expiry-queue.ts +148 -0
- package/src/internal/expressions.ts +415 -0
- package/src/internal/failures.ts +492 -0
- package/src/internal/field-text.ts +40 -0
- package/src/internal/gateway/commands.ts +328 -0
- package/src/internal/gateway/dispatch-table.ts +383 -0
- package/src/internal/gateway/event-dispatches.ts +201 -0
- package/src/internal/gateway/frames.ts +176 -0
- package/src/internal/gateway/options.ts +144 -0
- package/src/internal/gateway/session.ts +625 -0
- package/src/internal/gateway-requests.ts +26 -0
- package/src/internal/gateway.ts +22 -0
- package/src/internal/guild-cache.ts +424 -0
- package/src/internal/guild-discovery.ts +332 -0
- package/src/internal/guild-lifecycle.ts +128 -0
- package/src/internal/guild-settings.ts +209 -0
- package/src/internal/guilds.ts +949 -0
- package/src/internal/init-command.ts +305 -0
- package/src/internal/instance.ts +645 -0
- package/src/internal/invalid-callback-return.ts +28 -0
- package/src/internal/invites.ts +234 -0
- package/src/internal/logging.ts +1007 -0
- package/src/internal/logical-scheduler.ts +139 -0
- package/src/internal/masking.ts +224 -0
- package/src/internal/member-chunks.ts +649 -0
- package/src/internal/member-search-workflow.ts +237 -0
- package/src/internal/member-search.ts +272 -0
- package/src/internal/message-cleanup.ts +515 -0
- package/src/internal/message-fields.ts +71 -0
- package/src/internal/message-search-workflow.ts +166 -0
- package/src/internal/message-search.ts +476 -0
- package/src/internal/message.ts +879 -0
- package/src/internal/metrics.ts +55 -0
- package/src/internal/moderation.ts +288 -0
- package/src/internal/multipart.ts +171 -0
- package/src/internal/node-version.ts +22 -0
- package/src/internal/oauth.ts +1146 -0
- package/src/internal/observer.ts +62 -0
- package/src/internal/operation-signal.ts +26 -0
- package/src/internal/pagination.ts +494 -0
- package/src/internal/permission-requirements.ts +359 -0
- package/src/internal/permissions.ts +417 -0
- package/src/internal/pins.ts +115 -0
- package/src/internal/presence.ts +745 -0
- package/src/internal/protocol/gateway.ts +299 -0
- package/src/internal/rate-limit-templates.ts +138 -0
- package/src/internal/rate-limits.ts +346 -0
- package/src/internal/reaction-collector.ts +499 -0
- package/src/internal/reaction-pages.ts +260 -0
- package/src/internal/reactions.ts +174 -0
- package/src/internal/rejection-scope.ts +119 -0
- package/src/internal/response-json.ts +76 -0
- package/src/internal/rest/admission.ts +210 -0
- package/src/internal/rest/attempt.ts +617 -0
- package/src/internal/rest/classify.ts +391 -0
- package/src/internal/rest/download.ts +658 -0
- package/src/internal/rest/options.ts +145 -0
- package/src/internal/rest/owner.ts +1828 -0
- package/src/internal/rest/request.ts +289 -0
- package/src/internal/rest.ts +9 -0
- package/src/internal/retention-age.ts +33 -0
- package/src/internal/role-hierarchy-workflow.ts +150 -0
- package/src/internal/role-hierarchy.ts +93 -0
- package/src/internal/scheduled-tasks.ts +217 -0
- package/src/internal/sharding.ts +270 -0
- package/src/internal/starter-project.ts +251 -0
- package/src/internal/suggest.ts +50 -0
- package/src/internal/supervisor.ts +2253 -0
- package/src/internal/testing/discovery.ts +23 -0
- package/src/internal/testing/errors.ts +67 -0
- package/src/internal/testing/fixtures.ts +714 -0
- package/src/internal/testing/gateway.ts +305 -0
- package/src/internal/testing/harness.ts +328 -0
- package/src/internal/testing/http.ts +395 -0
- package/src/internal/testing/types.ts +240 -0
- package/src/internal/testing/wait.ts +63 -0
- package/src/internal/thread-events.ts +128 -0
- package/src/internal/threads.ts +718 -0
- package/src/internal/transfer-source.ts +359 -0
- package/src/internal/transport/http.ts +46 -0
- package/src/internal/transport/index.ts +23 -0
- package/src/internal/transport/socket.ts +71 -0
- package/src/internal/transport/user-agent.ts +46 -0
- package/src/internal/uploads.ts +111 -0
- package/src/internal/user-cache.ts +294 -0
- package/src/internal/users.ts +402 -0
- package/src/internal/vanity-url.ts +80 -0
- package/src/internal/webhooks.ts +690 -0
- package/src/invites.ts +87 -0
- package/src/logging.ts +247 -0
- package/src/member-chunks.ts +195 -0
- package/src/member-search.ts +152 -0
- package/src/message-cleanup.ts +308 -0
- package/src/message-errors.ts +245 -0
- package/src/message-search.ts +213 -0
- package/src/messages.ts +768 -0
- package/src/native-commands.ts +1249 -0
- package/src/native-supervisor.ts +345 -0
- package/src/oauth.ts +413 -0
- package/src/observer.ts +118 -0
- package/src/pagination.ts +172 -0
- package/src/permissions.ts +74 -0
- package/src/pins.ts +65 -0
- package/src/presence.ts +124 -0
- package/src/reaction-pages.ts +106 -0
- package/src/reactions.ts +126 -0
- package/src/rest.ts +282 -0
- package/src/role-hierarchy.ts +127 -0
- package/src/sharding.ts +272 -0
- package/src/supervisor.ts +460 -0
- package/src/testing.ts +424 -0
- package/src/text.ts +76 -0
- package/src/threads.ts +274 -0
- package/src/users.ts +237 -0
- package/src/webhooks.ts +512 -0
|
@@ -0,0 +1,1249 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CommandCooldownClaim,
|
|
3
|
+
CommandCooldownPer,
|
|
4
|
+
CommandCooldownRequest,
|
|
5
|
+
MemoryCooldownOptions,
|
|
6
|
+
PrefixCommandDefinition,
|
|
7
|
+
PrefixCommandGroupDefinition,
|
|
8
|
+
PrefixCommandGroupMetadata,
|
|
9
|
+
PrefixCommandMetadata,
|
|
10
|
+
PrefixCommandGuardResult,
|
|
11
|
+
PrefixCommandParse,
|
|
12
|
+
PrefixCommandParseInput,
|
|
13
|
+
PrefixCommandParseRejection,
|
|
14
|
+
PrefixCommandParsing,
|
|
15
|
+
PrefixCommandPrefixValue,
|
|
16
|
+
PrefixCommandRejection,
|
|
17
|
+
PrefixCommandRegistrationOptions,
|
|
18
|
+
PrefixCommandUnmatched,
|
|
19
|
+
} from "#sdk/commands"
|
|
20
|
+
import type { CommandArgumentDescriptor, CommandArgumentSchema, CommandArgumentValues } from "#sdk/command-arguments"
|
|
21
|
+
import type { CommandContextHelpOptions, CommandHelpOptions } from "#sdk/command-help"
|
|
22
|
+
import { commandHelp, contextHelpOptions } from "#sdk/internal/command-help"
|
|
23
|
+
import { parseQuotedPrefixCommand } from "#sdk/commands"
|
|
24
|
+
import { ApplicationError, ConfigurationError, SdkDefect } from "#sdk/errors"
|
|
25
|
+
import { readCaller, readInput, suspendMarked, thrownReason } from "#sdk/internal/defects"
|
|
26
|
+
import {
|
|
27
|
+
configurationEffect,
|
|
28
|
+
cooldownRequest,
|
|
29
|
+
cooldownSuffix,
|
|
30
|
+
createMemoryCooldownStore,
|
|
31
|
+
snapshotClaimInput,
|
|
32
|
+
dispatchCommand,
|
|
33
|
+
type LocalMemoryCooldownStore,
|
|
34
|
+
PrefixCommandRegistry,
|
|
35
|
+
rejectionReply,
|
|
36
|
+
routerSubscriptionOptions,
|
|
37
|
+
sameCommandPath,
|
|
38
|
+
snapshotCommandDefinition,
|
|
39
|
+
snapshotCommandCooldown,
|
|
40
|
+
validateCommandShape,
|
|
41
|
+
checkBotCommandKeys,
|
|
42
|
+
} from "#sdk/internal/commands"
|
|
43
|
+
import { convertCommandArguments } from "#sdk/internal/command-arguments"
|
|
44
|
+
import type { SendError } from "#sdk/message-errors"
|
|
45
|
+
import type { Message, MessageCore, ReplyInput, SendOptions } from "#sdk/messages"
|
|
46
|
+
import { askerPageOptions } from "#sdk/internal/reaction-pages"
|
|
47
|
+
import type { PageInput, PaginateFailure, PaginateOptions, PaginateResult } from "#sdk/reaction-pages"
|
|
48
|
+
import * as Cause from "effect/Cause"
|
|
49
|
+
import * as Clock from "effect/Clock"
|
|
50
|
+
import type * as Context from "effect/Context"
|
|
51
|
+
import * as Deferred from "effect/Deferred"
|
|
52
|
+
import * as Effect from "effect/Effect"
|
|
53
|
+
import * as Exit from "effect/Exit"
|
|
54
|
+
import type * as Scope from "effect/Scope"
|
|
55
|
+
import { clientServices } from "#sdk/internal/client-registry"
|
|
56
|
+
import { makeReport, messageReference, primaryError, type InternalReport } from "#sdk/internal/failures"
|
|
57
|
+
import type { ClientLogger } from "#sdk/internal/logging"
|
|
58
|
+
import { recordCommandFailure } from "#sdk/internal/events"
|
|
59
|
+
import type { Client, EventHandlerOptions, Subscription } from "./effect.js"
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Message and parsed arguments for a native command's guard and rejection callback. These values cannot be changed.
|
|
63
|
+
* Execution and cooldown-key callbacks receive the extended context with converted values.
|
|
64
|
+
* Native callbacks run in the attachment's Effect context, with interruption rather than the default API's AbortSignal field
|
|
65
|
+
*
|
|
66
|
+
* @category Commands
|
|
67
|
+
*/
|
|
68
|
+
export interface NativePrefixCommandContext<M extends MessageCore = Message> {
|
|
69
|
+
/** Client supplied to `attach`, available for explicit Effect operations. The application still owns its connection and shutdown */
|
|
70
|
+
readonly client: Client<M>
|
|
71
|
+
/** Frozen incoming message with the attached client's selected fields. The router does not fetch omitted fields */
|
|
72
|
+
readonly message: M
|
|
73
|
+
/** Exact prefix selected for this invocation, such as `!` or `!!` */
|
|
74
|
+
readonly prefix: string
|
|
75
|
+
/** Registered command name, regardless of the alias or letter case used in the message */
|
|
76
|
+
readonly name: string
|
|
77
|
+
/** Frozen registered names through this command, such as `["admin", "inspect"]`. Absent at root and does not imply authorization */
|
|
78
|
+
readonly path?: readonly string[]
|
|
79
|
+
/** Parsed string tokens copied to a frozen array, preserved alongside any converted values */
|
|
80
|
+
readonly args: readonly string[]
|
|
81
|
+
/** Argument text retained by the parser. The default removes command-name separator whitespace but preserves the remainder */
|
|
82
|
+
readonly rawArgs: string
|
|
83
|
+
/**
|
|
84
|
+
* Reply to the incoming message through the attached client. The returned Effect follows handler interruption and can fail with SendError.
|
|
85
|
+
* A string is sent as the reply's content, such as `reply("Pong")`.
|
|
86
|
+
* Delegates to `client.messages.reply`, including its validation, deadline, nonce, retry, cache and defect behavior.
|
|
87
|
+
* Interruption or a lost response can leave the reply posted. Failure does not always mean nothing was sent, and uncertain sends are not replayed.
|
|
88
|
+
* The router replies on its own only when `onReject: "reply"` is selected
|
|
89
|
+
*/
|
|
90
|
+
readonly reply: (input: ReplyInput | string, options?: SendOptions) => Effect.Effect<M, SendError>
|
|
91
|
+
/**
|
|
92
|
+
* Build help pages from the router that matched this command, for example `({ help, reply }) => reply(help()[0] ?? "No commands")`.
|
|
93
|
+
* Takes the same settings as `router.help`, all optional: The prefix defaults to the one this message used and the
|
|
94
|
+
* page length to 2,000 UTF-16 code units. Nothing is sent. Invalid settings throw ConfigurationError as `router.help` does
|
|
95
|
+
*/
|
|
96
|
+
readonly help: (options?: CommandContextHelpOptions) => readonly string[]
|
|
97
|
+
/**
|
|
98
|
+
* Show several pages in this message's channel that the command's author flips with ◀ and ▶ reactions, such as `({ paginate }) => paginate(["First", "Second"])`.
|
|
99
|
+
* Delegates to `client.messages.paginate` with users defaulting to this message's author.
|
|
100
|
+
* Pass users to let other people flip, such as `() => true` for anyone. The other options, defaults, permissions, cleanup and failures are those of `client.messages.paginate`.
|
|
101
|
+
* The Effect completes when listening ends, so the handler stays active until then
|
|
102
|
+
*/
|
|
103
|
+
readonly paginate: (
|
|
104
|
+
pages: readonly PageInput[],
|
|
105
|
+
options?: PaginateOptions,
|
|
106
|
+
) => Effect.Effect<PaginateResult<M>, PaginateFailure>
|
|
107
|
+
/**
|
|
108
|
+
* Send this router's help in this message's channel, such as `({ sendHelp }) => sendHelp()`.
|
|
109
|
+
* Takes the same optional settings as `help`. One page is sent as a plain message, and several pages use `paginate`
|
|
110
|
+
* with its defaults, so only the command's author can flip them.
|
|
111
|
+
* Invalid settings, and help with no visible entries, fail with ConfigurationError without sending anything
|
|
112
|
+
*/
|
|
113
|
+
readonly sendHelp: (options?: CommandContextHelpOptions) => Effect.Effect<PaginateResult<M>, PaginateFailure>
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Command context supplied to execution and cooldown-key callbacks only after the complete argument schema succeeds
|
|
118
|
+
*
|
|
119
|
+
* @category Commands
|
|
120
|
+
*/
|
|
121
|
+
export interface NativePrefixCommandExecutionContext<
|
|
122
|
+
S extends CommandArgumentSchema = {},
|
|
123
|
+
M extends MessageCore = Message,
|
|
124
|
+
> extends NativePrefixCommandContext<M> {
|
|
125
|
+
/** Frozen values keyed by schema names, such as `values.count`, or an empty object when no schema is supplied. Not available to guards or rejection callbacks */
|
|
126
|
+
readonly values: CommandArgumentValues<S>
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Frozen message and prefix for native `onUnmatched` feedback, without an assumed command or converted arguments
|
|
131
|
+
*
|
|
132
|
+
* @category Commands
|
|
133
|
+
*/
|
|
134
|
+
export interface NativePrefixCommandUnmatchedContext<M extends MessageCore = Message> {
|
|
135
|
+
/** Attached client for explicit feedback operations, without transferring its lifetime to the router */
|
|
136
|
+
readonly client: Client<M>
|
|
137
|
+
/** Incoming frozen message with the client's selected fields only */
|
|
138
|
+
readonly message: M
|
|
139
|
+
/** Exact prefix selected before parsing declined, name lookup missed or a group needed a subcommand */
|
|
140
|
+
readonly prefix: string
|
|
141
|
+
/**
|
|
142
|
+
* Reply to the unmatched incoming message through the attached client, inheriting this callback's interruption.
|
|
143
|
+
* A string is sent as the reply's content.
|
|
144
|
+
* Delegates to `client.messages.reply`, including its validation, deadline, nonce, retry, cache and defect behavior.
|
|
145
|
+
* Interruption or a lost response can leave the reply posted. Failure does not always mean nothing was sent, and uncertain sends are not replayed
|
|
146
|
+
*/
|
|
147
|
+
readonly reply: (input: ReplyInput | string, options?: SendOptions) => Effect.Effect<M, SendError>
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Decide whether a matched command may run, from raw context before argument conversion.
|
|
152
|
+
* The Effect produces true to allow it, false to deny it silently, or `{ deny: "reason" }` to deny it with text that
|
|
153
|
+
* `onReject: "reply"` sends. The built-in `guards` cover common checks.
|
|
154
|
+
* A false verdict is still counted, logged at Debug and passed to a custom onReject callback, but never sends an automatic reply.
|
|
155
|
+
* Failures, defects and other values use subscription error reporting
|
|
156
|
+
*
|
|
157
|
+
* @category Commands
|
|
158
|
+
*/
|
|
159
|
+
export type NativePrefixCommandGuard<E = never, R = never, M extends MessageCore = Message> = (
|
|
160
|
+
context: NativePrefixCommandContext<M>,
|
|
161
|
+
) => Effect.Effect<PrefixCommandGuardResult, E, R>
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Run around every matched command of a router, in registration order, before its guards.
|
|
165
|
+
* Include `next` in the returned Effect to continue. Leaving it out stops the command, which is logged at Debug.
|
|
166
|
+
* The rest of the chain runs at most once: Evaluating `next` again, even concurrently as in
|
|
167
|
+
* `Effect.all([next, next], { concurrency: 2 })`, waits for the first run and repeats its outcome.
|
|
168
|
+
* When the command fails, `next` fails with the command's own failure, the same error or defect its execute Effect produced
|
|
169
|
+
*
|
|
170
|
+
* A failure of the command is reported once with its command name, whatever the middleware does with it.
|
|
171
|
+
* Failing again with that same error adds no second report. A different failure or defect of the middleware is
|
|
172
|
+
* reported as a separate failure after the command's, also with the command name. Without a command failure, a
|
|
173
|
+
* middleware failure is reported like a failed command and stops the command if `next` has not run yet.
|
|
174
|
+
* The command's failure is still reported when the middleware is interrupted, for example because the subscription closes
|
|
175
|
+
*
|
|
176
|
+
* @category Commands
|
|
177
|
+
*/
|
|
178
|
+
export type NativePrefixCommandMiddleware<E = never, R = never, M extends MessageCore = Message> = (
|
|
179
|
+
context: NativePrefixCommandContext<M>,
|
|
180
|
+
next: Effect.Effect<void, unknown>,
|
|
181
|
+
) => Effect.Effect<unknown, E, R>
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Rejection feedback for a command: `"reply"` sends a short explanation, such as the missing argument and the command's
|
|
185
|
+
* usage, the guard's deny reason or the cooldown's remaining time. `"silent"` sends nothing, and the rejection is still
|
|
186
|
+
* logged at Debug. A guard returning false never sends an automatic reply, even with "reply" selected.
|
|
187
|
+
* A function returns an Effect that gives feedback instead, including for false guard denials
|
|
188
|
+
*
|
|
189
|
+
* So that repeated attempts do not make the bot repeat itself, `"reply"` answers an active cooldown key once until its
|
|
190
|
+
* retry time, and a guard denial once per user and command every 5 seconds, measured with the handler's Effect Clock.
|
|
191
|
+
* Argument rejections are always answered. A skipped reply is counted with the rejection and logged at Debug in the
|
|
192
|
+
* commands category. A function is called for every rejection, so it can count attempts and apply its own limit, for
|
|
193
|
+
* example with `retryAtMs`
|
|
194
|
+
*
|
|
195
|
+
* @category Commands
|
|
196
|
+
*/
|
|
197
|
+
export type NativePrefixCommandRejectionFeedback<E = never, R = never, M extends MessageCore = Message> =
|
|
198
|
+
| "reply"
|
|
199
|
+
| "silent"
|
|
200
|
+
| ((context: NativePrefixCommandContext<M>, rejection: PrefixCommandRejection) => Effect.Effect<unknown, E, R>)
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Prefix and parser configuration with optional Effect feedback when no executable command is selected
|
|
204
|
+
*
|
|
205
|
+
* @category Commands
|
|
206
|
+
*/
|
|
207
|
+
export interface NativePrefixCommandsOptions<
|
|
208
|
+
E = never,
|
|
209
|
+
R = never,
|
|
210
|
+
M extends MessageCore = Message,
|
|
211
|
+
> extends PrefixCommandParsing<M> {
|
|
212
|
+
/**
|
|
213
|
+
* Prefix text, accepted-prefix list or per-message resolver, which may return an Effect. If several prefixes match,
|
|
214
|
+
* the longest wins. Return undefined to ignore the message. A resolver failure is reported without a command name
|
|
215
|
+
*/
|
|
216
|
+
readonly prefix:
|
|
217
|
+
| string
|
|
218
|
+
| readonly string[]
|
|
219
|
+
| ((message: M) => PrefixCommandPrefixValue | Effect.Effect<PrefixCommandPrefixValue, unknown>)
|
|
220
|
+
/**
|
|
221
|
+
* Rejection feedback for commands that do not set their own `onReject`. Omit it to give no feedback, except in
|
|
222
|
+
* runBot, which replies by default. Guards returning false never send an automatic reply
|
|
223
|
+
*/
|
|
224
|
+
readonly onReject?: NativePrefixCommandRejectionFeedback<E, R, M>
|
|
225
|
+
/** Middleware run around every matched command, in order. See NativePrefixCommandMiddleware */
|
|
226
|
+
readonly use?: readonly NativePrefixCommandMiddleware<E, R, M>[]
|
|
227
|
+
/**
|
|
228
|
+
* Return an Effect that handles a parser decline, unknown name or group without a subcommand.
|
|
229
|
+
* An unknown name carries a `suggestion` when a registered name is close, and a parser decline carries a `reason` when the parser explained a syntax mistake, such as an unclosed quote from `commands.parseQuoted`.
|
|
230
|
+
* The Effect runs for every such message and anyone can cause that, so a reply sent from it needs the application's own limit, and in a channel shared with other bots the prefix may belong to a command of another bot.
|
|
231
|
+
* Runs in the attachment's captured Effect context and follows subscription interruption, with its success value discarded.
|
|
232
|
+
* Failures and defects use attachment `onError` reporting, without retry or automatic replies.
|
|
233
|
+
* Not called for ignored bot messages or messages without a matching prefix.
|
|
234
|
+
* Returning anything other than an Effect fails dispatch with ConfigurationError
|
|
235
|
+
*/
|
|
236
|
+
readonly onUnmatched?: (
|
|
237
|
+
context: NativePrefixCommandUnmatchedContext<M>,
|
|
238
|
+
unmatched: PrefixCommandUnmatched,
|
|
239
|
+
) => Effect.Effect<unknown, E, R>
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Storage that checks and reserves a command cooldown in one atomic claim.
|
|
244
|
+
* The application owns persistence and coordination of competing claims, including across processes.
|
|
245
|
+
* A claim can be immediate or return an Effect requiring the handler's services
|
|
246
|
+
*
|
|
247
|
+
* @category Commands
|
|
248
|
+
*/
|
|
249
|
+
export interface NativeCooldownStore<E = never, R = never> {
|
|
250
|
+
/**
|
|
251
|
+
* Reserve `input.key` for `input.durationMs`, returning a claim directly or through an Effect.
|
|
252
|
+
* The returned Effect runs within command dispatch, preserving the attachment's services and interruption.
|
|
253
|
+
* Only `CooldownAcquired` permits execution. Other claims call optional rejection feedback without waiting or retrying.
|
|
254
|
+
* Malformed claims fail with ConfigurationError. Store failures and defects use subscription error reporting
|
|
255
|
+
*/
|
|
256
|
+
claim(input: CommandCooldownRequest): CommandCooldownClaim | Effect.Effect<CommandCooldownClaim, E, R>
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Limit how often a command executes, per user by default. Claimed after the guards allow execution and all arguments
|
|
261
|
+
* convert, before executing the handler.
|
|
262
|
+
* A claimed cooldown remains claimed if the handler fails or is interrupted
|
|
263
|
+
*
|
|
264
|
+
* @category Commands
|
|
265
|
+
*/
|
|
266
|
+
export interface NativePrefixCommandCooldown<
|
|
267
|
+
E = never,
|
|
268
|
+
R = never,
|
|
269
|
+
S extends CommandArgumentSchema = {},
|
|
270
|
+
M extends MessageCore = Message,
|
|
271
|
+
> {
|
|
272
|
+
/** Whole milliseconds per claim, from 1 through 2,147,483,647 */
|
|
273
|
+
readonly durationMs: number
|
|
274
|
+
/** Whose invocations share the cooldown: `user` (default), `channel` or `guild` */
|
|
275
|
+
readonly per?: CommandCooldownPer
|
|
276
|
+
/**
|
|
277
|
+
* Reservation store retained by reference. Omit it to use the router's own memory store in this process, sized by the
|
|
278
|
+
* router's `cooldowns` option, using the handler's Effect Clock and shared by every router derived from the same create
|
|
279
|
+
*/
|
|
280
|
+
readonly store?: NativeCooldownStore<E, R>
|
|
281
|
+
/**
|
|
282
|
+
* Synchronously return a nonempty suffix from the converted context, replacing the one selected by `per`.
|
|
283
|
+
* The router adds the canonical command name or full group path, so aliases share a claim but different parent groups do not.
|
|
284
|
+
* Routers sharing a store also share claims when their command identities and suffixes match
|
|
285
|
+
*/
|
|
286
|
+
readonly key?: (context: NativePrefixCommandExecutionContext<S, M>) => string
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* A prefix command whose application callbacks return Effects rather than promises.
|
|
291
|
+
* Dispatch evaluates its guard, converts arguments, claims any cooldown and runs the execution Effect.
|
|
292
|
+
* Callbacks use the attachment's captured services and interruption, without a detached runtime.
|
|
293
|
+
* Registration copies metadata and arguments while retaining callbacks and the cooldown store.
|
|
294
|
+
* `E` describes callback failures and `R` describes required services. Callback failures are reported by the subscription, not by a completed `attach`
|
|
295
|
+
*
|
|
296
|
+
* @category Commands
|
|
297
|
+
*/
|
|
298
|
+
export interface NativePrefixCommand<
|
|
299
|
+
E = never,
|
|
300
|
+
R = never,
|
|
301
|
+
S extends CommandArgumentSchema = {},
|
|
302
|
+
M extends MessageCore = Message,
|
|
303
|
+
> extends PrefixCommandDefinition {
|
|
304
|
+
/** Named positional conversions in property order. Omitted leaves parsed `args` unrestricted and converted `values` empty */
|
|
305
|
+
readonly arguments?: S
|
|
306
|
+
/**
|
|
307
|
+
* One guard or a list of guards, run in order before argument conversion. The first that denies stops the command.
|
|
308
|
+
* Each command owns its policy, with no inherited group guard or authorization from help visibility.
|
|
309
|
+
* Non-Effect returns and invalid verdicts fail with ConfigurationError.
|
|
310
|
+
* Failures and defects use subscription error reporting rather than rejection feedback
|
|
311
|
+
*/
|
|
312
|
+
readonly guard?: NativePrefixCommandGuard<E, R, M> | readonly NativePrefixCommandGuard<E, R, M>[]
|
|
313
|
+
/**
|
|
314
|
+
* Feedback after a denied guard, rejected arguments or a denied cooldown, overriding the router's `onReject`.
|
|
315
|
+
* A function receives raw context and a safe rejection classification, never partially converted values.
|
|
316
|
+
* Its success value is discarded. Failures and defects use attachment error reporting, without retry.
|
|
317
|
+
* Non-Effect returns fail with ConfigurationError
|
|
318
|
+
*/
|
|
319
|
+
readonly onReject?: NativePrefixCommandRejectionFeedback<E, R, M>
|
|
320
|
+
/** Optional cooldown claim required after the guard and arguments succeed. Denied claims skip execution */
|
|
321
|
+
readonly cooldown?: NativePrefixCommandCooldown<E, R, S, M>
|
|
322
|
+
/**
|
|
323
|
+
* Return the Effect that performs work for this allowed command with fully converted arguments.
|
|
324
|
+
* The subscription runs it in the attachment's context and discards its success value, rather than sending it as a reply.
|
|
325
|
+
* Failures and defects use safe attachment `onError` reporting, without retry or cooldown rollback.
|
|
326
|
+
* Non-Effect returns fail with ConfigurationError. Cooperative Effect work is interrupted when the attachment closes.
|
|
327
|
+
* Synchronous work and promises that ignore cancellation cannot be forcibly stopped
|
|
328
|
+
*/
|
|
329
|
+
readonly execute: (context: NativePrefixCommandExecutionContext<S, M>) => Effect.Effect<unknown, E, R>
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Commands keyed by name, as registerMany and the runBot commands option accept them. Each value defines one command without its name.
|
|
334
|
+
* Omit `arguments` to leave raw args unrestricted, or set `arguments: {}` to reject positional arguments
|
|
335
|
+
*
|
|
336
|
+
* @category Commands
|
|
337
|
+
*/
|
|
338
|
+
export type NativePrefixCommandBatch<M extends MessageCore, S extends Readonly<Record<string, unknown>>> = {
|
|
339
|
+
readonly [K in keyof S]: Omit<
|
|
340
|
+
NativePrefixCommand<unknown, any, S[K] extends CommandArgumentSchema ? S[K] : {}, M>,
|
|
341
|
+
"name" | "arguments"
|
|
342
|
+
> & {
|
|
343
|
+
/** Argument schema for the command under this key. Omit it to leave positional arguments unrestricted.
|
|
344
|
+
* Each descriptor is checked on its own, so a mistake such as an unknown type is reported on that descriptor
|
|
345
|
+
*/
|
|
346
|
+
readonly arguments?: {
|
|
347
|
+
readonly [A in keyof S[K]]: S[K][A] extends CommandArgumentDescriptor ? S[K][A] : CommandArgumentDescriptor
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The services required by the Effect that callback F returns, or never when F returns no Effect
|
|
354
|
+
*
|
|
355
|
+
* @category Commands
|
|
356
|
+
*/
|
|
357
|
+
export type NativeEffectRequirements<F> = F extends (...arguments_: any[]) => Effect.Effect<unknown, unknown, infer R>
|
|
358
|
+
? R
|
|
359
|
+
: never
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The services required by one command's execute, guard, onReject and cooldown claim callbacks
|
|
363
|
+
*
|
|
364
|
+
* @category Commands
|
|
365
|
+
*/
|
|
366
|
+
export type NativeCommandRequirements<C> =
|
|
367
|
+
| (C extends {
|
|
368
|
+
/** Command callback */
|
|
369
|
+
readonly execute: infer F
|
|
370
|
+
}
|
|
371
|
+
? NativeEffectRequirements<F>
|
|
372
|
+
: never)
|
|
373
|
+
| (C extends {
|
|
374
|
+
/** Optional access check or list of checks */
|
|
375
|
+
readonly guard: infer F
|
|
376
|
+
}
|
|
377
|
+
? F extends readonly (infer G)[]
|
|
378
|
+
? NativeEffectRequirements<G>
|
|
379
|
+
: NativeEffectRequirements<F>
|
|
380
|
+
: never)
|
|
381
|
+
| (C extends {
|
|
382
|
+
/** Optional argument rejection callback */
|
|
383
|
+
readonly onReject: infer F
|
|
384
|
+
}
|
|
385
|
+
? NativeEffectRequirements<F>
|
|
386
|
+
: never)
|
|
387
|
+
| (C extends {
|
|
388
|
+
/** Optional cooldown settings */
|
|
389
|
+
readonly cooldown: {
|
|
390
|
+
/** Store that reserves cooldown keys */
|
|
391
|
+
readonly store: {
|
|
392
|
+
/** Reservation method, whose returned Effect may require services */
|
|
393
|
+
readonly claim: infer F
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
? F extends (...arguments_: any[]) => infer A
|
|
398
|
+
? A extends Effect.Effect<unknown, unknown, infer R>
|
|
399
|
+
? R
|
|
400
|
+
: never
|
|
401
|
+
: never
|
|
402
|
+
: never)
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* The services required by every command in a registerMany batch, recorded on the returned router
|
|
406
|
+
*
|
|
407
|
+
* @category Commands
|
|
408
|
+
*/
|
|
409
|
+
export type NativeBatchRequirements<C> =
|
|
410
|
+
C extends Readonly<Record<string, unknown>> ? NativeCommandRequirements<C[keyof C]> : never
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Bounded in-memory cooldown reservations for one process, using the caller's Effect Clock wall time.
|
|
414
|
+
* Claim, sweep and clear return lazy Effects, so storage changes occur only when those Effects run.
|
|
415
|
+
* No background timer, persistence or cross-process coordination is provided
|
|
416
|
+
*
|
|
417
|
+
* @category Commands
|
|
418
|
+
*/
|
|
419
|
+
export interface MemoryCooldownStore {
|
|
420
|
+
/** Fixed key limit selected when the store is created */
|
|
421
|
+
readonly maxEntries: number
|
|
422
|
+
/** Immediate stored-key count, including expired keys until a full store needs room or a sweep removes them */
|
|
423
|
+
readonly size: number
|
|
424
|
+
/**
|
|
425
|
+
* When run, atomically reserve the key or report its active cooldown.
|
|
426
|
+
* Acquired expiry is the caller Clock's current wall time plus `durationMs`.
|
|
427
|
+
* A new key is never refused for lack of space: A full store removes expired keys first, then the reservation that
|
|
428
|
+
* expires soonest, whose key can then claim again early.
|
|
429
|
+
* Malformed keys or durations are misuse and die with ConfigurationError. Unexpected input getter defects remain in the Effect cause
|
|
430
|
+
*/
|
|
431
|
+
claim(input: CommandCooldownRequest): Effect.Effect<CommandCooldownClaim>
|
|
432
|
+
/** Return an Effect that removes keys expired according to the caller's Effect Clock and produces the number removed, preserving active claims */
|
|
433
|
+
sweep(): Effect.Effect<number>
|
|
434
|
+
/** Return an Effect that forgets this store's reservations, allowing new claims. Does not cancel handlers or clear other stores */
|
|
435
|
+
clear(): Effect.Effect<void>
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Immutable registered commands and groups for attachment to a native client.
|
|
440
|
+
* Registration returns a new router synchronously, leaving earlier routers and attachments unchanged, and throws ConfigurationError for misuse.
|
|
441
|
+
* `R` records services required by registered callbacks, which must be provided when attaching the router.
|
|
442
|
+
* Creating or registering a router does not run its callbacks
|
|
443
|
+
*
|
|
444
|
+
* @category Commands
|
|
445
|
+
*/
|
|
446
|
+
export interface NativePrefixCommandRouter<R = never, M extends MessageCore = Message> {
|
|
447
|
+
/** Frozen executable-command information in registration order across groups, without callbacks or resource candidates. Grouped commands include canonical paths */
|
|
448
|
+
readonly commands: readonly PrefixCommandMetadata[]
|
|
449
|
+
/** Frozen group information in registration order, including empty groups. Groups organize lookup and help, not authorization */
|
|
450
|
+
readonly groups: readonly PrefixCommandGroupMetadata[]
|
|
451
|
+
/**
|
|
452
|
+
* Build frozen help pages locally and synchronously, without sending messages or executing commands.
|
|
453
|
+
* It needs no scope or registered callback services
|
|
454
|
+
*
|
|
455
|
+
* Root help lists immediate commands and groups in sibling registration order.
|
|
456
|
+
* A canonical group selection shows the group and its immediate children, including empty groups, unless include rejects an ancestor.
|
|
457
|
+
* Entries show full canonical paths, aliases and descriptions, with `(Group)` marking groups.
|
|
458
|
+
* Commands and groups registered with `hidden: true` never appear, nor does anything inside a hidden group,
|
|
459
|
+
* and selecting a hidden group throws ConfigurationError as for a missing one
|
|
460
|
+
*
|
|
461
|
+
* Schemas generate `<required>`, `[optional]` and `<rest...>` or `[rest...]` syntax unless explicit `usage` overrides it.
|
|
462
|
+
* An empty usage suppresses inferred syntax, and an absent schema adds no argument syntax.
|
|
463
|
+
* A selection that is empty, or whose group or ancestor include rejects, produces `[]`. No prefix resolver, guard, cooldown or handler is evaluated
|
|
464
|
+
*
|
|
465
|
+
* The explicit UTF-16 page limit preserves surrogate pairs, but may split visible character clusters or Markdown.
|
|
466
|
+
* Page-edge whitespace is trimmed and empty pages are removed, so joining pages does not reconstruct the exact original text.
|
|
467
|
+
* The application chooses which pages to send and how to handle mentions
|
|
468
|
+
*
|
|
469
|
+
* Malformed options, ill-formed text, too-small limits and invalid visibility callbacks throw ConfigurationError.
|
|
470
|
+
* A throwing option getter throws SdkDefect for `commands` with code `application.defect` and the thrown value as its cause, while another unexpected fault uses `sdk.defect`
|
|
471
|
+
*/
|
|
472
|
+
help(options: CommandHelpOptions): readonly string[]
|
|
473
|
+
/**
|
|
474
|
+
* Validate and add a command to a new router, at root or an existing canonical `options.group` path.
|
|
475
|
+
* Copies metadata and arguments, retaining callbacks and the cooldown store without invoking them.
|
|
476
|
+
* The resulting router requires this command's services `R2` in addition to existing `R` when attached.
|
|
477
|
+
* Names and aliases must not collide with sibling commands or groups under the router's case policy.
|
|
478
|
+
* Invalid definitions, collisions and missing or alias-only parent paths throw ConfigurationError.
|
|
479
|
+
* A throwing getter throws SdkDefect for `commands` with code `application.defect`, while another unexpected fault uses `sdk.defect`. Earlier routers and active attachments remain unchanged
|
|
480
|
+
*/
|
|
481
|
+
register<E, R2, const S extends CommandArgumentSchema = {}>(
|
|
482
|
+
command: NativePrefixCommand<E, R2, S, M>,
|
|
483
|
+
options?: PrefixCommandRegistrationOptions,
|
|
484
|
+
): NativePrefixCommandRouter<R | R2, M>
|
|
485
|
+
/**
|
|
486
|
+
* Validate and add a nonempty keyed command object to one new router, in JavaScript own enumerable string-key order and under one optional parent.
|
|
487
|
+
* Each object key supplies its command name. Set `arguments: {}` to reject positional arguments, or `arguments: undefined` to leave raw args unrestricted.
|
|
488
|
+
* Every definition is snapshotted before registration. Inherited batch keys are ignored.
|
|
489
|
+
* Recognized fields inside each definition are read once, including inherited and non-enumerable fields.
|
|
490
|
+
* If any definition is invalid or any name collides, the call throws
|
|
491
|
+
* ConfigurationError and produces no partially registered router. Earlier routers and attachments remain unchanged.
|
|
492
|
+
* The optional parent is validated and snapshotted once. A throwing getter throws SdkDefect for `commands` with code `application.defect`, while another unexpected fault uses `sdk.defect`.
|
|
493
|
+
* Each entry retains its inferred argument values, and the returned router records every callback service requirement
|
|
494
|
+
*/
|
|
495
|
+
registerMany<
|
|
496
|
+
const S extends Readonly<Record<string, unknown>>,
|
|
497
|
+
const C extends Readonly<
|
|
498
|
+
Record<
|
|
499
|
+
keyof S,
|
|
500
|
+
{
|
|
501
|
+
/** Argument schema of the command under this key */
|
|
502
|
+
readonly arguments?: CommandArgumentSchema
|
|
503
|
+
/** Command callback, whose required services the returned router records */
|
|
504
|
+
readonly execute: unknown
|
|
505
|
+
}
|
|
506
|
+
>
|
|
507
|
+
>,
|
|
508
|
+
>(
|
|
509
|
+
commands: C & NativePrefixCommandBatch<M, S>,
|
|
510
|
+
options?: PrefixCommandRegistrationOptions,
|
|
511
|
+
): NativePrefixCommandRouter<R | NativeBatchRequirements<C>, M>
|
|
512
|
+
/**
|
|
513
|
+
* Add a group to a new router, at root or beneath an existing canonical `options.group` path.
|
|
514
|
+
* Register parent groups before children. Groups accept identity and description only, without callbacks or argument schemas.
|
|
515
|
+
* Group names and aliases use fixed whitespace separators at dispatch, before the command parser runs.
|
|
516
|
+
* Invalid metadata, missing parents and sibling name collisions throw ConfigurationError.
|
|
517
|
+
* A throwing getter throws SdkDefect for `commands` with code `application.defect`, while another unexpected fault uses `sdk.defect`. Existing routers keep their data, and required services `R` do not change
|
|
518
|
+
*/
|
|
519
|
+
registerGroup(
|
|
520
|
+
group: PrefixCommandGroupDefinition,
|
|
521
|
+
options?: PrefixCommandRegistrationOptions,
|
|
522
|
+
): NativePrefixCommandRouter<R, M>
|
|
523
|
+
/**
|
|
524
|
+
* Return an Effect that registers this router as one bounded `messageCreate` subscription in the caller's scope.
|
|
525
|
+
* Provide registered callback services `R` and any error-callback services `R2` when running this Effect
|
|
526
|
+
*
|
|
527
|
+
* Produces a Subscription after registration, not after connecting the client or completing future command work.
|
|
528
|
+
* Callback failures and defects use subscription `onError` reporting with the command name and full Cause, rather than failing an already completed attachment Effect.
|
|
529
|
+
* A failed onUnmatched callback or custom parser is reported the same way without a command name.
|
|
530
|
+
* The router owns one bounded queue for its `onError` hook, which receives reports one at a time in order, as for client.on.
|
|
531
|
+
* Omitted or undefined settings default to eight concurrent commands and overflow dropOldest, so a burst never stops the router.
|
|
532
|
+
* Rejected and unmatched commands are counted and logged at Debug in the commands category.
|
|
533
|
+
* The observe option receives one handler observation per router invocation, including event and command middleware.
|
|
534
|
+
* A matched command supplies its canonical command name, even when a guard denies it or middleware stops it.
|
|
535
|
+
* Reported failures produce outcome failure, interruption produces cancelled, and other completions produce success.
|
|
536
|
+
* A message with no command match still produces an observation without a command name.
|
|
537
|
+
* Only messages a person typed can run commands. Messages from bots are skipped unless `ignoreBots` is false, and so is every message whose type is neither Default nor Reply, such as the notice Fluxer posts with a new thread's name as its content. A message without a type, which Fluxer never sends, counts as typed.
|
|
538
|
+
* Each attachment dispatches independently, so duplicate attachments can execute a command twice
|
|
539
|
+
*
|
|
540
|
+
* Run `subscription.close()` or close the registration scope to detach and interrupt handlers, without shutting down the client.
|
|
541
|
+
* The returned `subscription.waitForClose()` completes after handler finalizers. Work that disables interruption can delay closure.
|
|
542
|
+
* Synchronous work and caller-owned promises that ignore interruption cannot be forcibly stopped
|
|
543
|
+
*
|
|
544
|
+
* The client must use message type `M`. A full-message router cannot attach to a client with omitted fields.
|
|
545
|
+
* Invalid options are misuse and die with ConfigurationError, and a throwing onError getter dies with its thrown value.
|
|
546
|
+
* On a closing or closed client, attach succeeds with an already-closed
|
|
547
|
+
* Subscription whose waitForClose succeeds, and writes a Warn log record with code events.registeredAfterShutdown
|
|
548
|
+
*/
|
|
549
|
+
attach<E = never, R2 = never>(
|
|
550
|
+
client: Client<M>,
|
|
551
|
+
options?: EventHandlerOptions<E, R2>,
|
|
552
|
+
): Effect.Effect<Subscription, never, Scope.Scope | R | R2>
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Recognize message commands such as `!repeat hello` with `commands` from the package's `/effect` entry point.
|
|
557
|
+
* Creation, registration and help are local and return their result directly, throwing ConfigurationError for misuse.
|
|
558
|
+
* Attachment and memory-store operations return Effects that do nothing until run
|
|
559
|
+
*
|
|
560
|
+
* @category Commands
|
|
561
|
+
*/
|
|
562
|
+
export interface NativeCommands {
|
|
563
|
+
/**
|
|
564
|
+
* Validate options and create an empty local router, without connecting or subscribing a client.
|
|
565
|
+
* Defaults to full Message typing. Supply MessageCore or the client's SelectedMessage type as `M` for fewer selected fields.
|
|
566
|
+
* Prefix resolvers, parsers, command callbacks and the context client keep the same message type.
|
|
567
|
+
* The router records services `R` required by optional unmatched feedback, but does not require them until attachment.
|
|
568
|
+
* Invalid options throw ConfigurationError. A throwing getter throws SdkDefect for `commands` with code `application.defect`, while another unexpected fault uses `sdk.defect`.
|
|
569
|
+
* No prefix resolver, parser or feedback callback runs during creation
|
|
570
|
+
*/
|
|
571
|
+
create<E = never, R = never, M extends MessageCore = Message>(
|
|
572
|
+
options: NativePrefixCommandsOptions<E, R, M>,
|
|
573
|
+
): NativePrefixCommandRouter<R, M>
|
|
574
|
+
/**
|
|
575
|
+
* Synchronously split a suffix with single or double quotes and backslash escapes, preserving original argument text in `rawArgs`.
|
|
576
|
+
* Select with `create({ prefix: "!", parse: commands.parseQuoted })`, since the default splits only on whitespace.
|
|
577
|
+
* Returns undefined for empty input or invalid names, and a `PrefixCommandParseRejection` with a fixed `reason` for an unclosed quote or a trailing escape, which `onUnmatched` receives. Empty quotes produce an empty token
|
|
578
|
+
*/
|
|
579
|
+
parseQuoted<M extends MessageCore = Message>(
|
|
580
|
+
input: PrefixCommandParseInput<M>,
|
|
581
|
+
): PrefixCommandParse | PrefixCommandParseRejection | undefined
|
|
582
|
+
/**
|
|
583
|
+
* Create a fresh in-memory cooldown store.
|
|
584
|
+
* Defaults to 10,000 retained keys, or the supplied positive safe integer `maxEntries`. A full store makes room rather
|
|
585
|
+
* than refusing a new key, removing expired keys first and then the reservation that expires soonest.
|
|
586
|
+
* Invalid options throw ConfigurationError. A throwing getter throws SdkDefect for `commands` with code `application.defect`, while another unexpected fault uses `sdk.defect`.
|
|
587
|
+
* Keep the store for reuse in command cooldowns. It has no persistence, scope finalizer or background timer
|
|
588
|
+
*/
|
|
589
|
+
memoryCooldowns(options?: MemoryCooldownOptions): MemoryCooldownStore
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/** Native tools behind the public `commands` namespace, with synchronous local setup and lazy attachment */
|
|
593
|
+
export const nativeCommands: NativeCommands = Object.freeze({
|
|
594
|
+
create: <E, R, M extends MessageCore = Message>(options: NativePrefixCommandsOptions<E, R, M>) =>
|
|
595
|
+
localSetup(() =>
|
|
596
|
+
freezeRouter(
|
|
597
|
+
new NativePrefixCommandRouterOwner<R, M>(
|
|
598
|
+
new PrefixCommandRegistry<StoredNativeCommand<M>, M>(options, ["onUnmatched", "onReject", "use"]),
|
|
599
|
+
readCaller(() => snapshotNativeSettings(options)),
|
|
600
|
+
),
|
|
601
|
+
),
|
|
602
|
+
),
|
|
603
|
+
parseQuoted: parseQuotedPrefixCommand,
|
|
604
|
+
memoryCooldowns: (options: MemoryCooldownOptions | undefined) =>
|
|
605
|
+
localSetup(() => nativeMemoryCooldownStore(createMemoryCooldownStore(options))),
|
|
606
|
+
})
|
|
607
|
+
|
|
608
|
+
interface StoredNativeCommand<M extends MessageCore> extends PrefixCommandDefinition {
|
|
609
|
+
readonly guards: readonly NativePrefixCommandGuard<unknown, unknown, M>[]
|
|
610
|
+
readonly onReject?: NativePrefixCommandRejectionFeedback<unknown, unknown, M>
|
|
611
|
+
readonly cooldown?: {
|
|
612
|
+
readonly store?: NativeCooldownStore<unknown, unknown>
|
|
613
|
+
readonly durationMs: number
|
|
614
|
+
readonly per: CommandCooldownPer
|
|
615
|
+
readonly key?: (context: NativePrefixCommandExecutionContext<CommandArgumentSchema, M>) => string
|
|
616
|
+
}
|
|
617
|
+
readonly execute: (
|
|
618
|
+
context: NativePrefixCommandExecutionContext<CommandArgumentSchema, M>,
|
|
619
|
+
) => Effect.Effect<unknown, unknown, unknown>
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
class NativePrefixCommandRouterOwner<R = never, M extends MessageCore = Message> implements NativePrefixCommandRouter<
|
|
623
|
+
R,
|
|
624
|
+
M
|
|
625
|
+
> {
|
|
626
|
+
readonly #registry: PrefixCommandRegistry<StoredNativeCommand<M>, M>
|
|
627
|
+
readonly #settings: NativeRouterSettings<M>
|
|
628
|
+
|
|
629
|
+
constructor(registry: PrefixCommandRegistry<StoredNativeCommand<M>, M>, settings: NativeRouterSettings<M>) {
|
|
630
|
+
this.#registry = registry
|
|
631
|
+
this.#settings = settings
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
get commands(): readonly PrefixCommandMetadata[] {
|
|
635
|
+
return this.#registry.commands
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
get groups(): readonly PrefixCommandGroupMetadata[] {
|
|
639
|
+
return this.#registry.groups
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
help(options: CommandHelpOptions): readonly string[] {
|
|
643
|
+
return localSetup(() => commandHelp(this.#registry.visibleEntries, options))
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
register<E, R2, const S extends CommandArgumentSchema = {}>(
|
|
647
|
+
command: NativePrefixCommand<E, R2, S, M>,
|
|
648
|
+
options?: PrefixCommandRegistrationOptions,
|
|
649
|
+
): NativePrefixCommandRouter<R | R2, M> {
|
|
650
|
+
return localSetup(() =>
|
|
651
|
+
freezeRouter(
|
|
652
|
+
new NativePrefixCommandRouterOwner<R | R2, M>(
|
|
653
|
+
this.#registry.register(
|
|
654
|
+
readCaller(() => snapshotNativeCommand(command)),
|
|
655
|
+
options,
|
|
656
|
+
),
|
|
657
|
+
this.#settings,
|
|
658
|
+
),
|
|
659
|
+
),
|
|
660
|
+
)
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
registerMany<
|
|
664
|
+
const S extends Readonly<Record<string, unknown>>,
|
|
665
|
+
const C extends Readonly<
|
|
666
|
+
Record<
|
|
667
|
+
keyof S,
|
|
668
|
+
{
|
|
669
|
+
/** Argument schema of the command under this key */
|
|
670
|
+
readonly arguments?: CommandArgumentSchema
|
|
671
|
+
/** Command callback, whose required services the returned router records */
|
|
672
|
+
readonly execute: unknown
|
|
673
|
+
}
|
|
674
|
+
>
|
|
675
|
+
>,
|
|
676
|
+
>(
|
|
677
|
+
commands: C & NativePrefixCommandBatch<M, S>,
|
|
678
|
+
options?: PrefixCommandRegistrationOptions,
|
|
679
|
+
): NativePrefixCommandRouter<R | NativeBatchRequirements<C>, M> {
|
|
680
|
+
return localSetup(() => {
|
|
681
|
+
const stored = readCaller(() => snapshotNativeCommandBatch(commands))
|
|
682
|
+
return freezeRouter(
|
|
683
|
+
new NativePrefixCommandRouterOwner<R | NativeBatchRequirements<C>, M>(
|
|
684
|
+
this.#registry.registerMany(stored, options),
|
|
685
|
+
this.#settings,
|
|
686
|
+
),
|
|
687
|
+
)
|
|
688
|
+
})
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
registerGroup(
|
|
692
|
+
group: PrefixCommandGroupDefinition,
|
|
693
|
+
options?: PrefixCommandRegistrationOptions,
|
|
694
|
+
): NativePrefixCommandRouter<R, M> {
|
|
695
|
+
return localSetup(() =>
|
|
696
|
+
freezeRouter(
|
|
697
|
+
new NativePrefixCommandRouterOwner<R, M>(this.#registry.registerGroup(group, options), this.#settings),
|
|
698
|
+
),
|
|
699
|
+
)
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
attach<E = never, R2 = never>(
|
|
703
|
+
client: Client<M>,
|
|
704
|
+
options?: EventHandlerOptions<E, R2>,
|
|
705
|
+
): Effect.Effect<Subscription, never, Scope.Scope | R | R2> {
|
|
706
|
+
const services = clientServices(client)
|
|
707
|
+
const router = this
|
|
708
|
+
return Effect.gen(function* () {
|
|
709
|
+
const onError: unknown = yield* readInput(() => options?.onError)
|
|
710
|
+
if (onError !== undefined && typeof onError !== "function")
|
|
711
|
+
return yield* Effect.die(new ConfigurationError("onError", 'The option "onError" must be a function'))
|
|
712
|
+
// The router's own hook gets one bounded queue in the registration context, so a failed command only
|
|
713
|
+
// enqueues its report and the hook never holds a command slot. client.on never sees onError
|
|
714
|
+
const hooks =
|
|
715
|
+
services && onError !== undefined
|
|
716
|
+
? services.failures.subscriptionQueue(
|
|
717
|
+
onError as (report: InternalReport) => Effect.Effect<unknown, unknown>,
|
|
718
|
+
(yield* Effect.context<R2>()) as Context.Context<never>,
|
|
719
|
+
)
|
|
720
|
+
: undefined
|
|
721
|
+
let subscriptionId: string | undefined
|
|
722
|
+
const report =
|
|
723
|
+
services &&
|
|
724
|
+
((message: M, name: string | undefined, cause: Cause.Cause<unknown>): Effect.Effect<void> =>
|
|
725
|
+
Effect.withFiber((fiber) => {
|
|
726
|
+
recordCommandFailure(name, cause, fiber.context)
|
|
727
|
+
try {
|
|
728
|
+
const internal = makeReport(
|
|
729
|
+
{
|
|
730
|
+
kind: "handler",
|
|
731
|
+
cause,
|
|
732
|
+
event: "messageCreate",
|
|
733
|
+
command: name,
|
|
734
|
+
subscriptionId,
|
|
735
|
+
message: messageReference(message),
|
|
736
|
+
},
|
|
737
|
+
services.logging.secrets,
|
|
738
|
+
)
|
|
739
|
+
if (!hooks) services.failures.report(internal, fiber.context)
|
|
740
|
+
else {
|
|
741
|
+
services.logging.count("handlerFailures")
|
|
742
|
+
hooks.offer(internal)
|
|
743
|
+
}
|
|
744
|
+
} catch (fault) {
|
|
745
|
+
services.logging.outputFailure(fault)
|
|
746
|
+
}
|
|
747
|
+
return Effect.void
|
|
748
|
+
}))
|
|
749
|
+
const subscription = yield* client.on(
|
|
750
|
+
"messageCreate",
|
|
751
|
+
(message) => router.dispatch(client, message, services?.logging, report) as Effect.Effect<void, E, R>,
|
|
752
|
+
routerSubscriptionOptions(options) as EventHandlerOptions<never, never>,
|
|
753
|
+
)
|
|
754
|
+
subscriptionId = subscription.id
|
|
755
|
+
return subscription
|
|
756
|
+
})
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
private dispatch<R2>(
|
|
760
|
+
client: Client<M>,
|
|
761
|
+
message: M,
|
|
762
|
+
logger: ClientLogger | undefined,
|
|
763
|
+
report:
|
|
764
|
+
((message: M, name: string | undefined, cause: Cause.Cause<unknown>) => Effect.Effect<void>) | undefined,
|
|
765
|
+
): Effect.Effect<void, ConfigurationError, R | R2> {
|
|
766
|
+
const registry = this.#registry
|
|
767
|
+
const settings = this.#settings
|
|
768
|
+
const services = clientServices(client)
|
|
769
|
+
return dispatchCommand<
|
|
770
|
+
StoredNativeCommand<M>,
|
|
771
|
+
NativePrefixCommandContext<M>,
|
|
772
|
+
NativePrefixCommandExecutionContext<CommandArgumentSchema, M>,
|
|
773
|
+
unknown,
|
|
774
|
+
unknown,
|
|
775
|
+
M
|
|
776
|
+
>(registry, message, {
|
|
777
|
+
logger,
|
|
778
|
+
prefix: (resolver, value) =>
|
|
779
|
+
Effect.suspend(() => {
|
|
780
|
+
const resolved: unknown = resolver(value)
|
|
781
|
+
return Effect.isEffect(resolved) ? resolved : Effect.succeed(resolved)
|
|
782
|
+
}),
|
|
783
|
+
...(services === undefined ? {} : { selfId: () => services.selfUserId() }),
|
|
784
|
+
...(settings.use.length === 0
|
|
785
|
+
? {}
|
|
786
|
+
: {
|
|
787
|
+
around: (
|
|
788
|
+
context: NativePrefixCommandContext<M>,
|
|
789
|
+
rest: Effect.Effect<void, unknown, unknown>,
|
|
790
|
+
): Effect.Effect<void, unknown, unknown> =>
|
|
791
|
+
nativeAround(
|
|
792
|
+
settings.use,
|
|
793
|
+
context,
|
|
794
|
+
rest,
|
|
795
|
+
report && ((cause) => report(message, context.name, cause)),
|
|
796
|
+
),
|
|
797
|
+
}),
|
|
798
|
+
...(report === undefined
|
|
799
|
+
? {}
|
|
800
|
+
: {
|
|
801
|
+
failed: (name: string | undefined, cause: Cause.Cause<unknown>) =>
|
|
802
|
+
report(message, name, cause) as unknown as Effect.Effect<void>,
|
|
803
|
+
}),
|
|
804
|
+
context: (match) =>
|
|
805
|
+
Object.freeze({
|
|
806
|
+
client,
|
|
807
|
+
message,
|
|
808
|
+
prefix: match.prefix,
|
|
809
|
+
name: match.definition.name,
|
|
810
|
+
...(match.path === undefined ? {} : { path: match.path }),
|
|
811
|
+
args: Object.freeze([...match.parse.args]),
|
|
812
|
+
rawArgs: match.parse.rawArgs,
|
|
813
|
+
reply: boundNativeReply(client, message),
|
|
814
|
+
help: (options?: CommandContextHelpOptions) => this.help(contextHelpOptions(options, match.prefix)),
|
|
815
|
+
paginate: boundNativePaginate(client, message),
|
|
816
|
+
sendHelp: (options?: CommandContextHelpOptions) =>
|
|
817
|
+
Effect.suspend(() => {
|
|
818
|
+
let pages: readonly string[]
|
|
819
|
+
try {
|
|
820
|
+
pages = this.help(contextHelpOptions(options, match.prefix))
|
|
821
|
+
} catch (error) {
|
|
822
|
+
if (error instanceof ConfigurationError) return Effect.fail(error)
|
|
823
|
+
throw error
|
|
824
|
+
}
|
|
825
|
+
return boundNativePaginate(client, message)(pages)
|
|
826
|
+
}),
|
|
827
|
+
}) as NativePrefixCommandContext<M>,
|
|
828
|
+
convert: (definition, context) =>
|
|
829
|
+
convertCommandArguments(definition.arguments, context.args, { guildId: context.message.guildId }),
|
|
830
|
+
executionContext: (context, values) =>
|
|
831
|
+
Object.freeze({
|
|
832
|
+
...context,
|
|
833
|
+
values: values as CommandArgumentValues<CommandArgumentSchema>,
|
|
834
|
+
}),
|
|
835
|
+
unmatched:
|
|
836
|
+
settings.onUnmatched === undefined
|
|
837
|
+
? undefined
|
|
838
|
+
: (match) =>
|
|
839
|
+
nativeCallback(
|
|
840
|
+
() =>
|
|
841
|
+
settings.onUnmatched!(
|
|
842
|
+
Object.freeze({
|
|
843
|
+
client,
|
|
844
|
+
message,
|
|
845
|
+
prefix: match.prefix,
|
|
846
|
+
reply: boundNativeReply(client, message),
|
|
847
|
+
}),
|
|
848
|
+
match.unmatched,
|
|
849
|
+
),
|
|
850
|
+
"A native command onUnmatched callback must return an Effect",
|
|
851
|
+
),
|
|
852
|
+
guard: (definition, context) =>
|
|
853
|
+
Effect.gen(function* () {
|
|
854
|
+
for (const guard of definition.guards) {
|
|
855
|
+
const verdict: PrefixCommandGuardResult = yield* nativeCallback(
|
|
856
|
+
() => guard(context),
|
|
857
|
+
"A native command guard must return an Effect",
|
|
858
|
+
)
|
|
859
|
+
if (verdict !== true) return verdict
|
|
860
|
+
}
|
|
861
|
+
return true
|
|
862
|
+
}),
|
|
863
|
+
feedback: (definition) => {
|
|
864
|
+
const feedback = definition.onReject ?? settings.onReject
|
|
865
|
+
return feedback === undefined || feedback === "silent"
|
|
866
|
+
? undefined
|
|
867
|
+
: feedback === "reply"
|
|
868
|
+
? "reply"
|
|
869
|
+
: "callback"
|
|
870
|
+
},
|
|
871
|
+
reject: (definition, context, rejection, now) => {
|
|
872
|
+
const feedback = definition.onReject ?? settings.onReject
|
|
873
|
+
if (feedback === undefined || feedback === "silent") return Effect.void
|
|
874
|
+
if (feedback === "reply") {
|
|
875
|
+
const path = context.path ?? [context.name]
|
|
876
|
+
const metadata = registry.commands.find((command) =>
|
|
877
|
+
sameCommandPath(command.path ?? [command.name], path),
|
|
878
|
+
)
|
|
879
|
+
// The remaining cooldown uses the handler's Clock time, the same Clock that claimed the cooldown
|
|
880
|
+
const text = rejectionReply(rejection, metadata, context.prefix, now)
|
|
881
|
+
return text === undefined ? Effect.void : Effect.suspend(() => context.reply(text))
|
|
882
|
+
}
|
|
883
|
+
return nativeCallback(
|
|
884
|
+
() => feedback(context, rejection),
|
|
885
|
+
"A native command onReject callback must return an Effect",
|
|
886
|
+
)
|
|
887
|
+
},
|
|
888
|
+
cooldown: (definition, context, routerStore) => nativeCooldown(definition, context, routerStore),
|
|
889
|
+
execute: (definition, context) =>
|
|
890
|
+
nativeCallback(
|
|
891
|
+
() => definition.execute(context),
|
|
892
|
+
"A native command execute callback must return an Effect",
|
|
893
|
+
),
|
|
894
|
+
}) as Effect.Effect<void, ConfigurationError, R>
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
interface NativeRouterSettings<M extends MessageCore> {
|
|
899
|
+
readonly onUnmatched?: (
|
|
900
|
+
context: NativePrefixCommandUnmatchedContext<M>,
|
|
901
|
+
unmatched: PrefixCommandUnmatched,
|
|
902
|
+
) => Effect.Effect<unknown, unknown, unknown>
|
|
903
|
+
readonly onReject?: NativePrefixCommandRejectionFeedback<unknown, unknown, M>
|
|
904
|
+
readonly use: readonly NativePrefixCommandMiddleware<unknown, unknown, M>[]
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function snapshotNativeSettings<E, R, M extends MessageCore>(
|
|
908
|
+
options: NativePrefixCommandsOptions<E, R, M>,
|
|
909
|
+
): NativeRouterSettings<M> {
|
|
910
|
+
const { onUnmatched, onReject, use } = options
|
|
911
|
+
if (onUnmatched !== undefined && typeof onUnmatched !== "function")
|
|
912
|
+
throw new ConfigurationError("commands", 'The option "onUnmatched" must be a function')
|
|
913
|
+
if (onReject !== undefined && onReject !== "reply" && onReject !== "silent" && typeof onReject !== "function")
|
|
914
|
+
throw new ConfigurationError("commands", 'The option "onReject" must be "reply", "silent" or a function')
|
|
915
|
+
return Object.freeze({
|
|
916
|
+
...(onUnmatched === undefined ? {} : { onUnmatched: onUnmatched as NativeRouterSettings<M>["onUnmatched"] }),
|
|
917
|
+
...(onReject === undefined ? {} : { onReject: onReject as NativeRouterSettings<M>["onReject"] }),
|
|
918
|
+
use: nativeFunctions<NativePrefixCommandMiddleware<unknown, unknown, M>>(
|
|
919
|
+
use,
|
|
920
|
+
'The option "use" must be an array of middleware functions',
|
|
921
|
+
),
|
|
922
|
+
}) as NativeRouterSettings<M>
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function nativeFunctions<F>(value: unknown, message: string): readonly F[] {
|
|
926
|
+
if (value === undefined) return Object.freeze([])
|
|
927
|
+
if (!Array.isArray(value)) throw new ConfigurationError("commands", message)
|
|
928
|
+
const copied: F[] = []
|
|
929
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
930
|
+
if (!Object.hasOwn(value, index) || typeof value[index] !== "function")
|
|
931
|
+
throw new ConfigurationError("commands", message)
|
|
932
|
+
copied.push(value[index] as F)
|
|
933
|
+
}
|
|
934
|
+
return Object.freeze(copied)
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Run middleware in order around the rest of a command. Each stage, including the rest, runs at most once: The first
|
|
939
|
+
* evaluation of a `next` starts it, and repeated or concurrent evaluations wait for that run's exit.
|
|
940
|
+
* The command's failure is reported once with its command name whether middleware recovers from it, rethrows it or
|
|
941
|
+
* replaces it. A different middleware failure is reported after it, and interruption keeps an earlier command failure
|
|
942
|
+
*/
|
|
943
|
+
function nativeAround<M extends MessageCore>(
|
|
944
|
+
middleware: readonly NativePrefixCommandMiddleware<unknown, unknown, M>[],
|
|
945
|
+
context: NativePrefixCommandContext<M>,
|
|
946
|
+
rest: Effect.Effect<void, unknown, unknown>,
|
|
947
|
+
report: ((cause: Cause.Cause<unknown>) => Effect.Effect<void>) | undefined,
|
|
948
|
+
): Effect.Effect<void, unknown, unknown> {
|
|
949
|
+
return Effect.suspend(() => {
|
|
950
|
+
let outcome: Exit.Exit<void, unknown> | undefined
|
|
951
|
+
// The latch is set before the stage starts, so a concurrent evaluation waits instead of starting it again
|
|
952
|
+
const once = (stage: Effect.Effect<void, unknown, unknown>): Effect.Effect<void, unknown, unknown> => {
|
|
953
|
+
let latch: Deferred.Deferred<void, unknown> | undefined
|
|
954
|
+
return Effect.suspend(() => {
|
|
955
|
+
if (latch !== undefined) return Deferred.await(latch)
|
|
956
|
+
const started = Deferred.makeUnsafe<void, unknown>()
|
|
957
|
+
latch = started
|
|
958
|
+
return stage.pipe(Effect.onExit((exit) => Deferred.done(started, exit)))
|
|
959
|
+
})
|
|
960
|
+
}
|
|
961
|
+
const last = once(
|
|
962
|
+
rest.pipe(
|
|
963
|
+
Effect.onExit((exit) =>
|
|
964
|
+
Effect.sync(() => {
|
|
965
|
+
outcome = exit
|
|
966
|
+
}),
|
|
967
|
+
),
|
|
968
|
+
),
|
|
969
|
+
)
|
|
970
|
+
const chain = middleware.reduceRight<Effect.Effect<void, unknown, unknown>>(
|
|
971
|
+
(next, step) =>
|
|
972
|
+
once(
|
|
973
|
+
nativeCallback(
|
|
974
|
+
// The rest keeps the attachment context, so middleware sees it as needing no further services
|
|
975
|
+
() => step(context, next as Effect.Effect<void, unknown>),
|
|
976
|
+
"Native command middleware must return an Effect",
|
|
977
|
+
).pipe(Effect.asVoid),
|
|
978
|
+
),
|
|
979
|
+
last,
|
|
980
|
+
)
|
|
981
|
+
const settle = settleNativeAround(() => outcome, report)
|
|
982
|
+
return chain.pipe(
|
|
983
|
+
Effect.exit,
|
|
984
|
+
Effect.flatMap((exit) => settle.finish(Exit.isSuccess(exit) ? undefined : exit.cause)),
|
|
985
|
+
Effect.onExit(() => settle.saved),
|
|
986
|
+
)
|
|
987
|
+
})
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Settle a native command wrapped by middleware. The command's own failure is reported once, with its command name,
|
|
992
|
+
* whether middleware succeeded, threw it again or failed differently. A different middleware failure is reported after it.
|
|
993
|
+
* The `saved` argument reports a command failure that nothing else settled, such as after interruption
|
|
994
|
+
*/
|
|
995
|
+
function settleNativeAround(
|
|
996
|
+
restExit: () => Exit.Exit<void, unknown> | undefined,
|
|
997
|
+
report: ((cause: Cause.Cause<unknown>) => Effect.Effect<void>) | undefined,
|
|
998
|
+
) {
|
|
999
|
+
let settled = false
|
|
1000
|
+
const commandFailure = () => {
|
|
1001
|
+
const exit = restExit()
|
|
1002
|
+
return exit !== undefined && Exit.isFailure(exit) ? exit.cause : undefined
|
|
1003
|
+
}
|
|
1004
|
+
const saved = Effect.suspend(() => {
|
|
1005
|
+
const failure = commandFailure()
|
|
1006
|
+
if (settled || failure === undefined || report === undefined || Cause.hasInterrupts(failure)) return Effect.void
|
|
1007
|
+
settled = true
|
|
1008
|
+
return report(failure)
|
|
1009
|
+
})
|
|
1010
|
+
const finish = (middlewareFailure: Cause.Cause<unknown> | undefined): Effect.Effect<void, unknown> =>
|
|
1011
|
+
Effect.suspend(() => {
|
|
1012
|
+
const failure = commandFailure()
|
|
1013
|
+
if (failure === undefined)
|
|
1014
|
+
return middlewareFailure === undefined ? Effect.void : Effect.failCause(middlewareFailure)
|
|
1015
|
+
// Recovered or rethrown, the command's failure reaches the dispatcher's report once
|
|
1016
|
+
if (
|
|
1017
|
+
middlewareFailure === undefined ||
|
|
1018
|
+
middlewareFailure === failure ||
|
|
1019
|
+
(!Cause.hasInterrupts(middlewareFailure) && primaryError(middlewareFailure) === primaryError(failure))
|
|
1020
|
+
) {
|
|
1021
|
+
settled = true
|
|
1022
|
+
return Effect.failCause(failure)
|
|
1023
|
+
}
|
|
1024
|
+
// Without a separate report, one combined failure still carries both errors
|
|
1025
|
+
if (report === undefined) {
|
|
1026
|
+
settled = true
|
|
1027
|
+
return Effect.failCause(Cause.combine(failure, middlewareFailure))
|
|
1028
|
+
}
|
|
1029
|
+
return saved.pipe(Effect.andThen(Effect.failCause(middlewareFailure)))
|
|
1030
|
+
})
|
|
1031
|
+
return { finish, saved }
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
function snapshotNativeCommand<E, R, S extends CommandArgumentSchema, M extends MessageCore>(
|
|
1035
|
+
command: NativePrefixCommand<E, R, S, M>,
|
|
1036
|
+
keyedName?: string,
|
|
1037
|
+
): StoredNativeCommand<M> {
|
|
1038
|
+
validateCommandShape(command, [
|
|
1039
|
+
"name",
|
|
1040
|
+
"aliases",
|
|
1041
|
+
"description",
|
|
1042
|
+
"usage",
|
|
1043
|
+
"hidden",
|
|
1044
|
+
"arguments",
|
|
1045
|
+
"guard",
|
|
1046
|
+
"onReject",
|
|
1047
|
+
"cooldown",
|
|
1048
|
+
"execute",
|
|
1049
|
+
])
|
|
1050
|
+
const { execute, guard, onReject, cooldown: sourceCooldown } = command
|
|
1051
|
+
if (typeof execute !== "function")
|
|
1052
|
+
throw new ConfigurationError("command", 'The command option "execute" must be a function')
|
|
1053
|
+
const guards =
|
|
1054
|
+
guard === undefined
|
|
1055
|
+
? Object.freeze([])
|
|
1056
|
+
: typeof guard === "function"
|
|
1057
|
+
? Object.freeze([guard])
|
|
1058
|
+
: nativeFunctions<NativePrefixCommandGuard<E, R, M>>(
|
|
1059
|
+
guard,
|
|
1060
|
+
'The option "guard" must be a function or an array of functions',
|
|
1061
|
+
)
|
|
1062
|
+
if (onReject !== undefined && onReject !== "reply" && onReject !== "silent" && typeof onReject !== "function")
|
|
1063
|
+
throw new ConfigurationError("command", 'The option "onReject" must be "reply", "silent" or a function')
|
|
1064
|
+
const cooldown = snapshotCommandCooldown(sourceCooldown)
|
|
1065
|
+
const definition = snapshotCommandDefinition(command, keyedName)
|
|
1066
|
+
return Object.freeze({
|
|
1067
|
+
...definition,
|
|
1068
|
+
execute: execute as StoredNativeCommand<M>["execute"],
|
|
1069
|
+
guards: guards as StoredNativeCommand<M>["guards"],
|
|
1070
|
+
...(onReject === undefined ? {} : { onReject: onReject as StoredNativeCommand<M>["onReject"] }),
|
|
1071
|
+
...(cooldown === undefined ? {} : { cooldown: cooldown as NonNullable<StoredNativeCommand<M>["cooldown"]> }),
|
|
1072
|
+
}) as StoredNativeCommand<M>
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
function snapshotNativeCommandBatch<M extends MessageCore>(
|
|
1076
|
+
commands: Readonly<Record<string, unknown>>,
|
|
1077
|
+
): readonly StoredNativeCommand<M>[] {
|
|
1078
|
+
if (typeof commands !== "object" || commands === null || Array.isArray(commands))
|
|
1079
|
+
throw new ConfigurationError("command", "A command batch must be an object")
|
|
1080
|
+
for (const key of Reflect.ownKeys(commands))
|
|
1081
|
+
if (typeof key === "symbol" && Object.prototype.propertyIsEnumerable.call(commands, key))
|
|
1082
|
+
throw new ConfigurationError("command", "Command batch keys must be strings")
|
|
1083
|
+
const names = Object.keys(commands)
|
|
1084
|
+
if (names.length === 0) throw new ConfigurationError("command", "A command batch must not be empty")
|
|
1085
|
+
const stored: StoredNativeCommand<M>[] = []
|
|
1086
|
+
for (const name of names) {
|
|
1087
|
+
const value = commands[name]
|
|
1088
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
1089
|
+
throw new ConfigurationError("command", `The command batch entry ${JSON.stringify(name)} must be an object`)
|
|
1090
|
+
if (Object.prototype.hasOwnProperty.call(value, "name"))
|
|
1091
|
+
throw new ConfigurationError(
|
|
1092
|
+
"command",
|
|
1093
|
+
`The command batch entry ${JSON.stringify(name)} must not set "name", because its object key is the name`,
|
|
1094
|
+
)
|
|
1095
|
+
stored.push(
|
|
1096
|
+
snapshotNativeCommand(value as NativePrefixCommand<unknown, unknown, CommandArgumentSchema, M>, name),
|
|
1097
|
+
)
|
|
1098
|
+
}
|
|
1099
|
+
return Object.freeze(stored)
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
function boundNativeReply<M extends MessageCore>(
|
|
1103
|
+
client: Client<M>,
|
|
1104
|
+
message: M,
|
|
1105
|
+
): NativePrefixCommandContext<M>["reply"] {
|
|
1106
|
+
return (input, options) => client.messages.reply(message, input, options)
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
function boundNativePaginate<M extends MessageCore>(
|
|
1110
|
+
client: Client<M>,
|
|
1111
|
+
message: M,
|
|
1112
|
+
): NativePrefixCommandContext<M>["paginate"] {
|
|
1113
|
+
return (pages, options) =>
|
|
1114
|
+
client.messages.paginate(message.channelId, pages, askerPageOptions(options, message.author.id))
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
function nativeCooldown<M extends MessageCore>(
|
|
1118
|
+
definition: StoredNativeCommand<M>,
|
|
1119
|
+
context: NativePrefixCommandExecutionContext<CommandArgumentSchema, M>,
|
|
1120
|
+
routerStore: LocalMemoryCooldownStore,
|
|
1121
|
+
): Effect.Effect<{ readonly key: string; readonly claim: unknown } | undefined, unknown, unknown> {
|
|
1122
|
+
const cooldown = definition.cooldown
|
|
1123
|
+
if (cooldown === undefined) return Effect.succeed(undefined)
|
|
1124
|
+
return Effect.suspend(() =>
|
|
1125
|
+
Effect.succeed(cooldown.key?.(context) ?? cooldownSuffix(cooldown.per, context.message)),
|
|
1126
|
+
).pipe(
|
|
1127
|
+
Effect.flatMap((key) =>
|
|
1128
|
+
configurationEffect(() => cooldownRequest(context.path ?? definition.name, key, cooldown.durationMs)),
|
|
1129
|
+
),
|
|
1130
|
+
Effect.flatMap((request) => {
|
|
1131
|
+
const store = cooldown.store
|
|
1132
|
+
const claim: Effect.Effect<unknown, unknown, unknown> =
|
|
1133
|
+
store === undefined
|
|
1134
|
+
? Clock.clockWith((clock) =>
|
|
1135
|
+
configurationEffect(() => {
|
|
1136
|
+
const claimed = routerStore.claim(request, clock.currentTimeMillisUnsafe())
|
|
1137
|
+
if (claimed._tag === "Failure") throw claimed.error
|
|
1138
|
+
return claimed.value
|
|
1139
|
+
}),
|
|
1140
|
+
)
|
|
1141
|
+
: Effect.suspend(() => {
|
|
1142
|
+
const claimed = store.claim(request)
|
|
1143
|
+
return Effect.isEffect(claimed) ? claimed : Effect.succeed(claimed)
|
|
1144
|
+
})
|
|
1145
|
+
return Effect.map(claim, (value) => ({ key: request.key, claim: value }))
|
|
1146
|
+
}),
|
|
1147
|
+
)
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
function nativeMemoryCooldownStore(owner: LocalMemoryCooldownStore): MemoryCooldownStore {
|
|
1151
|
+
return Object.freeze({
|
|
1152
|
+
maxEntries: owner.maxEntries,
|
|
1153
|
+
get size() {
|
|
1154
|
+
return owner.size
|
|
1155
|
+
},
|
|
1156
|
+
claim: (input: CommandCooldownRequest) =>
|
|
1157
|
+
Clock.clockWith((clock) =>
|
|
1158
|
+
suspendMarked(() => {
|
|
1159
|
+
const result = owner.claim(
|
|
1160
|
+
readCaller(() => snapshotClaimInput(input)),
|
|
1161
|
+
clock.currentTimeMillisUnsafe(),
|
|
1162
|
+
)
|
|
1163
|
+
return result._tag === "Success" ? Effect.succeed(result.value) : Effect.die(result.error)
|
|
1164
|
+
}),
|
|
1165
|
+
),
|
|
1166
|
+
sweep: () => Clock.clockWith((clock) => Effect.sync(() => owner.sweep(clock.currentTimeMillisUnsafe()))),
|
|
1167
|
+
clear: () => Effect.sync(() => owner.clear()),
|
|
1168
|
+
})
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
function freezeRouter<R, M extends MessageCore>(
|
|
1172
|
+
router: NativePrefixCommandRouterOwner<R, M>,
|
|
1173
|
+
): NativePrefixCommandRouter<R, M> {
|
|
1174
|
+
return Object.freeze(router)
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
function nativeCallback<A, E, R>(
|
|
1178
|
+
callback: () => Effect.Effect<A, E, R>,
|
|
1179
|
+
message: string,
|
|
1180
|
+
): Effect.Effect<A, ConfigurationError | E, R> {
|
|
1181
|
+
return Effect.suspend(() => {
|
|
1182
|
+
const value: unknown = callback()
|
|
1183
|
+
return Effect.isEffect(value) ? value : Effect.fail(new ConfigurationError("command", message))
|
|
1184
|
+
}) as Effect.Effect<A, ConfigurationError | E, R>
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Run local command setup, keeping ConfigurationError for misuse. A throw from a marked read of caller definitions or
|
|
1189
|
+
* options is an application fault, and any other throw, such as from building the registry, is an SDK fault
|
|
1190
|
+
*/
|
|
1191
|
+
function localSetup<A>(create: () => A): A {
|
|
1192
|
+
try {
|
|
1193
|
+
return create()
|
|
1194
|
+
} catch (error) {
|
|
1195
|
+
if (error instanceof ConfigurationError) throw error
|
|
1196
|
+
throw new SdkDefect("commands", [thrownReason(error)])
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* Run a runBot register callback. Misuse and SDK defects from the registrations it makes keep their errors, and any
|
|
1202
|
+
* other throw is the application's own failure, carried by ApplicationError naming `runBot commands`
|
|
1203
|
+
*/
|
|
1204
|
+
function registerCallback<A>(register: () => A): A {
|
|
1205
|
+
try {
|
|
1206
|
+
return register()
|
|
1207
|
+
} catch (error) {
|
|
1208
|
+
if (error instanceof ConfigurationError || error instanceof SdkDefect) throw error
|
|
1209
|
+
throw new ApplicationError("runBot commands", error)
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Create the native router a runBot commands option describes, registering its keyed commands or its register callback.
|
|
1215
|
+
* Rejections are answered with `onReject: "reply"` unless the option selects other feedback.
|
|
1216
|
+
* Bot-authored messages are skipped as the runBot ignoreBots setting says, unless the option sets its own ignoreBots.
|
|
1217
|
+
* Misuse throws ConfigurationError. A register callback's own throw becomes ApplicationError naming `runBot commands`
|
|
1218
|
+
*/
|
|
1219
|
+
export function nativeBotRouter<M extends MessageCore>(
|
|
1220
|
+
options: unknown,
|
|
1221
|
+
ignoreBots: boolean,
|
|
1222
|
+
): NativePrefixCommandRouter<unknown, M> {
|
|
1223
|
+
if (typeof options !== "object" || options === null || Array.isArray(options))
|
|
1224
|
+
throw new ConfigurationError("commands", "The commands option must be an object")
|
|
1225
|
+
checkBotCommandKeys(options, ["onUnmatched", "onReject", "use"])
|
|
1226
|
+
// The onError hook and delivery settings belong to the router's attachment, which runBot makes with them
|
|
1227
|
+
const {
|
|
1228
|
+
commands: definitions,
|
|
1229
|
+
onError: _onError,
|
|
1230
|
+
concurrency: _concurrency,
|
|
1231
|
+
partition: _partition,
|
|
1232
|
+
overflow: _overflow,
|
|
1233
|
+
maxPendingMessages: _maxPendingMessages,
|
|
1234
|
+
maxPendingBytes: _maxPendingBytes,
|
|
1235
|
+
...settings
|
|
1236
|
+
} = options as Record<string, unknown>
|
|
1237
|
+
const router = nativeCommands.create<unknown, unknown, M>({
|
|
1238
|
+
...settings,
|
|
1239
|
+
ignoreBots: settings.ignoreBots ?? ignoreBots,
|
|
1240
|
+
onReject: settings.onReject ?? "reply",
|
|
1241
|
+
} as unknown as NativePrefixCommandsOptions<unknown, unknown, M>)
|
|
1242
|
+
if (typeof definitions === "function") {
|
|
1243
|
+
const registered: unknown = registerCallback(() => (definitions as (router: unknown) => unknown)(router))
|
|
1244
|
+
if (!(registered instanceof NativePrefixCommandRouterOwner))
|
|
1245
|
+
throw new ConfigurationError("commands", "A commands register callback must return the registered router")
|
|
1246
|
+
return registered as NativePrefixCommandRouter<unknown, M>
|
|
1247
|
+
}
|
|
1248
|
+
return router.registerMany(definitions as never) as NativePrefixCommandRouter<unknown, M>
|
|
1249
|
+
}
|