lunibee 0.1.7 → 0.2.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/LICENSE +21 -21
- package/README.md +225 -223
- package/dist/builders/commands.d.ts +6 -4
- package/dist/builders/components.d.ts +23 -0
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/index.js +120 -24
- package/dist/builders/index.js.map +9 -8
- package/dist/collection/index.d.ts +68 -1
- package/dist/collection/index.js +335 -1
- package/dist/collection/index.js.map +4 -4
- package/dist/core/collector.d.ts +13 -0
- package/dist/core/events.d.ts +112 -2
- package/dist/core/index.d.ts +30 -93
- package/dist/core/index.js +3386 -957
- package/dist/core/index.js.map +48 -24
- package/dist/core/permissions.d.ts +48 -0
- package/dist/formatters/index.js.map +1 -1
- package/dist/handlers/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3806 -1193
- package/dist/index.js.map +64 -43
- package/dist/managers/advanced.d.ts +116 -0
- package/dist/managers/base.d.ts +13 -2
- package/dist/managers/emoji.d.ts +1 -1
- package/dist/managers/guild-resources.d.ts +109 -0
- package/dist/managers/guild.d.ts +33 -2
- package/dist/managers/index.d.ts +44 -6
- package/dist/managers/index.js +1186 -150
- package/dist/managers/index.js.map +27 -21
- package/dist/managers/message.d.ts +10 -1
- package/dist/rest/decoder.d.ts +23 -0
- package/dist/rest/errors.d.ts +53 -0
- package/dist/rest/index.d.ts +21 -17
- package/dist/rest/index.js +526 -264
- package/dist/rest/index.js.map +14 -8
- package/dist/rest/limiter.d.ts +42 -0
- package/dist/rest/redis.d.ts +18 -1
- package/dist/rest/route.d.ts +31 -0
- package/dist/rest/routes.d.ts +22 -0
- package/dist/rest/scheduler.d.ts +42 -0
- package/dist/rest/store.d.ts +29 -0
- package/dist/rest/transport.d.ts +40 -0
- package/dist/sharding/bus.d.ts +31 -0
- package/dist/sharding/cluster.d.ts +10 -0
- package/dist/sharding/index.d.ts +39 -2
- package/dist/sharding/index.js +1105 -404
- package/dist/sharding/index.js.map +18 -8
- package/dist/structures/base.d.ts +10 -0
- package/dist/structures/channels.d.ts +56 -0
- package/dist/structures/index.d.ts +1 -0
- package/dist/structures/index.js +305 -311
- package/dist/structures/index.js.map +18 -14
- package/dist/structures/interactions.d.ts +38 -52
- package/dist/structures/options.d.ts +55 -0
- package/dist/structures/resources.d.ts +3 -3
- package/dist/types/gateway-events.d.ts +132 -0
- package/dist/types/gateway.d.ts +197 -0
- package/dist/types/index.d.ts +53 -260
- package/dist/types/index.js +44 -2
- package/dist/types/index.js.map +5 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/voice/index.d.ts +32 -1
- package/dist/voice/index.js +73 -7
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/close-codes.d.ts +23 -0
- package/dist/ws/decoder.d.ts +58 -0
- package/dist/ws/heartbeat.d.ts +87 -0
- package/dist/ws/index.d.ts +18 -65
- package/dist/ws/index.js +911 -385
- package/dist/ws/index.js.map +15 -5
- package/dist/ws/opcodes.d.ts +14 -0
- package/dist/ws/protocol.d.ts +110 -0
- package/dist/ws/reconnect.d.ts +108 -0
- package/dist/ws/send-budget.d.ts +17 -0
- package/dist/ws/session.d.ts +100 -0
- package/dist/ws/state.d.ts +27 -0
- package/dist/ws/transport.d.ts +80 -0
- package/package.json +21 -20
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Ekretos
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ekretos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,223 +1,225 @@
|
|
|
1
|
-
# Lunibee 🐝
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/lunibee)
|
|
4
|
-
[](https://www.npmjs.com/package/lunibee)
|
|
5
|
-
[](https://discord.gg/SSADgyBpgw)
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/lunibee)
|
|
8
|
-
|
|
9
|
-
A lightweight, Bun-first Discord API library for TypeScript.
|
|
10
|
-
|
|
11
|
-
## Requirements
|
|
12
|
-
|
|
13
|
-
- [Bun](https://bun.sh/) for the supported runtime and package manager
|
|
14
|
-
- TypeScript for typed application development
|
|
15
|
-
- A Discord bot token for connecting to Discord
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
For repository development:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
bun install
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
For application usage, install the published `lunibee` package when a release is available:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
bun add lunibee
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Documentation
|
|
32
|
-
|
|
33
|
-
Full documentation, practical guides, and API references are available at **[lunibee.js.org](https://lunibee.js.org)**.
|
|
34
|
-
|
|
35
|
-
## Getting started
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import { Client, GatewayIntentBits } from "lunibee";
|
|
39
|
-
|
|
40
|
-
const client = new Client({
|
|
41
|
-
token: process.env.DISCORD_TOKEN!,
|
|
42
|
-
intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
client.on("ready", user => {
|
|
46
|
-
console.log(`Ready as ${user.username}`);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
client.on("messageCreate", message => {
|
|
50
|
-
console.log(message.content);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
await client.login();
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Destroy the client when the application is shutting down:
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
client.destroy();
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Client
|
|
63
|
-
|
|
64
|
-
`Client` is the main application entry point. It coordinates the REST transport, resource managers, Gateway, event dispatch, interactions, and lifecycle state.
|
|
65
|
-
|
|
66
|
-
### Lifecycle
|
|
67
|
-
|
|
68
|
-
```text
|
|
69
|
-
idle → connecting → ready
|
|
70
|
-
↑ ↓
|
|
71
|
-
└──── reconnect ──┘
|
|
72
|
-
|
|
73
|
-
ready → destroyed
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Useful APIs include:
|
|
77
|
-
|
|
78
|
-
- `client.login()` — authenticate and connect to Discord.
|
|
79
|
-
- `client.isReady()` — type guard for a ready client.
|
|
80
|
-
- `client.destroy()` — close the Gateway and clear client-managed resources.
|
|
81
|
-
- `client.rest` — access the REST transport.
|
|
82
|
-
- `client.users`, `client.guilds`, `client.channels` — resource managers.
|
|
83
|
-
|
|
84
|
-
## Gateway
|
|
85
|
-
|
|
86
|
-
The Gateway package implements the Discord WebSocket lifecycle:
|
|
87
|
-
|
|
88
|
-
```text
|
|
89
|
-
CONNECT → HELLO → IDENTIFY/RESUME → READY → DISPATCH
|
|
90
|
-
↘ HEARTBEAT / ACK
|
|
91
|
-
↓
|
|
92
|
-
RECONNECT
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
The Gateway tracks sequence numbers and sessions, handles Discord resume URLs, heartbeat acknowledgement timeouts, invalid sessions, server reconnect requests, and stale/zombie connections.
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
import { Gateway } from "@lunibee/ws";
|
|
99
|
-
|
|
100
|
-
const gateway = new Gateway({
|
|
101
|
-
token: process.env.DISCORD_TOKEN!,
|
|
102
|
-
intents: 513
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
await gateway.connect();
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## REST
|
|
109
|
-
|
|
110
|
-
The REST client supports Discord bucket-aware rate limiting and retries. It consumes Discord's rate-limit headers including bucket identifiers, remaining requests, reset information, and `Retry-After`.
|
|
111
|
-
|
|
112
|
-
Requests accept an `AbortSignal`:
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
const controller = new AbortController();
|
|
116
|
-
|
|
117
|
-
const request = client.rest.get("/users/@me", {
|
|
118
|
-
signal: controller.signal
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
controller.abort();
|
|
122
|
-
await request;
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
`RESTError` includes HTTP status, Discord error code, method, path, and the raw error payload when available.
|
|
126
|
-
|
|
127
|
-
## Structures and caching
|
|
128
|
-
|
|
129
|
-
Resource managers maintain canonical instances by Discord resource ID. Re-resolving an already cached resource returns the same structure instance, allowing identity-sensitive application code to remain consistent.
|
|
130
|
-
|
|
131
|
-
REST-created and Gateway-updated resources are routed through manager cache mutation APIs so the same resource is not represented by unrelated structure instances.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Interactions
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
await interaction.
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
- `
|
|
166
|
-
- `
|
|
167
|
-
- `
|
|
168
|
-
- `
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
| `@lunibee/
|
|
199
|
-
| `@lunibee/
|
|
200
|
-
| `@lunibee/
|
|
201
|
-
| `@lunibee/
|
|
202
|
-
| `@lunibee/
|
|
203
|
-
| `@lunibee/
|
|
204
|
-
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
The
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
1
|
+
# Lunibee 🐝
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/lunibee)
|
|
4
|
+
[](https://www.npmjs.com/package/lunibee)
|
|
5
|
+
[](https://discord.gg/SSADgyBpgw)
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/lunibee)
|
|
8
|
+
|
|
9
|
+
A lightweight, Bun-first Discord API library for TypeScript.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- [Bun](https://bun.sh/) for the supported runtime and package manager
|
|
14
|
+
- TypeScript for typed application development
|
|
15
|
+
- A Discord bot token for connecting to Discord
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
For repository development:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bun install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For application usage, install the published `lunibee` package when a release is available:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bun add lunibee
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
Full documentation, practical guides, and API references are available at **[lunibee.js.org](https://lunibee.js.org)**.
|
|
34
|
+
|
|
35
|
+
## Getting started
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { Client, GatewayIntentBits } from "lunibee";
|
|
39
|
+
|
|
40
|
+
const client = new Client({
|
|
41
|
+
token: process.env.DISCORD_TOKEN!,
|
|
42
|
+
intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
client.on("ready", user => {
|
|
46
|
+
console.log(`Ready as ${user.username}`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
client.on("messageCreate", message => {
|
|
50
|
+
console.log(message.content);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await client.login();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Destroy the client when the application is shutting down:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
client.destroy();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Client
|
|
63
|
+
|
|
64
|
+
`Client` is the main application entry point. It coordinates the REST transport, resource managers, Gateway, event dispatch, interactions, and lifecycle state.
|
|
65
|
+
|
|
66
|
+
### Lifecycle
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
idle → connecting → ready
|
|
70
|
+
↑ ↓
|
|
71
|
+
└──── reconnect ──┘
|
|
72
|
+
|
|
73
|
+
ready → destroyed
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Useful APIs include:
|
|
77
|
+
|
|
78
|
+
- `client.login()` — authenticate and connect to Discord.
|
|
79
|
+
- `client.isReady()` — type guard for a ready client.
|
|
80
|
+
- `client.destroy()` — close the Gateway and clear client-managed resources.
|
|
81
|
+
- `client.rest` — access the REST transport.
|
|
82
|
+
- `client.users`, `client.guilds`, `client.channels` — resource managers.
|
|
83
|
+
|
|
84
|
+
## Gateway
|
|
85
|
+
|
|
86
|
+
The Gateway package implements the Discord WebSocket lifecycle:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
CONNECT → HELLO → IDENTIFY/RESUME → READY → DISPATCH
|
|
90
|
+
↘ HEARTBEAT / ACK
|
|
91
|
+
↓
|
|
92
|
+
RECONNECT
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The Gateway tracks sequence numbers and sessions, handles Discord resume URLs, heartbeat acknowledgement timeouts, invalid sessions, server reconnect requests, and stale/zombie connections.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { Gateway } from "@lunibee/ws";
|
|
99
|
+
|
|
100
|
+
const gateway = new Gateway({
|
|
101
|
+
token: process.env.DISCORD_TOKEN!,
|
|
102
|
+
intents: 513
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await gateway.connect();
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## REST
|
|
109
|
+
|
|
110
|
+
The REST client supports Discord bucket-aware rate limiting and retries. It consumes Discord's rate-limit headers including bucket identifiers, remaining requests, reset information, and `Retry-After`.
|
|
111
|
+
|
|
112
|
+
Requests accept an `AbortSignal`:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
const controller = new AbortController();
|
|
116
|
+
|
|
117
|
+
const request = client.rest.get("/users/@me", {
|
|
118
|
+
signal: controller.signal
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
controller.abort();
|
|
122
|
+
await request;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`RESTError` includes HTTP status, Discord error code, method, path, and the raw error payload when available.
|
|
126
|
+
|
|
127
|
+
## Structures and caching
|
|
128
|
+
|
|
129
|
+
Resource managers maintain canonical instances by Discord resource ID. Re-resolving an already cached resource returns the same structure instance, allowing identity-sensitive application code to remain consistent.
|
|
130
|
+
|
|
131
|
+
REST-created and Gateway-updated resources are routed through manager cache mutation APIs so the same resource is not represented by unrelated structure instances.
|
|
132
|
+
|
|
133
|
+
Discord resources are stored with `Collection.setWithoutTTL()` and leave the cache only through Gateway delete events or an explicit `delete()`, never through expiry. Messages are cached only with the `messageCache: { maxSize?, ttl? }` client option, and `cache: { users, members, roles, emojis }` turns off per-resource caching on large bots. For your own data, `new Collection(null, { ttl, maxSize, onEvict })` is a TTL/LRU cache. See the [0.2.0 upgrade guide](https://lunibee.js.org/getting-started/upgrading/).
|
|
134
|
+
|
|
135
|
+
## Permissions
|
|
136
|
+
|
|
137
|
+
`PermissionSet` provides named and raw permission checks:
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
if (member.permissions.has(Permission.manageMessages)) {
|
|
141
|
+
// permitted
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Multiple permissions can be checked together, and immutable `add()` / `remove()` operations return a new bitfield.
|
|
146
|
+
|
|
147
|
+
## Interactions
|
|
148
|
+
|
|
149
|
+
Interactions expose an ergonomic acknowledgement lifecycle:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
if (interaction.isChatInputCommand()) {
|
|
153
|
+
await interaction.deferReply();
|
|
154
|
+
await interaction.editReply({ content: "Done!" });
|
|
155
|
+
await interaction.followUp({ content: "Follow-up" });
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Available lifecycle methods include `reply()`, `deferReply()`, `editReply()`, `deleteReply()`, and `followUp()`.
|
|
160
|
+
|
|
161
|
+
## Builders
|
|
162
|
+
|
|
163
|
+
Lunibee provides strict builders for Discord payloads (Discord.js V2 compatible), including:
|
|
164
|
+
|
|
165
|
+
- `ActionRowBuilder`
|
|
166
|
+
- `ButtonBuilder`
|
|
167
|
+
- `StringSelectBuilder`
|
|
168
|
+
- `EmbedBuilder`
|
|
169
|
+
- `ModalBuilder`
|
|
170
|
+
- `TextInputBuilder`
|
|
171
|
+
|
|
172
|
+
Builders validate Discord limits before serialization and expose typed `toJSON()` payloads.
|
|
173
|
+
|
|
174
|
+
## Sharding
|
|
175
|
+
|
|
176
|
+
`@lunibee/sharding` manages multiple Gateway connections and supports explicit shard counts or Discord's recommended shard count.
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { ShardManager } from "@lunibee/sharding";
|
|
180
|
+
|
|
181
|
+
const shards = new ShardManager({
|
|
182
|
+
token: process.env.DISCORD_TOKEN!,
|
|
183
|
+
intents: 513,
|
|
184
|
+
shardCount: "auto"
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
await shards.connect();
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Call `destroy()` during shutdown. The manager releases its Gateway instances and can initialize a fresh shard set on a later `connect()`.
|
|
191
|
+
|
|
192
|
+
## Package layout
|
|
193
|
+
|
|
194
|
+
The monorepo is organized into focused packages:
|
|
195
|
+
|
|
196
|
+
| Package | Responsibility |
|
|
197
|
+
| --- | --- |
|
|
198
|
+
| `@lunibee/types` | Discord API and shared TypeScript types |
|
|
199
|
+
| `@lunibee/structures` | Discord resource and interaction structures |
|
|
200
|
+
| `@lunibee/managers` | Resource caches and REST-backed managers |
|
|
201
|
+
| `@lunibee/rest` | HTTP transport, routes, rate limits, retries |
|
|
202
|
+
| `@lunibee/ws` | Discord Gateway connection |
|
|
203
|
+
| `@lunibee/core` | Main client and high-level orchestration |
|
|
204
|
+
| `@lunibee/builders` | Typed Discord payload builders |
|
|
205
|
+
| `@lunibee/sharding` | Multi-Gateway shard management |
|
|
206
|
+
| `lunibee` | End-user package entry point |
|
|
207
|
+
|
|
208
|
+
## Development
|
|
209
|
+
|
|
210
|
+
Run the repository's checks before submitting changes:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
bun install
|
|
214
|
+
bunx tsc --noEmit
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Documentation & API Reference
|
|
218
|
+
|
|
219
|
+
The full, official API reference and practical guides are available at **[lunibee.js.org](https://lunibee.js.org)**.
|
|
220
|
+
|
|
221
|
+
The source remains the authoritative API surface while Lunibee is pre-1.0. Public exports are intentionally split by responsibility so applications can import either the high-level `lunibee` package or individual packages when appropriate.
|
|
222
|
+
|
|
223
|
+
## Status
|
|
224
|
+
|
|
225
|
+
Lunibee is in active development and the API may change before the first stable release.
|
|
@@ -116,10 +116,13 @@ export declare class NumberOptionBuilder extends CommandOptionBuilder {
|
|
|
116
116
|
/** Creates a subcommand group. */ constructor();
|
|
117
117
|
/** Adds a subcommand to this group. */ addSubcommand(configure: (option: SubcommandBuilder) => SubcommandBuilder): this;
|
|
118
118
|
}
|
|
119
|
-
/**
|
|
120
|
-
|
|
119
|
+
/** Builder for application commands that appear in right-click context menus.
|
|
120
|
+
* Discord.js-familiar: `new ContextMenuCommandBuilder().setName("x").setType(2)`. */
|
|
121
|
+
export declare class ContextMenuCommandBuilder {
|
|
121
122
|
protected readonly data: Record<string, unknown>;
|
|
122
|
-
constructor(type
|
|
123
|
+
constructor(type?: 2 | 3);
|
|
124
|
+
/** Sets the command type: 2 = USER, 3 = MESSAGE. @throws {RangeError} For any other type. */
|
|
125
|
+
setType(type: 2 | 3): this;
|
|
123
126
|
/** Sets the command name (shown in the right-click menu).
|
|
124
127
|
* Unlike CHAT_INPUT commands, USER (type 2) and MESSAGE (type 3) context-menu
|
|
125
128
|
* command names may contain uppercase letters and spaces, so no lowercase/charset
|
|
@@ -152,4 +155,3 @@ export declare class UserCommandBuilder extends ContextMenuCommandBuilder {
|
|
|
152
155
|
export declare class MessageCommandBuilder extends ContextMenuCommandBuilder {
|
|
153
156
|
constructor();
|
|
154
157
|
}
|
|
155
|
-
export {};
|
|
@@ -35,6 +35,8 @@ export interface APIButtonComponent {
|
|
|
35
35
|
label?: string;
|
|
36
36
|
emoji?: APIComponentEmoji;
|
|
37
37
|
url?: string;
|
|
38
|
+
/** SKU for premium (style 6) buttons. */
|
|
39
|
+
sku_id?: string;
|
|
38
40
|
disabled?: boolean;
|
|
39
41
|
}
|
|
40
42
|
export interface APISelectOption {
|
|
@@ -164,10 +166,13 @@ export declare class StringSelectBuilder {
|
|
|
164
166
|
}
|
|
165
167
|
export declare class ButtonBuilder {
|
|
166
168
|
#private;
|
|
169
|
+
/** Sets the style and drops fields that style cannot carry. */
|
|
167
170
|
setStyle(style: APIButtonComponent["style"]): this;
|
|
168
171
|
setCustomId(value: string): this;
|
|
169
172
|
setLabel(value: string): this;
|
|
170
173
|
setURL(value: string): this;
|
|
174
|
+
/** Makes this a premium (purchase) button for a SKU. Premium buttons carry no label, emoji, custom ID or URL. */
|
|
175
|
+
setSKUId(skuId: string): this;
|
|
171
176
|
setEmoji(emoji: APIComponentEmoji | string): this;
|
|
172
177
|
setDisabled(value?: boolean): this;
|
|
173
178
|
toJSON(): APIButtonComponent;
|
|
@@ -264,3 +269,21 @@ export declare class ContentInventoryEntryBuilder {
|
|
|
264
269
|
setId(id: string): this;
|
|
265
270
|
toJSON(): APIContentInventoryEntryComponent;
|
|
266
271
|
}
|
|
272
|
+
/** Discord.js-familiar alias for {@link StringSelectBuilder}. */
|
|
273
|
+
export { StringSelectBuilder as StringSelectMenuBuilder };
|
|
274
|
+
/** User select menu builder (Discord.js-familiar). */
|
|
275
|
+
export declare class UserSelectMenuBuilder extends EntitySelectBuilder {
|
|
276
|
+
constructor();
|
|
277
|
+
}
|
|
278
|
+
/** Role select menu builder (Discord.js-familiar). */
|
|
279
|
+
export declare class RoleSelectMenuBuilder extends EntitySelectBuilder {
|
|
280
|
+
constructor();
|
|
281
|
+
}
|
|
282
|
+
/** Mentionable select menu builder (Discord.js-familiar). */
|
|
283
|
+
export declare class MentionableSelectMenuBuilder extends EntitySelectBuilder {
|
|
284
|
+
constructor();
|
|
285
|
+
}
|
|
286
|
+
/** Channel select menu builder (Discord.js-familiar). */
|
|
287
|
+
export declare class ChannelSelectMenuBuilder extends EntitySelectBuilder {
|
|
288
|
+
constructor();
|
|
289
|
+
}
|
package/dist/builders/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { EmbedBuilder } from "./embed.js";
|
|
2
2
|
export type { EmbedField } from "./embed.js";
|
|
3
|
-
export { ButtonBuilder, ButtonStyle, ComponentType, ActionRowBuilder, StringSelectBuilder, EntitySelectBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ContainerBuilder, SectionBuilder, TextDisplayBuilder, MediaGalleryBuilder, FileComponentBuilder, SeparatorBuilder, ThumbnailBuilder, ContentInventoryEntryBuilder, } from "./components.js";
|
|
4
|
-
export { SlashCommandBuilder, StringOptionBuilder, IntegerOptionBuilder, NumberOptionBuilder, BooleanOptionBuilder, UserOptionBuilder, ChannelOptionBuilder, RoleOptionBuilder, MentionableOptionBuilder, AttachmentOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, ApplicationCommandOptionType, UserCommandBuilder, MessageCommandBuilder, } from "./commands.js";
|
|
3
|
+
export { ButtonBuilder, ButtonStyle, ComponentType, ActionRowBuilder, StringSelectBuilder, StringSelectMenuBuilder, EntitySelectBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ContainerBuilder, SectionBuilder, TextDisplayBuilder, MediaGalleryBuilder, FileComponentBuilder, SeparatorBuilder, ThumbnailBuilder, ContentInventoryEntryBuilder, } from "./components.js";
|
|
4
|
+
export { SlashCommandBuilder, StringOptionBuilder, IntegerOptionBuilder, NumberOptionBuilder, BooleanOptionBuilder, UserOptionBuilder, ChannelOptionBuilder, RoleOptionBuilder, MentionableOptionBuilder, AttachmentOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, ApplicationCommandOptionType, UserCommandBuilder, MessageCommandBuilder, ContextMenuCommandBuilder, } from "./commands.js";
|
|
5
5
|
export { AttachmentBuilder, type AttachmentData } from "./attachment.js";
|