yuzuha 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/README.md +22 -14
- package/VERSIONING.md +56 -7
- package/benchmarks/parser.mjs +1 -1
- package/benchmarks/run.mjs +3 -2
- package/dist/canvas/card.d.ts +10 -0
- package/dist/canvas/card.d.ts.map +1 -0
- package/dist/canvas/card.js +11 -0
- package/dist/canvas/card.js.map +1 -0
- package/dist/canvas.d.ts +30 -9
- package/dist/canvas.d.ts.map +1 -1
- package/dist/canvas.js +64 -9
- package/dist/canvas.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +2 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/lint.d.ts.map +1 -1
- package/dist/cli/lint.js +1 -2
- package/dist/cli/lint.js.map +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +8 -9
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/scaffold.js +1 -1
- package/dist/cli/scaffold.js.map +1 -1
- package/dist/cli/scenarios.d.ts.map +1 -1
- package/dist/cli/scenarios.js +2 -1
- package/dist/cli/scenarios.js.map +1 -1
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +7 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/domain/resource-batches.d.ts +6 -0
- package/dist/domain/resource-batches.d.ts.map +1 -1
- package/dist/domain/resource-batches.js +31 -0
- package/dist/domain/resource-batches.js.map +1 -1
- package/dist/framework/bot.d.ts +9 -5
- package/dist/framework/bot.d.ts.map +1 -1
- package/dist/framework/bot.js +51 -27
- package/dist/framework/bot.js.map +1 -1
- package/dist/framework/command-registry.d.ts +8 -7
- package/dist/framework/command-registry.d.ts.map +1 -1
- package/dist/framework/command-registry.js +14 -11
- package/dist/framework/command-registry.js.map +1 -1
- package/dist/framework/options.d.ts +3 -3
- package/dist/framework/options.d.ts.map +1 -1
- package/dist/framework/options.js.map +1 -1
- package/dist/{scripting → functions}/builtins/arguments.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/arguments.js.map +1 -1
- package/dist/functions/builtins/canvas.d.ts +2 -0
- package/dist/functions/builtins/canvas.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/canvas.js +1 -1
- package/dist/{scripting → functions}/builtins/canvas.js.map +1 -1
- package/dist/functions/builtins/context.d.ts +2 -0
- package/dist/functions/builtins/context.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/context.js.map +1 -1
- package/dist/{scripting → functions}/builtins/definition.d.ts +1 -1
- package/dist/functions/builtins/definition.d.ts.map +1 -0
- package/dist/functions/builtins/definition.js.map +1 -0
- package/dist/functions/builtins/embeds.d.ts +3 -0
- package/dist/{scripting → functions}/builtins/embeds.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/embeds.js +1 -1
- package/dist/functions/builtins/embeds.js.map +1 -0
- package/dist/functions/builtins/events.d.ts +2 -0
- package/dist/functions/builtins/events.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/events.js.map +1 -1
- package/dist/functions/builtins/flow.d.ts +2 -0
- package/dist/functions/builtins/flow.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/flow.js +2 -2
- package/dist/functions/builtins/flow.js.map +1 -0
- package/dist/functions/builtins/guards.d.ts +2 -0
- package/dist/functions/builtins/guards.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/guards.js +1 -1
- package/dist/functions/builtins/guards.js.map +1 -0
- package/dist/functions/builtins/http.d.ts +2 -0
- package/dist/functions/builtins/http.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/http.js +2 -2
- package/dist/functions/builtins/http.js.map +1 -0
- package/dist/functions/builtins/index.d.ts +5 -0
- package/dist/functions/builtins/index.d.ts.map +1 -0
- package/dist/functions/builtins/index.js.map +1 -0
- package/dist/functions/builtins/language/array-callbacks.d.ts +2 -0
- package/dist/functions/builtins/language/array-callbacks.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/array-callbacks.js +1 -1
- package/dist/{scripting → functions}/builtins/language/array-callbacks.js.map +1 -1
- package/dist/functions/builtins/language/arrays.d.ts +2 -0
- package/dist/functions/builtins/language/arrays.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/arrays.js +1 -1
- package/dist/{scripting → functions}/builtins/language/arrays.js.map +1 -1
- package/dist/{scripting → functions}/builtins/language/common.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/common.js.map +1 -1
- package/dist/functions/builtins/language/decimals.d.ts +2 -0
- package/dist/functions/builtins/language/decimals.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/decimals.js.map +1 -1
- package/dist/functions/builtins/language/index.d.ts +3 -0
- package/dist/functions/builtins/language/index.d.ts.map +1 -0
- package/dist/functions/builtins/language/index.js.map +1 -0
- package/dist/functions/builtins/language/loops.d.ts +4 -0
- package/dist/{scripting → functions}/builtins/language/loops.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/loops.js +3 -3
- package/dist/{scripting → functions}/builtins/language/loops.js.map +1 -1
- package/dist/functions/builtins/language/numbers.d.ts +2 -0
- package/dist/functions/builtins/language/numbers.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/numbers.js.map +1 -1
- package/dist/{scripting → functions}/builtins/language/objects.d.ts +1 -1
- package/dist/{scripting → functions}/builtins/language/objects.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/objects.js.map +1 -1
- package/dist/functions/builtins/language/regex.d.ts +2 -0
- package/dist/functions/builtins/language/regex.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/regex.js +1 -1
- package/dist/{scripting → functions}/builtins/language/regex.js.map +1 -1
- package/dist/functions/builtins/language/sort.d.ts +2 -0
- package/dist/functions/builtins/language/sort.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/sort.js.map +1 -1
- package/dist/{scripting → functions}/builtins/language/state.d.ts +1 -1
- package/dist/{scripting → functions}/builtins/language/state.d.ts.map +1 -1
- package/dist/{scripting → functions}/builtins/language/state.js.map +1 -1
- package/dist/functions/builtins/language/texts.d.ts +2 -0
- package/dist/functions/builtins/language/texts.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/language/texts.js.map +1 -1
- package/dist/functions/builtins/messages.d.ts +2 -0
- package/dist/functions/builtins/messages.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/messages.js.map +1 -1
- package/dist/functions/builtins/moderation.d.ts +2 -0
- package/dist/functions/builtins/moderation.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/moderation.js.map +1 -1
- package/dist/functions/builtins/native-channels.d.ts +2 -0
- package/dist/functions/builtins/native-channels.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-channels.js.map +1 -1
- package/dist/functions/builtins/native-collectors.d.ts +2 -0
- package/dist/functions/builtins/native-collectors.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-collectors.js.map +1 -1
- package/dist/functions/builtins/native-expressions.d.ts +2 -0
- package/dist/functions/builtins/native-expressions.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-expressions.js.map +1 -1
- package/dist/functions/builtins/native-invites.d.ts +2 -0
- package/dist/functions/builtins/native-invites.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-invites.js.map +1 -1
- package/dist/functions/builtins/native-messages.d.ts +2 -0
- package/dist/functions/builtins/native-messages.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-messages.js.map +1 -1
- package/dist/functions/builtins/native-roles.d.ts +2 -0
- package/dist/functions/builtins/native-roles.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-roles.js.map +1 -1
- package/dist/functions/builtins/native-threads.d.ts +2 -0
- package/dist/functions/builtins/native-threads.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-threads.js.map +1 -1
- package/dist/functions/builtins/native-users.d.ts +2 -0
- package/dist/functions/builtins/native-users.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-users.js.map +1 -1
- package/dist/functions/builtins/native-webhooks.d.ts +2 -0
- package/dist/functions/builtins/native-webhooks.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/native-webhooks.js.map +1 -1
- package/dist/{scripting → functions}/builtins/payload.d.ts +2 -2
- package/dist/functions/builtins/payload.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/payload.js +1 -1
- package/dist/functions/builtins/payload.js.map +1 -0
- package/dist/functions/builtins/resource-extras.d.ts +2 -0
- package/dist/functions/builtins/resource-extras.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/resource-extras.js.map +1 -1
- package/dist/functions/builtins/schedule.d.ts +2 -0
- package/dist/functions/builtins/schedule.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/schedule.js.map +1 -1
- package/dist/functions/builtins/storage.d.ts +2 -0
- package/dist/functions/builtins/storage.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/storage.js.map +1 -1
- package/dist/functions/builtins/values.d.ts +2 -0
- package/dist/functions/builtins/values.d.ts.map +1 -0
- package/dist/{scripting → functions}/builtins/values.js +1 -1
- package/dist/functions/builtins/values.js.map +1 -0
- package/dist/functions/runtime/ast.d.ts.map +1 -0
- package/dist/functions/runtime/ast.js.map +1 -0
- package/dist/{scripting → functions/runtime}/canvas-execution.d.ts +1 -1
- package/dist/functions/runtime/canvas-execution.d.ts.map +1 -0
- package/dist/functions/runtime/canvas-execution.js.map +1 -0
- package/dist/functions/runtime/control-flow.d.ts.map +1 -0
- package/dist/functions/runtime/control-flow.js.map +1 -0
- package/dist/{scripting → functions/runtime}/evaluator.d.ts +1 -1
- package/dist/functions/runtime/evaluator.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/evaluator.js +1 -1
- package/dist/functions/runtime/evaluator.js.map +1 -0
- package/dist/functions/runtime/limits.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/limits.js +1 -1
- package/dist/functions/runtime/limits.js.map +1 -0
- package/dist/functions/runtime/parser.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/parser.js +1 -1
- package/dist/functions/runtime/parser.js.map +1 -0
- package/dist/functions/runtime/regex.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/regex.js +1 -1
- package/dist/functions/runtime/regex.js.map +1 -0
- package/dist/functions/runtime/registry.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/registry.js +1 -1
- package/dist/functions/runtime/registry.js.map +1 -0
- package/dist/{scripting → functions/runtime}/runtime.d.ts +3 -1
- package/dist/functions/runtime/runtime.d.ts.map +1 -0
- package/dist/{scripting → functions/runtime}/runtime.js +3 -0
- package/dist/functions/runtime/runtime.js.map +1 -0
- package/dist/{scripting → functions/runtime}/types.d.ts +1 -1
- package/dist/functions/runtime/types.d.ts.map +1 -0
- package/dist/functions/runtime/types.js.map +1 -0
- package/dist/functions/runtime/values.d.ts.map +1 -0
- package/dist/functions/runtime/values.js.map +1 -0
- package/dist/functions.d.ts +19 -8
- package/dist/functions.d.ts.map +1 -1
- package/dist/functions.js +18 -6
- package/dist/functions.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/canvas/napi.d.ts +4 -0
- package/dist/infrastructure/canvas/napi.d.ts.map +1 -0
- package/dist/infrastructure/canvas/napi.js +17 -0
- package/dist/infrastructure/canvas/napi.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/cache.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/cache.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/cache.js +68 -0
- package/dist/infrastructure/fluxer/resources/cache.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/channels.d.ts +3 -2
- package/dist/infrastructure/fluxer/resources/channels.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/channels.js +54 -2
- package/dist/infrastructure/fluxer/resources/channels.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/collectors.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/collectors.js +86 -4
- package/dist/infrastructure/fluxer/resources/collectors.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/expressions.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/expressions.js +8 -1
- package/dist/infrastructure/fluxer/resources/expressions.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/gateway.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/gateway.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/gateway.js +31 -0
- package/dist/infrastructure/fluxer/resources/gateway.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/instance.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/instance.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/instance.js +96 -0
- package/dist/infrastructure/fluxer/resources/instance.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/messages.d.ts +3 -1
- package/dist/infrastructure/fluxer/resources/messages.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/messages.js +91 -36
- package/dist/infrastructure/fluxer/resources/messages.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/roles.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/roles.js +8 -0
- package/dist/infrastructure/fluxer/resources/roles.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/self.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources/self.d.ts.map +1 -0
- package/dist/infrastructure/fluxer/resources/self.js +36 -0
- package/dist/infrastructure/fluxer/resources/self.js.map +1 -0
- package/dist/infrastructure/fluxer/resources/threads.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/threads.js +15 -0
- package/dist/infrastructure/fluxer/resources/threads.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/users.d.ts +5 -2
- package/dist/infrastructure/fluxer/resources/users.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/users.js +36 -3
- package/dist/infrastructure/fluxer/resources/users.js.map +1 -1
- package/dist/infrastructure/fluxer/resources/webhooks.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/webhooks.js +9 -0
- package/dist/infrastructure/fluxer/resources/webhooks.js.map +1 -1
- package/dist/infrastructure/fluxer/resources.d.ts +4 -0
- package/dist/infrastructure/fluxer/resources.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources.js +12 -0
- package/dist/infrastructure/fluxer/resources.js.map +1 -1
- package/dist/ports/resources/cache.d.ts +74 -0
- package/dist/ports/resources/cache.d.ts.map +1 -0
- package/dist/ports/resources/cache.js +2 -0
- package/dist/ports/resources/cache.js.map +1 -0
- package/dist/ports/resources/channels.d.ts +17 -0
- package/dist/ports/resources/channels.d.ts.map +1 -1
- package/dist/ports/resources/channels.js.map +1 -1
- package/dist/ports/resources/collectors.d.ts +18 -0
- package/dist/ports/resources/collectors.d.ts.map +1 -1
- package/dist/ports/resources/collectors.js.map +1 -1
- package/dist/ports/resources/common.d.ts +2 -0
- package/dist/ports/resources/common.d.ts.map +1 -1
- package/dist/ports/resources/common.js.map +1 -1
- package/dist/ports/resources/expressions.d.ts +8 -0
- package/dist/ports/resources/expressions.d.ts.map +1 -1
- package/dist/ports/resources/expressions.js.map +1 -1
- package/dist/ports/resources/gateway.d.ts +48 -0
- package/dist/ports/resources/gateway.d.ts.map +1 -0
- package/dist/ports/resources/gateway.js +2 -0
- package/dist/ports/resources/gateway.js.map +1 -0
- package/dist/ports/resources/instance.d.ts +101 -0
- package/dist/ports/resources/instance.d.ts.map +1 -0
- package/dist/ports/resources/instance.js +2 -0
- package/dist/ports/resources/instance.js.map +1 -0
- package/dist/ports/resources/messages.d.ts +27 -0
- package/dist/ports/resources/messages.d.ts.map +1 -1
- package/dist/ports/resources/messages.js.map +1 -1
- package/dist/ports/resources/roles.d.ts +6 -0
- package/dist/ports/resources/roles.d.ts.map +1 -1
- package/dist/ports/resources/roles.js.map +1 -1
- package/dist/ports/resources/self.d.ts +30 -0
- package/dist/ports/resources/self.d.ts.map +1 -0
- package/dist/ports/resources/self.js +2 -0
- package/dist/ports/resources/self.js.map +1 -0
- package/dist/ports/resources/threads.d.ts +16 -0
- package/dist/ports/resources/threads.d.ts.map +1 -1
- package/dist/ports/resources/threads.js.map +1 -1
- package/dist/ports/resources/users.d.ts +30 -0
- package/dist/ports/resources/users.d.ts.map +1 -1
- package/dist/ports/resources/users.js.map +1 -1
- package/dist/ports/resources/webhooks.d.ts +5 -0
- package/dist/ports/resources/webhooks.d.ts.map +1 -1
- package/dist/ports/resources/webhooks.js.map +1 -1
- package/dist/ports/resources.d.ts +8 -0
- package/dist/ports/resources.d.ts.map +1 -1
- package/dist/ports/resources.js.map +1 -1
- package/dist/ports/script-engine.d.ts +45 -0
- package/dist/ports/script-engine.d.ts.map +1 -0
- package/dist/ports/script-engine.js +2 -0
- package/dist/ports/script-engine.js.map +1 -0
- package/dist/sdk/builders.d.ts +2 -0
- package/dist/sdk/builders.d.ts.map +1 -0
- package/dist/sdk/builders.js +2 -0
- package/dist/sdk/builders.js.map +1 -0
- package/dist/sdk/client.d.ts +2 -0
- package/dist/sdk/client.d.ts.map +1 -0
- package/dist/sdk/client.js +2 -0
- package/dist/sdk/client.js.map +1 -0
- package/dist/sdk/cluster.d.ts +2 -0
- package/dist/sdk/cluster.d.ts.map +1 -0
- package/dist/sdk/cluster.js +2 -0
- package/dist/sdk/cluster.js.map +1 -0
- package/dist/sdk/collection.d.ts +2 -0
- package/dist/sdk/collection.d.ts.map +1 -0
- package/dist/sdk/collection.js +2 -0
- package/dist/sdk/collection.js.map +1 -0
- package/dist/sdk/errors.d.ts +2 -0
- package/dist/sdk/errors.d.ts.map +1 -0
- package/dist/sdk/errors.js +2 -0
- package/dist/sdk/errors.js.map +1 -0
- package/dist/sdk/internal.d.ts +2 -0
- package/dist/sdk/internal.d.ts.map +1 -0
- package/dist/sdk/internal.js +2 -0
- package/dist/sdk/internal.js.map +1 -0
- package/dist/sdk/message.d.ts +2 -0
- package/dist/sdk/message.d.ts.map +1 -0
- package/dist/sdk/message.js +2 -0
- package/dist/sdk/message.js.map +1 -0
- package/dist/sdk/rest/request-manager.d.ts +2 -0
- package/dist/sdk/rest/request-manager.d.ts.map +1 -0
- package/dist/sdk/rest/request-manager.js +2 -0
- package/dist/sdk/rest/request-manager.js.map +1 -0
- package/dist/sdk/rest.d.ts +2 -0
- package/dist/sdk/rest.d.ts.map +1 -0
- package/dist/sdk/rest.js +2 -0
- package/dist/sdk/rest.js.map +1 -0
- package/dist/sdk/sharding.d.ts +2 -0
- package/dist/sdk/sharding.d.ts.map +1 -0
- package/dist/sdk/sharding.js +2 -0
- package/dist/sdk/sharding.js.map +1 -0
- package/dist/sdk/types/routes.d.ts +2 -0
- package/dist/sdk/types/routes.d.ts.map +1 -0
- package/dist/sdk/types/routes.js +2 -0
- package/dist/sdk/types/routes.js.map +1 -0
- package/dist/sdk/types.d.ts +2 -0
- package/dist/sdk/types.d.ts.map +1 -0
- package/dist/sdk/types.js +2 -0
- package/dist/sdk/types.js.map +1 -0
- package/dist/sdk/util.d.ts +2 -0
- package/dist/sdk/util.d.ts.map +1 -0
- package/dist/sdk/util.js +2 -0
- package/dist/sdk/util.js.map +1 -0
- package/dist/sdk/voice.d.ts +2 -0
- package/dist/sdk/voice.d.ts.map +1 -0
- package/dist/sdk/voice.js +2 -0
- package/dist/sdk/voice.js.map +1 -0
- package/dist/sdk/ws.d.ts +2 -0
- package/dist/sdk/ws.d.ts.map +1 -0
- package/dist/sdk/ws.js +2 -0
- package/dist/sdk/ws.js.map +1 -0
- package/dist/services/canvas-image.d.ts +12 -0
- package/dist/services/canvas-image.d.ts.map +1 -0
- package/dist/services/canvas-image.js +56 -0
- package/dist/services/canvas-image.js.map +1 -0
- package/dist/services/canvas.d.ts +12 -2
- package/dist/services/canvas.d.ts.map +1 -1
- package/dist/services/canvas.js +91 -5
- package/dist/services/canvas.js.map +1 -1
- package/dist/services/moderation.d.ts +1 -0
- package/dist/services/moderation.d.ts.map +1 -1
- package/dist/services/moderation.js +11 -0
- package/dist/services/moderation.js.map +1 -1
- package/dist/services/native-moderation.d.ts +6 -1
- package/dist/services/native-moderation.d.ts.map +1 -1
- package/dist/services/native-moderation.js +11 -1
- package/dist/services/native-moderation.js.map +1 -1
- package/dist/services/resource-authorization.d.ts.map +1 -1
- package/dist/services/resource-authorization.js +95 -3
- package/dist/services/resource-authorization.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +4 -0
- package/dist/testing.js.map +1 -1
- package/docs/API.md +8 -7
- package/docs/ARCHITECTURE.md +14 -9
- package/docs/BENCHMARKS.md +1 -1
- package/docs/CANVAS.md +70 -15
- package/docs/EDITOR.md +1 -1
- package/docs/FRAMEWORK.md +2 -3
- package/docs/HTTP.md +1 -1
- package/docs/IMAGES.md +2 -1
- package/docs/NATIVE.md +45 -14
- package/docs/PARITY-MATRIX.md +853 -843
- package/docs/PARITY.md +24 -12
- package/docs/PLAN.md +14 -3
- package/docs/QUICKSTART.md +5 -5
- package/docs/README.md +7 -7
- package/docs/REPOSITORY.md +1 -1
- package/docs/SCHEDULER.md +1 -1
- package/docs/TROUBLESHOOTING.md +1 -1
- package/docs/VALIDATION.md +5 -5
- package/docs/{FUNCTION-GAPS.md → functions/FUNCTION-GAPS.md} +18 -13
- package/docs/{LANGUAGE.md → functions/LANGUAGE.md} +7 -7
- package/docs/functions/README.md +33 -0
- package/docs/tutorials/DATA.md +2 -2
- package/docs/tutorials/FUNCTION-MODE.md +2 -2
- package/examples/canvas/napi-style.ts +24 -0
- package/examples/canvas/output/napi-style.png +0 -0
- package/examples/canvas/profile.d.mts +1 -1
- package/examples/canvas/profile.mjs +2 -2
- package/examples/canvas/profile.ts +3 -3
- package/examples/canvas/ranking.d.mts +1 -1
- package/examples/canvas/ranking.mjs +2 -2
- package/examples/canvas/ranking.ts +3 -3
- package/examples/canvas/render.ts +2 -1
- package/examples/canvas/welcome.d.mts +1 -1
- package/examples/canvas/welcome.mjs +2 -2
- package/examples/canvas/welcome.ts +3 -3
- package/examples/embeds/complete-embed-functions.ts +2 -2
- package/examples/function-mode.ts +3 -3
- package/examples/yuzuha.config.js +2 -0
- package/package.json +26 -1
- package/src/canvas/card.ts +20 -0
- package/src/canvas.ts +69 -17
- package/src/cli/config.ts +2 -1
- package/src/cli/lint.ts +1 -2
- package/src/cli/main.ts +8 -9
- package/src/cli/scaffold.ts +1 -1
- package/src/cli/scenarios.ts +2 -1
- package/src/commands/context.ts +9 -2
- package/src/domain/resource-batches.ts +31 -0
- package/src/framework/bot.ts +44 -27
- package/src/framework/command-registry.ts +15 -10
- package/src/framework/options.ts +3 -3
- package/src/{scripting → functions}/builtins/canvas.ts +2 -2
- package/src/{scripting → functions}/builtins/context.ts +1 -1
- package/src/{scripting → functions}/builtins/definition.ts +1 -1
- package/src/{scripting → functions}/builtins/embeds.ts +1 -1
- package/src/{scripting → functions}/builtins/flow.ts +2 -2
- package/src/{scripting → functions}/builtins/guards.ts +1 -1
- package/src/{scripting → functions}/builtins/http.ts +2 -2
- package/src/{scripting → functions}/builtins/index.ts +2 -2
- package/src/{scripting → functions}/builtins/language/array-callbacks.ts +2 -2
- package/src/{scripting → functions}/builtins/language/arrays.ts +1 -1
- package/src/{scripting → functions}/builtins/language/index.ts +1 -1
- package/src/{scripting → functions}/builtins/language/loops.ts +4 -4
- package/src/{scripting → functions}/builtins/language/regex.ts +1 -1
- package/src/{scripting → functions}/builtins/moderation.ts +1 -1
- package/src/{scripting → functions}/builtins/native-channels.ts +1 -1
- package/src/{scripting → functions}/builtins/native-roles.ts +1 -1
- package/src/{scripting → functions}/builtins/native-users.ts +1 -1
- package/src/{scripting → functions}/builtins/payload.ts +2 -2
- package/src/{scripting → functions}/builtins/resource-extras.ts +1 -1
- package/src/{scripting → functions}/builtins/values.ts +1 -1
- package/src/{scripting → functions/runtime}/canvas-execution.ts +1 -1
- package/src/{scripting → functions/runtime}/evaluator.ts +2 -2
- package/src/{scripting → functions/runtime}/limits.ts +1 -1
- package/src/{scripting → functions/runtime}/parser.ts +1 -1
- package/src/{scripting → functions/runtime}/regex.ts +1 -1
- package/src/{scripting → functions/runtime}/registry.ts +1 -1
- package/src/{scripting → functions/runtime}/runtime.ts +6 -1
- package/src/{scripting → functions/runtime}/types.ts +1 -1
- package/src/functions.ts +28 -8
- package/src/index.ts +9 -2
- package/src/infrastructure/canvas/napi.ts +17 -0
- package/src/infrastructure/fluxer/resources/cache.ts +69 -0
- package/src/infrastructure/fluxer/resources/channels.ts +51 -3
- package/src/infrastructure/fluxer/resources/collectors.ts +87 -4
- package/src/infrastructure/fluxer/resources/expressions.ts +7 -1
- package/src/infrastructure/fluxer/resources/gateway.ts +33 -0
- package/src/infrastructure/fluxer/resources/instance.ts +105 -0
- package/src/infrastructure/fluxer/resources/messages.ts +84 -36
- package/src/infrastructure/fluxer/resources/roles.ts +8 -0
- package/src/infrastructure/fluxer/resources/self.ts +39 -0
- package/src/infrastructure/fluxer/resources/threads.ts +14 -0
- package/src/infrastructure/fluxer/resources/users.ts +40 -4
- package/src/infrastructure/fluxer/resources/webhooks.ts +9 -0
- package/src/infrastructure/fluxer/resources.ts +12 -0
- package/src/ports/resources/cache.ts +81 -0
- package/src/ports/resources/channels.ts +12 -0
- package/src/ports/resources/collectors.ts +20 -0
- package/src/ports/resources/common.ts +2 -0
- package/src/ports/resources/expressions.ts +6 -0
- package/src/ports/resources/gateway.ts +49 -0
- package/src/ports/resources/instance.ts +109 -0
- package/src/ports/resources/messages.ts +30 -0
- package/src/ports/resources/roles.ts +3 -0
- package/src/ports/resources/self.ts +30 -0
- package/src/ports/resources/threads.ts +15 -0
- package/src/ports/resources/users.ts +33 -0
- package/src/ports/resources/webhooks.ts +6 -0
- package/src/ports/resources.ts +8 -0
- package/src/ports/script-engine.ts +42 -0
- package/src/sdk/builders.ts +1 -0
- package/src/sdk/client.ts +1 -0
- package/src/sdk/cluster.ts +1 -0
- package/src/sdk/collection.ts +1 -0
- package/src/sdk/errors.ts +1 -0
- package/src/sdk/internal.ts +1 -0
- package/src/sdk/message.ts +1 -0
- package/src/sdk/rest/request-manager.ts +1 -0
- package/src/sdk/rest.ts +1 -0
- package/src/sdk/sharding.ts +1 -0
- package/src/sdk/types/routes.ts +1 -0
- package/src/sdk/types.ts +1 -0
- package/src/sdk/util.ts +1 -0
- package/src/sdk/voice.ts +1 -0
- package/src/sdk/ws.ts +1 -0
- package/src/services/canvas-image.ts +54 -0
- package/src/services/canvas.ts +89 -6
- package/src/services/moderation.ts +4 -0
- package/src/services/native-moderation.ts +11 -1
- package/src/services/resource-authorization.ts +89 -3
- package/src/testing.ts +4 -0
- package/dist/parser.d.ts +0 -3
- package/dist/parser.d.ts.map +0 -1
- package/dist/parser.js +0 -2
- package/dist/parser.js.map +0 -1
- package/dist/runtime.d.ts +0 -5
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -4
- package/dist/runtime.js.map +0 -1
- package/dist/scripting/ast.d.ts.map +0 -1
- package/dist/scripting/ast.js.map +0 -1
- package/dist/scripting/builtins/canvas.d.ts +0 -2
- package/dist/scripting/builtins/canvas.d.ts.map +0 -1
- package/dist/scripting/builtins/context.d.ts +0 -2
- package/dist/scripting/builtins/context.d.ts.map +0 -1
- package/dist/scripting/builtins/definition.d.ts.map +0 -1
- package/dist/scripting/builtins/definition.js.map +0 -1
- package/dist/scripting/builtins/embeds.d.ts +0 -3
- package/dist/scripting/builtins/embeds.js.map +0 -1
- package/dist/scripting/builtins/events.d.ts +0 -2
- package/dist/scripting/builtins/events.d.ts.map +0 -1
- package/dist/scripting/builtins/flow.d.ts +0 -2
- package/dist/scripting/builtins/flow.d.ts.map +0 -1
- package/dist/scripting/builtins/flow.js.map +0 -1
- package/dist/scripting/builtins/guards.d.ts +0 -2
- package/dist/scripting/builtins/guards.d.ts.map +0 -1
- package/dist/scripting/builtins/guards.js.map +0 -1
- package/dist/scripting/builtins/http.d.ts +0 -2
- package/dist/scripting/builtins/http.d.ts.map +0 -1
- package/dist/scripting/builtins/http.js.map +0 -1
- package/dist/scripting/builtins/index.d.ts +0 -5
- package/dist/scripting/builtins/index.d.ts.map +0 -1
- package/dist/scripting/builtins/index.js.map +0 -1
- package/dist/scripting/builtins/language/array-callbacks.d.ts +0 -2
- package/dist/scripting/builtins/language/array-callbacks.d.ts.map +0 -1
- package/dist/scripting/builtins/language/arrays.d.ts +0 -2
- package/dist/scripting/builtins/language/arrays.d.ts.map +0 -1
- package/dist/scripting/builtins/language/decimals.d.ts +0 -2
- package/dist/scripting/builtins/language/decimals.d.ts.map +0 -1
- package/dist/scripting/builtins/language/index.d.ts +0 -3
- package/dist/scripting/builtins/language/index.d.ts.map +0 -1
- package/dist/scripting/builtins/language/index.js.map +0 -1
- package/dist/scripting/builtins/language/loops.d.ts +0 -4
- package/dist/scripting/builtins/language/numbers.d.ts +0 -2
- package/dist/scripting/builtins/language/numbers.d.ts.map +0 -1
- package/dist/scripting/builtins/language/regex.d.ts +0 -2
- package/dist/scripting/builtins/language/regex.d.ts.map +0 -1
- package/dist/scripting/builtins/language/sort.d.ts +0 -2
- package/dist/scripting/builtins/language/sort.d.ts.map +0 -1
- package/dist/scripting/builtins/language/texts.d.ts +0 -2
- package/dist/scripting/builtins/language/texts.d.ts.map +0 -1
- package/dist/scripting/builtins/messages.d.ts +0 -2
- package/dist/scripting/builtins/messages.d.ts.map +0 -1
- package/dist/scripting/builtins/moderation.d.ts +0 -2
- package/dist/scripting/builtins/moderation.d.ts.map +0 -1
- package/dist/scripting/builtins/native-channels.d.ts +0 -2
- package/dist/scripting/builtins/native-channels.d.ts.map +0 -1
- package/dist/scripting/builtins/native-collectors.d.ts +0 -2
- package/dist/scripting/builtins/native-collectors.d.ts.map +0 -1
- package/dist/scripting/builtins/native-expressions.d.ts +0 -2
- package/dist/scripting/builtins/native-expressions.d.ts.map +0 -1
- package/dist/scripting/builtins/native-invites.d.ts +0 -2
- package/dist/scripting/builtins/native-invites.d.ts.map +0 -1
- package/dist/scripting/builtins/native-messages.d.ts +0 -2
- package/dist/scripting/builtins/native-messages.d.ts.map +0 -1
- package/dist/scripting/builtins/native-roles.d.ts +0 -2
- package/dist/scripting/builtins/native-roles.d.ts.map +0 -1
- package/dist/scripting/builtins/native-threads.d.ts +0 -2
- package/dist/scripting/builtins/native-threads.d.ts.map +0 -1
- package/dist/scripting/builtins/native-users.d.ts +0 -2
- package/dist/scripting/builtins/native-users.d.ts.map +0 -1
- package/dist/scripting/builtins/native-webhooks.d.ts +0 -2
- package/dist/scripting/builtins/native-webhooks.d.ts.map +0 -1
- package/dist/scripting/builtins/payload.d.ts.map +0 -1
- package/dist/scripting/builtins/payload.js.map +0 -1
- package/dist/scripting/builtins/resource-extras.d.ts +0 -2
- package/dist/scripting/builtins/resource-extras.d.ts.map +0 -1
- package/dist/scripting/builtins/schedule.d.ts +0 -2
- package/dist/scripting/builtins/schedule.d.ts.map +0 -1
- package/dist/scripting/builtins/storage.d.ts +0 -2
- package/dist/scripting/builtins/storage.d.ts.map +0 -1
- package/dist/scripting/builtins/values.d.ts +0 -2
- package/dist/scripting/builtins/values.d.ts.map +0 -1
- package/dist/scripting/builtins/values.js.map +0 -1
- package/dist/scripting/canvas-execution.d.ts.map +0 -1
- package/dist/scripting/canvas-execution.js.map +0 -1
- package/dist/scripting/control-flow.d.ts.map +0 -1
- package/dist/scripting/control-flow.js.map +0 -1
- package/dist/scripting/evaluator.d.ts.map +0 -1
- package/dist/scripting/evaluator.js.map +0 -1
- package/dist/scripting/limits.d.ts.map +0 -1
- package/dist/scripting/limits.js.map +0 -1
- package/dist/scripting/parser.d.ts.map +0 -1
- package/dist/scripting/parser.js.map +0 -1
- package/dist/scripting/regex.d.ts.map +0 -1
- package/dist/scripting/regex.js.map +0 -1
- package/dist/scripting/registry.d.ts.map +0 -1
- package/dist/scripting/registry.js.map +0 -1
- package/dist/scripting/runtime.d.ts.map +0 -1
- package/dist/scripting/runtime.js.map +0 -1
- package/dist/scripting/types.d.ts.map +0 -1
- package/dist/scripting/types.js.map +0 -1
- package/dist/scripting/values.d.ts.map +0 -1
- package/dist/scripting/values.js.map +0 -1
- package/src/parser.ts +0 -2
- package/src/runtime.ts +0 -4
- /package/dist/{scripting → functions}/builtins/arguments.d.ts +0 -0
- /package/dist/{scripting → functions}/builtins/arguments.js +0 -0
- /package/dist/{scripting → functions}/builtins/context.js +0 -0
- /package/dist/{scripting → functions}/builtins/definition.js +0 -0
- /package/dist/{scripting → functions}/builtins/events.js +0 -0
- /package/dist/{scripting → functions}/builtins/index.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/common.d.ts +0 -0
- /package/dist/{scripting → functions}/builtins/language/common.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/decimals.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/index.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/numbers.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/objects.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/sort.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/state.js +0 -0
- /package/dist/{scripting → functions}/builtins/language/texts.js +0 -0
- /package/dist/{scripting → functions}/builtins/messages.js +0 -0
- /package/dist/{scripting → functions}/builtins/moderation.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-channels.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-collectors.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-expressions.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-invites.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-messages.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-roles.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-threads.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-users.js +0 -0
- /package/dist/{scripting → functions}/builtins/native-webhooks.js +0 -0
- /package/dist/{scripting → functions}/builtins/resource-extras.js +0 -0
- /package/dist/{scripting → functions}/builtins/schedule.js +0 -0
- /package/dist/{scripting → functions}/builtins/storage.js +0 -0
- /package/dist/{scripting → functions/runtime}/ast.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/ast.js +0 -0
- /package/dist/{scripting → functions/runtime}/canvas-execution.js +0 -0
- /package/dist/{scripting → functions/runtime}/control-flow.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/control-flow.js +0 -0
- /package/dist/{scripting → functions/runtime}/limits.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/parser.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/regex-worker.mjs +0 -0
- /package/dist/{scripting → functions/runtime}/regex.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/registry.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/types.js +0 -0
- /package/dist/{scripting → functions/runtime}/values.d.ts +0 -0
- /package/dist/{scripting → functions/runtime}/values.js +0 -0
- /package/docs/{FUNCTIONS.md → functions/FUNCTIONS.md} +0 -0
- /package/docs/{LANGUAGE-EXTENSIONS.md → functions/LANGUAGE-EXTENSIONS.md} +0 -0
- /package/src/{scripting → functions}/builtins/arguments.ts +0 -0
- /package/src/{scripting → functions}/builtins/events.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/common.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/decimals.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/numbers.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/objects.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/sort.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/state.ts +0 -0
- /package/src/{scripting → functions}/builtins/language/texts.ts +0 -0
- /package/src/{scripting → functions}/builtins/messages.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-collectors.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-expressions.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-invites.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-messages.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-threads.ts +0 -0
- /package/src/{scripting → functions}/builtins/native-webhooks.ts +0 -0
- /package/src/{scripting → functions}/builtins/schedule.ts +0 -0
- /package/src/{scripting → functions}/builtins/storage.ts +0 -0
- /package/src/{scripting → functions/runtime}/ast.ts +0 -0
- /package/src/{scripting → functions/runtime}/control-flow.ts +0 -0
- /package/src/{scripting → functions/runtime}/regex-worker.mjs +0 -0
- /package/src/{scripting → functions/runtime}/values.ts +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Client, Message } from '@fluxerjs/core';
|
|
2
2
|
import { MessageCollector, ReactionCollector } from '@fluxerjs/core';
|
|
3
|
-
import type { AwaitMessageInput, CollectedMessageInfo, CollectorsResources, ReactionVote } from '../../../ports/resources/collectors.js';
|
|
3
|
+
import type { AwaitMessageInput, CollectedMessageInfo, CollectMessagesInput, CollectReactionsInput, CollectorsResources, ReactionVote } from '../../../ports/resources/collectors.js';
|
|
4
4
|
import { cancellationError } from '../../../services/cancellation.js';
|
|
5
|
+
import { YuzuhaError } from '../../../errors.js';
|
|
6
|
+
|
|
7
|
+
type ReactionLike = { emojiIdentifier: string; emoji: { name: string }; messageId: string };
|
|
5
8
|
|
|
6
9
|
function info(message: Message): CollectedMessageInfo {
|
|
7
10
|
return { id: message.id, channelID: message.channelId, authorID: message.author.id, content: message.content };
|
|
@@ -11,11 +14,47 @@ function targets(emojis: string | string[]): string[] {
|
|
|
11
14
|
return (Array.isArray(emojis) ? emojis : [emojis]).map(value => value.trim().toLowerCase()).filter(Boolean);
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
function
|
|
17
|
+
function matches(reaction: ReactionLike, wanted: string[]): boolean {
|
|
15
18
|
const identifier = reaction.emojiIdentifier.toLowerCase();
|
|
16
19
|
const name = reaction.emoji.name.toLowerCase();
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
return wanted.includes(identifier) || wanted.includes(name);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function voteInfo(reaction: ReactionLike, userID: string): ReactionVote {
|
|
24
|
+
return { userID, emoji: reaction.emoji.name, messageID: reaction.messageId };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function vote(reaction: ReactionLike, userID: string, wanted: string[]): ReactionVote | null {
|
|
28
|
+
return matches(reaction, wanted) ? voteInfo(reaction, userID) : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function positiveBound(value: number | undefined): number {
|
|
32
|
+
return value !== undefined && Number.isFinite(value) && value > 0 ? value : 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function requireBounds(time: number, max: number, signal: AbortSignal | undefined): void {
|
|
36
|
+
if (time <= 0 && max <= 0 && signal === undefined) {
|
|
37
|
+
throw new YuzuhaError('COLLECTOR_BOUNDS', 'Informe um limite para o coletor: timeMs, max ou signal.');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Itera itens de um coletor do SDK: enfileira 'collect', encerra no 'end' e limpa ao sair. */
|
|
42
|
+
async function* pump<T>(attach: (push: (item: T) => void, finish: () => void) => () => void): AsyncGenerator<T, void> {
|
|
43
|
+
const queue: T[] = [];
|
|
44
|
+
let ended = false;
|
|
45
|
+
let waiting: (() => void) | undefined;
|
|
46
|
+
const notify = (): void => { const wake = waiting; waiting = undefined; wake?.(); };
|
|
47
|
+
const detach = attach(item => { queue.push(item); notify(); }, () => { ended = true; notify(); });
|
|
48
|
+
try {
|
|
49
|
+
for (;;) {
|
|
50
|
+
const item = queue.shift();
|
|
51
|
+
if (item !== undefined) { yield item; continue; }
|
|
52
|
+
if (ended) return;
|
|
53
|
+
await new Promise<void>(resolve => { waiting = resolve; });
|
|
54
|
+
}
|
|
55
|
+
} finally {
|
|
56
|
+
detach();
|
|
57
|
+
}
|
|
19
58
|
}
|
|
20
59
|
|
|
21
60
|
export function createCollectorsResources(client: Client): CollectorsResources {
|
|
@@ -85,5 +124,49 @@ export function createCollectorsResources(client: Client): CollectorsResources {
|
|
|
85
124
|
if (signal?.aborted) abort();
|
|
86
125
|
});
|
|
87
126
|
},
|
|
127
|
+
collectMessages(channelID: string, input: CollectMessagesInput): AsyncIterable<CollectedMessageInfo> {
|
|
128
|
+
const time = positiveBound(input.timeMs);
|
|
129
|
+
const max = positiveBound(input.max);
|
|
130
|
+
requireBounds(time, max, input.signal);
|
|
131
|
+
const filter = input.userID === undefined && input.contains === undefined
|
|
132
|
+
? undefined
|
|
133
|
+
: (message: Message) =>
|
|
134
|
+
(input.userID === undefined || message.author.id === input.userID) &&
|
|
135
|
+
(input.contains === undefined || message.content.includes(input.contains));
|
|
136
|
+
const signal = input.signal;
|
|
137
|
+
return pump<CollectedMessageInfo>((push, finish) => {
|
|
138
|
+
// O SDK exige time ou max; com só signal o teto de max é inalcançável e o abort encerra.
|
|
139
|
+
const collector = new MessageCollector(client, channelID, {
|
|
140
|
+
filter, time, max: time > 0 || max > 0 ? max : Number.MAX_SAFE_INTEGER,
|
|
141
|
+
});
|
|
142
|
+
const abort = (): void => collector.stop('user');
|
|
143
|
+
collector.on('collect', message => push(info(message)));
|
|
144
|
+
collector.on('end', () => finish());
|
|
145
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
146
|
+
if (signal?.aborted) collector.stop('user');
|
|
147
|
+
return () => { signal?.removeEventListener('abort', abort); collector.stop('user'); };
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
collectReactions(channelID: string, input: CollectReactionsInput): AsyncIterable<ReactionVote> {
|
|
151
|
+
const time = positiveBound(input.timeMs);
|
|
152
|
+
const max = positiveBound(input.max);
|
|
153
|
+
requireBounds(time, max, input.signal);
|
|
154
|
+
if (!input.messageID) throw new YuzuhaError('COLLECTOR_MESSAGE', 'Informe a mensagem (messageID) para coletar reações.');
|
|
155
|
+
const wanted = targets(input.emojis ?? []);
|
|
156
|
+
const signal = input.signal;
|
|
157
|
+
return pump<ReactionVote>((push, finish) => {
|
|
158
|
+
const collector = new ReactionCollector(client, input.messageID, channelID, {
|
|
159
|
+
time, max,
|
|
160
|
+
filter: (reaction, user) => (input.userID === undefined || user.id === input.userID)
|
|
161
|
+
&& (wanted.length === 0 || matches(reaction, wanted)),
|
|
162
|
+
});
|
|
163
|
+
const abort = (): void => collector.stop('user');
|
|
164
|
+
collector.on('collect', (reaction, user) => push(voteInfo(reaction, user.id)));
|
|
165
|
+
collector.on('end', () => finish());
|
|
166
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
167
|
+
if (signal?.aborted) collector.stop('user');
|
|
168
|
+
return () => { signal?.removeEventListener('abort', abort); collector.stop('user'); };
|
|
169
|
+
});
|
|
170
|
+
},
|
|
88
171
|
};
|
|
89
172
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Client, GuildEmoji, GuildSticker } from '@fluxerjs/core';
|
|
2
2
|
import { YuzuhaError } from '../../../errors.js';
|
|
3
|
-
import { emojiBatch } from '../../../domain/resource-batches.js';
|
|
3
|
+
import { emojiBatch, stickerBatch } from '../../../domain/resource-batches.js';
|
|
4
4
|
import type { EmojiInfo, ExpressionsResources, StickerInfo } from '../../../ports/resources/expressions.js';
|
|
5
5
|
|
|
6
6
|
function toEmojiInfo(emoji: GuildEmoji): EmojiInfo {
|
|
@@ -68,6 +68,12 @@ export function createExpressionsResources(client: Client): ExpressionsResources
|
|
|
68
68
|
toEmojiInfo(await (await resolveEmoji(guildID, nameOrID)).edit({ name, reason })),
|
|
69
69
|
createSticker: async (guildID, input) =>
|
|
70
70
|
toStickerInfo(await (await guild(guildID)).createSticker(input)),
|
|
71
|
+
createStickersBulk: async (guildID, inputs) => {
|
|
72
|
+
const batch = stickerBatch(inputs);
|
|
73
|
+
if (!guildID) throw new YuzuhaError('GUILD_REQUIRED', 'Esta operação exige um servidor.');
|
|
74
|
+
const result = await (await guild(guildID)).createStickersBulk(batch);
|
|
75
|
+
return { success: result.success.map(toStickerInfo), failed: result.failed.map(item => ({ name: item.name, error: item.error })) };
|
|
76
|
+
},
|
|
71
77
|
editSticker: async (guildID, nameOrID, input) =>
|
|
72
78
|
toStickerInfo(await (await resolveSticker(guildID, nameOrID)).edit(input)),
|
|
73
79
|
deleteSticker: async (guildID, nameOrID, reason) => {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Client } from '@fluxerjs/core';
|
|
2
|
+
import type { GatewayResources } from '../../../ports/resources/gateway.js';
|
|
3
|
+
|
|
4
|
+
export function createGatewayResources(client: Client): GatewayResources {
|
|
5
|
+
return {
|
|
6
|
+
requestMembers(input) {
|
|
7
|
+
client.requestGuildMembers({
|
|
8
|
+
guildId: input.guildID, guildIds: input.guildIDs, query: input.query, limit: input.limit,
|
|
9
|
+
userIds: input.userIDs, presences: input.presences, nonce: input.nonce,
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
requestGuildCounts(guildIDs, nonce) {
|
|
13
|
+
client.requestGuildCounts({ guildIds: guildIDs, nonce });
|
|
14
|
+
},
|
|
15
|
+
requestChannelCounts(input) {
|
|
16
|
+
client.requestChannelMemberCounts({
|
|
17
|
+
guildId: input.guildID, channelId: input.channelID, channelIds: input.channelIDs, nonce: input.nonce,
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
requestForumUnreads(input) {
|
|
21
|
+
client.requestForumUnreads({
|
|
22
|
+
guildId: input.guildID, channelId: input.channelID,
|
|
23
|
+
threads: input.threads.map(thread => ({ threadId: thread.threadID, ackMessageId: thread.ackMessageID })),
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
subscribeThreads(input) {
|
|
27
|
+
client.subscribeThreads({ guildId: input.guildID, threads: input.threads, threadIds: input.threadIDs });
|
|
28
|
+
},
|
|
29
|
+
send(shardID, payload) {
|
|
30
|
+
client.sendToGateway(shardID, payload);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Client } from '@fluxerjs/core';
|
|
2
|
+
import type { APIApplicationMe, APIInstance, APIInstanceEndpoints, APIOAuthApplication } from '@fluxerjs/types';
|
|
3
|
+
import type {
|
|
4
|
+
ApplicationInfo,
|
|
5
|
+
InstanceInfo,
|
|
6
|
+
InstanceResources,
|
|
7
|
+
} from '../../../ports/resources/instance.js';
|
|
8
|
+
|
|
9
|
+
function instanceInfo(endpoints: APIInstanceEndpoints, discovery: APIInstance | null): InstanceInfo {
|
|
10
|
+
return {
|
|
11
|
+
apiCodeVersion: discovery?.api_code_version ?? null,
|
|
12
|
+
codename: discovery?.codename ?? null,
|
|
13
|
+
endpoints: {
|
|
14
|
+
api: endpoints.api,
|
|
15
|
+
apiClient: endpoints.api_client,
|
|
16
|
+
apiPublic: endpoints.api_public,
|
|
17
|
+
gateway: endpoints.gateway,
|
|
18
|
+
media: endpoints.media,
|
|
19
|
+
staticCDN: endpoints.static_cdn,
|
|
20
|
+
marketing: endpoints.marketing,
|
|
21
|
+
admin: endpoints.admin,
|
|
22
|
+
invite: endpoints.invite,
|
|
23
|
+
gift: endpoints.gift,
|
|
24
|
+
webapp: endpoints.webapp,
|
|
25
|
+
},
|
|
26
|
+
features: discovery?.features ? {
|
|
27
|
+
voiceEnabled: discovery.features.voice_enabled,
|
|
28
|
+
stripeEnabled: discovery.features.stripe_enabled,
|
|
29
|
+
selfHosted: discovery.features.self_hosted,
|
|
30
|
+
presignedAttachmentUploads: discovery.features.presigned_attachment_uploads,
|
|
31
|
+
emailsEnabled: discovery.features.emails_enabled,
|
|
32
|
+
} : null,
|
|
33
|
+
registrationMode: discovery?.registration?.mode ?? null,
|
|
34
|
+
ssoEnabled: discovery?.sso?.enabled ?? null,
|
|
35
|
+
ssoEnforced: discovery?.sso?.enforced ?? null,
|
|
36
|
+
singleCommunity: discovery?.community?.single_community ?? null,
|
|
37
|
+
singleCommunityGuildID: discovery?.community?.single_community_guild_id ?? null,
|
|
38
|
+
directMessagesDisabled: discovery?.community?.direct_messages_disabled ?? null,
|
|
39
|
+
services: discovery?.services ? {
|
|
40
|
+
gif: discovery.services.gif_enabled,
|
|
41
|
+
youtube: discovery.services.youtube_enabled,
|
|
42
|
+
bluesky: discovery.services.bluesky_enabled,
|
|
43
|
+
} : null,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function applicationInfo(application: APIApplicationMe | APIOAuthApplication): ApplicationInfo {
|
|
48
|
+
return {
|
|
49
|
+
id: application.id,
|
|
50
|
+
name: application.name,
|
|
51
|
+
icon: application.icon ?? null,
|
|
52
|
+
description: application.description ?? null,
|
|
53
|
+
botPublic: application.bot_public ?? null,
|
|
54
|
+
botRequireCodeGrant: application.bot_require_code_grant ?? null,
|
|
55
|
+
verifyKey: 'verify_key' in application ? application.verify_key ?? null : null,
|
|
56
|
+
flags: 'flags' in application ? application.flags ?? null : null,
|
|
57
|
+
ownerID: 'owner' in application ? application.owner?.id ?? null : null,
|
|
58
|
+
botID: 'bot' in application ? application.bot?.id ?? null : null,
|
|
59
|
+
redirectURIs: 'redirect_uris' in application ? [...application.redirect_uris ?? []] : [],
|
|
60
|
+
clientSecret: 'client_secret' in application ? application.client_secret ?? null : null,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function createInstanceResources(client: Client): InstanceResources {
|
|
65
|
+
return {
|
|
66
|
+
async describe() {
|
|
67
|
+
const resolved = client.instance;
|
|
68
|
+
const fetched = await client.fetchInstance();
|
|
69
|
+
return instanceInfo(fetched?.endpoints ?? resolved.endpoints, fetched ?? resolved.discovery);
|
|
70
|
+
},
|
|
71
|
+
async gatewayInfo() {
|
|
72
|
+
const info = await client.fetchGatewayInfo();
|
|
73
|
+
const limit = info.session_start_limit;
|
|
74
|
+
return {
|
|
75
|
+
url: info.url,
|
|
76
|
+
shards: info.shards,
|
|
77
|
+
sessionStartLimit: limit ? {
|
|
78
|
+
total: limit.total,
|
|
79
|
+
remaining: limit.remaining,
|
|
80
|
+
resetAfter: limit.reset_after,
|
|
81
|
+
maxConcurrency: limit.max_concurrency,
|
|
82
|
+
} : null,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
async application() {
|
|
86
|
+
return applicationInfo(await client.fetchApplication());
|
|
87
|
+
},
|
|
88
|
+
async oauthApplications() {
|
|
89
|
+
return (await client.fetchOAuthApplications()).map(applicationInfo);
|
|
90
|
+
},
|
|
91
|
+
async emojiMetadata(emojiID) {
|
|
92
|
+
const metadata = await client.fetchEmojiMetadata(emojiID);
|
|
93
|
+
return { id: metadata.id, guildID: metadata.guild_id, name: metadata.name,
|
|
94
|
+
animated: metadata.animated, allowCloning: metadata.allow_cloning };
|
|
95
|
+
},
|
|
96
|
+
async stickerMetadata(stickerID) {
|
|
97
|
+
const metadata = await client.fetchStickerMetadata(stickerID);
|
|
98
|
+
return { id: metadata.id, guildID: metadata.guild_id, name: metadata.name,
|
|
99
|
+
animated: metadata.animated, allowCloning: metadata.allow_cloning };
|
|
100
|
+
},
|
|
101
|
+
resolveEmoji(emoji, guildID) {
|
|
102
|
+
return client.resolveEmoji(emoji, guildID);
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -4,7 +4,7 @@ import type { ReceivedEmbed, ReceivedEmbedMedia } from '../../../domain/messages
|
|
|
4
4
|
import { limitOf } from '../../../ports/resources/common.js';
|
|
5
5
|
import type { AttachmentSpec, BinaryAttachmentSpec } from '../../../ports/resources/common.js';
|
|
6
6
|
import { YuzuhaError } from '../../../errors.js';
|
|
7
|
-
import type { MessageInfo, MessagesResources } from '../../../ports/resources/messages.js';
|
|
7
|
+
import type { BulkFetchRawChannel, MessageInfo, MessageSearchInput, MessageSearchPage, MessagesResources } from '../../../ports/resources/messages.js';
|
|
8
8
|
import { preloadChannels } from '../../../domain/resource-batches.js';
|
|
9
9
|
import { messageSearchInput, pinnedMessagesInput, reactionUsersInput } from '../../../domain/message-query.js';
|
|
10
10
|
|
|
@@ -27,7 +27,7 @@ function receivedEmbed(embed: MessageEmbed): ReceivedEmbed {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
export function toMessageInfo(message: Message): MessageInfo {
|
|
31
31
|
return {
|
|
32
32
|
id: message.id, channelID: message.channelId, authorID: message.author.id,
|
|
33
33
|
authorName: message.author.username, content: message.content,
|
|
@@ -51,22 +51,53 @@ export function createMessagesResources(client: Client): MessagesResources {
|
|
|
51
51
|
}
|
|
52
52
|
const builders = files.map(file => {
|
|
53
53
|
if (!file.name.trim() || file.name.length > 255) throw new YuzuhaError('ATTACHMENT_NAME', 'Nome de anexo deve ter de 1 a 255 caracteres.');
|
|
54
|
-
|
|
54
|
+
const builder = new AttachmentBuilder('data' in file ? Buffer.from(file.data) : file.url,
|
|
55
55
|
{ name: file.name, description: file.description });
|
|
56
|
+
if (file.spoiler) builder.setSpoiler();
|
|
57
|
+
return builder;
|
|
56
58
|
});
|
|
57
59
|
return (await client.channels.send(channelID, { content, files: builders,
|
|
58
60
|
attachments: builders.map((builder, id) => builder.toJSON(id)),
|
|
59
61
|
allowedMentions: { parse: [], repliedUser: false },
|
|
60
62
|
})).id;
|
|
61
63
|
};
|
|
64
|
+
const search = async (rawInput: MessageSearchInput): Promise<MessageSearchPage> => {
|
|
65
|
+
const input = messageSearchInput(rawInput);
|
|
66
|
+
const result = await client.searchMessages({ content: input.content,
|
|
67
|
+
contextGuildId: input.guildID, contextChannelId: input.channelID,
|
|
68
|
+
channelIds: input.channelIDs ?? (input.channelID ? [input.channelID] : undefined),
|
|
69
|
+
authorIds: input.authorIDs ?? (input.authorID ? [input.authorID] : undefined),
|
|
70
|
+
hitsPerPage: limitOf(input.limit, 25, 100), cursor: input.cursor,
|
|
71
|
+
...(input.contents === undefined ? {} : { contents: input.contents }),
|
|
72
|
+
...(input.exactPhrases === undefined ? {} : { exactPhrases: input.exactPhrases }),
|
|
73
|
+
...(input.excludeChannelIDs === undefined ? {} : { excludeChannelIds: input.excludeChannelIDs }),
|
|
74
|
+
...(input.excludeAuthorIDs === undefined ? {} : { excludeAuthorIds: input.excludeAuthorIDs }),
|
|
75
|
+
...(input.authorType === undefined ? {} : { authorType: input.authorType }),
|
|
76
|
+
...(input.excludeAuthorType === undefined ? {} : { excludeAuthorType: input.excludeAuthorType }),
|
|
77
|
+
...(input.mentions === undefined ? {} : { mentions: input.mentions }),
|
|
78
|
+
...(input.excludeMentions === undefined ? {} : { excludeMentions: input.excludeMentions }),
|
|
79
|
+
...(input.mentionEveryone === undefined ? {} : { mentionEveryone: input.mentionEveryone }),
|
|
80
|
+
...(input.pinned === undefined ? {} : { pinned: input.pinned }),
|
|
81
|
+
...(input.includeNsfw === undefined ? {} : { includeNsfw: input.includeNsfw }),
|
|
82
|
+
...(input.has === undefined ? {} : { has: input.has }),
|
|
83
|
+
...(input.excludeHas === undefined ? {} : { excludeHas: input.excludeHas }),
|
|
84
|
+
...(input.minID === undefined ? {} : { minId: input.minID }),
|
|
85
|
+
...(input.maxID === undefined ? {} : { maxId: input.maxID }),
|
|
86
|
+
...(input.sortBy === undefined ? {} : { sortBy: input.sortBy }),
|
|
87
|
+
...(input.sortOrder === undefined ? {} : { sortOrder: input.sortOrder }),
|
|
88
|
+
...(input.page === undefined ? {} : { page: input.page }) });
|
|
89
|
+
if ('indexing' in result) return { indexing: true, messages: [], total: 0, cursor: null };
|
|
90
|
+
return { indexing: false, messages: result.messages.map(data => toMessageInfo(new Message(client, data))),
|
|
91
|
+
total: result.total, cursor: result.cursor ?? null };
|
|
92
|
+
};
|
|
62
93
|
return {
|
|
63
94
|
async preload(channelIDs) {
|
|
64
95
|
const ids = preloadChannels(channelIDs);
|
|
65
96
|
const result = await client.preloadMessages(ids);
|
|
66
|
-
return Object.fromEntries(ids.map(id => [id, result[id] ?
|
|
97
|
+
return Object.fromEntries(ids.map(id => [id, result[id] ? toMessageInfo(new Message(client, result[id])) : null]));
|
|
67
98
|
},
|
|
68
99
|
async fetch(channelID: string, messageID: string): Promise<MessageInfo> {
|
|
69
|
-
return
|
|
100
|
+
return toMessageInfo(await client.channels.fetchMessage(channelID, messageID));
|
|
70
101
|
},
|
|
71
102
|
async list(channelID, limit, cursor = {}): Promise<MessageInfo[]> {
|
|
72
103
|
if (Object.values(cursor).filter(value => value !== undefined).length > 1) {
|
|
@@ -75,7 +106,7 @@ export function createMessagesResources(client: Client): MessagesResources {
|
|
|
75
106
|
const channel = await client.channels.fetch(channelID, { force: true });
|
|
76
107
|
if (!channel.isTextBased()) throw new YuzuhaError('CHANNEL_TEXT', 'Canal sem suporte a mensagens.');
|
|
77
108
|
const messages = await channel.messages.fetch({ limit: limitOf(limit, 20, 100), ...cursor });
|
|
78
|
-
return order([...messages.values()].map(
|
|
109
|
+
return order([...messages.values()].map(toMessageInfo));
|
|
79
110
|
},
|
|
80
111
|
async pin(channelID: string, messageID: string): Promise<void> {
|
|
81
112
|
await (await client.channels.fetchMessage(channelID, messageID)).pin();
|
|
@@ -90,14 +121,14 @@ export function createMessagesResources(client: Client): MessagesResources {
|
|
|
90
121
|
const messages = limit === undefined
|
|
91
122
|
? await channel.fetchPinnedMessages()
|
|
92
123
|
: await channel.fetchPinnedMessagesPage({ limit }).then(page => page.messages);
|
|
93
|
-
return order(messages.map(
|
|
124
|
+
return order(messages.map(toMessageInfo));
|
|
94
125
|
},
|
|
95
126
|
async pinnedPage(channelID, input) {
|
|
96
127
|
const options = pinnedMessagesInput(input);
|
|
97
128
|
const channel = await client.channels.fetch(channelID, { force: true });
|
|
98
129
|
if (!channel.isTextBased()) throw new YuzuhaError('CHANNEL_TEXT', 'Canal sem suporte a mensagens.');
|
|
99
130
|
const page = await channel.fetchPinnedMessagesPage(options);
|
|
100
|
-
return { messages: page.messages.map(
|
|
131
|
+
return { messages: page.messages.map(toMessageInfo), pinnedAt: [...page.pinnedAt], hasMore: page.hasMore,
|
|
101
132
|
nextBefore: page.hasMore ? page.pinnedAt.at(-1) ?? null : null };
|
|
102
133
|
},
|
|
103
134
|
sendFiles: send,
|
|
@@ -111,34 +142,19 @@ export function createMessagesResources(client: Client): MessagesResources {
|
|
|
111
142
|
allowedMentions: { parse: [], repliedUser: false },
|
|
112
143
|
})).id;
|
|
113
144
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
...(input.mentions === undefined ? {} : { mentions: input.mentions }),
|
|
128
|
-
...(input.excludeMentions === undefined ? {} : { excludeMentions: input.excludeMentions }),
|
|
129
|
-
...(input.mentionEveryone === undefined ? {} : { mentionEveryone: input.mentionEveryone }),
|
|
130
|
-
...(input.pinned === undefined ? {} : { pinned: input.pinned }),
|
|
131
|
-
...(input.includeNsfw === undefined ? {} : { includeNsfw: input.includeNsfw }),
|
|
132
|
-
...(input.has === undefined ? {} : { has: input.has }),
|
|
133
|
-
...(input.excludeHas === undefined ? {} : { excludeHas: input.excludeHas }),
|
|
134
|
-
...(input.minID === undefined ? {} : { minId: input.minID }),
|
|
135
|
-
...(input.maxID === undefined ? {} : { maxId: input.maxID }),
|
|
136
|
-
...(input.sortBy === undefined ? {} : { sortBy: input.sortBy }),
|
|
137
|
-
...(input.sortOrder === undefined ? {} : { sortOrder: input.sortOrder }),
|
|
138
|
-
...(input.page === undefined ? {} : { page: input.page }) });
|
|
139
|
-
if ('indexing' in result) return { indexing: true, messages: [], total: 0, cursor: null };
|
|
140
|
-
return { indexing: false, messages: result.messages.map(data => info(new Message(client, data))),
|
|
141
|
-
total: result.total, cursor: result.cursor ?? null };
|
|
145
|
+
search,
|
|
146
|
+
searchAll: search,
|
|
147
|
+
async bulkFetch(requests, input): Promise<MessageInfo[] | BulkFetchRawChannel[]> {
|
|
148
|
+
const options = requests.map(request => ({ channelId: request.channelID, limit: request.limit,
|
|
149
|
+
...(request.before === undefined ? {} : { before: request.before }),
|
|
150
|
+
...(request.after === undefined ? {} : { after: request.after }),
|
|
151
|
+
...(request.around === undefined ? {} : { around: request.around }) }));
|
|
152
|
+
if (input?.hydrate === false) {
|
|
153
|
+
const raw = await client.bulkFetchMessages(options, { hydrate: false });
|
|
154
|
+
return raw.channels.map(channel => ({ channelID: channel.channel_id, messages: channel.messages }));
|
|
155
|
+
}
|
|
156
|
+
const result = await client.bulkFetchMessages(options);
|
|
157
|
+
return result.channels.flatMap(channel => [...channel.messages.values()].map(toMessageInfo));
|
|
142
158
|
},
|
|
143
159
|
sendBytes: send,
|
|
144
160
|
sendAttachments: send,
|
|
@@ -164,5 +180,37 @@ export function createMessagesResources(client: Client): MessagesResources {
|
|
|
164
180
|
const page = await message.fetchReactionUsersPage(emoji, input);
|
|
165
181
|
return { users: page.users.map(user => user.id), hasMore: page.hasMore, nextAfter: page.nextAfter };
|
|
166
182
|
},
|
|
183
|
+
async deleteAttachment(channelID, messageID, attachmentID): Promise<void> {
|
|
184
|
+
await (await client.channels.fetchMessage(channelID, messageID)).deleteAttachment(attachmentID);
|
|
185
|
+
},
|
|
186
|
+
async sendTo(channelID, content): Promise<string> {
|
|
187
|
+
return (await client.channels.send(channelID, { content, allowedMentions: { parse: [], repliedUser: false } })).id;
|
|
188
|
+
},
|
|
189
|
+
async bulkDelete(channelID, messageIDs): Promise<string[]> {
|
|
190
|
+
const channel = await client.channels.fetch(channelID, { force: true });
|
|
191
|
+
if (!channel.isTextBased()) throw new YuzuhaError('CHANNEL_TEXT', 'Canal sem suporte a mensagens.');
|
|
192
|
+
return channel.bulkDelete(messageIDs);
|
|
193
|
+
},
|
|
194
|
+
async bulkDeleteOwn(channelID): Promise<void> {
|
|
195
|
+
const channel = await client.channels.fetch(channelID, { force: true });
|
|
196
|
+
if (!channel.isTextBased()) throw new YuzuhaError('CHANNEL_TEXT', 'Canal sem suporte a mensagens.');
|
|
197
|
+
await channel.bulkDeleteMyMessages();
|
|
198
|
+
},
|
|
199
|
+
async acknowledgePins(channelID): Promise<void> {
|
|
200
|
+
const channel = await client.channels.fetch(channelID, { force: true });
|
|
201
|
+
if (!channel.isTextBased()) throw new YuzuhaError('CHANNEL_TEXT', 'Canal sem suporte a mensagens.');
|
|
202
|
+
await channel.acknowledgePins();
|
|
203
|
+
},
|
|
204
|
+
async clearReadState(channelID): Promise<void> {
|
|
205
|
+
const channel = await client.channels.fetch(channelID, { force: true });
|
|
206
|
+
if (!channel.isTextBased()) throw new YuzuhaError('CHANNEL_TEXT', 'Canal sem suporte a mensagens.');
|
|
207
|
+
await channel.clearReadState();
|
|
208
|
+
},
|
|
209
|
+
async purgeDM(channelID): Promise<number> {
|
|
210
|
+
const channel = await client.channels.fetch(channelID, { force: true });
|
|
211
|
+
if (!channel.isDM()) throw new YuzuhaError('CHANNEL_DM', 'Esta operação exige um canal de DM.');
|
|
212
|
+
if (Number(channel.type) !== 999) throw new YuzuhaError('CHANNEL_NOTES', 'purgeDM só funciona no canal de anotações pessoais.');
|
|
213
|
+
return channel.purgeMessages();
|
|
214
|
+
},
|
|
167
215
|
};
|
|
168
216
|
}
|
|
@@ -10,6 +10,7 @@ function toInfo(role: Role): RoleInfo {
|
|
|
10
10
|
position: role.position,
|
|
11
11
|
permissions: role.permissions.bitfield.toString(),
|
|
12
12
|
hoist: role.hoist,
|
|
13
|
+
hoistPosition: role.hoistPosition,
|
|
13
14
|
mentionable: role.mentionable,
|
|
14
15
|
unicodeEmoji: role.unicodeEmoji,
|
|
15
16
|
managed: Reflect.get(role, 'managed') === true,
|
|
@@ -103,6 +104,13 @@ export function createRolesResources(client: Client): RolesResources {
|
|
|
103
104
|
const guild = await getGuild(client, guildID);
|
|
104
105
|
await (await resolveRole(guild, role)).delete(reason);
|
|
105
106
|
},
|
|
107
|
+
async setRoleHoistPositions(guildID, updates) {
|
|
108
|
+
const guild = await client.guilds.resolve(guildID);
|
|
109
|
+
return (await guild.setRoleHoistPositions(updates)).map(toInfo);
|
|
110
|
+
},
|
|
111
|
+
async resetRoleHoistPositions(guildID) {
|
|
112
|
+
return (await (await client.guilds.resolve(guildID)).resetRoleHoistPositions()).map(toInfo);
|
|
113
|
+
},
|
|
106
114
|
async move(guildID, role, position): Promise<void> {
|
|
107
115
|
if (!Number.isSafeInteger(position) || position < 0) throw new YuzuhaError('POSITION', 'Posição deve ser um inteiro a partir de 0.');
|
|
108
116
|
const guild = await getGuild(client, guildID);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Client, ClientUser } from '@fluxerjs/core';
|
|
2
|
+
import { YuzuhaError } from '../../../errors.js';
|
|
3
|
+
import type { SelfResources } from '../../../ports/resources/self.js';
|
|
4
|
+
import { toUserInfo } from './users.js';
|
|
5
|
+
|
|
6
|
+
function selfUser(client: Client): ClientUser {
|
|
7
|
+
const user = client.user;
|
|
8
|
+
if (!user) {
|
|
9
|
+
throw new YuzuhaError('NOT_READY', 'O cliente ainda não está pronto; o usuário autenticado não está disponível.');
|
|
10
|
+
}
|
|
11
|
+
return user;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createSelfResources(client: Client): SelfResources {
|
|
15
|
+
return {
|
|
16
|
+
async fetch() {
|
|
17
|
+
return toUserInfo(await selfUser(client).fetch());
|
|
18
|
+
},
|
|
19
|
+
async guilds(input) {
|
|
20
|
+
const guilds = await selfUser(client).fetchGuilds({ withCounts: input?.withCounts ?? false });
|
|
21
|
+
return guilds.map(guild => ({
|
|
22
|
+
id: guild.id,
|
|
23
|
+
name: guild.name,
|
|
24
|
+
icon: guild.icon,
|
|
25
|
+
owner: guild.owner ?? false,
|
|
26
|
+
permissions: guild.permissions ?? null,
|
|
27
|
+
features: guild.features ?? [],
|
|
28
|
+
memberCount: guild.approximateMemberCount ?? null,
|
|
29
|
+
onlineCount: guild.approximatePresenceCount ?? null,
|
|
30
|
+
}));
|
|
31
|
+
},
|
|
32
|
+
async leaveGuild(guildID, verification) {
|
|
33
|
+
await selfUser(client).leaveGuild(guildID, verification);
|
|
34
|
+
},
|
|
35
|
+
async deleteMyMessages(guildID, verification) {
|
|
36
|
+
await selfUser(client).bulkDeleteMyMessagesInGuild(guildID, verification);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -133,6 +133,20 @@ export function createThreadsResources(client: Client): ThreadsResources {
|
|
|
133
133
|
},
|
|
134
134
|
async join(threadID) { await asThread(await client.channels.fetch(threadID)).join(); },
|
|
135
135
|
async leave(threadID) { await asThread(await client.channels.fetch(threadID)).leave(); },
|
|
136
|
+
async setLocked(threadID, locked, reason): Promise<void> {
|
|
137
|
+
await asThread(await client.channels.fetch(threadID)).setLocked(locked, reason);
|
|
138
|
+
},
|
|
139
|
+
async editSelf(threadID, input) {
|
|
140
|
+
const member = await asThread(await client.channels.fetch(threadID)).editSelf(input);
|
|
141
|
+
return member === null ? null : { threadID: member.id, userID: member.userId,
|
|
142
|
+
joinedTimestamp: member.joinedAt.getTime(), flags: member.flags };
|
|
143
|
+
},
|
|
144
|
+
async editDefaults(parentID, input): Promise<void> {
|
|
145
|
+
const { slowmode, autoArchiveDuration, reason } = input;
|
|
146
|
+
await parentThreads(await client.channels.fetch(parentID)).editDefaults({
|
|
147
|
+
autoArchiveDuration: autoArchiveDuration === null ? null : archiveDuration(autoArchiveDuration),
|
|
148
|
+
rateLimitPerUser: slowmode, reason });
|
|
149
|
+
},
|
|
136
150
|
async search(channelID, input) {
|
|
137
151
|
const limit = input.limit ?? 25, offset = input.offset ?? 0;
|
|
138
152
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 25 || !Number.isSafeInteger(offset) || offset < 0 || offset > 9975) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Client, Guild, GuildMember, PresenceUpdateOptions, User, ProfilePayload } from '@fluxerjs/core';
|
|
1
|
+
import type { Client, DiscoveryApplicationPayload, Guild, GuildMember, PresenceUpdateOptions, User, ProfilePayload } from '@fluxerjs/core';
|
|
2
2
|
import type { ActivityInfo, ActivityType, PresenceStatus } from '../../../ports/resources/common.js';
|
|
3
3
|
import { limitOf } from '../../../ports/resources/common.js';
|
|
4
4
|
import type {
|
|
@@ -11,6 +11,8 @@ import type {
|
|
|
11
11
|
LiveCountsInput,
|
|
12
12
|
ProfileInfo,
|
|
13
13
|
} from '../../../ports/resources/users.js';
|
|
14
|
+
import type { DiscoveryApplicationInfo } from '../../../ports/resources/users.js';
|
|
15
|
+
import type { ChannelInfo } from '../../../ports/resources/channels.js';
|
|
14
16
|
import { YuzuhaError } from '../../../errors.js';
|
|
15
17
|
|
|
16
18
|
/** Época Fluxer (01/01/2015 UTC) para derivar timestamps de snowflakes. */
|
|
@@ -65,7 +67,7 @@ function snowflakeTimestamp(id: string): number {
|
|
|
65
67
|
return Number((BigInt(id) >> 22n) + FLUXER_EPOCH);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
function toUserInfo(user: User): UserInfo {
|
|
70
|
+
export function toUserInfo(user: User): UserInfo {
|
|
69
71
|
return {
|
|
70
72
|
id: user.id,
|
|
71
73
|
username: user.username,
|
|
@@ -77,7 +79,7 @@ function toUserInfo(user: User): UserInfo {
|
|
|
77
79
|
};
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
function toMemberInfo(member: GuildMember): MemberInfo {
|
|
82
|
+
export function toMemberInfo(member: GuildMember): MemberInfo {
|
|
81
83
|
const user = member.user;
|
|
82
84
|
return {
|
|
83
85
|
id: member.id,
|
|
@@ -95,7 +97,7 @@ function toMemberInfo(member: GuildMember): MemberInfo {
|
|
|
95
97
|
};
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
function toGuildInfo(guild: Guild): GuildInfo {
|
|
100
|
+
export function toGuildInfo(guild: Guild): GuildInfo {
|
|
99
101
|
return {
|
|
100
102
|
id: guild.id,
|
|
101
103
|
name: guild.name,
|
|
@@ -108,6 +110,13 @@ function toGuildInfo(guild: Guild): GuildInfo {
|
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
function toDiscoveryApplicationInfo(payload: DiscoveryApplicationPayload): DiscoveryApplicationInfo {
|
|
114
|
+
return { guildID: payload.guildId, status: payload.status, description: payload.description,
|
|
115
|
+
categoryType: payload.categoryType, primaryLanguage: payload.primaryLanguage ?? null,
|
|
116
|
+
customTags: payload.customTags, appliedAt: payload.appliedAt, reviewedAt: payload.reviewedAt ?? null,
|
|
117
|
+
guildNsfwLevel: payload.guildNsfwLevel ?? null };
|
|
118
|
+
}
|
|
119
|
+
|
|
111
120
|
export function createUsersResources(client: Client): UsersResources {
|
|
112
121
|
return {
|
|
113
122
|
async leaveGuild(guildID) {
|
|
@@ -186,6 +195,27 @@ export function createUsersResources(client: Client): UsersResources {
|
|
|
186
195
|
const { systemChannelID, afkChannelID, ...fields } = input;
|
|
187
196
|
return toGuildInfo(await guild.edit({ ...fields, systemChannelId: systemChannelID, afkChannelId: afkChannelID }));
|
|
188
197
|
},
|
|
198
|
+
async me(guildID) {
|
|
199
|
+
const guild = await client.guilds.resolve(guildID);
|
|
200
|
+
return toMemberInfo(await guild.members.fetchMe());
|
|
201
|
+
},
|
|
202
|
+
async transferOwnership(guildID, userID): Promise<void> {
|
|
203
|
+
await (await client.guilds.resolve(guildID)).transferOwnership(userID);
|
|
204
|
+
},
|
|
205
|
+
async withdrawDiscoveryApplication(guildID): Promise<void> {
|
|
206
|
+
await (await client.guilds.resolve(guildID)).withdrawDiscoveryApplication();
|
|
207
|
+
},
|
|
208
|
+
async discoveryStatus(guildID) {
|
|
209
|
+
const status = await (await client.guilds.resolve(guildID)).fetchDiscoveryStatus();
|
|
210
|
+
return { application: status.application ? toDiscoveryApplicationInfo(status.application) : null,
|
|
211
|
+
eligible: status.eligible, minMemberCount: status.minMemberCount };
|
|
212
|
+
},
|
|
213
|
+
async applyForDiscovery(guildID, input) {
|
|
214
|
+
return toDiscoveryApplicationInfo(await (await client.guilds.resolve(guildID)).applyForDiscovery(input));
|
|
215
|
+
},
|
|
216
|
+
async editDiscoveryApplication(guildID, input) {
|
|
217
|
+
return toDiscoveryApplicationInfo(await (await client.guilds.resolve(guildID)).editDiscoveryApplication(input));
|
|
218
|
+
},
|
|
189
219
|
async setPresence(status: PresenceStatus, activity?: ActivityInfo): Promise<void> {
|
|
190
220
|
const self = client.user;
|
|
191
221
|
if (!self) throw new YuzuhaError('NOT_READY', 'O cliente ainda não está pronto para definir presença.');
|
|
@@ -204,5 +234,11 @@ export function createUsersResources(client: Client): UsersResources {
|
|
|
204
234
|
}
|
|
205
235
|
self.setPresence(presence);
|
|
206
236
|
},
|
|
237
|
+
async createDM(userID): Promise<ChannelInfo> {
|
|
238
|
+
const user = await client.users.fetch(userID, { force: true });
|
|
239
|
+
const dm = await user.createDM();
|
|
240
|
+
return { id: dm.id, name: '', type: 1, guildID: null, parentID: null, position: 0,
|
|
241
|
+
topic: null, slowmode: 0, nsfw: false };
|
|
242
|
+
},
|
|
207
243
|
};
|
|
208
244
|
}
|
|
@@ -40,5 +40,14 @@ export function createWebhooksResources(client: Client): WebhooksResources {
|
|
|
40
40
|
const webhook = token ? Webhook.fromToken(client, webhookID, token) : await Webhook.fetch(client, webhookID);
|
|
41
41
|
await webhook.delete();
|
|
42
42
|
},
|
|
43
|
+
editMessage: async (webhookID, token, messageID, input) => {
|
|
44
|
+
const webhook = Webhook.fromToken(client, webhookID, token);
|
|
45
|
+
const message = await webhook.editMessage(messageID, { content: input.content });
|
|
46
|
+
return message.id;
|
|
47
|
+
},
|
|
48
|
+
deleteMessage: async (webhookID, token, messageID) => {
|
|
49
|
+
const webhook = Webhook.fromToken(client, webhookID, token);
|
|
50
|
+
await webhook.deleteMessage(messageID);
|
|
51
|
+
},
|
|
43
52
|
};
|
|
44
53
|
}
|