seyfert 3.0.1-dev-14656752310.0 → 3.0.1-dev-14682613353.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/lib/api/api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type UUID } from 'node:crypto';
|
|
1
2
|
import { type Awaitable, Logger } from '../common';
|
|
2
3
|
import type { WorkerSendApiRequest } from '../websocket/discord/worker';
|
|
3
4
|
import type { APIRoutes } from './Routes';
|
|
@@ -8,7 +9,6 @@ export interface ApiHandler {
|
|
|
8
9
|
}
|
|
9
10
|
export type OnRatelimitCallback = (response: Response, request: ApiRequestOptions) => Awaitable<any>;
|
|
10
11
|
export declare class ApiHandler {
|
|
11
|
-
#private;
|
|
12
12
|
options: ApiHandlerInternalOptions;
|
|
13
13
|
globalBlock: boolean;
|
|
14
14
|
ratelimits: Map<string, Bucket>;
|
|
@@ -23,7 +23,8 @@ export declare class ApiHandler {
|
|
|
23
23
|
set debug(active: boolean);
|
|
24
24
|
get proxy(): APIRoutes;
|
|
25
25
|
globalUnblock(): void;
|
|
26
|
-
|
|
26
|
+
randomUUID(): UUID;
|
|
27
|
+
protected sendMessage(_body: WorkerSendApiRequest): void;
|
|
27
28
|
protected postMessage<T = unknown>(body: WorkerSendApiRequest): Promise<T>;
|
|
28
29
|
request<T = unknown>(method: HttpMethods, url: `/${string}`, { auth, ...request }?: ApiRequestOptions): Promise<T>;
|
|
29
30
|
parseError(method: HttpMethods, route: `/${string}`, response: Response, result: string | Record<string, any>): Error;
|
package/lib/api/api.js
CHANGED
|
@@ -72,10 +72,10 @@ class ApiHandler {
|
|
|
72
72
|
cb();
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
randomUUID() {
|
|
76
76
|
const uuid = (0, node_crypto_1.randomUUID)();
|
|
77
77
|
if (this.workerPromises.has(uuid))
|
|
78
|
-
return this
|
|
78
|
+
return this.randomUUID();
|
|
79
79
|
return uuid;
|
|
80
80
|
}
|
|
81
81
|
sendMessage(_body) {
|
|
@@ -89,7 +89,7 @@ class ApiHandler {
|
|
|
89
89
|
}
|
|
90
90
|
async request(method, url, { auth = true, ...request } = {}) {
|
|
91
91
|
if (this.options.workerProxy) {
|
|
92
|
-
const nonce = this
|
|
92
|
+
const nonce = this.randomUUID();
|
|
93
93
|
return this.postMessage({
|
|
94
94
|
method,
|
|
95
95
|
url,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RawFile } from '../../api';
|
|
2
2
|
import type { Attachment, AttachmentBuilder, Embed, Modal, PollBuilder, TopLevelBuilders } from '../../builders';
|
|
3
|
-
import type { APIEmbed, APIInteractionResponseCallbackData, APIInteractionResponseChannelMessageWithSource, APIModalInteractionResponse, RESTAPIPollCreate, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from '../../types';
|
|
3
|
+
import type { APIEmbed, APIInteractionResponseCallbackData, APIInteractionResponseChannelMessageWithSource, APIModalInteractionResponse, MessageFlags, RESTAPIPollCreate, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIWebhookWithTokenMessageJSONBody, RESTPostAPIChannelMessageJSONBody, RESTPostAPIWebhookWithTokenJSONBody } from '../../types';
|
|
4
4
|
import type { OmitInsert } from './util';
|
|
5
5
|
export interface ResolverProps {
|
|
6
6
|
embeds?: Embed[] | APIEmbed[] | undefined;
|
|
@@ -14,7 +14,9 @@ export type MessageCreateBodyRequest = OmitInsert<RESTPostAPIChannelMessageJSONB
|
|
|
14
14
|
export type MessageUpdateBodyRequest = OmitInsert<RESTPatchAPIChannelMessageJSONBody, 'components' | 'embeds', ResolverProps>;
|
|
15
15
|
export type MessageWebhookCreateBodyRequest = OmitInsert<RESTPostAPIWebhookWithTokenJSONBody, 'components' | 'embeds' | 'poll', SendResolverProps>;
|
|
16
16
|
export type MessageWebhookUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds' | 'poll', ResolverProps>;
|
|
17
|
-
export type InteractionMessageUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds' | 'poll', SendResolverProps
|
|
17
|
+
export type InteractionMessageUpdateBodyRequest = OmitInsert<RESTPatchAPIWebhookWithTokenMessageJSONBody, 'components' | 'embeds' | 'poll', SendResolverProps> & {
|
|
18
|
+
flags?: MessageFlags;
|
|
19
|
+
};
|
|
18
20
|
export type ComponentInteractionMessageUpdate = OmitInsert<APIInteractionResponseCallbackData, 'components' | 'embeds', ResolverProps>;
|
|
19
21
|
export type InteractionCreateBodyRequest = OmitInsert<APIInteractionResponseChannelMessageWithSource['data'], 'components' | 'embeds' | 'poll', SendResolverProps>;
|
|
20
22
|
export type ModalCreateBodyRequest = APIModalInteractionResponse['data'] | Modal;
|
|
@@ -277,8 +277,8 @@ class Interaction extends BaseInteraction {
|
|
|
277
277
|
}
|
|
278
278
|
async editOrReply(body, fetchReply) {
|
|
279
279
|
if (await this.replied) {
|
|
280
|
-
const { content, embeds, allowed_mentions, components, files, attachments, poll } = body;
|
|
281
|
-
return this.editResponse({ content, embeds, allowed_mentions, components, files, attachments, poll });
|
|
280
|
+
const { content, embeds, allowed_mentions, components, files, attachments, poll, flags } = body;
|
|
281
|
+
return this.editResponse({ content, embeds, allowed_mentions, components, files, attachments, poll, flags });
|
|
282
282
|
}
|
|
283
283
|
return this.write(body, fetchReply);
|
|
284
284
|
}
|