lunibee 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/builders/attachment.d.ts +8 -4
- package/dist/builders/commands.d.ts +122 -149
- package/dist/builders/components.d.ts +10 -150
- package/dist/builders/embed.d.ts +66 -37
- package/dist/builders/index.d.ts +0 -4
- package/dist/builders/index.js +112 -221
- package/dist/builders/index.js.map +10 -9
- package/dist/collection/cache.d.ts +15 -6
- package/dist/collection/index.d.ts +92 -17
- package/dist/collection/index.js +471 -279
- package/dist/collection/index.js.map +4 -4
- package/dist/core/api.d.ts +130 -0
- package/dist/core/channel-create.d.ts +72 -0
- package/dist/core/commands.d.ts +232 -0
- package/dist/core/events.d.ts +24 -7
- package/dist/core/handles.d.ts +157 -0
- package/dist/core/index.d.ts +68 -4
- package/dist/core/index.js +2639 -493
- package/dist/core/index.js.map +47 -37
- package/dist/core/permissions.d.ts +7 -7
- package/dist/formatters/index.js +9 -5
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js +5 -10
- package/dist/handlers/index.js.map +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9527 -7809
- package/dist/index.js.map +63 -53
- package/dist/managers/advanced.d.ts +29 -1
- package/dist/managers/base.d.ts +22 -14
- package/dist/managers/emoji.d.ts +0 -2
- package/dist/managers/guild-resources.d.ts +13 -5
- package/dist/managers/guild.d.ts +40 -4
- package/dist/managers/index.d.ts +21 -13
- package/dist/managers/index.js +969 -386
- package/dist/managers/index.js.map +30 -25
- package/dist/managers/member.d.ts +9 -2
- package/dist/managers/message.d.ts +10 -15
- package/dist/managers/role.d.ts +18 -10
- package/dist/managers/thread.d.ts +68 -0
- package/dist/managers/user.d.ts +18 -0
- package/dist/rest/errors.d.ts +14 -7
- package/dist/rest/index.d.ts +24 -12
- package/dist/rest/index.js +70 -20
- package/dist/rest/index.js.map +9 -9
- package/dist/rest/redis.d.ts +1 -1
- package/dist/rest/route.d.ts +8 -4
- package/dist/rest/routes.d.ts +122 -48
- package/dist/rest/transport.d.ts +10 -5
- package/dist/rest/webhook.d.ts +9 -5
- package/dist/sharding/bus.d.ts +47 -19
- package/dist/sharding/cluster.d.ts +11 -0
- package/dist/sharding/gateway-bot.d.ts +18 -0
- package/dist/sharding/index.d.ts +64 -25
- package/dist/sharding/index.js +439 -124
- package/dist/sharding/index.js.map +19 -14
- package/dist/sharding/supervisor.d.ts +32 -0
- package/dist/sharding/transport.d.ts +45 -0
- package/dist/structures/audit-log.d.ts +99 -2
- package/dist/structures/base.d.ts +40 -23
- package/dist/structures/channels.d.ts +45 -14
- package/dist/structures/index.d.ts +8 -12
- package/dist/structures/index.js +280 -132
- package/dist/structures/index.js.map +21 -15
- package/dist/structures/interactions.d.ts +91 -63
- package/dist/structures/resources.d.ts +99 -52
- package/dist/structures/sticker.d.ts +33 -0
- package/dist/types/channel-kind.d.ts +26 -0
- package/dist/types/gateway.d.ts +24 -12
- package/dist/types/index.d.ts +115 -113
- package/dist/types/index.js +53 -48
- package/dist/types/index.js.map +6 -5
- package/dist/voice/index.d.ts +12 -4
- package/dist/voice/index.js +14 -18
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/decoder.d.ts +6 -2
- package/dist/ws/dispatcher.d.ts +19 -0
- package/dist/ws/index.d.ts +61 -15
- package/dist/ws/index.js +194 -77
- package/dist/ws/index.js.map +13 -11
- package/dist/ws/protocol.d.ts +10 -2
- package/dist/ws/reconnect.d.ts +10 -0
- package/dist/ws/send-budget.d.ts +6 -2
- package/dist/ws/session.d.ts +14 -4
- package/dist/ws/state.d.ts +22 -11
- package/package.json +20 -16
package/dist/ws/protocol.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export interface IdentifyProperties {
|
|
|
91
91
|
os?: string;
|
|
92
92
|
browser?: string;
|
|
93
93
|
device?: string;
|
|
94
|
-
[key: string]:
|
|
94
|
+
[key: string]: string | undefined;
|
|
95
95
|
}
|
|
96
96
|
/** Everything IDENTIFY needs. */
|
|
97
97
|
export interface IdentifyOptions {
|
|
@@ -102,8 +102,16 @@ export interface IdentifyOptions {
|
|
|
102
102
|
properties?: IdentifyProperties;
|
|
103
103
|
presence?: GatewayPresence;
|
|
104
104
|
}
|
|
105
|
+
/** The `d` field of an IDENTIFY payload. */
|
|
106
|
+
export interface IdentifyData {
|
|
107
|
+
token: string;
|
|
108
|
+
intents: number;
|
|
109
|
+
properties: IdentifyProperties;
|
|
110
|
+
presence: Required<GatewayPresence>;
|
|
111
|
+
shard: [shardId: number, shardCount: number];
|
|
112
|
+
}
|
|
105
113
|
/** Builds an IDENTIFY payload. */
|
|
106
|
-
export declare function identifyPayload(options: IdentifyOptions): GatewayPayload
|
|
114
|
+
export declare function identifyPayload(options: IdentifyOptions): GatewayPayload<IdentifyData>;
|
|
107
115
|
/** Builds a RESUME payload from the session's resume material. */
|
|
108
116
|
export declare function resumePayload(token: string, resume: ResumeInfo): GatewayPayload;
|
|
109
117
|
/** Builds a heartbeat payload carrying the last sequence seen. */
|
package/dist/ws/reconnect.d.ts
CHANGED
|
@@ -44,6 +44,10 @@ export type ScheduleResult = {
|
|
|
44
44
|
scheduled: true;
|
|
45
45
|
delayMs: number;
|
|
46
46
|
attempt: number;
|
|
47
|
+
/** Set when reconnects are coming too fast: the delay was raised. */
|
|
48
|
+
unstable?: {
|
|
49
|
+
reconnects: number;
|
|
50
|
+
};
|
|
47
51
|
} | {
|
|
48
52
|
scheduled: false;
|
|
49
53
|
reason: ScheduleRefusal;
|
|
@@ -60,6 +64,12 @@ export interface ReconnectOptions {
|
|
|
60
64
|
maxDelay: number;
|
|
61
65
|
/** Randomness source for jitter; injected in tests. */
|
|
62
66
|
random?: () => number;
|
|
67
|
+
/** Reconnects inside `stormWindow` before the link counts as unstable (default 5). */
|
|
68
|
+
stormLimit?: number;
|
|
69
|
+
/** The span over which reconnects are counted, in ms (default 60,000). */
|
|
70
|
+
stormWindow?: number;
|
|
71
|
+
/** Clock in ms; injected in tests. */
|
|
72
|
+
now?: () => number;
|
|
63
73
|
}
|
|
64
74
|
/** Reconnect scheduling, backoff and attempt coordination. */
|
|
65
75
|
export declare class GatewayReconnect {
|
package/dist/ws/send-budget.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sliding-window budget for outgoing Gateway payloads.
|
|
2
|
+
* Sliding-window budget for outgoing Gateway payloads. Heartbeats, IDENTIFY and
|
|
3
|
+
* RESUME are privileged: they always go out (and are still counted), so
|
|
4
|
+
* application traffic can never starve them.
|
|
3
5
|
*
|
|
4
6
|
* Discord allows 120 sends per 60 seconds. Application traffic is capped at
|
|
5
7
|
* 115 so the remaining headroom is reserved for privileged sends (heartbeats),
|
|
6
8
|
* which are still recorded so the true total stays under Discord's limit.
|
|
7
9
|
*/
|
|
8
|
-
export declare class
|
|
10
|
+
export declare class GatewaySendLimiter {
|
|
9
11
|
#private;
|
|
10
12
|
constructor(limit?: number, windowMs?: number);
|
|
11
13
|
/** Sends recorded within the current window. */
|
|
@@ -15,3 +17,5 @@ export declare class SendBudget {
|
|
|
15
17
|
/** Records a send that went out. */
|
|
16
18
|
record(now?: number): void;
|
|
17
19
|
}
|
|
20
|
+
/** The limiter's name before 0.3.0. */
|
|
21
|
+
export declare const SendBudget: typeof GatewaySendLimiter;
|
package/dist/ws/session.d.ts
CHANGED
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
/** Everything needed to send a RESUME, or nothing when one is impossible. */
|
|
11
11
|
export interface ResumeInfo {
|
|
12
|
-
/** Discord's session identifier from READY. */
|
|
13
|
-
|
|
14
|
-
/**
|
|
12
|
+
/** Discord's session identifier from READY. */
|
|
13
|
+
sessionId: string;
|
|
14
|
+
/** Last sequence number observed on this session. */
|
|
15
|
+
sequence: number;
|
|
16
|
+
/** Host READY nominated for resuming this session. */
|
|
17
|
+
resumeURL: string;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* What the next connection must do.
|
|
@@ -95,6 +98,13 @@ export declare class GatewaySession {
|
|
|
95
98
|
resumeInfo(): ResumeInfo | undefined;
|
|
96
99
|
/** What the next connection must send: RESUME with material, or IDENTIFY. */
|
|
97
100
|
handshake(): HandshakeIntent;
|
|
98
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Host the next connection should dial: the resume host, else `fallback`.
|
|
103
|
+
* The resume host comes from READY, so it is used only when it is a `wss:`
|
|
104
|
+
* URL on discord.gg (or a subdomain), or on the fallback's own host; any
|
|
105
|
+
* other host would receive the bot token in the RESUME frame.
|
|
106
|
+
*/
|
|
99
107
|
connectURL(fallback: string): string;
|
|
100
108
|
}
|
|
109
|
+
/** Whether `url` is a `wss:` URL on discord.gg (or a subdomain) or on `fallback`'s host. */
|
|
110
|
+
export declare function isTrustedGatewayURL(url: string, fallback: string): boolean;
|
package/dist/ws/state.d.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
/** Gateway connection lifecycle states. */
|
|
2
2
|
export declare enum GatewayState {
|
|
3
|
-
/** Initial connection state. */
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/** Gateway
|
|
3
|
+
/** Initial connection state. */
|
|
4
|
+
Connect = "CONNECT",
|
|
5
|
+
/** Gateway HELLO received state. */
|
|
6
|
+
Hello = "HELLO",
|
|
7
|
+
/** IDENTIFY operation in progress. */
|
|
8
|
+
Identify = "IDENTIFY",
|
|
9
|
+
/** RESUME operation in progress. */
|
|
10
|
+
Resume = "RESUME",
|
|
11
|
+
/** Gateway READY state. */
|
|
12
|
+
Ready = "READY",
|
|
13
|
+
/** Gateway dispatch processing state. */
|
|
14
|
+
Dispatch = "DISPATCH",
|
|
15
|
+
/** Heartbeat processing state. */
|
|
16
|
+
Heartbeat = "HEARTBEAT",
|
|
17
|
+
/** Reconnect in progress. */
|
|
18
|
+
Reconnect = "RECONNECT",
|
|
19
|
+
/** Gateway is permanently closed. */
|
|
20
|
+
Closed = "CLOSED"
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
14
23
|
* Discord.js-familiar alias for {@link GatewayState}.
|
|
@@ -22,6 +31,8 @@ export declare enum GatewayState {
|
|
|
22
31
|
export { GatewayState as Status };
|
|
23
32
|
/** Gateway protocol error. */
|
|
24
33
|
export declare class GatewayError extends Error {
|
|
25
|
-
/** Gateway close/error code. */
|
|
26
|
-
|
|
34
|
+
/** Gateway close/error code. */
|
|
35
|
+
readonly code?: number;
|
|
36
|
+
/** Creates a Gateway error. @param message Error message. @param code Optional Gateway code. @param options Optional error metadata. */
|
|
37
|
+
constructor(message: string, code?: number, options?: ErrorOptions);
|
|
27
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lunibee",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A lightweight, Bun-first Discord API library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -92,38 +92,42 @@
|
|
|
92
92
|
"format:check": "prettier --check \"packages/*/src/**/*.ts\" \"tests/**/*.ts\"",
|
|
93
93
|
"check:deps": "bun scripts/check-dependency-graph.ts",
|
|
94
94
|
"audit:api": "bun scripts/api-audit.ts",
|
|
95
|
+
"audit:coverage": "bun scripts/api-coverage.ts --check",
|
|
95
96
|
"typecheck": "bunx tsc --noEmit --project tsconfig.json && bunx tsc --noEmit --project tsconfig.strict.json",
|
|
96
97
|
"ci:install": "bun install --frozen-lockfile",
|
|
97
98
|
"ci:deps": "bun run check:deps",
|
|
98
99
|
"ci:typecheck": "bun run typecheck",
|
|
99
100
|
"ci:test": "bun test --coverage && bun test ./packages/testing/src",
|
|
100
|
-
"ci": "bun run ci:deps && bun run audit:api && bun run format:check && bun run ci:typecheck && bun run ci:test",
|
|
101
|
+
"ci": "bun run ci:deps && bun run audit:api && bun run audit:coverage && bun run format:check && bun run ci:typecheck && bun run ci:test",
|
|
101
102
|
"bench": "bun benchmarks/parity.ts",
|
|
103
|
+
"bench:rest": "bun benchmarks/rest-buckets.ts",
|
|
104
|
+
"bench:compare": "bun scripts/bench-compare.mjs",
|
|
102
105
|
"build:all": "bun run build && bun run build:dts",
|
|
103
106
|
"publish:all": "bun run scripts/publish.ts"
|
|
104
107
|
},
|
|
105
108
|
"dependencies": {
|
|
106
|
-
"@lunibee/builders": "^0.
|
|
107
|
-
"@lunibee/collection": "^0.
|
|
108
|
-
"@lunibee/core": "^0.
|
|
109
|
-
"@lunibee/formatters": "^0.
|
|
110
|
-
"@lunibee/handlers": "^0.
|
|
111
|
-
"@lunibee/managers": "^0.
|
|
112
|
-
"@lunibee/rest": "^0.
|
|
113
|
-
"@lunibee/sharding": "^0.
|
|
114
|
-
"@lunibee/structures": "^0.
|
|
115
|
-
"@lunibee/types": "^0.
|
|
116
|
-
"@lunibee/utils": "^0.
|
|
117
|
-
"@lunibee/voice": "^0.
|
|
118
|
-
"@lunibee/ws": "^0.
|
|
109
|
+
"@lunibee/builders": "^0.3.0",
|
|
110
|
+
"@lunibee/collection": "^0.3.0",
|
|
111
|
+
"@lunibee/core": "^0.3.0",
|
|
112
|
+
"@lunibee/formatters": "^0.3.0",
|
|
113
|
+
"@lunibee/handlers": "^0.3.0",
|
|
114
|
+
"@lunibee/managers": "^0.3.0",
|
|
115
|
+
"@lunibee/rest": "^0.3.0",
|
|
116
|
+
"@lunibee/sharding": "^0.3.0",
|
|
117
|
+
"@lunibee/structures": "^0.3.0",
|
|
118
|
+
"@lunibee/types": "^0.3.0",
|
|
119
|
+
"@lunibee/utils": "^0.3.0",
|
|
120
|
+
"@lunibee/voice": "^0.3.0",
|
|
121
|
+
"@lunibee/ws": "^0.3.0"
|
|
119
122
|
},
|
|
120
123
|
"devDependencies": {
|
|
124
|
+
"@discordjs/collection": "^2.1.1",
|
|
121
125
|
"@types/bun": "^1.4.1",
|
|
122
126
|
"prettier": "^3.9.9",
|
|
123
127
|
"typescript": "^7.0.2"
|
|
124
128
|
},
|
|
125
129
|
"engines": {
|
|
126
|
-
"bun": ">=1.
|
|
130
|
+
"bun": ">=1.4.0"
|
|
127
131
|
},
|
|
128
132
|
"license": "MIT"
|
|
129
133
|
}
|