yuzuha 0.2.0 → 0.2.1
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 +12 -0
- package/VERSIONING.md +29 -7
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +6 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- 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 +51 -0
- package/dist/infrastructure/fluxer/resources/cache.js.map +1 -0
- 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/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 +49 -35
- package/dist/infrastructure/fluxer/resources/messages.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/users.d.ts +4 -2
- package/dist/infrastructure/fluxer/resources/users.d.ts.map +1 -1
- package/dist/infrastructure/fluxer/resources/users.js +2 -2
- package/dist/infrastructure/fluxer/resources/users.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 +52 -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/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/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 +20 -0
- package/dist/ports/resources/messages.d.ts.map +1 -1
- package/dist/ports/resources/messages.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.d.ts +8 -0
- package/dist/ports/resources.d.ts.map +1 -1
- package/dist/ports/resources.js.map +1 -1
- 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/resource-authorization.d.ts.map +1 -1
- package/dist/services/resource-authorization.js +2 -1
- 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/FUNCTION-GAPS.md +8 -3
- package/docs/NATIVE.md +32 -5
- package/docs/PARITY-MATRIX.md +25 -25
- package/docs/PARITY.md +21 -9
- package/package.json +22 -1
- package/src/commands/context.ts +6 -1
- package/src/index.ts +8 -2
- package/src/infrastructure/fluxer/resources/cache.ts +52 -0
- package/src/infrastructure/fluxer/resources/collectors.ts +87 -4
- 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 +49 -35
- package/src/infrastructure/fluxer/resources/self.ts +39 -0
- package/src/infrastructure/fluxer/resources/users.ts +2 -2
- package/src/infrastructure/fluxer/resources.ts +12 -0
- package/src/ports/resources/cache.ts +56 -0
- package/src/ports/resources/collectors.ts +20 -0
- package/src/ports/resources/gateway.ts +49 -0
- package/src/ports/resources/instance.ts +109 -0
- package/src/ports/resources/messages.ts +23 -0
- package/src/ports/resources/self.ts +30 -0
- package/src/ports/resources.ts +8 -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/resource-authorization.ts +2 -1
- package/src/testing.ts +4 -0
package/docs/NATIVE.md
CHANGED
|
@@ -187,6 +187,15 @@ Yuzuha. Chamadas diretas ao client exigem mocks ou fixtures próprios.
|
|
|
187
187
|
importar `Events`, `AttachmentBuilder`, `EmbedBuilder` e os tipos do Fluxer.js.
|
|
188
188
|
A assinatura completa dessas classes pertence ao SDK fixado em 3.3.0.
|
|
189
189
|
|
|
190
|
+
Os subpaths do SDK também são espelhados: `yuzuha/sdk/client`, `yuzuha/sdk/errors`,
|
|
191
|
+
`yuzuha/sdk/message`, `yuzuha/sdk/cluster` e `yuzuha/sdk/internal` equivalem aos
|
|
192
|
+
caminhos homônimos de `@fluxerjs/core`. Os pacotes satélites aparecem como
|
|
193
|
+
`yuzuha/sdk/types` (com `yuzuha/sdk/types/routes`), `yuzuha/sdk/rest` (com
|
|
194
|
+
`yuzuha/sdk/rest/request-manager`), `yuzuha/sdk/ws`, `yuzuha/sdk/builders`,
|
|
195
|
+
`yuzuha/sdk/collection` e `yuzuha/sdk/util`. `yuzuha/sdk/voice` e
|
|
196
|
+
`yuzuha/sdk/sharding` reexportam os pacotes opcionais homônimos e só funcionam
|
|
197
|
+
quando o peer correspondente está instalado.
|
|
198
|
+
|
|
190
199
|
## Recursos nativos
|
|
191
200
|
|
|
192
201
|
As funções `$...` de usuários, cargos, canais, mensagens, coletores, webhooks,
|
|
@@ -206,8 +215,12 @@ await ctx.reply(`${membro.displayName}: ${canais.length} canais, ${fixadas.lengt
|
|
|
206
215
|
| `users` | `user`, `member`, `members`, `memberCount`, `guild`, `bans`, `auditLogs`, `setPresence`, `searchMembers`, `setNickname`, `editGuild` |
|
|
207
216
|
| `roles` | `list`, `resolve`, `has`, `create`, `edit`, `delete`, `add`, `remove`, `move` |
|
|
208
217
|
| `channels` | `list`, `get`, `create`, `edit`, `delete`, `setSlowmode`, `overwrite`, `permissionsFor`, `move`, `setCategory` |
|
|
209
|
-
| `messages` | Histórico com cursores, `pinnedPage`, `reactionUsersPage`, `dm`, `forward`, `search` com filtros avançados, `sendFiles`, `sendBytes`, `sendAttachments` |
|
|
210
|
-
| `collectors` | `awaitMessage`, `awaitReaction` |
|
|
218
|
+
| `messages` | Histórico com cursores, `pinnedPage`, `reactionUsersPage`, `dm`, `forward`, `search`/`searchAll` com filtros avançados, `bulkFetch`, `sendFiles`, `sendBytes`, `sendAttachments` |
|
|
219
|
+
| `collectors` | `awaitMessage`, `awaitReaction`, streams `collectMessages`/`collectReactions` (AsyncIterable) |
|
|
220
|
+
| `gateway` | `requestMembers`, `requestGuildCounts`, `requestChannelCounts`, `requestForumUnreads`, `subscribeThreads`, `send` (fire-and-forget) |
|
|
221
|
+
| `instance` | `describe`, `gatewayInfo`, `application`, `oauthApplications`, `emojiMetadata`, `stickerMetadata`, `resolveEmoji` |
|
|
222
|
+
| `self` | `fetch`, `guilds`, `leaveGuild` e `deleteMyMessages` com verificação sudo |
|
|
223
|
+
| `cache` | `stats`, `sweepMessages`, `sweepMembers` |
|
|
211
224
|
| `webhooks` | `list`, `create`, `send`, `edit`, `delete` |
|
|
212
225
|
| `expressions` | CRUD de emojis/stickers, `cloneEmoji`, `cloneSticker` |
|
|
213
226
|
| `threads` | `create`, `archive`, `unarchive`, `forumPost`, `addMember`, `removeMember`, `members`, `member`, `edit`, `join`, `leave`, `search` |
|
|
@@ -252,9 +265,23 @@ o SDK. `$createEmoji[nome;url]` faz o download e a conversão com `ctx.http`;
|
|
|
252
265
|
`$createSticker` recebe base64 diretamente. Edição de sticker suporta nome,
|
|
253
266
|
descrição e motivo; tags são aceitas na criação.
|
|
254
267
|
|
|
255
|
-
|
|
256
|
-
`
|
|
257
|
-
|
|
268
|
+
`collectors.collectMessages` e `collectors.collectReactions` retornam um
|
|
269
|
+
`AsyncIterable` que emite cada item coletado até o limite (`timeMs`, `max` ou
|
|
270
|
+
`signal`) ou o cancelamento do comando. Reações exigem `messageID`: o coletor do
|
|
271
|
+
SDK é por mensagem. Iteradores são de uso único; cada chamada cria um novo stream.
|
|
272
|
+
|
|
273
|
+
`messages.bulkFetch` agrupa pedidos de janela por canal e hidrata as mensagens
|
|
274
|
+
por padrão; `hydrate: false` devolve os payloads brutos da API. `searchAll` é a
|
|
275
|
+
busca global do client com os mesmos filtros e paginação de `search`.
|
|
276
|
+
|
|
277
|
+
`gateway` envia pedidos brutos ao gateway sem aguardar resposta — os resultados
|
|
278
|
+
chegam pelos eventos do client. `users.guildCounts` e `users.channelCounts`
|
|
279
|
+
continuam sendo o caminho quando se espera o valor de volta.
|
|
280
|
+
|
|
281
|
+
Implementações próprias dos contratos `Resources` devem fornecer as áreas
|
|
282
|
+
`gateway`, `instance`, `self` e `cache` além das anteriores; `CollectorsResources`
|
|
283
|
+
ganhou `collectMessages`/`collectReactions` e `MessagesResources` ganhou
|
|
284
|
+
`searchAll`/`bulkFetch`. Para testes que exercitam apenas parte dos recursos,
|
|
258
285
|
use `mockResources`, que aceita implementações parciais por método.
|
|
259
286
|
|
|
260
287
|
## Membros, mensagens e transações
|
package/docs/PARITY-MATRIX.md
CHANGED
|
@@ -17,9 +17,9 @@ A cobertura é por nome: um método `send` de uma classe conta como coberto se q
|
|
|
17
17
|
| Status | Exports de runtime | Membros |
|
|
18
18
|
|---|---:|---:|
|
|
19
19
|
| coberto-script | 50 | 414 |
|
|
20
|
-
| coberto-nativo | 4 |
|
|
20
|
+
| coberto-nativo | 4 | 85 |
|
|
21
21
|
| só-SDK | 3 | 0 |
|
|
22
|
-
| lacuna | 60 |
|
|
22
|
+
| lacuna | 60 | 223 |
|
|
23
23
|
|
|
24
24
|
Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são listados, mas não contam como lacuna.
|
|
25
25
|
|
|
@@ -192,11 +192,11 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
192
192
|
| `CacheController` | `cascadeGuild` | método | lacuna |
|
|
193
193
|
| `CacheController` | `cascading` | acessor | lacuna |
|
|
194
194
|
| `CacheController` | `limits` | propriedade | coberto-nativo |
|
|
195
|
-
| `CacheController` | `stats` | método |
|
|
195
|
+
| `CacheController` | `stats` | método | coberto-nativo |
|
|
196
196
|
| `CacheController` | `sweepChannels` | método | lacuna |
|
|
197
197
|
| `CacheController` | `sweepGuilds` | método | lacuna |
|
|
198
|
-
| `CacheController` | `sweepMembers` | método |
|
|
199
|
-
| `CacheController` | `sweepMessages` | método |
|
|
198
|
+
| `CacheController` | `sweepMembers` | método | coberto-nativo |
|
|
199
|
+
| `CacheController` | `sweepMessages` | método | coberto-nativo |
|
|
200
200
|
| `CacheController` | `sweepUsers` | método | lacuna |
|
|
201
201
|
| `Channel` | `_patch` | método | lacuna |
|
|
202
202
|
| `Channel` | `acknowledgePins` | método | lacuna |
|
|
@@ -216,7 +216,7 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
216
216
|
| `Channel` | `fetchSlowmode` | método | lacuna |
|
|
217
217
|
| `Channel` | `from` | método | coberto-script |
|
|
218
218
|
| `Channel` | `fromOrCreate` | método | lacuna |
|
|
219
|
-
| `Channel` | `icon` | propriedade |
|
|
219
|
+
| `Channel` | `icon` | propriedade | coberto-nativo |
|
|
220
220
|
| `Channel` | `id` | propriedade | coberto-script |
|
|
221
221
|
| `Channel` | `isAnnouncement` | método | lacuna |
|
|
222
222
|
| `Channel` | `isCategory` | método | coberto-script |
|
|
@@ -249,7 +249,7 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
249
249
|
| `Client` | `_finalizeReady` | método | lacuna |
|
|
250
250
|
| `Client` | `_getMessageCache` | método | lacuna |
|
|
251
251
|
| `Client` | `_guildStreamSettleTimeout` | propriedade | lacuna |
|
|
252
|
-
| `Client` | `_messageCacheStats` | método |
|
|
252
|
+
| `Client` | `_messageCacheStats` | método | coberto-nativo |
|
|
253
253
|
| `Client` | `_onGuildReceived` | método | lacuna |
|
|
254
254
|
| `Client` | `_pendingGuildIds` | propriedade | lacuna |
|
|
255
255
|
| `Client` | `_readyStubGuildIds` | propriedade | lacuna |
|
|
@@ -257,22 +257,22 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
257
257
|
| `Client` | `_sendToAllShards` | método | lacuna |
|
|
258
258
|
| `Client` | `_ws` | propriedade | lacuna |
|
|
259
259
|
| `Client` | `assertReady` | método | lacuna |
|
|
260
|
-
| `Client` | `bulkFetchMessages` | método |
|
|
260
|
+
| `Client` | `bulkFetchMessages` | método | coberto-nativo |
|
|
261
261
|
| `Client` | `cache` | propriedade | coberto-nativo |
|
|
262
262
|
| `Client` | `channels` | propriedade | coberto-script |
|
|
263
263
|
| `Client` | `destroy` | método | coberto-nativo |
|
|
264
264
|
| `Client` | `emit` | método | coberto-nativo |
|
|
265
265
|
| `Client` | `events` | propriedade | coberto-nativo |
|
|
266
|
-
| `Client` | `fetchApplication` | método |
|
|
267
|
-
| `Client` | `fetchEmojiMetadata` | método |
|
|
268
|
-
| `Client` | `fetchGatewayInfo` | método |
|
|
269
|
-
| `Client` | `fetchInstance` | método |
|
|
270
|
-
| `Client` | `fetchOAuthApplications` | método |
|
|
271
|
-
| `Client` | `fetchStickerMetadata` | método |
|
|
266
|
+
| `Client` | `fetchApplication` | método | coberto-nativo |
|
|
267
|
+
| `Client` | `fetchEmojiMetadata` | método | coberto-nativo |
|
|
268
|
+
| `Client` | `fetchGatewayInfo` | método | coberto-nativo |
|
|
269
|
+
| `Client` | `fetchInstance` | método | coberto-nativo |
|
|
270
|
+
| `Client` | `fetchOAuthApplications` | método | coberto-nativo |
|
|
271
|
+
| `Client` | `fetchStickerMetadata` | método | coberto-nativo |
|
|
272
272
|
| `Client` | `fromDiscovery` | método | lacuna |
|
|
273
273
|
| `Client` | `getOrCreateUser` | método | lacuna |
|
|
274
274
|
| `Client` | `guilds` | propriedade | coberto-script |
|
|
275
|
-
| `Client` | `instance` | propriedade |
|
|
275
|
+
| `Client` | `instance` | propriedade | coberto-nativo |
|
|
276
276
|
| `Client` | `isReady` | método | lacuna |
|
|
277
277
|
| `Client` | `logger` | propriedade | lacuna |
|
|
278
278
|
| `Client` | `login` | método | coberto-nativo |
|
|
@@ -284,17 +284,17 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
284
284
|
| `Client` | `preloadMessagesAlt` | método | lacuna |
|
|
285
285
|
| `Client` | `readyAt` | propriedade | coberto-nativo |
|
|
286
286
|
| `Client` | `requestChannelMemberCounts` | método | coberto-script |
|
|
287
|
-
| `Client` | `requestForumUnreads` | método |
|
|
287
|
+
| `Client` | `requestForumUnreads` | método | coberto-nativo |
|
|
288
288
|
| `Client` | `requestGuildCounts` | método | coberto-script |
|
|
289
|
-
| `Client` | `requestGuildMembers` | método |
|
|
289
|
+
| `Client` | `requestGuildMembers` | método | coberto-nativo |
|
|
290
290
|
| `Client` | `resolveEmoji` | método | coberto-script |
|
|
291
291
|
| `Client` | `rest` | propriedade | lacuna |
|
|
292
292
|
| `Client` | `Routes` | acessor | lacuna |
|
|
293
293
|
| `Client` | `searchMessages` | método | coberto-script |
|
|
294
|
-
| `Client` | `sendToGateway` | método |
|
|
295
|
-
| `Client` | `subscribeThreads` | método |
|
|
296
|
-
| `Client` | `sweepMembers` | método |
|
|
297
|
-
| `Client` | `sweepMessages` | método |
|
|
294
|
+
| `Client` | `sendToGateway` | método | coberto-nativo |
|
|
295
|
+
| `Client` | `subscribeThreads` | método | coberto-nativo |
|
|
296
|
+
| `Client` | `sweepMembers` | método | coberto-nativo |
|
|
297
|
+
| `Client` | `sweepMessages` | método | coberto-nativo |
|
|
298
298
|
| `Client` | `uptime` | acessor | lacuna |
|
|
299
299
|
| `Client` | `user` | propriedade | coberto-script |
|
|
300
300
|
| `Client` | `users` | propriedade | coberto-script |
|
|
@@ -313,10 +313,10 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
313
313
|
| `ClientCluster` | `runtimeValues` | método | lacuna |
|
|
314
314
|
| `ClientCluster` | `size` | acessor | coberto-script |
|
|
315
315
|
| `ClientCluster` | `values` | método | coberto-script |
|
|
316
|
-
| `ClientUser` | `bulkDeleteMyMessagesInGuild` | método |
|
|
316
|
+
| `ClientUser` | `bulkDeleteMyMessagesInGuild` | método | coberto-nativo |
|
|
317
317
|
| `ClientUser` | `client` | propriedade | coberto-script |
|
|
318
318
|
| `ClientUser` | `fetch` | método | coberto-script |
|
|
319
|
-
| `ClientUser` | `fetchGuilds` | método |
|
|
319
|
+
| `ClientUser` | `fetchGuilds` | método | coberto-nativo |
|
|
320
320
|
| `ClientUser` | `leaveGuild` | método | coberto-nativo |
|
|
321
321
|
| `ClientUser` | `setPresence` | método | coberto-script |
|
|
322
322
|
| `DMChannel` | `_patch` | método | lacuna |
|
|
@@ -419,7 +419,7 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
419
419
|
| `Guild` | `fetchStickers` | método | coberto-script |
|
|
420
420
|
| `Guild` | `fetchVanityURL` | método | coberto-script |
|
|
421
421
|
| `Guild` | `fetchWebhooks` | método | coberto-script |
|
|
422
|
-
| `Guild` | `icon` | propriedade |
|
|
422
|
+
| `Guild` | `icon` | propriedade | coberto-nativo |
|
|
423
423
|
| `Guild` | `iconURL` | método | coberto-script |
|
|
424
424
|
| `Guild` | `id` | propriedade | coberto-script |
|
|
425
425
|
| `Guild` | `kick` | método | coberto-nativo |
|
|
@@ -606,7 +606,7 @@ Pacotes: @fluxerjs/core, @fluxerjs/builders, @fluxerjs/types. Tipos e enums são
|
|
|
606
606
|
| `Message` | `mentions` | propriedade | coberto-script |
|
|
607
607
|
| `Message` | `messageReference` | propriedade | lacuna |
|
|
608
608
|
| `Message` | `messageSnapshots` | propriedade | lacuna |
|
|
609
|
-
| `Message` | `nonce` | propriedade |
|
|
609
|
+
| `Message` | `nonce` | propriedade | coberto-nativo |
|
|
610
610
|
| `Message` | `nsfwEmojis` | propriedade | lacuna |
|
|
611
611
|
| `Message` | `partial` | propriedade | coberto-nativo |
|
|
612
612
|
| `Message` | `pin` | método | coberto-script |
|
package/docs/PARITY.md
CHANGED
|
@@ -17,27 +17,39 @@ públicos da raiz do pacote e seus tipos. `bot.client` é uma instância real de
|
|
|
17
17
|
`Client`; `SDK` na raiz do Yuzuha é um namespace do mesmo pacote. O acesso nativo
|
|
18
18
|
não é uma reprodução parcial do client.
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
Os subpaths do pacote e os pacotes satélites do monorepo também são espelhados:
|
|
21
|
+
`yuzuha/sdk/client`, `yuzuha/sdk/errors`, `yuzuha/sdk/message`,
|
|
22
|
+
`yuzuha/sdk/cluster` e `yuzuha/sdk/internal` equivalem a `@fluxerjs/core/*`;
|
|
23
|
+
`yuzuha/sdk/types`, `yuzuha/sdk/types/routes`, `yuzuha/sdk/rest`,
|
|
24
|
+
`yuzuha/sdk/rest/request-manager`, `yuzuha/sdk/ws`, `yuzuha/sdk/builders`,
|
|
25
|
+
`yuzuha/sdk/collection` e `yuzuha/sdk/util` reexportam os pacotes homônimos, que
|
|
26
|
+
passam a ser dependências diretas do Yuzuha. `yuzuha/sdk/voice` e
|
|
27
|
+
`yuzuha/sdk/sharding` reexportam os pacotes opcionais homônimos, exigindo o peer
|
|
28
|
+
instalado. O teste de consumidor compara os exports de cada subpath `yuzuha/sdk*`
|
|
29
|
+
aos do pacote correspondente instalado.
|
|
30
|
+
|
|
31
|
+
Isso não significa que cada método tem uma função `$...`. `@fluxerjs/sharding`
|
|
32
|
+
declara peer em `@fluxerjs/core` 3.0.0 exato; consumidores que o instalarem
|
|
33
|
+
precisam de `overrides` para o core fixado, como no manifesto do Yuzuha.
|
|
23
34
|
|
|
24
35
|
| Área | JS/TS pelo client/SDK | Function mode |
|
|
25
36
|
|---|---|---|
|
|
26
|
-
| Gateway, conexão, heartbeat e reconexão | Herdado do SDK | Via inicialização do bot |
|
|
37
|
+
| Gateway, conexão, heartbeat e reconexão | Herdado do SDK; pedidos brutos por `ctx.resources.gateway` (membros, contagens, não lidos de fórum, assinatura de threads, envio por shard) | Via inicialização do bot |
|
|
27
38
|
| Eventos | `bot.on/once/off`, `bot.event`, `bot.scriptEvent` e `bot.client.on` | Eventos de membros, edição/exclusão de mensagens e reações, com contexto próprio |
|
|
28
39
|
| Mensagens e replies | API completa do SDK | reply, sendMessage, editMessage, deleteMessage, fetchMessage, messages com cursores, pin/unpin, pinnedMessagesPage, dm, forward, searchMessages, searchMessagesAdvanced e preloadMessages |
|
|
29
|
-
| Reações e collectors | API do SDK | react, removeReaction, clearReactions, reactionUsers e reactionUsersPage com metadados de paginação, awaitMessage, awaitReaction, confirm |
|
|
40
|
+
| Reações e collectors | API do SDK; streams `collectMessages`/`collectReactions` como `AsyncIterable` | react, removeReaction, clearReactions, reactionUsers e reactionUsersPage com metadados de paginação, awaitMessage, awaitReaction, confirm |
|
|
30
41
|
| Embeds e anexos | Builders do SDK, sendBytes e sendAttachments | Embeds completos (autor, link, data, campos, alt text e rodapé com ícone), até 10 embeds, opções de envio com autorização, anexos URL/base64 e múltiplos anexos; leitura normalizada em `$fetchMessage` |
|
|
31
42
|
| Membros, cargos, canais e permissões | API do SDK e `ctx.members` | User/member, perfil completo, contagens ao vivo, nickname, roles, canais de link, avisos, posição, categorias e overwrites |
|
|
32
43
|
| Ban, kick, timeout, unban e moderação de voz | SDK + `ctx.mod` e `ctx.moderate` | Versões simples e mod* com casos, incluindo move/mute/deafen |
|
|
33
44
|
| Servidor, convites, webhooks e expressões | API do SDK e auxiliares autorizados | guildFeatures, leaveGuild, editGuild, convites/vanity, clonagem e mutações de emojis/stickers, createEmojisBulk; CRUD e envio de webhooks |
|
|
34
45
|
| Threads e fóruns | API do SDK | Criação, edição, busca, posts, membros, threadMember e listagens ativas/arquivadas com paginação |
|
|
35
46
|
| Presença | `client.user.setPresence` | setPresence, setStatus e setActivity |
|
|
36
|
-
| Cache e presença |
|
|
37
|
-
|
|
|
47
|
+
| Cache e presença | `ctx.resources.cache` (estatísticas, limites e limpezas) e opções do SDK | Acesso nativo |
|
|
48
|
+
| Usuário autenticado | `ctx.resources.self` (fetch, guilds, saída e limpeza com verificação sudo) | setPresence, setStatus, setActivity e leaveGuild |
|
|
49
|
+
| Instância e aplicação | `ctx.resources.instance` (describe, gatewayInfo, application, oauthApplications, metadados de emoji/sticker, resolveEmoji); `Client.fromDiscovery`, client injetado | Mesmo adaptador do client |
|
|
38
50
|
| Áudio em voz | `FluxerVoice` sobre `@fluxerjs/voice` opcional; Lavalink v4 com plugin de áudio, `FluxerLavalinkBridge`, filas editáveis e recuperação em `yuzuha/music` | Sem wrappers de reprodução; moderação de membros usa o SDK core |
|
|
39
|
-
| Sharding |
|
|
40
|
-
| Cluster/subpaths |
|
|
51
|
+
| Sharding | `yuzuha/sdk/sharding` reexporta `@fluxerjs/sharding` (peer opcional) | Sem coordenação própria |
|
|
52
|
+
| Cluster/subpaths | `yuzuha/sdk/cluster` e demais subpaths `yuzuha/sdk/*` espelham `@fluxerjs/core/*` e os pacotes satélites | Sem wrapper próprio |
|
|
41
53
|
| Estado e casos | `ctx.data`, TTL, userFor, transaction entre chaves e stores | Variáveis, TTL, incrementos, listas, casos e dataTransaction com operações declarativas |
|
|
42
54
|
| Agendamentos | `ctx.scheduler`, cron/fusos, concorrência limitada, histórico, heartbeat e controles | schedule, scheduleEvery, scheduleCron, controles, histórico, reexecução e retry com jitter |
|
|
43
55
|
| HTTP | `request`, `requestBytes`, `stream`, `multipart`, `withPolicy` e cancelamento | `$http`, `$httpJson`, `$httpMultipart` e download de imagens com política de rede por comando |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuzuha",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Fluxer bots with simple scripts and typed JavaScript/TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"types": "./dist/sdk.d.ts",
|
|
27
27
|
"import": "./dist/sdk.js"
|
|
28
28
|
},
|
|
29
|
+
"./sdk/*": {
|
|
30
|
+
"types": "./dist/sdk/*.d.ts",
|
|
31
|
+
"import": "./dist/sdk/*.js"
|
|
32
|
+
},
|
|
29
33
|
"./testing": {
|
|
30
34
|
"types": "./dist/testing.d.ts",
|
|
31
35
|
"import": "./dist/testing.js"
|
|
@@ -93,11 +97,19 @@
|
|
|
93
97
|
"package:editor": "node scripts/package-editor.mjs"
|
|
94
98
|
},
|
|
95
99
|
"dependencies": {
|
|
100
|
+
"@fluxerjs/builders": "3.0.0",
|
|
101
|
+
"@fluxerjs/collection": "3.0.0",
|
|
96
102
|
"@fluxerjs/core": "3.3.0",
|
|
103
|
+
"@fluxerjs/rest": "3.1.0",
|
|
104
|
+
"@fluxerjs/types": "3.3.0",
|
|
105
|
+
"@fluxerjs/util": "3.1.0",
|
|
106
|
+
"@fluxerjs/ws": "3.1.0",
|
|
97
107
|
"tsx": "^4.20.0",
|
|
98
108
|
"ws": "^8.22.0"
|
|
99
109
|
},
|
|
100
110
|
"devDependencies": {
|
|
111
|
+
"@fluxerjs/sharding": "^3.0.0",
|
|
112
|
+
"@fluxerjs/voice": "^3.1.0",
|
|
101
113
|
"@napi-rs/canvas": "1.0.13",
|
|
102
114
|
"@types/node": "^22.0.0",
|
|
103
115
|
"@types/vscode": "^1.140.0",
|
|
@@ -106,11 +118,15 @@
|
|
|
106
118
|
"typescript": "^5.9.0"
|
|
107
119
|
},
|
|
108
120
|
"peerDependencies": {
|
|
121
|
+
"@fluxerjs/sharding": "^3.0.0",
|
|
109
122
|
"@fluxerjs/voice": "^3.1.0",
|
|
110
123
|
"@napi-rs/canvas": "^1.0.13",
|
|
111
124
|
"sharp": "^0.35.5"
|
|
112
125
|
},
|
|
113
126
|
"peerDependenciesMeta": {
|
|
127
|
+
"@fluxerjs/sharding": {
|
|
128
|
+
"optional": true
|
|
129
|
+
},
|
|
114
130
|
"@fluxerjs/voice": {
|
|
115
131
|
"optional": true
|
|
116
132
|
},
|
|
@@ -120,5 +136,10 @@
|
|
|
120
136
|
"@napi-rs/canvas": {
|
|
121
137
|
"optional": true
|
|
122
138
|
}
|
|
139
|
+
},
|
|
140
|
+
"overrides": {
|
|
141
|
+
"@fluxerjs/sharding": {
|
|
142
|
+
"@fluxerjs/core": "3.3.0"
|
|
143
|
+
}
|
|
123
144
|
}
|
|
124
145
|
}
|
package/src/commands/context.ts
CHANGED
|
@@ -186,11 +186,16 @@ export class CommandContext {
|
|
|
186
186
|
const source = bindAuthorizedResources(this.nativeResources, this.transport, { guildID: this.guildID, authorID: this.authorID }), collectors = source.collectors;
|
|
187
187
|
return this.scopedResources = { users: source.users, roles: source.roles, channels: source.channels,
|
|
188
188
|
messages: source.messages, webhooks: source.webhooks, expressions: source.expressions,
|
|
189
|
-
threads: source.threads, invites: source.invites,
|
|
189
|
+
threads: source.threads, invites: source.invites, gateway: source.gateway,
|
|
190
|
+
instance: source.instance, self: source.self, cache: source.cache, collectors: {
|
|
190
191
|
awaitMessage: (channelID, input) => collectors.awaitMessage(channelID, { ...input,
|
|
191
192
|
signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
|
|
192
193
|
awaitReaction: (channelID, messageID, emojis, timeMs, userID, signal) => collectors.awaitReaction(
|
|
193
194
|
channelID, messageID, emojis, timeMs, userID, signal ? AbortSignal.any([this.signal, signal]) : this.signal),
|
|
195
|
+
collectMessages: (channelID, input) => collectors.collectMessages(channelID, { ...input,
|
|
196
|
+
signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
|
|
197
|
+
collectReactions: (channelID, input) => collectors.collectReactions(channelID, { ...input,
|
|
198
|
+
signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
|
|
194
199
|
} };
|
|
195
200
|
}
|
|
196
201
|
get scheduler(): Scheduler {
|
package/src/index.ts
CHANGED
|
@@ -28,12 +28,18 @@ export type {
|
|
|
28
28
|
ChannelInfo, ChannelCreateInput, ChannelEditInput, ChannelOverwriteInput, ChannelsResources,
|
|
29
29
|
} from './ports/resources/channels.js';
|
|
30
30
|
export type { AttachmentInfo, MessageInfo, MessagesResources, MessageCursor, MessageSearchInput, MessageSearchPage,
|
|
31
|
-
PinnedMessagesInput, PinnedMessagesPage, ReactionUsersPage
|
|
32
|
-
|
|
31
|
+
PinnedMessagesInput, PinnedMessagesPage, ReactionUsersPage,
|
|
32
|
+
BulkFetchRequest, BulkFetchInput, BulkFetchRawChannel } from './ports/resources/messages.js';
|
|
33
|
+
export type { AwaitMessageInput, CollectedMessageInfo, CollectMessagesInput, CollectReactionsInput, CollectorsResources, ReactionVote } from './ports/resources/collectors.js';
|
|
33
34
|
export type { WebhookInfo, WebhookSendInput, WebhooksResources } from './ports/resources/webhooks.js';
|
|
34
35
|
export type { EmojiInfo, EmojiCreateInput, EmojiBulkResult, StickerInfo, StickerCreateInput, StickerEditInput, ExpressionsResources } from './ports/resources/expressions.js';
|
|
35
36
|
export type { ThreadInfo, ThreadMemberInfo, ThreadMemberDetails, ThreadCreateInput, ForumPostInput, ThreadsResources, ThreadEditInput, ThreadSearchInput, ThreadSearchPage, ArchivedThreadsInput, ThreadListPage } from './ports/resources/threads.js';
|
|
36
37
|
export type { InviteInfo, InviteCreateInput, InvitesResources } from './ports/resources/invites.js';
|
|
38
|
+
export type { GatewayMembersRequest, ChannelCountsRequest, ForumUnreadsRequest, ThreadSubscriptionInput, GatewayResources } from './ports/resources/gateway.js';
|
|
39
|
+
export type { InstanceEndpointsInfo, InstanceFeaturesInfo, InstanceServicesInfo, InstanceInfo, GatewayInfo, ApplicationInfo,
|
|
40
|
+
EmojiMetadataInfo, StickerMetadataInfo, EmojiReference, InstanceResources } from './ports/resources/instance.js';
|
|
41
|
+
export type { SudoVerification, SelfGuildInfo, SelfResources } from './ports/resources/self.js';
|
|
42
|
+
export type { CacheLimitsInfo, CacheStatsInfo, MessageSweepInput, MemberSweepInput, CacheResources } from './ports/resources/cache.js';
|
|
37
43
|
export type { AttachmentSpec, BinaryAttachmentSpec, PresenceStatus, ActivityType, ActivityInfo } from './ports/resources/common.js';
|
|
38
44
|
export { NativeModeration } from './services/native-moderation.js';
|
|
39
45
|
export type { NativeModerationOptions, NativeBanOptions, NativeTimeoutOptions, NativeMoveOptions, NativeVoiceOptions, ModerationTarget } from './services/native-moderation.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Client } from '@fluxerjs/core';
|
|
2
|
+
import { YuzuhaError } from '../../../errors.js';
|
|
3
|
+
import type { CacheResources } from '../../../ports/resources/cache.js';
|
|
4
|
+
import { toMessageInfo } from './messages.js';
|
|
5
|
+
import { toMemberInfo } from './users.js';
|
|
6
|
+
|
|
7
|
+
function bounded(value: number): number | null {
|
|
8
|
+
return Number.isFinite(value) ? value : null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createCacheResources(client: Client): CacheResources {
|
|
12
|
+
return {
|
|
13
|
+
async stats() {
|
|
14
|
+
const sizes = client.cache.stats();
|
|
15
|
+
const messages = client._messageCacheStats();
|
|
16
|
+
const limits = client.cache.limits;
|
|
17
|
+
return {
|
|
18
|
+
...sizes,
|
|
19
|
+
messages: messages.messages,
|
|
20
|
+
messageChannels: messages.channels,
|
|
21
|
+
limits: {
|
|
22
|
+
guilds: bounded(limits.guilds),
|
|
23
|
+
channels: bounded(limits.channels),
|
|
24
|
+
users: bounded(limits.users),
|
|
25
|
+
members: bounded(limits.members),
|
|
26
|
+
messages: limits.messages === false ? false : bounded(limits.messages),
|
|
27
|
+
roles: bounded(limits.roles),
|
|
28
|
+
emojis: bounded(limits.emojis),
|
|
29
|
+
stickers: bounded(limits.stickers),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
async sweepMessages(input = {}) {
|
|
34
|
+
const { channelID, maxAgeMs, keep } = input;
|
|
35
|
+
if (maxAgeMs !== undefined && (!Number.isSafeInteger(maxAgeMs) || maxAgeMs < 0)) {
|
|
36
|
+
throw new YuzuhaError('SWEEP_AGE', 'maxAgeMs deve ser um inteiro não negativo.');
|
|
37
|
+
}
|
|
38
|
+
const cutoff = maxAgeMs === undefined ? null : Date.now() - maxAgeMs;
|
|
39
|
+
return client.sweepMessages((message, channelId) => {
|
|
40
|
+
if (cutoff !== null && message.createdAt.getTime() >= cutoff) return false;
|
|
41
|
+
return keep ? !keep(toMessageInfo(message), channelId) : true;
|
|
42
|
+
}, channelID);
|
|
43
|
+
},
|
|
44
|
+
async sweepMembers(input = {}) {
|
|
45
|
+
const { guildID, keep } = input;
|
|
46
|
+
return client.sweepMembers((member, guildId) => {
|
|
47
|
+
if (guildID !== undefined && guildId !== guildID) return false;
|
|
48
|
+
return keep ? !keep(toMemberInfo(member), guildId) : true;
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -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
|
}
|
|
@@ -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
|
+
}
|