lunibee 0.1.7 → 0.1.8
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 +223 -223
- package/dist/builders/commands.d.ts +6 -4
- package/dist/builders/components.d.ts +18 -0
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/index.js +49 -13
- package/dist/builders/index.js.map +9 -8
- package/dist/collection/index.js +2 -1
- package/dist/collection/index.js.map +4 -4
- package/dist/core/events.d.ts +86 -2
- package/dist/core/index.d.ts +10 -87
- package/dist/core/index.js +1752 -725
- package/dist/core/index.js.map +44 -24
- 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 +2103 -800
- package/dist/index.js.map +63 -43
- package/dist/managers/guild-resources.d.ts +109 -0
- package/dist/managers/guild.d.ts +5 -0
- package/dist/managers/index.d.ts +7 -1
- package/dist/managers/index.js +330 -12
- package/dist/managers/index.js.map +25 -21
- package/dist/rest/decoder.d.ts +23 -0
- package/dist/rest/errors.d.ts +20 -0
- package/dist/rest/index.d.ts +21 -17
- package/dist/rest/index.js +479 -263
- 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 +2 -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 +10 -2
- package/dist/sharding/index.js +1011 -394
- package/dist/sharding/index.js.map +18 -8
- package/dist/structures/base.d.ts +8 -0
- package/dist/structures/channels.d.ts +56 -0
- package/dist/structures/index.d.ts +1 -0
- package/dist/structures/index.js +211 -271
- package/dist/structures/index.js.map +17 -14
- package/dist/structures/interactions.d.ts +12 -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 +181 -0
- package/dist/types/index.d.ts +2 -263
- 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 +29 -1
- package/dist/voice/index.js +59 -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 +903 -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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Normalised shape of a Discord error payload. */
|
|
2
|
+
export interface DecodedError {
|
|
3
|
+
message?: string;
|
|
4
|
+
code?: number;
|
|
5
|
+
retry_after?: number;
|
|
6
|
+
global?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Turns a raw {@link Response} into a payload and the error metadata retries need. */
|
|
9
|
+
export declare class ResponseDecoder {
|
|
10
|
+
/** Reads a Discord response payload as JSON, text, or nothing for 204. */
|
|
11
|
+
read(response: Response): Promise<unknown>;
|
|
12
|
+
/** Extracts Discord's error metadata from a decoded payload. */
|
|
13
|
+
errorData(payload: unknown): DecodedError;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves Retry-After (seconds) from the payload, falling back to the
|
|
16
|
+
* header and finally to one second.
|
|
17
|
+
*
|
|
18
|
+
* An absent header is explicitly *not* a zero delay: `Number(null)` is 0,
|
|
19
|
+
* which is finite, so reading it directly would answer a 429 that carries
|
|
20
|
+
* no Retry-After by retrying immediately — exactly when backing off matters.
|
|
21
|
+
*/
|
|
22
|
+
retryAfter(response: Response, data: DecodedError): number;
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Error thrown when Discord rejects a REST request. */
|
|
2
|
+
export declare class RESTError extends Error {
|
|
3
|
+
/** HTTP status returned by Discord. */ readonly status: number;
|
|
4
|
+
/** Discord API error code, when provided. */ readonly code?: number;
|
|
5
|
+
/** Raw Discord validation/error payload. */ readonly errors?: unknown;
|
|
6
|
+
/** HTTP method used for the failed request. */ readonly method?: string;
|
|
7
|
+
/** API path used for the failed request. */ readonly path?: string;
|
|
8
|
+
/** Creates a REST error with request context. @param message Error message. @param status HTTP status. @param code Discord error code. @param errors Raw error payload. @param options Request context and cause. */
|
|
9
|
+
constructor(message: string, status: number, code?: number, errors?: unknown, options?: {
|
|
10
|
+
method?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
cause?: unknown;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Creates the cancellation error shared by every stage of the request pipeline. */
|
|
16
|
+
export declare function abortError(path: string, reason: unknown): RESTError;
|
|
17
|
+
/** Waits for a delay, rejecting early if the signal aborts. */
|
|
18
|
+
export declare function sleep(delay: number, signal: AbortSignal | undefined, path: string): Promise<void>;
|
|
19
|
+
/** Awaits a promise, rejecting early if the signal aborts. */
|
|
20
|
+
export declare function abortable(promise: Promise<void>, signal: AbortSignal | undefined, path: string): Promise<void>;
|
package/dist/rest/index.d.ts
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
/** Error thrown when Discord rejects a REST request. */
|
|
2
|
-
export declare class RESTError extends Error {
|
|
3
|
-
/** HTTP status returned by Discord. */ readonly status: number;
|
|
4
|
-
/** Discord API error code, when provided. */ readonly code?: number;
|
|
5
|
-
/** Raw Discord validation/error payload. */ readonly errors?: unknown;
|
|
6
|
-
/** HTTP method used for the failed request. */ readonly method?: string;
|
|
7
|
-
/** API path used for the failed request. */ readonly path?: string;
|
|
8
|
-
/** Creates a REST error with request context. @param message Error message. @param status HTTP status. @param code Discord error code. @param errors Raw error payload. @param options Request context and cause. */
|
|
9
|
-
constructor(message: string, status: number, code?: number, errors?: unknown, options?: {
|
|
10
|
-
method?: string;
|
|
11
|
-
path?: string;
|
|
12
|
-
cause?: unknown;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
1
|
import { type RateLimitStore } from "./store.js";
|
|
2
|
+
import { RESTError } from "./errors.js";
|
|
3
|
+
import { type RESTQuery } from "./route.js";
|
|
4
|
+
import { HttpTransport } from "./transport.js";
|
|
16
5
|
/** A file attachment sent as part of a multipart REST request. */
|
|
17
6
|
export interface RESTFileAttachment {
|
|
18
7
|
name: string;
|
|
19
8
|
data: Blob | Uint8Array | ArrayBuffer;
|
|
20
9
|
contentType?: string;
|
|
21
10
|
}
|
|
22
|
-
/** Query-string value accepted by {@link RESTRequestOptions.query}. */
|
|
23
|
-
export type RESTQuery = URLSearchParams | Record<string, string | number | boolean | null | undefined> | string;
|
|
24
11
|
/**
|
|
25
12
|
* Options controlling an individual REST request.
|
|
26
13
|
*
|
|
@@ -112,7 +99,18 @@ export declare class REST {
|
|
|
112
99
|
baseURL?: string;
|
|
113
100
|
hooks?: RESTHooks;
|
|
114
101
|
store?: RateLimitStore;
|
|
102
|
+
/** Replaces the HTTP stage, e.g. with a recording transport in tests. */
|
|
103
|
+
transport?: HttpTransport;
|
|
104
|
+
/**
|
|
105
|
+
* Lets requests on a bucket whose limit is known run concurrently, up
|
|
106
|
+
* to its `remaining` allowance, instead of one at a time. Requires a
|
|
107
|
+
* store with `reserve`. Requests on one bucket may then complete out
|
|
108
|
+
* of order (e.g. messages to one channel). Defaults to `false`.
|
|
109
|
+
*/
|
|
110
|
+
concurrentBuckets?: boolean;
|
|
115
111
|
});
|
|
112
|
+
/** The rate-limit store backing this transport. */
|
|
113
|
+
get store(): RateLimitStore;
|
|
116
114
|
/** Replaces the current hook set. Pass an empty object to clear all hooks. */
|
|
117
115
|
setHooks(hooks: RESTHooks): this;
|
|
118
116
|
/** Sets the authentication token. @param token Discord bot token. @returns Nothing. @throws {TypeError} If token is empty. */
|
|
@@ -162,7 +160,13 @@ export declare class REST {
|
|
|
162
160
|
patchWithFiles<T>(path: string, payload: unknown, files: RESTFileAttachment[], options?: RESTRequestOptions): Promise<T>;
|
|
163
161
|
}
|
|
164
162
|
export { Routes } from "./routes.js";
|
|
165
|
-
export {
|
|
163
|
+
export { RESTError, abortError } from "./errors.js";
|
|
164
|
+
export { createRouteKey, normalizeRoutePath, majorParameter, scopeBucket, serializeQuery, type RouteKey, type RESTQuery, } from "./route.js";
|
|
165
|
+
export { RequestScheduler } from "./scheduler.js";
|
|
166
|
+
export { RateLimiter } from "./limiter.js";
|
|
167
|
+
export { HttpTransport, TransportError, type TransportRequest, type FetchLike, } from "./transport.js";
|
|
168
|
+
export { ResponseDecoder, type DecodedError } from "./decoder.js";
|
|
169
|
+
export { type RateLimitStore, type BucketState, type Reservation, MemoryRateLimitStore, } from "./store.js";
|
|
166
170
|
export { RedisRateLimitStore, type RedisRateLimitStoreOptions, type MinimalRedisClient, } from "./redis.js";
|
|
167
171
|
export { WebhookClient, type WebhookClientOptions, type WebhookMessageOptions, } from "./webhook.js";
|
|
168
172
|
/**
|