micup.ts 1.0.0 → 1.1.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.
Files changed (94) hide show
  1. package/README.md +93 -38
  2. package/README.tr.md +137 -0
  3. package/dist/bot/client.d.ts +79 -0
  4. package/dist/bot/client.js +299 -0
  5. package/dist/events/background.d.ts +7 -0
  6. package/dist/events/background.js +23 -0
  7. package/dist/events/catalog.d.ts +243 -0
  8. package/dist/events/catalog.js +1 -0
  9. package/dist/events/guild-tag.d.ts +9 -0
  10. package/dist/events/guild-tag.js +38 -0
  11. package/dist/events/mux.d.ts +20 -5
  12. package/dist/events/names.d.ts +1 -0
  13. package/dist/events/names.js +71 -0
  14. package/dist/events/safe.d.ts +9 -0
  15. package/dist/events/safe.js +27 -0
  16. package/dist/gateway/compression.d.ts +9 -0
  17. package/dist/gateway/compression.js +119 -0
  18. package/dist/gateway/connection.js +42 -17
  19. package/dist/gateway/protocol.d.ts +4 -1
  20. package/dist/gateway/protocol.js +9 -3
  21. package/dist/gateway/subscription.d.ts +10 -0
  22. package/dist/gateway/subscription.js +26 -0
  23. package/dist/index.d.ts +48 -4
  24. package/dist/index.js +19 -3
  25. package/dist/model/components.d.ts +82 -0
  26. package/dist/model/components.js +74 -0
  27. package/dist/model/constants.d.ts +330 -0
  28. package/dist/model/constants.js +330 -0
  29. package/dist/model/embed.d.ts +59 -0
  30. package/dist/model/embed.js +40 -0
  31. package/dist/model/entities.d.ts +125 -0
  32. package/dist/model/entities.js +12 -0
  33. package/dist/model/format.d.ts +32 -0
  34. package/dist/model/format.js +61 -0
  35. package/dist/model/guild.d.ts +114 -1
  36. package/dist/model/helpers.d.ts +88 -0
  37. package/dist/model/helpers.js +185 -0
  38. package/dist/model/interaction.d.ts +1 -1
  39. package/dist/model/locale.d.ts +15 -0
  40. package/dist/model/locale.js +55 -0
  41. package/dist/model/media.d.ts +23 -0
  42. package/dist/model/media.js +65 -0
  43. package/dist/model/permissions.d.ts +5 -0
  44. package/dist/model/permissions.js +31 -0
  45. package/dist/rest/attachments.d.ts +26 -0
  46. package/dist/rest/attachments.js +82 -0
  47. package/dist/rest/channels.d.ts +87 -3
  48. package/dist/rest/channels.js +181 -2
  49. package/dist/rest/commands.d.ts +1 -0
  50. package/dist/rest/commands.js +17 -0
  51. package/dist/rest/discovery.d.ts +35 -0
  52. package/dist/rest/discovery.js +33 -0
  53. package/dist/rest/errors.d.ts +38 -0
  54. package/dist/rest/errors.js +46 -0
  55. package/dist/rest/expressions.d.ts +65 -0
  56. package/dist/rest/expressions.js +89 -0
  57. package/dist/rest/guilds.d.ts +102 -1
  58. package/dist/rest/guilds.js +127 -0
  59. package/dist/rest/identity.d.ts +1 -0
  60. package/dist/rest/identity.js +15 -0
  61. package/dist/rest/interactions.d.ts +1 -1
  62. package/dist/rest/messages.d.ts +54 -30
  63. package/dist/rest/messages.js +32 -12
  64. package/dist/rest/rooms.d.ts +142 -0
  65. package/dist/rest/rooms.js +133 -0
  66. package/dist/rest/sounds.d.ts +44 -0
  67. package/dist/rest/sounds.js +89 -0
  68. package/dist/rest/transport.d.ts +8 -2
  69. package/dist/rest/transport.js +38 -5
  70. package/dist/rest/users.d.ts +65 -0
  71. package/dist/rest/users.js +63 -0
  72. package/dist/rest/webhooks.d.ts +56 -0
  73. package/dist/rest/webhooks.js +94 -0
  74. package/dist/session/inventory.d.ts +22 -0
  75. package/dist/session/inventory.js +159 -0
  76. package/dist/session/session.d.ts +21 -2
  77. package/dist/session/session.js +61 -4
  78. package/dist/session/voice.d.ts +1 -0
  79. package/dist/session/voice.js +25 -17
  80. package/dist/shard/manager.d.ts +38 -1
  81. package/dist/shard/manager.js +87 -0
  82. package/dist/state/cache.d.ts +6 -1
  83. package/dist/state/cache.js +45 -1
  84. package/docs/README.md +13 -0
  85. package/docs/commands-and-interactions.md +120 -0
  86. package/docs/errors-and-limits.md +79 -0
  87. package/docs/gateway-and-sharding.md +102 -0
  88. package/docs/getting-started.md +79 -0
  89. package/docs/migrating.md +44 -0
  90. package/docs/rest-reference.md +101 -0
  91. package/docs/voice.md +95 -0
  92. package/package.json +25 -7
  93. package/dist/rest/client.d.ts +0 -48
  94. package/dist/rest/client.js +0 -151
package/README.md CHANGED
@@ -1,80 +1,135 @@
1
1
  # micup.ts
2
2
 
3
- TypeScript SDK for Micup bots (Fluxer API), based on [micup.go](https://github.com/yestefir/micup.go). The SDK includes API discovery, REST requests and supervised Gateway sessions.
3
+ The TypeScript SDK for [Micup](https://micup.gg) bots. It connects a bot to the Micup Gateway and REST API with reconnects, resume, sharding, rate-limit handling and full type declarations, and covers slash commands, buttons, select menus, modals, soundboard, voice rooms and voice playback.
4
4
 
5
- Requires Node.js 22 or later and a Micup bot token. The build produces JavaScript and TypeScript declarations. Install it with:
5
+ [Türkçe README](README.tr.md) · [Docs](docs/README.md) · [Changelog](CHANGELOG.md)
6
6
 
7
7
  ```sh
8
8
  npm install micup.ts
9
9
  ```
10
10
 
11
+ Requires Node.js 22 or later and a Micup bot token. Based on [micup.go](https://github.com/yestefir/micup.go), the Go library that runs production bots.
12
+
13
+ ## Quick start
14
+
15
+ Send a message:
16
+
11
17
  ```js
12
18
  import { MicupClient } from 'micup.ts';
13
19
 
14
20
  const client = await MicupClient.connect({ token: process.env.MICUP_BOT_TOKEN });
15
- const user = await client.getCurrentUser();
16
- console.log(user.username);
17
-
21
+ console.log(client.self.username);
18
22
  await client.sendMessage(process.env.MICUP_CHANNEL_ID, 'Merhaba!');
19
23
  ```
20
24
 
21
- Supply a message ID as `{ replyTo: '123456789' }` in the third argument to send a reply. Supply an `AbortSignal` as `{ signal }` to cancel an operation. HTTP errors expose `status`, the Micup error `code` when present, and the raw `retryAfter` header when present.
25
+ Answer a command and a button:
22
26
 
23
- ## Gateway
27
+ ```js
28
+ import { EventMux, InteractionRouter, MicupClient, actionRow, primaryButton } from 'micup.ts';
24
29
 
25
- Use a session to keep a bot connected and receive events.
30
+ const client = await MicupClient.connect({ token: process.env.MICUP_BOT_TOKEN });
31
+ await client.commands.create({ name: 'ping', description: 'Check the bot' }, { guildId: process.env.MICUP_GUILD_ID });
26
32
 
27
- ```js
28
- import { EventMux, MicupClient } from 'micup.ts';
33
+ const router = new InteractionRouter()
34
+ .command('ping', (interaction, signal) =>
35
+ client.interactions.respond(interaction, {
36
+ content: 'pong',
37
+ components: [actionRow(primaryButton('again', 'Again'))],
38
+ }, { signal }))
39
+ .component('again', (interaction, signal) =>
40
+ client.interactions.update(interaction, { content: 'pong again', components: [] }, { signal }));
29
41
 
30
- const bot = await MicupClient.connect({ token: process.env.MICUP_BOT_TOKEN });
31
42
  const events = new EventMux();
32
- events.on('MESSAGE_CREATE', async (message, event, signal) => {
33
- if (message.author.bot || message.content !== '!ping') return;
34
- await bot.sendMessage(message.channel_id, 'pong', { replyTo: message.id, signal });
35
- });
43
+ events.on('INTERACTION_CREATE', (interaction, event, signal) => router.handle(interaction, signal));
44
+
36
45
  const stop = new AbortController();
37
46
  process.once('SIGINT', () => stop.abort());
38
- process.once('SIGTERM', () => stop.abort());
39
- await bot.newSession({ handler: events.handle }).run({ signal: stop.signal });
47
+ await client.newSession({ handler: events.handle }).run({ signal: stop.signal });
40
48
  ```
41
49
 
42
- The session reconnects with backoff and resumes from the last successfully processed sequence. A failed handler can receive the event again, so make externally visible effects safe to repeat. The handler's signal is aborted when the connection or session is replaced. Unknown event names can be registered with the mux and have an `unknown` payload until you provide a type.
50
+ `client.newSession().run()` reconnects with backoff and resumes from the last processed sequence. A failed handler can receive its event again, so keep externally visible effects safe to repeat.
51
+
52
+ ## What is inside
43
53
 
44
- With `bot.newShardManager({ shardCount, session: { handler: events.handle } })`, a single process can run multiple shards. The manager spaces IDENTIFY commands and `manager.forGuild(guildId)` returns the local session responsible for a guild.
54
+ | Area | What you get | Start here |
55
+ | --- | --- | --- |
56
+ | Client | Authenticated REST with rate-limit waits, retries, audit-log reasons, `AbortSignal` support, bot identity (`self`, `application()`, `tokenId`) | `MicupClient` |
57
+ | Gateway | Supervised sessions with resume, heartbeat checks, Zstandard compression, presence, lazy subscriptions, member inventories, guild and channel counts | `client.newSession()` |
58
+ | Sharding | Shard manager that spaces IDENTIFY, routes guilds to shards and recommends a shard count | `client.newShardManager()` |
59
+ | State | Cache of guilds, channels, threads, members, roles and voice states with permission and hierarchy checks | `session.state` |
60
+ | Commands and interactions | Slash and context menu commands, autocomplete, buttons, select menus, modals, deferred and private replies, follow-ups, routing by name | `client.commands`, `client.interactions`, `InteractionRouter` |
61
+ | Messages | Send, edit, reply, forward, crosspost, search, bulk delete, embeds, direct uploads, embed suppression, reactions, pins | `client.sendMessage()`, `client.channels`, `client.attachments` |
62
+ | Servers | Guild, member, role, ban, timeout, audit log, vanity URL, channel layout, invites, threads and forums, webhooks | `client.guilds`, `client.channels`, `client.webhooks` |
63
+ | Expressions | Emoji and sticker listing, creation, cloning, bulk creation | `client.expressions` |
64
+ | Sound | Soundboard sounds, playback in a voice channel, guild and channel notification sounds | `client.sounds` |
65
+ | Voice rooms | The 3D room stage (board or video on the room TV, host, effects) and room tournaments | `client.rooms` |
66
+ | Discovery | Read, apply for, edit and withdraw a server discovery listing | `client.discovery` |
67
+ | Events | A typed catalog of Gateway events, an event mux and handler wrappers | `EventMux`, `knownGatewayEvents`, `safeHandler()` |
68
+ | Helpers | Constant groups, button and select builders, command option readers, permission helpers, mentions, timestamps, snowflakes, localized message catalogs | `ChannelType`, `primaryButton()`, `optionString()`, `permissionNames()` |
69
+ | Voice playback | LiveKit audio with FFmpeg decoding, PCM player and a connection object with events | [`@micupts/voice`](packages/voice) |
45
70
 
46
- ## Commands and interactions
71
+ Everything takes an optional `AbortSignal`. HTTP failures throw `MicupAPIError` with `status`, `code`, field errors, `retryAfter` and helpers such as `notFound`, `rateLimited` and `hasFieldCode()`. `MicupErrorCode` names the error codes.
47
72
 
48
- Register slash commands for a development guild using `client.commands.set`. Omit `guildId` to register globally.
73
+ ## More examples
74
+
75
+ Read command options and open a modal:
49
76
 
50
77
  ```js
51
- import { EventMux, InteractionRouter, MicupClient } from 'micup.ts';
78
+ import { modalRows, optionString, shortInput } from 'micup.ts';
52
79
 
53
- const client = await MicupClient.connect({ token: process.env.MICUP_BOT_TOKEN });
54
- await client.commands.set([{ name: 'ping', description: 'Check the bot' }], {
55
- guildId: process.env.MICUP_GUILD_ID,
80
+ router.command('hello', async (interaction, signal) => {
81
+ const name = optionString(interaction.data, 'name') ?? 'there';
82
+ await client.interactions.respond(interaction, `Hello ${name}`, { ephemeral: true, signal });
56
83
  });
57
84
 
58
- const router = new InteractionRouter().command('ping', (interaction, signal) =>
59
- client.interactions.respond(interaction, 'pong', { signal }),
60
- );
61
- const events = new EventMux();
62
- events.on('INTERACTION_CREATE', async (interaction, event, signal) => {
63
- await router.handle(interaction, signal);
64
- });
65
- await client.newSession({ handler: events.handle }).run();
85
+ router.command('feedback', (interaction, signal) =>
86
+ client.interactions.modal(interaction, {
87
+ title: 'Feedback',
88
+ custom_id: 'feedback',
89
+ components: modalRows(shortInput('subject', 'Subject')),
90
+ }, { signal }));
66
91
  ```
67
92
 
68
- The router also handles autocomplete, buttons, select menus and modal submissions. Use `client.interactions.defer` and `editResponse` when work needs more time.
93
+ Run several shards and move slow work off the Gateway handler:
69
94
 
70
- ## Server administration
95
+ ```js
96
+ import { background } from 'micup.ts';
71
97
 
72
- Use the `client.guilds` and `client.channels` APIs for members, roles, channel permissions, threads, pins, reactions and invitations. Each Gateway session exposes `session.state` for cached guilds, channels, members, voice states and permission checks.
98
+ const manager = client.newShardManager({
99
+ shardCount: await client.recommendedShards(),
100
+ session: { handler: events.handle, compress: true, trackMembers: true },
101
+ });
102
+ void background(async (signal) => { await slowSearch(signal); }, { timeoutMs: 30_000, name: 'search' });
103
+ await manager.run({ signal: stop.signal });
104
+ ```
105
+
106
+ Log requests that fail because the bot lacks a permission, at most once a minute per route:
107
+
108
+ ```js
109
+ const client = await MicupClient.connect({
110
+ token: process.env.MICUP_BOT_TOKEN,
111
+ logger: { warn: (message, fields) => console.warn(message, fields) },
112
+ });
113
+ ```
73
114
 
74
115
  ## Voice
75
116
 
76
- The optional [`@micupts/voice`](packages/voice) workspace publishes audio to LiveKit. Install it with `npm install @micupts/voice` when your bot needs audio playback.
117
+ [`@micupts/voice`](packages/voice) publishes audio to a voice channel through LiveKit. `VoiceConnection` joins the channel, plays files, URLs, streams or raw PCM, and emits `start`, `finish`, `status`, `memberJoin`, `memberLeave`, `disconnect` and `error`. Install it with `npm install @micupts/voice` and install FFmpeg to decode files and streams.
118
+
119
+ ## Documentation
120
+
121
+ - [Getting started](docs/getting-started.md): token, invite link, first bot, project layout
122
+ - [Commands and interactions](docs/commands-and-interactions.md): commands, options, buttons, selects, modals, autocomplete, private replies
123
+ - [Gateway and sharding](docs/gateway-and-sharding.md): sessions, resume, presence, shards, state cache, events
124
+ - [REST reference](docs/rest-reference.md): every resource and method
125
+ - [Voice](docs/voice.md): joining, playing, regranting, soundboard and voice rooms
126
+ - [Errors and limits](docs/errors-and-limits.md): error handling, rate limits, cancellation, logging
127
+ - [Migrating](docs/migrating.md): from micup.js, micup.gg.js or discord.js
128
+
129
+ ## Reliability
130
+
131
+ The test suite runs the SDK against mocked servers and a local LiveKit room. Releases are also checked end to end against the Micup service with a live bot: commands, autocomplete, buttons, select menus, modals, deferred and private replies, REST resources and voice playback.
77
132
 
78
- Run `npm ci` once, then `npm test` to verify the REST client locally.
133
+ Run `npm ci` once, then `npm test` to verify both workspaces locally.
79
134
 
80
135
  MIT license. See [LICENSE](LICENSE).
package/README.tr.md ADDED
@@ -0,0 +1,137 @@
1
+ # micup.ts
2
+
3
+ [Micup](https://micup.gg) botları için TypeScript SDK'sı. Botu Micup Gateway ve REST API'sine yeniden bağlanma, oturum sürdürme (resume), shard desteği, hız sınırı yönetimi ve tam tip tanımlarıyla bağlar. Slash komutları, butonlar, seçim menüleri, modallar, soundboard, ses odaları ve ses çalmayı kapsar.
4
+
5
+ [English README](README.md) · [Dokümantasyon](docs/README.md) · [Değişiklik günlüğü](CHANGELOG.md)
6
+
7
+ ```sh
8
+ npm install micup.ts
9
+ ```
10
+
11
+ Node.js 22 veya üstü ve bir Micup bot token'ı gerekir. Üretimdeki botları çalıştıran Go kütüphanesi [micup.go](https://github.com/yestefir/micup.go) temel alınmıştır.
12
+
13
+ ## Hızlı başlangıç
14
+
15
+ Mesaj gönderme:
16
+
17
+ ```js
18
+ import { MicupClient } from 'micup.ts';
19
+
20
+ const client = await MicupClient.connect({ token: process.env.MICUP_BOT_TOKEN });
21
+ console.log(client.self.username);
22
+ await client.sendMessage(process.env.MICUP_CHANNEL_ID, 'Merhaba!');
23
+ ```
24
+
25
+ Komut ve butona yanıt verme:
26
+
27
+ ```js
28
+ import { EventMux, InteractionRouter, MicupClient, actionRow, primaryButton } from 'micup.ts';
29
+
30
+ const client = await MicupClient.connect({ token: process.env.MICUP_BOT_TOKEN });
31
+ await client.commands.create({ name: 'ping', description: 'Botu dene' }, { guildId: process.env.MICUP_GUILD_ID });
32
+
33
+ const router = new InteractionRouter()
34
+ .command('ping', (interaction, signal) =>
35
+ client.interactions.respond(interaction, {
36
+ content: 'pong',
37
+ components: [actionRow(primaryButton('again', 'Tekrar'))],
38
+ }, { signal }))
39
+ .component('again', (interaction, signal) =>
40
+ client.interactions.update(interaction, { content: 'tekrar pong', components: [] }, { signal }));
41
+
42
+ const events = new EventMux();
43
+ events.on('INTERACTION_CREATE', (interaction, event, signal) => router.handle(interaction, signal));
44
+
45
+ const stop = new AbortController();
46
+ process.once('SIGINT', () => stop.abort());
47
+ await client.newSession({ handler: events.handle }).run({ signal: stop.signal });
48
+ ```
49
+
50
+ `client.newSession().run()` geri çekilmeyle yeniden bağlanır ve en son işlenen sıradan devam eder. Başarısız bir işleyici aynı olayı yeniden alabilir; dışarıdan görünen işlemleri tekrarlanabilir yazın.
51
+
52
+ ## İçinde neler var
53
+
54
+ | Alan | Ne sağlar | Başlangıç |
55
+ | --- | --- | --- |
56
+ | İstemci | Hız sınırı beklemeli, yeniden denemeli, denetim kaydı sebepli, `AbortSignal` destekli REST; bot kimliği (`self`, `application()`, `tokenId`) | `MicupClient` |
57
+ | Gateway | Resume, kalp atışı denetimi, Zstandard sıkıştırma, durum (presence), tembel abonelikler, üye envanteri ve sayımlar içeren denetlenen oturumlar | `client.newSession()` |
58
+ | Shard | IDENTIFY'ları aralıklayan, sunucuları shard'lara yönlendiren ve shard sayısı öneren yönetici | `client.newShardManager()` |
59
+ | Durum | Sunucu, kanal, thread, üye, rol ve ses durumu önbelleği; izin ve rol hiyerarşisi kontrolleri | `session.state` |
60
+ | Komutlar ve etkileşimler | Slash ve bağlam menüsü komutları, otomatik tamamlama, butonlar, seçim menüleri, modallar, ertelenmiş ve gizli yanıtlar, takip mesajları, isme göre yönlendirme | `client.commands`, `client.interactions`, `InteractionRouter` |
61
+ | Mesajlar | Gönderme, düzenleme, yanıt, iletme, yayınlama, arama, toplu silme, embed, doğrudan yükleme, embed gizleme, tepki, sabitleme | `client.sendMessage()`, `client.channels`, `client.attachments` |
62
+ | Sunucu yönetimi | Sunucu, üye, rol, ban, zaman aşımı, denetim kaydı, özel davet adresi, kanal düzeni, davetler, thread ve forum, webhook | `client.guilds`, `client.channels`, `client.webhooks` |
63
+ | İfadeler | Emoji ve çıkartma listeleme, oluşturma, kopyalama, toplu oluşturma | `client.expressions` |
64
+ | Ses efektleri | Soundboard sesleri, ses kanalında çalma, sunucu ve kanal bildirim sesleri | `client.sounds` |
65
+ | Ses odaları | 3D oda sahnesi (oda TV'sinde pano veya video, host, efektler) ve oda turnuvaları | `client.rooms` |
66
+ | Keşif | Sunucu keşif kaydını okuma, başvuru, düzenleme ve geri çekme | `client.discovery` |
67
+ | Olaylar | Tipli Gateway olay kataloğu, olay çoklayıcı ve işleyici sarmalayıcıları | `EventMux`, `knownGatewayEvents`, `safeHandler()` |
68
+ | Yardımcılar | Sabit grupları, buton ve seçim menüsü oluşturucular, komut seçeneği okuyucuları, izin yardımcıları, etiketleme, zaman damgası, snowflake, yerelleştirilmiş mesaj kataloğu | `ChannelType`, `primaryButton()`, `optionString()`, `permissionNames()` |
69
+ | Ses çalma | FFmpeg çözmeli LiveKit sesi, PCM oynatıcı ve olay yayan bağlantı nesnesi | [`@micupts/voice`](packages/voice) |
70
+
71
+ Her çağrı isteğe bağlı `AbortSignal` alır. HTTP hataları `status`, `code`, alan hataları, `retryAfter` ve `notFound`, `rateLimited`, `hasFieldCode()` gibi yardımcılarla `MicupAPIError` olarak gelir. Hata kodlarının adları `MicupErrorCode` içindedir.
72
+
73
+ ## Daha fazla örnek
74
+
75
+ Komut seçeneğini okuma ve modal açma:
76
+
77
+ ```js
78
+ import { modalRows, optionString, shortInput } from 'micup.ts';
79
+
80
+ router.command('merhaba', async (interaction, signal) => {
81
+ const name = optionString(interaction.data, 'isim') ?? 'dostum';
82
+ await client.interactions.respond(interaction, `Merhaba ${name}`, { ephemeral: true, signal });
83
+ });
84
+
85
+ router.command('geri-bildirim', (interaction, signal) =>
86
+ client.interactions.modal(interaction, {
87
+ title: 'Geri bildirim',
88
+ custom_id: 'feedback',
89
+ components: modalRows(shortInput('subject', 'Konu')),
90
+ }, { signal }));
91
+ ```
92
+
93
+ Birden çok shard çalıştırma ve yavaş işi Gateway işleyicisinden ayırma:
94
+
95
+ ```js
96
+ import { background } from 'micup.ts';
97
+
98
+ const manager = client.newShardManager({
99
+ shardCount: await client.recommendedShards(),
100
+ session: { handler: events.handle, compress: true, trackMembers: true },
101
+ });
102
+ void background(async (signal) => { await slowSearch(signal); }, { timeoutMs: 30_000, name: 'search' });
103
+ await manager.run({ signal: stop.signal });
104
+ ```
105
+
106
+ Botun izni olmadığı için başarısız olan istekleri, rota başına dakikada en fazla bir kez günlüğe yazma:
107
+
108
+ ```js
109
+ const client = await MicupClient.connect({
110
+ token: process.env.MICUP_BOT_TOKEN,
111
+ logger: { warn: (message, fields) => console.warn(message, fields) },
112
+ });
113
+ ```
114
+
115
+ ## Ses
116
+
117
+ [`@micupts/voice`](packages/voice) sesi LiveKit üzerinden ses kanalına yayınlar. `VoiceConnection` kanala girer; dosya, URL, akış veya ham PCM çalar ve `start`, `finish`, `status`, `memberJoin`, `memberLeave`, `disconnect`, `error` olaylarını yayar. `npm install @micupts/voice` ile kurun; dosya ve akışları çözmek için FFmpeg kurun.
118
+
119
+ ## Dokümantasyon
120
+
121
+ - [Başlangıç](docs/getting-started.md): token, davet bağlantısı, ilk bot, proje düzeni
122
+ - [Komutlar ve etkileşimler](docs/commands-and-interactions.md)
123
+ - [Gateway ve shard](docs/gateway-and-sharding.md)
124
+ - [REST başvurusu](docs/rest-reference.md)
125
+ - [Ses](docs/voice.md)
126
+ - [Hatalar ve sınırlar](docs/errors-and-limits.md)
127
+ - [Geçiş rehberi](docs/migrating.md): micup.js, micup.gg.js veya discord.js'ten
128
+
129
+ Dokümanlar İngilizcedir.
130
+
131
+ ## Güvenilirlik
132
+
133
+ Test paketi SDK'yı sahte sunucular ve yerel bir LiveKit odasına karşı çalıştırır. Sürümler ayrıca canlı bir botla Micup servisine karşı uçtan uca denenir: komutlar, otomatik tamamlama, butonlar, seçim menüleri, modallar, ertelenmiş ve gizli yanıtlar, REST kaynakları ve ses çalma.
134
+
135
+ İki çalışma alanını yerelde doğrulamak için bir kez `npm ci`, ardından `npm test` çalıştırın.
136
+
137
+ MIT lisansı. Bkz. [LICENSE](LICENSE).
@@ -0,0 +1,79 @@
1
+ import { GatewaySession, type GatewaySessionConfig, type GatewaySessionOptions } from '../session/session.js';
2
+ import { ShardManager, type ShardManagerOptions } from '../shard/manager.js';
3
+ import { type MicupLogger, type MicupRequestOptions, type RestMethod, type RestRequestOptions } from '../rest/transport.js';
4
+ import type { MicupApplication } from '../rest/users.js';
5
+ import { type ListMessageOptions, type MessageForward, type MessageInput, type MessageSearch, type MessageSearchResult } from '../rest/messages.js';
6
+ import { MicupCommands } from '../rest/commands.js';
7
+ import { MicupInteractions } from '../rest/interactions.js';
8
+ import { MicupGuilds } from '../rest/guilds.js';
9
+ import { MicupChannels } from '../rest/channels.js';
10
+ import type { MicupMessage, MicupUser } from '../model/entities.js';
11
+ import { MicupAttachments } from '../rest/attachments.js';
12
+ import { MicupWebhooks } from '../rest/webhooks.js';
13
+ import { MicupUsers } from '../rest/users.js';
14
+ import { MicupExpressions } from '../rest/expressions.js';
15
+ import { MicupSounds } from '../rest/sounds.js';
16
+ import { MicupDiscovery } from '../rest/discovery.js';
17
+ import { MicupVoiceRooms } from '../rest/rooms.js';
18
+ import { MicupMedia } from '../model/media.js';
19
+ export interface MicupClientOptions {
20
+ token: string;
21
+ origin?: string;
22
+ maxRestAttempts?: number;
23
+ logger?: MicupLogger;
24
+ }
25
+ export declare class MicupClient {
26
+ #private;
27
+ readonly interactions: MicupInteractions;
28
+ readonly guilds: MicupGuilds;
29
+ readonly channels: MicupChannels;
30
+ readonly attachments: MicupAttachments;
31
+ readonly webhooks: MicupWebhooks;
32
+ readonly users: MicupUsers;
33
+ readonly expressions: MicupExpressions;
34
+ readonly sounds: MicupSounds;
35
+ readonly discovery: MicupDiscovery;
36
+ readonly rooms: MicupVoiceRooms;
37
+ readonly media: MicupMedia;
38
+ readonly inviteBase: string;
39
+ private constructor();
40
+ static connect({ token, origin, maxRestAttempts, logger }: MicupClientOptions, { signal }?: MicupRequestOptions): Promise<MicupClient>;
41
+ get self(): MicupUser;
42
+ get tokenId(): string | undefined;
43
+ application(options?: MicupRequestOptions): Promise<MicupApplication>;
44
+ applicationId(options?: MicupRequestOptions): Promise<string>;
45
+ get commands(): MicupCommands;
46
+ newSession(options: GatewaySessionOptions, shard?: Pick<GatewaySessionConfig, 'shardId' | 'shardCount'>): GatewaySession;
47
+ newShardManager(options: ShardManagerOptions): ShardManager;
48
+ gateway(options: GatewaySessionOptions, runOptions?: {
49
+ signal?: AbortSignal;
50
+ }): Promise<void>;
51
+ recommendedShards(options?: MicupRequestOptions): Promise<number>;
52
+ botInviteURL({ scopes, permissions, guildId }?: {
53
+ scopes?: readonly string[];
54
+ permissions?: bigint;
55
+ guildId?: string;
56
+ }): string;
57
+ getCurrentUser({ signal }?: MicupRequestOptions): Promise<MicupUser>;
58
+ sendMessage(channelId: string, content: string | MessageInput, { replyTo, signal }?: MicupRequestOptions & {
59
+ replyTo?: string;
60
+ }): Promise<MicupMessage>;
61
+ getMessage(channelId: string, messageId: string, options?: MicupRequestOptions): Promise<MicupMessage>;
62
+ listMessages(channelId: string, options?: ListMessageOptions): Promise<MicupMessage[]>;
63
+ iterateMessages(channelId: string, options?: Omit<ListMessageOptions, 'around' | 'limit'>): AsyncGenerator<MicupMessage>;
64
+ editMessage(channelId: string, messageId: string, edit: MessageInput, options?: MicupRequestOptions): Promise<MicupMessage>;
65
+ suppressEmbeds(channelId: string, messageId: string, suppress?: boolean, options?: MicupRequestOptions): Promise<MicupMessage>;
66
+ deleteMessage(channelId: string, messageId: string, options?: MicupRequestOptions & {
67
+ reason?: string;
68
+ }): Promise<void>;
69
+ triggerTyping(channelId: string, options?: MicupRequestOptions): Promise<void>;
70
+ sendDM(userId: string, message: string | MessageInput, options?: MicupRequestOptions): Promise<MicupMessage>;
71
+ forwardMessage(channelId: string, forward: MessageForward, { signal, nonce, flags }?: MicupRequestOptions & Pick<MessageInput, 'nonce' | 'flags'>): Promise<MicupMessage>;
72
+ crosspostMessage(channelId: string, messageId: string, options?: MicupRequestOptions): Promise<MicupMessage>;
73
+ bulkDeleteMessages(channelId: string, messageIds: readonly string[], options?: MicupRequestOptions & {
74
+ reason?: string;
75
+ }): Promise<void>;
76
+ deleteAttachment(channelId: string, messageId: string, attachmentId: string, options?: MicupRequestOptions): Promise<void>;
77
+ searchMessages(search: MessageSearch, options?: MicupRequestOptions): Promise<MessageSearchResult>;
78
+ request<T = unknown>(method: RestMethod, path: string, options?: RestRequestOptions): Promise<T>;
79
+ }