seyfert 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.
- package/lib/api/CDN.d.ts +1 -1
- package/lib/api/CDN.js +0 -2
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +29 -33
- package/lib/api/Routes/channels.d.ts +11 -17
- package/lib/api/Routes/interactions.d.ts +3 -7
- package/lib/api/Routes/webhooks.d.ts +4 -6
- package/lib/api/api.d.ts +5 -0
- package/lib/api/api.js +36 -0
- package/lib/api/shared.d.ts +5 -3
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/builders/Button.d.ts +2 -2
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +1 -0
- package/lib/cache/adapters/redis.d.ts +1 -0
- package/lib/cache/adapters/redis.js +7 -0
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +5 -4
- package/lib/cache/adapters/workeradapter.js +11 -5
- package/lib/cache/index.d.ts +4 -6
- package/lib/cache/index.js +5 -6
- package/lib/cache/resources/default/base.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +1 -1
- package/lib/cache/resources/guilds.js +2 -1
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +7 -1
- package/lib/client/base.d.ts +18 -171
- package/lib/client/base.js +12 -15
- package/lib/client/client.d.ts +6 -1
- package/lib/client/client.js +13 -12
- package/lib/client/oninteractioncreate.js +4 -4
- package/lib/client/onmessagecreate.js +188 -152
- package/lib/client/workerclient.d.ts +15 -1
- package/lib/client/workerclient.js +135 -27
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +15 -7
- package/lib/commands/applications/chat.js +7 -7
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +12 -7
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +4 -0
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +9 -4
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/decorators.d.ts +17 -5
- package/lib/commands/decorators.js +17 -7
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +40 -36
- package/lib/commands/optionresolver.d.ts +11 -4
- package/lib/commands/optionresolver.js +6 -4
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +7 -0
- package/lib/common/it/utils.js +2 -0
- package/lib/common/shorters/channels.d.ts +67 -129
- package/lib/common/shorters/channels.js +119 -135
- package/lib/common/shorters/emojis.d.ts +47 -0
- package/lib/common/shorters/emojis.js +80 -0
- package/lib/common/shorters/guilds.d.ts +22 -249
- package/lib/common/shorters/guilds.js +51 -140
- package/lib/common/shorters/members.d.ts +82 -108
- package/lib/common/shorters/members.js +151 -166
- package/lib/common/shorters/messages.d.ts +11 -23
- package/lib/common/shorters/messages.js +58 -104
- package/lib/common/shorters/reactions.d.ts +10 -0
- package/lib/common/shorters/reactions.js +45 -0
- package/lib/common/shorters/roles.d.ts +39 -7
- package/lib/common/shorters/roles.js +74 -42
- package/lib/common/shorters/templates.d.ts +6 -8
- package/lib/common/shorters/templates.js +17 -21
- package/lib/common/shorters/users.d.ts +4 -0
- package/lib/common/shorters/users.js +30 -0
- package/lib/common/shorters/webhook.d.ts +62 -26
- package/lib/common/shorters/webhook.js +113 -58
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/util.d.ts +1 -1
- package/lib/components/handler.d.ts +11 -8
- package/lib/components/handler.js +34 -22
- package/lib/index.d.ts +4 -2
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +2 -2
- package/lib/structures/ClientUser.d.ts +2 -2
- package/lib/structures/Guild.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +7 -7
- package/lib/structures/GuildMember.d.ts +6 -6
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/GuildPreview.d.ts +2 -2
- package/lib/structures/GuildRole.d.ts +2 -2
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/Interaction.d.ts +7 -8
- package/lib/structures/Interaction.js +1 -1
- package/lib/structures/Message.d.ts +7 -6
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +19 -20
- package/lib/structures/channels.js +13 -25
- package/lib/structures/extra/Base.d.ts +1 -2
- package/lib/structures/extra/DiscordBase.d.ts +2 -2
- package/lib/websocket/constants/index.js +2 -3
- package/lib/websocket/discord/shard.js +4 -2
- package/lib/websocket/discord/sharder.d.ts +3 -0
- package/lib/websocket/discord/sharder.js +12 -5
- package/lib/websocket/discord/shared.d.ts +3 -0
- package/lib/websocket/discord/worker.d.ts +24 -7
- package/lib/websocket/discord/workermanager.d.ts +30 -6
- package/lib/websocket/discord/workermanager.js +160 -51
- package/package.json +8 -5
package/lib/api/CDN.d.ts
CHANGED
package/lib/api/CDN.js
CHANGED
|
@@ -212,8 +212,6 @@ class CDN {
|
|
|
212
212
|
* @param options - The extension/size options for the link
|
|
213
213
|
*/
|
|
214
214
|
makeURL(route, { allowedExtensions = constants_js_1.ALLOWED_EXTENSIONS, extension = 'webp', size } = {}) {
|
|
215
|
-
// eslint-disable-next-line no-param-reassign
|
|
216
|
-
extension = String(extension).toLowerCase();
|
|
217
215
|
if (!allowedExtensions.includes(extension)) {
|
|
218
216
|
throw new RangeError(`Invalid extension provided: ${extension}\nMust be one of: ${allowedExtensions.join(', ')}`);
|
|
219
217
|
}
|
package/lib/api/Router.js
CHANGED
|
@@ -28,7 +28,7 @@ class Router {
|
|
|
28
28
|
return this.createProxy([...route, key]);
|
|
29
29
|
},
|
|
30
30
|
apply: (...[, _, args]) => {
|
|
31
|
-
return this.createProxy([...route, ...args
|
|
31
|
+
return this.createProxy([...route, ...args]);
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -56,7 +56,7 @@ exports.CDNRouter = {
|
|
|
56
56
|
return this.createProxy([...route, key]);
|
|
57
57
|
},
|
|
58
58
|
apply: (...[, _, args]) => {
|
|
59
|
-
return this.createProxy([...route, ...args
|
|
59
|
+
return this.createProxy([...route, ...args]);
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
62
|
},
|
|
@@ -2,44 +2,40 @@ import type { RESTGetAPIApplicationCommandResult, RESTGetAPIApplicationCommandsQ
|
|
|
2
2
|
import type { RestArguments } from '../api';
|
|
3
3
|
import type { ProxyRequestMethod } from '../Router';
|
|
4
4
|
export interface ApplicationRoutes {
|
|
5
|
-
applications: {
|
|
6
|
-
(id: string)
|
|
7
|
-
guilds: {
|
|
8
|
-
(id: string): {
|
|
9
|
-
commands: {
|
|
10
|
-
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIApplicationGuildCommandsQuery>): Promise<RESTGetAPIApplicationGuildCommandsResult>;
|
|
11
|
-
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIApplicationGuildCommandsJSONBody>): Promise<RESTPostAPIApplicationGuildCommandsResult>;
|
|
12
|
-
put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationGuildCommandsJSONBody>): Promise<RESTPutAPIApplicationGuildCommandsResult>;
|
|
13
|
-
permissions: {
|
|
14
|
-
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildApplicationCommandsPermissionsResult>;
|
|
15
|
-
};
|
|
16
|
-
(id: string): {
|
|
17
|
-
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIApplicationGuildCommandResult>;
|
|
18
|
-
patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIApplicationGuildCommandJSONBody>): Promise<RESTPatchAPIApplicationGuildCommandResult>;
|
|
19
|
-
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<never>;
|
|
20
|
-
permissions: {
|
|
21
|
-
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildApplicationCommandsPermissionsResult>;
|
|
22
|
-
put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationCommandPermissionsJSONBody>): Promise<RESTPutAPIGuildApplicationCommandsPermissionsResult>;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
5
|
+
applications: (id: string) => {
|
|
6
|
+
guilds: (id: string) => {
|
|
28
7
|
commands: {
|
|
29
|
-
get(args?: RestArguments<ProxyRequestMethod.Get,
|
|
30
|
-
post(args: RestArguments<ProxyRequestMethod.Post,
|
|
31
|
-
put(args?: RestArguments<ProxyRequestMethod.Put,
|
|
8
|
+
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIApplicationGuildCommandsQuery>): Promise<RESTGetAPIApplicationGuildCommandsResult>;
|
|
9
|
+
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIApplicationGuildCommandsJSONBody>): Promise<RESTPostAPIApplicationGuildCommandsResult>;
|
|
10
|
+
put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationGuildCommandsJSONBody>): Promise<RESTPutAPIApplicationGuildCommandsResult>;
|
|
11
|
+
permissions: {
|
|
12
|
+
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildApplicationCommandsPermissionsResult>;
|
|
13
|
+
};
|
|
32
14
|
(id: string): {
|
|
33
|
-
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<
|
|
34
|
-
patch(args: RestArguments<ProxyRequestMethod.Patch,
|
|
15
|
+
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIApplicationGuildCommandResult>;
|
|
16
|
+
patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIApplicationGuildCommandJSONBody>): Promise<RESTPatchAPIApplicationGuildCommandResult>;
|
|
35
17
|
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<never>;
|
|
18
|
+
permissions: {
|
|
19
|
+
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildApplicationCommandsPermissionsResult>;
|
|
20
|
+
put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationCommandPermissionsJSONBody>): Promise<RESTPutAPIGuildApplicationCommandsPermissionsResult>;
|
|
21
|
+
};
|
|
36
22
|
};
|
|
37
23
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
};
|
|
25
|
+
commands: {
|
|
26
|
+
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIApplicationCommandsQuery>): Promise<RESTGetAPIApplicationCommandsResult>;
|
|
27
|
+
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIApplicationCommandsJSONBody>): Promise<RESTPostAPIApplicationCommandsResult>;
|
|
28
|
+
put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationCommandsJSONBody>): Promise<RESTPutAPIApplicationCommandsResult>;
|
|
29
|
+
(id: string): {
|
|
30
|
+
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIApplicationCommandResult>;
|
|
31
|
+
patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIApplicationCommandJSONBody>): Promise<RESTPatchAPIApplicationCommandResult>;
|
|
32
|
+
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<never>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
'role-connections': {
|
|
36
|
+
metadata: {
|
|
37
|
+
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIApplicationRoleConnectionMetadataResult>;
|
|
38
|
+
put(args: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationRoleConnectionMetadataJSONBody>): Promise<RESTPutAPIApplicationRoleConnectionMetadataResult>;
|
|
43
39
|
};
|
|
44
40
|
};
|
|
45
41
|
};
|
|
@@ -6,13 +6,11 @@ export interface ChannelRoutes {
|
|
|
6
6
|
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelResult>;
|
|
7
7
|
patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIChannelJSONBody>): Promise<RESTPatchAPIChannelResult>;
|
|
8
8
|
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelResult>;
|
|
9
|
-
users: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>): Promise<RESTGetAPIChannelUsersThreadsArchivedResult>;
|
|
15
|
-
};
|
|
9
|
+
users: (id: '@me') => {
|
|
10
|
+
threads: {
|
|
11
|
+
archived: {
|
|
12
|
+
private: {
|
|
13
|
+
get(args?: RestArguments<ProxyRequestMethod.Get, RESTGetAPIChannelThreadsArchivedQuery>): Promise<RESTGetAPIChannelUsersThreadsArchivedResult>;
|
|
16
14
|
};
|
|
17
15
|
};
|
|
18
16
|
};
|
|
@@ -40,11 +38,9 @@ export interface ChannelRoutes {
|
|
|
40
38
|
};
|
|
41
39
|
};
|
|
42
40
|
};
|
|
43
|
-
recipients: {
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelRecipientResult>;
|
|
47
|
-
};
|
|
41
|
+
recipients: (id: string) => {
|
|
42
|
+
put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelRecipientJSONBody>): Promise<RESTPutAPIChannelRecipientResult>;
|
|
43
|
+
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelRecipientResult>;
|
|
48
44
|
};
|
|
49
45
|
pins: {
|
|
50
46
|
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelPinsResult>;
|
|
@@ -56,11 +52,9 @@ export interface ChannelRoutes {
|
|
|
56
52
|
followers: {
|
|
57
53
|
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelFollowersJSONBody>): Promise<RESTPostAPIChannelFollowersResult>;
|
|
58
54
|
};
|
|
59
|
-
permissions: {
|
|
60
|
-
(
|
|
61
|
-
|
|
62
|
-
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelPermissionResult>;
|
|
63
|
-
};
|
|
55
|
+
permissions: (id: string) => {
|
|
56
|
+
put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelPermissionJSONBody>): Promise<RESTPutAPIChannelPermissionResult>;
|
|
57
|
+
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIChannelPermissionResult>;
|
|
64
58
|
};
|
|
65
59
|
invites: {
|
|
66
60
|
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIChannelInvitesResult>;
|
|
@@ -2,13 +2,9 @@ import type { RESTPostAPIInteractionCallbackJSONBody } from '../../common';
|
|
|
2
2
|
import type { RestArguments } from '../api';
|
|
3
3
|
import type { ProxyRequestMethod } from '../Router';
|
|
4
4
|
export interface InteractionRoutes {
|
|
5
|
-
interactions: {
|
|
6
|
-
|
|
7
|
-
(
|
|
8
|
-
callback: {
|
|
9
|
-
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIInteractionCallbackJSONBody>): Promise<never>;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
5
|
+
interactions: (id: string) => (token: string) => {
|
|
6
|
+
callback: {
|
|
7
|
+
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIInteractionCallbackJSONBody>): Promise<never>;
|
|
12
8
|
};
|
|
13
9
|
};
|
|
14
10
|
}
|
|
@@ -17,12 +17,10 @@ export interface WebhookRoutes {
|
|
|
17
17
|
github: {
|
|
18
18
|
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIWebhookWithTokenJSONBody, RESTPostAPIWebhookWithTokenGitHubQuery>): Promise<RESTPostAPIWebhookWithTokenGitHubResult | RESTPostAPIWebhookWithTokenGitHubWaitResult>;
|
|
19
19
|
};
|
|
20
|
-
messages: {
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIWebhookWithTokenMessageResult>;
|
|
25
|
-
};
|
|
20
|
+
messages: (id: string | '@original') => {
|
|
21
|
+
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIWebhookWithTokenMessageResult>;
|
|
22
|
+
patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIWebhookWithTokenMessageJSONBody>): Promise<RESTPatchAPIWebhookWithTokenMessageResult>;
|
|
23
|
+
delete(args?: RestArguments<ProxyRequestMethod.Delete>): Promise<RESTDeleteAPIWebhookWithTokenMessageResult>;
|
|
26
24
|
};
|
|
27
25
|
};
|
|
28
26
|
};
|
package/lib/api/api.d.ts
CHANGED
|
@@ -4,12 +4,17 @@ import type { ProxyRequestMethod } from './Router';
|
|
|
4
4
|
import { Bucket } from './bucket';
|
|
5
5
|
import { type ApiHandlerInternalOptions, type ApiHandlerOptions, type ApiRequestOptions, type HttpMethods, type RawFile, type RequestHeaders } from './shared';
|
|
6
6
|
export declare class ApiHandler {
|
|
7
|
+
#private;
|
|
7
8
|
options: ApiHandlerInternalOptions;
|
|
8
9
|
globalBlock: boolean;
|
|
9
10
|
ratelimits: Map<string, Bucket>;
|
|
10
11
|
readyQueue: (() => void)[];
|
|
11
12
|
cdn: CDN;
|
|
12
13
|
debugger?: Logger;
|
|
14
|
+
workerPromises?: Map<string, {
|
|
15
|
+
resolve: (value: any) => any;
|
|
16
|
+
reject: (error: any) => any;
|
|
17
|
+
}>;
|
|
13
18
|
constructor(options: ApiHandlerOptions);
|
|
14
19
|
globalUnblock(): void;
|
|
15
20
|
request<T = any>(method: HttpMethods, url: `/${string}`, { auth, ...request }?: ApiRequestOptions): Promise<T>;
|
package/lib/api/api.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiHandler = void 0;
|
|
4
4
|
const magic_bytes_js_1 = require("magic-bytes.js");
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
6
|
const promises_1 = require("node:timers/promises");
|
|
7
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
6
8
|
const common_1 = require("../common");
|
|
7
9
|
const functions_1 = require("../structures/extra/functions");
|
|
8
10
|
const CDN_1 = require("./CDN");
|
|
@@ -16,8 +18,11 @@ class ApiHandler {
|
|
|
16
18
|
readyQueue = [];
|
|
17
19
|
cdn = new CDN_1.CDN();
|
|
18
20
|
debugger;
|
|
21
|
+
workerPromises;
|
|
19
22
|
constructor(options) {
|
|
20
23
|
this.options = {
|
|
24
|
+
baseUrl: 'api/v10',
|
|
25
|
+
domain: 'https://discord.com',
|
|
21
26
|
...options,
|
|
22
27
|
userAgent: shared_1.DefaultUserAgent,
|
|
23
28
|
};
|
|
@@ -26,6 +31,10 @@ class ApiHandler {
|
|
|
26
31
|
name: '[API]',
|
|
27
32
|
});
|
|
28
33
|
}
|
|
34
|
+
if (options.workerProxy && !node_worker_threads_1.parentPort)
|
|
35
|
+
throw new Error('Cannot use workerProxy without a parent.');
|
|
36
|
+
if (options.workerProxy)
|
|
37
|
+
this.workerPromises = new Map();
|
|
29
38
|
}
|
|
30
39
|
globalUnblock() {
|
|
31
40
|
this.globalBlock = false;
|
|
@@ -34,7 +43,34 @@ class ApiHandler {
|
|
|
34
43
|
cb();
|
|
35
44
|
}
|
|
36
45
|
}
|
|
46
|
+
#randomUUID() {
|
|
47
|
+
const uuid = (0, node_crypto_1.randomUUID)();
|
|
48
|
+
if (this.workerPromises.has(uuid))
|
|
49
|
+
return this.#randomUUID();
|
|
50
|
+
return uuid;
|
|
51
|
+
}
|
|
37
52
|
async request(method, url, { auth = true, ...request } = {}) {
|
|
53
|
+
if (this.options.workerProxy) {
|
|
54
|
+
const nonce = this.#randomUUID();
|
|
55
|
+
node_worker_threads_1.parentPort.postMessage({
|
|
56
|
+
method,
|
|
57
|
+
url,
|
|
58
|
+
type: 'WORKER_API_REQUEST',
|
|
59
|
+
workerId: node_worker_threads_1.workerData.workerId,
|
|
60
|
+
nonce,
|
|
61
|
+
requestOptions: { auth, ...request },
|
|
62
|
+
}, request.files
|
|
63
|
+
?.filter(x => !['string', 'boolean', 'number'].includes(typeof x.data))
|
|
64
|
+
.map(x => x.data));
|
|
65
|
+
let resolve = (_value) => { };
|
|
66
|
+
let reject = () => { };
|
|
67
|
+
const promise = new Promise((res, rej) => {
|
|
68
|
+
resolve = res;
|
|
69
|
+
reject = rej;
|
|
70
|
+
});
|
|
71
|
+
this.workerPromises.set(nonce, { reject, resolve });
|
|
72
|
+
return promise;
|
|
73
|
+
}
|
|
38
74
|
const route = request.route || this.routefy(url, method);
|
|
39
75
|
let attempts = 0;
|
|
40
76
|
const callback = async (next, resolve, reject) => {
|
package/lib/api/shared.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import type { MakeRequired } from '../common';
|
|
2
3
|
export * from './api';
|
|
3
4
|
export * from './utils/constants';
|
|
4
5
|
export * from './utils/types';
|
|
5
6
|
export { calculateUserDefaultAvatarIndex } from './utils/utils';
|
|
6
7
|
export interface ApiHandlerOptions {
|
|
7
|
-
baseUrl
|
|
8
|
-
domain
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
domain?: string;
|
|
9
10
|
token: string;
|
|
10
11
|
debug?: boolean;
|
|
11
12
|
agent?: string;
|
|
12
13
|
smartBucket?: boolean;
|
|
14
|
+
workerProxy?: boolean;
|
|
13
15
|
}
|
|
14
|
-
export interface ApiHandlerInternalOptions extends ApiHandlerOptions {
|
|
16
|
+
export interface ApiHandlerInternalOptions extends MakeRequired<ApiHandlerOptions, 'baseUrl' | 'domain'> {
|
|
15
17
|
userAgent: string;
|
|
16
18
|
}
|
|
17
19
|
export interface RawFile {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { APIAttachment, RESTAPIAttachment } from 'discord-api-types/v10';
|
|
3
|
-
import { type RawFile } from '..';
|
|
4
|
-
import type { BaseClient } from '../client/base';
|
|
3
|
+
import { type UsingClient, type RawFile } from '..';
|
|
5
4
|
import type { ImageResolvable, ObjectToLower } from '../common';
|
|
6
5
|
import { Base } from '../structures/extra/Base';
|
|
7
6
|
export interface AttachmentResolvableMap {
|
|
@@ -21,7 +20,7 @@ export interface Attachment extends ObjectToLower<APIAttachment> {
|
|
|
21
20
|
}
|
|
22
21
|
export declare class Attachment extends Base {
|
|
23
22
|
data: APIAttachment;
|
|
24
|
-
constructor(client:
|
|
23
|
+
constructor(client: UsingClient, data: APIAttachment);
|
|
25
24
|
}
|
|
26
25
|
export declare class AttachmentBuilder {
|
|
27
26
|
data: Partial<AttachmentData>;
|
package/lib/builders/Button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type APIButtonComponentWithCustomId, type APIButtonComponentWithURL, type ButtonStyle, type EmojiResolvable, type When } from '../common';
|
|
2
2
|
export type ButtonStylesForID = Exclude<ButtonStyle, ButtonStyle.Link>;
|
|
3
3
|
/**
|
|
4
4
|
* Represents a button component.
|
|
@@ -46,5 +46,5 @@ export declare class Button<Type extends boolean = boolean> {
|
|
|
46
46
|
* Converts the Button instance to its JSON representation.
|
|
47
47
|
* @returns The JSON representation of the Button instance.
|
|
48
48
|
*/
|
|
49
|
-
toJSON():
|
|
49
|
+
toJSON(): When<Type, APIButtonComponentWithCustomId, APIButtonComponentWithURL>;
|
|
50
50
|
}
|
|
@@ -9,6 +9,7 @@ catch {
|
|
|
9
9
|
// potocuit > seyfert
|
|
10
10
|
}
|
|
11
11
|
class RedisAdapter {
|
|
12
|
+
isAsync = true;
|
|
12
13
|
client;
|
|
13
14
|
namespace;
|
|
14
15
|
constructor(data) {
|
|
@@ -137,6 +138,10 @@ const isObject = (o) => {
|
|
|
137
138
|
return !!o && typeof o === 'object' && !Array.isArray(o);
|
|
138
139
|
};
|
|
139
140
|
function toNormal(target) {
|
|
141
|
+
if (typeof target.ARRAY_OF === 'string')
|
|
142
|
+
return JSON.parse(target.ARRAY_OF).map(toNormal);
|
|
143
|
+
if (!Object.keys(target).length)
|
|
144
|
+
return undefined;
|
|
140
145
|
const result = {};
|
|
141
146
|
for (const [key, value] of Object.entries(target)) {
|
|
142
147
|
if (key.startsWith('O_')) {
|
|
@@ -155,6 +160,8 @@ function toNormal(target) {
|
|
|
155
160
|
return result;
|
|
156
161
|
}
|
|
157
162
|
function toDb(target) {
|
|
163
|
+
if (Array.isArray(target))
|
|
164
|
+
return { ARRAY_OF: JSON.stringify(target.map(toDb)) };
|
|
158
165
|
const result = {};
|
|
159
166
|
for (const [key, value] of Object.entries(target)) {
|
|
160
167
|
switch (typeof value) {
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
5
|
/// <reference types="node" />
|
|
6
|
-
|
|
7
|
-
import { type MessagePort } from 'node:worker_threads';
|
|
6
|
+
import type { WorkerData } from '../../websocket';
|
|
8
7
|
import type { WorkerSendCacheRequest } from '../../websocket/discord/worker';
|
|
9
8
|
import type { Adapter } from './types';
|
|
10
9
|
export declare class WorkerAdapter implements Adapter {
|
|
11
|
-
|
|
10
|
+
workerData: WorkerData;
|
|
11
|
+
isAsync: boolean;
|
|
12
12
|
promises: Map<string, {
|
|
13
13
|
resolve: (value: unknown) => void;
|
|
14
14
|
timeout: NodeJS.Timeout;
|
|
15
15
|
}>;
|
|
16
|
-
constructor(
|
|
16
|
+
constructor(workerData: WorkerData);
|
|
17
|
+
postMessage(body: any): boolean | void;
|
|
17
18
|
protected send(method: WorkerSendCacheRequest['method'], ...args: any[]): Promise<any>;
|
|
18
19
|
scan(...rest: any[]): Promise<any>;
|
|
19
20
|
get(...rest: any[]): Promise<any>;
|
|
@@ -4,21 +4,27 @@ exports.WorkerAdapter = void 0;
|
|
|
4
4
|
const node_crypto_1 = require("node:crypto");
|
|
5
5
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
6
6
|
class WorkerAdapter {
|
|
7
|
-
|
|
7
|
+
workerData;
|
|
8
|
+
isAsync = true;
|
|
8
9
|
promises = new Map();
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
10
|
+
constructor(workerData) {
|
|
11
|
+
this.workerData = workerData;
|
|
12
|
+
}
|
|
13
|
+
postMessage(body) {
|
|
14
|
+
if (node_worker_threads_1.parentPort)
|
|
15
|
+
return node_worker_threads_1.parentPort.postMessage(body);
|
|
16
|
+
return process.send(body);
|
|
11
17
|
}
|
|
12
18
|
send(method, ...args) {
|
|
13
19
|
const nonce = (0, node_crypto_1.randomUUID)();
|
|
14
20
|
if (this.promises.has(nonce))
|
|
15
21
|
return this.send(method, ...args);
|
|
16
|
-
|
|
22
|
+
this.postMessage({
|
|
17
23
|
type: 'CACHE_REQUEST',
|
|
18
24
|
args,
|
|
19
25
|
nonce,
|
|
20
26
|
method,
|
|
21
|
-
workerId:
|
|
27
|
+
workerId: this.workerData.workerId,
|
|
22
28
|
});
|
|
23
29
|
let resolve = (_) => {
|
|
24
30
|
/**/
|
package/lib/cache/index.d.ts
CHANGED
|
@@ -11,8 +11,7 @@ import { StageInstances } from './resources/stage-instances';
|
|
|
11
11
|
import { Stickers } from './resources/stickers';
|
|
12
12
|
import { Threads } from './resources/threads';
|
|
13
13
|
import { VoiceStates } from './resources/voice-states';
|
|
14
|
-
import type {
|
|
15
|
-
import type { InternalOptions } from '../commands';
|
|
14
|
+
import type { InternalOptions, UsingClient } from '../commands';
|
|
16
15
|
import { GatewayIntentBits } from '../common';
|
|
17
16
|
import { Overwrites } from './resources/overwrites';
|
|
18
17
|
export type InferAsyncCache = InternalOptions extends {
|
|
@@ -27,11 +26,11 @@ export type CachedEvents = 'READY' | 'GUILD_CREATE' | 'GUILD_UPDATE' | 'GUILD_DE
|
|
|
27
26
|
export declare class Cache {
|
|
28
27
|
intents: number;
|
|
29
28
|
adapter: Adapter;
|
|
30
|
-
asyncCache: boolean;
|
|
31
29
|
readonly disabledCache: (NonGuildBased | GuildBased | GuildRelated)[];
|
|
32
30
|
users?: Users;
|
|
33
31
|
guilds?: Guilds;
|
|
34
32
|
members?: Members;
|
|
33
|
+
voiceStates?: VoiceStates;
|
|
35
34
|
overwrites?: Overwrites;
|
|
36
35
|
roles?: Roles;
|
|
37
36
|
emojis?: Emojis;
|
|
@@ -39,9 +38,8 @@ export declare class Cache {
|
|
|
39
38
|
channels?: Channels;
|
|
40
39
|
stickers?: Stickers;
|
|
41
40
|
presences?: Presences;
|
|
42
|
-
voiceStates?: VoiceStates;
|
|
43
41
|
stageInstances?: StageInstances;
|
|
44
|
-
constructor(intents: number, adapter: Adapter,
|
|
42
|
+
constructor(intents: number, adapter: Adapter, disabledCache?: (NonGuildBased | GuildBased | GuildRelated)[], client?: UsingClient);
|
|
45
43
|
hasIntent(intent: keyof typeof GatewayIntentBits): boolean;
|
|
46
44
|
get hasGuildsIntent(): boolean;
|
|
47
45
|
get hasRolesIntent(): boolean;
|
|
@@ -66,12 +64,12 @@ export declare class Cache {
|
|
|
66
64
|
channels: NonNullable<ReturnCache<import("..").AllChannels | undefined>>[];
|
|
67
65
|
members: import("..").GuildMember[];
|
|
68
66
|
users: import("..").User[];
|
|
67
|
+
threads: import("..").ThreadChannel[];
|
|
69
68
|
presences: (Omit<import("discord-api-types/payloads/v10/gateway").GatewayPresenceUpdate, "user"> & {
|
|
70
69
|
id: string;
|
|
71
70
|
} & {
|
|
72
71
|
guild_id: string;
|
|
73
72
|
})[];
|
|
74
|
-
threads: import("..").ThreadChannel[];
|
|
75
73
|
voiceStates: (Omit<import("discord-api-types/payloads/v10/voice").GatewayVoiceState, "member"> & {
|
|
76
74
|
guild_id: string;
|
|
77
75
|
} & {
|
package/lib/cache/index.js
CHANGED
|
@@ -32,13 +32,13 @@ __exportStar(require("./adapters/index"), exports);
|
|
|
32
32
|
class Cache {
|
|
33
33
|
intents;
|
|
34
34
|
adapter;
|
|
35
|
-
asyncCache;
|
|
36
35
|
disabledCache;
|
|
37
36
|
// non-guild based
|
|
38
37
|
users;
|
|
39
38
|
guilds;
|
|
40
39
|
// guild based
|
|
41
40
|
members;
|
|
41
|
+
voiceStates;
|
|
42
42
|
// guild related
|
|
43
43
|
overwrites;
|
|
44
44
|
roles;
|
|
@@ -47,12 +47,10 @@ class Cache {
|
|
|
47
47
|
channels;
|
|
48
48
|
stickers;
|
|
49
49
|
presences;
|
|
50
|
-
voiceStates;
|
|
51
50
|
stageInstances;
|
|
52
|
-
constructor(intents, adapter,
|
|
51
|
+
constructor(intents, adapter, disabledCache = [], client) {
|
|
53
52
|
this.intents = intents;
|
|
54
53
|
this.adapter = adapter;
|
|
55
|
-
this.asyncCache = asyncCache;
|
|
56
54
|
this.disabledCache = disabledCache;
|
|
57
55
|
// non-guild based
|
|
58
56
|
if (!this.disabledCache.includes('users')) {
|
|
@@ -101,6 +99,7 @@ class Cache {
|
|
|
101
99
|
this.members?.__setClient(client);
|
|
102
100
|
this.voiceStates?.__setClient(client);
|
|
103
101
|
this.roles?.__setClient(client);
|
|
102
|
+
this.overwrites?.__setClient(client);
|
|
104
103
|
this.channels?.__setClient(client);
|
|
105
104
|
this.emojis?.__setClient(client);
|
|
106
105
|
this.stickers?.__setClient(client);
|
|
@@ -225,7 +224,7 @@ class Cache {
|
|
|
225
224
|
}
|
|
226
225
|
relationshipsData[hashId].push(id);
|
|
227
226
|
data.guild_id = guildId;
|
|
228
|
-
allData.push([this[type].hashGuildId(
|
|
227
|
+
allData.push([this[type].hashGuildId(guildId, id), this[type].parse(data, id, guildId)]);
|
|
229
228
|
}
|
|
230
229
|
break;
|
|
231
230
|
case 'users':
|
|
@@ -289,7 +288,7 @@ class Cache {
|
|
|
289
288
|
}
|
|
290
289
|
relationshipsData[hashId].push(id);
|
|
291
290
|
data.guild_id = guildId;
|
|
292
|
-
allData.push([this[type].hashGuildId(
|
|
291
|
+
allData.push([this[type].hashGuildId(guildId, id), this[type].parse(data, id, guildId)]);
|
|
293
292
|
}
|
|
294
293
|
break;
|
|
295
294
|
case 'users':
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { BaseClient } from '../../../client/base';
|
|
2
|
+
import type { UsingClient } from '../../../commands';
|
|
2
3
|
import { type GatewayIntentBits } from '../../../common';
|
|
3
4
|
import type { Cache, ReturnCache } from '../../index';
|
|
4
5
|
export declare class BaseResource<T = any> {
|
|
5
6
|
protected cache: Cache;
|
|
6
7
|
client: BaseClient;
|
|
7
8
|
namespace: string;
|
|
8
|
-
constructor(cache: Cache, client?:
|
|
9
|
+
constructor(cache: Cache, client?: UsingClient);
|
|
9
10
|
get rest(): import("../../..").ApiHandler;
|
|
10
11
|
get adapter(): import("../../index").Adapter;
|
|
11
12
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../index").RPV<void>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { BaseClient } from '../../../client/base';
|
|
2
|
+
import type { UsingClient } from '../../../commands';
|
|
2
3
|
import { type GatewayIntentBits } from '../../../common';
|
|
3
4
|
import type { Cache, ReturnCache } from '../../index';
|
|
4
5
|
export declare class GuildBasedResource<T = any> {
|
|
5
6
|
protected cache: Cache;
|
|
6
7
|
client: BaseClient;
|
|
7
8
|
namespace: string;
|
|
8
|
-
constructor(cache: Cache, client?:
|
|
9
|
+
constructor(cache: Cache, client?: UsingClient);
|
|
9
10
|
parse(data: any, id: string, guild_id: string): any;
|
|
10
11
|
get adapter(): import("../../index").Adapter;
|
|
11
12
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
|
|
@@ -36,27 +36,27 @@ class GuildBasedResource {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
get(id, guild) {
|
|
39
|
-
return this.adapter.get(this.hashGuildId(
|
|
39
|
+
return this.adapter.get(this.hashGuildId(guild, id));
|
|
40
40
|
}
|
|
41
41
|
bulk(ids, guild) {
|
|
42
|
-
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashGuildId(
|
|
42
|
+
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashGuildId(guild, id)))).then(x => x.filter(y => y));
|
|
43
43
|
}
|
|
44
44
|
set(__keys, guild, data) {
|
|
45
45
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
46
46
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
47
|
-
return [this.hashGuildId(
|
|
47
|
+
return [this.hashGuildId(guild, key), this.parse(value, key, guild)];
|
|
48
48
|
})));
|
|
49
49
|
}
|
|
50
50
|
patch(__keys, guild, data) {
|
|
51
51
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
52
|
-
return (0, common_1.fakePromise)(this.adapter.get(keys.map(([key]) => this.hashGuildId(
|
|
52
|
+
return (0, common_1.fakePromise)(this.adapter.get(keys.map(([key]) => this.hashGuildId(guild, key)))).then(oldDatas => (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
53
53
|
const oldData = oldDatas.find(x => x.id === key) ?? {};
|
|
54
|
-
return [this.hashGuildId(
|
|
54
|
+
return [this.hashGuildId(guild, key), this.parse({ ...oldData, ...value }, key, guild)];
|
|
55
55
|
}))));
|
|
56
56
|
}
|
|
57
57
|
remove(id, guild) {
|
|
58
58
|
const ids = Array.isArray(id) ? id : [id];
|
|
59
|
-
return (0, common_1.fakePromise)(this.removeToRelationship(ids, guild)).then(() => this.adapter.remove(ids.map(x => this.hashGuildId(
|
|
59
|
+
return (0, common_1.fakePromise)(this.removeToRelationship(ids, guild)).then(() => this.adapter.remove(ids.map(x => this.hashGuildId(guild, x))));
|
|
60
60
|
}
|
|
61
61
|
keys(guild) {
|
|
62
62
|
return this.adapter.scan(this.hashGuildId(guild, '*'), true);
|