seyfert 1.0.1 → 1.1.1
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/builders/Attachment.d.ts +2 -3
- package/lib/cache/adapters/redis.js +6 -0
- package/lib/cache/adapters/types.d.ts +23 -23
- package/lib/cache/adapters/workeradapter.d.ts +4 -4
- package/lib/cache/adapters/workeradapter.js +10 -5
- package/lib/cache/index.d.ts +4 -5
- package/lib/cache/index.js +4 -3
- package/lib/cache/resources/default/base.d.ts +11 -10
- package/lib/cache/resources/default/guild-based.d.ts +8 -7
- package/lib/cache/resources/default/guild-based.js +8 -7
- package/lib/cache/resources/default/guild-related.d.ts +10 -9
- package/lib/cache/resources/default/guild-related.js +3 -2
- 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 +33 -179
- package/lib/client/base.js +56 -21
- package/lib/client/client.d.ts +10 -3
- package/lib/client/client.js +23 -8
- package/lib/client/oninteractioncreate.js +9 -9
- package/lib/client/onmessagecreate.js +192 -153
- package/lib/client/workerclient.d.ts +9 -3
- package/lib/client/workerclient.js +50 -23
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +16 -8
- package/lib/commands/applications/chat.js +20 -13
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +6 -1
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +11 -5
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +7 -2
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/applications/shared.d.ts +5 -4
- package/lib/commands/decorators.d.ts +18 -6
- package/lib/commands/decorators.js +18 -8
- package/lib/commands/handler.d.ts +11 -5
- package/lib/commands/handler.js +46 -37
- 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.d.ts +1 -0
- package/lib/common/it/utils.js +4 -1
- 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 -6
- package/lib/common/shorters/users.js +29 -33
- 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 +3 -0
- package/lib/components/handler.d.ts +28 -9
- package/lib/components/handler.js +28 -11
- package/lib/events/handler.d.ts +10 -2
- package/lib/events/handler.js +6 -8
- package/lib/index.d.ts +4 -2
- package/lib/index.js +1 -1
- package/lib/langs/handler.d.ts +8 -0
- package/lib/langs/handler.js +8 -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 +7 -6
- package/lib/structures/GuildMember.js +5 -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 +9 -10
- package/lib/structures/Interaction.js +2 -2
- package/lib/structures/Message.d.ts +8 -7
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/User.d.ts +1 -0
- package/lib/structures/User.js +5 -0
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +21 -22
- 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 +1 -0
- 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 +1 -0
- package/lib/websocket/discord/worker.d.ts +2 -1
- package/lib/websocket/discord/workermanager.d.ts +8 -3
- package/lib/websocket/discord/workermanager.js +78 -30
- package/package.json +8 -6
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
|
};
|
|
@@ -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>;
|
|
@@ -138,6 +138,10 @@ const isObject = (o) => {
|
|
|
138
138
|
return !!o && typeof o === 'object' && !Array.isArray(o);
|
|
139
139
|
};
|
|
140
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;
|
|
141
145
|
const result = {};
|
|
142
146
|
for (const [key, value] of Object.entries(target)) {
|
|
143
147
|
if (key.startsWith('O_')) {
|
|
@@ -156,6 +160,8 @@ function toNormal(target) {
|
|
|
156
160
|
return result;
|
|
157
161
|
}
|
|
158
162
|
function toDb(target) {
|
|
163
|
+
if (Array.isArray(target))
|
|
164
|
+
return { ARRAY_OF: JSON.stringify(target.map(toDb)) };
|
|
159
165
|
const result = {};
|
|
160
166
|
for (const [key, value] of Object.entries(target)) {
|
|
161
167
|
switch (typeof value) {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
+
import type { Awaitable } from '../../common';
|
|
1
2
|
export interface Adapter {
|
|
2
3
|
isAsync: boolean;
|
|
3
|
-
scan(query: string, keys?: false):
|
|
4
|
-
scan(query: string, keys: true):
|
|
5
|
-
scan(query: string, keys?: boolean):
|
|
6
|
-
get(keys: string[]):
|
|
7
|
-
get(keys: string):
|
|
8
|
-
get(keys: string | string[]):
|
|
9
|
-
set(keyValue: [string, any][]):
|
|
10
|
-
set(id: string, data: any):
|
|
11
|
-
set(id: string | [string, any][], data?: any):
|
|
12
|
-
patch(updateOnly: boolean, keyValue: [string, any][]):
|
|
13
|
-
patch(updateOnly: boolean, id: string, data: any):
|
|
14
|
-
patch(updateOnly: boolean, id: string | [string, any][], data?: any):
|
|
15
|
-
values(to: string):
|
|
16
|
-
keys(to: string):
|
|
17
|
-
count(to: string):
|
|
18
|
-
remove(keys: string | string[]):
|
|
19
|
-
contains(to: string, keys: string):
|
|
20
|
-
getToRelationship(to: string):
|
|
21
|
-
bulkAddToRelationShip(data: Record<string, string[]>):
|
|
22
|
-
addToRelationship(to: string, keys: string | string[]):
|
|
23
|
-
removeToRelationship(to: string, keys: string | string[]):
|
|
24
|
-
removeRelationship(to: string | string[]):
|
|
4
|
+
scan(query: string, keys?: false): Awaitable<any[]>;
|
|
5
|
+
scan(query: string, keys: true): Awaitable<string[]>;
|
|
6
|
+
scan(query: string, keys?: boolean): Awaitable<(any | string)[]>;
|
|
7
|
+
get(keys: string[]): Awaitable<any[]>;
|
|
8
|
+
get(keys: string): Awaitable<any | null>;
|
|
9
|
+
get(keys: string | string[]): Awaitable<any | null>;
|
|
10
|
+
set(keyValue: [string, any][]): Awaitable<void>;
|
|
11
|
+
set(id: string, data: any): Awaitable<void>;
|
|
12
|
+
set(id: string | [string, any][], data?: any): Awaitable<void>;
|
|
13
|
+
patch(updateOnly: boolean, keyValue: [string, any][]): Awaitable<void>;
|
|
14
|
+
patch(updateOnly: boolean, id: string, data: any): Awaitable<void>;
|
|
15
|
+
patch(updateOnly: boolean, id: string | [string, any][], data?: any): Awaitable<void>;
|
|
16
|
+
values(to: string): Awaitable<any[]>;
|
|
17
|
+
keys(to: string): Awaitable<string[]>;
|
|
18
|
+
count(to: string): Awaitable<number>;
|
|
19
|
+
remove(keys: string | string[]): Awaitable<void>;
|
|
20
|
+
contains(to: string, keys: string): Awaitable<boolean>;
|
|
21
|
+
getToRelationship(to: string): Awaitable<string[]>;
|
|
22
|
+
bulkAddToRelationShip(data: Record<string, string[]>): Awaitable<void>;
|
|
23
|
+
addToRelationship(to: string, keys: string | string[]): Awaitable<void>;
|
|
24
|
+
removeToRelationship(to: string, keys: string | string[]): Awaitable<void>;
|
|
25
|
+
removeRelationship(to: string | string[]): Awaitable<void>;
|
|
25
26
|
}
|
|
26
|
-
export type RPV<V> = Promise<V> | V;
|
|
@@ -3,18 +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;
|
|
12
11
|
isAsync: boolean;
|
|
13
12
|
promises: Map<string, {
|
|
14
13
|
resolve: (value: unknown) => void;
|
|
15
14
|
timeout: NodeJS.Timeout;
|
|
16
15
|
}>;
|
|
17
|
-
constructor(
|
|
16
|
+
constructor(workerData: WorkerData);
|
|
17
|
+
postMessage(body: any): boolean | void;
|
|
18
18
|
protected send(method: WorkerSendCacheRequest['method'], ...args: any[]): Promise<any>;
|
|
19
19
|
scan(...rest: any[]): Promise<any>;
|
|
20
20
|
get(...rest: any[]): Promise<any>;
|
|
@@ -4,22 +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
8
|
isAsync = true;
|
|
9
9
|
promises = new Map();
|
|
10
|
-
constructor(
|
|
11
|
-
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);
|
|
12
17
|
}
|
|
13
18
|
send(method, ...args) {
|
|
14
19
|
const nonce = (0, node_crypto_1.randomUUID)();
|
|
15
20
|
if (this.promises.has(nonce))
|
|
16
21
|
return this.send(method, ...args);
|
|
17
|
-
|
|
22
|
+
this.postMessage({
|
|
18
23
|
type: 'CACHE_REQUEST',
|
|
19
24
|
args,
|
|
20
25
|
nonce,
|
|
21
26
|
method,
|
|
22
|
-
workerId:
|
|
27
|
+
workerId: this.workerData.workerId,
|
|
23
28
|
});
|
|
24
29
|
let resolve = (_) => {
|
|
25
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 {
|
|
@@ -31,6 +30,7 @@ export declare class Cache {
|
|
|
31
30
|
users?: Users;
|
|
32
31
|
guilds?: Guilds;
|
|
33
32
|
members?: Members;
|
|
33
|
+
voiceStates?: VoiceStates;
|
|
34
34
|
overwrites?: Overwrites;
|
|
35
35
|
roles?: Roles;
|
|
36
36
|
emojis?: Emojis;
|
|
@@ -38,9 +38,8 @@ export declare class Cache {
|
|
|
38
38
|
channels?: Channels;
|
|
39
39
|
stickers?: Stickers;
|
|
40
40
|
presences?: Presences;
|
|
41
|
-
voiceStates?: VoiceStates;
|
|
42
41
|
stageInstances?: StageInstances;
|
|
43
|
-
constructor(intents: number, adapter: Adapter, disabledCache?: (NonGuildBased | GuildBased | GuildRelated)[], client?:
|
|
42
|
+
constructor(intents: number, adapter: Adapter, disabledCache?: (NonGuildBased | GuildBased | GuildRelated)[], client?: UsingClient);
|
|
44
43
|
hasIntent(intent: keyof typeof GatewayIntentBits): boolean;
|
|
45
44
|
get hasGuildsIntent(): boolean;
|
|
46
45
|
get hasRolesIntent(): boolean;
|
|
@@ -65,12 +64,12 @@ export declare class Cache {
|
|
|
65
64
|
channels: NonNullable<ReturnCache<import("..").AllChannels | undefined>>[];
|
|
66
65
|
members: import("..").GuildMember[];
|
|
67
66
|
users: import("..").User[];
|
|
67
|
+
threads: import("..").ThreadChannel[];
|
|
68
68
|
presences: (Omit<import("discord-api-types/payloads/v10/gateway").GatewayPresenceUpdate, "user"> & {
|
|
69
69
|
id: string;
|
|
70
70
|
} & {
|
|
71
71
|
guild_id: string;
|
|
72
72
|
})[];
|
|
73
|
-
threads: import("..").ThreadChannel[];
|
|
74
73
|
voiceStates: (Omit<import("discord-api-types/payloads/v10/voice").GatewayVoiceState, "member"> & {
|
|
75
74
|
guild_id: string;
|
|
76
75
|
} & {
|
package/lib/cache/index.js
CHANGED
|
@@ -38,6 +38,7 @@ class Cache {
|
|
|
38
38
|
guilds;
|
|
39
39
|
// guild based
|
|
40
40
|
members;
|
|
41
|
+
voiceStates;
|
|
41
42
|
// guild related
|
|
42
43
|
overwrites;
|
|
43
44
|
roles;
|
|
@@ -46,7 +47,6 @@ class Cache {
|
|
|
46
47
|
channels;
|
|
47
48
|
stickers;
|
|
48
49
|
presences;
|
|
49
|
-
voiceStates;
|
|
50
50
|
stageInstances;
|
|
51
51
|
constructor(intents, adapter, disabledCache = [], client) {
|
|
52
52
|
this.intents = intents;
|
|
@@ -99,6 +99,7 @@ class Cache {
|
|
|
99
99
|
this.members?.__setClient(client);
|
|
100
100
|
this.voiceStates?.__setClient(client);
|
|
101
101
|
this.roles?.__setClient(client);
|
|
102
|
+
this.overwrites?.__setClient(client);
|
|
102
103
|
this.channels?.__setClient(client);
|
|
103
104
|
this.emojis?.__setClient(client);
|
|
104
105
|
this.stickers?.__setClient(client);
|
|
@@ -223,7 +224,7 @@ class Cache {
|
|
|
223
224
|
}
|
|
224
225
|
relationshipsData[hashId].push(id);
|
|
225
226
|
data.guild_id = guildId;
|
|
226
|
-
allData.push([this[type].hashGuildId(
|
|
227
|
+
allData.push([this[type].hashGuildId(guildId, id), this[type].parse(data, id, guildId)]);
|
|
227
228
|
}
|
|
228
229
|
break;
|
|
229
230
|
case 'users':
|
|
@@ -287,7 +288,7 @@ class Cache {
|
|
|
287
288
|
}
|
|
288
289
|
relationshipsData[hashId].push(id);
|
|
289
290
|
data.guild_id = guildId;
|
|
290
|
-
allData.push([this[type].hashGuildId(
|
|
291
|
+
allData.push([this[type].hashGuildId(guildId, id), this[type].parse(data, id, guildId)]);
|
|
291
292
|
}
|
|
292
293
|
break;
|
|
293
294
|
case 'users':
|
|
@@ -1,26 +1,27 @@
|
|
|
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
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("
|
|
12
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../../common").Awaitable<void>;
|
|
12
13
|
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any): any;
|
|
13
14
|
get(id: string): ReturnCache<T | undefined>;
|
|
14
15
|
bulk(ids: string[]): ReturnCache<T[]>;
|
|
15
|
-
set(id: string, data: any): import("
|
|
16
|
-
patch<T extends Record<any, any> = Record<any, any>>(id: string, data: T): import("
|
|
17
|
-
remove(id: string): import("
|
|
16
|
+
set(id: string, data: any): import("../../../common").Awaitable<void>;
|
|
17
|
+
patch<T extends Record<any, any> = Record<any, any>>(id: string, data: T): import("../../../common").Awaitable<void>;
|
|
18
|
+
remove(id: string): import("../../../common").Awaitable<void>;
|
|
18
19
|
keys(): ReturnCache<string[]>;
|
|
19
20
|
values(): ReturnCache<T[]>;
|
|
20
|
-
count(): import("
|
|
21
|
-
contains(id: string): import("
|
|
22
|
-
getToRelationship(): import("
|
|
23
|
-
addToRelationship(id: string | string[]): import("
|
|
24
|
-
removeToRelationship(id: string | string[]): import("
|
|
21
|
+
count(): import("../../../common").Awaitable<number>;
|
|
22
|
+
contains(id: string): import("../../../common").Awaitable<boolean>;
|
|
23
|
+
getToRelationship(): import("../../../common").Awaitable<string[]>;
|
|
24
|
+
addToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
25
|
+
removeToRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
25
26
|
hashId(id: string): string;
|
|
26
27
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
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
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("
|
|
12
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
12
13
|
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
|
|
13
14
|
get(id: string, guild: string): ReturnCache<(T & {
|
|
14
15
|
guild_id: string;
|
|
@@ -20,17 +21,17 @@ export declare class GuildBasedResource<T = any> {
|
|
|
20
21
|
set(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
21
22
|
patch(__keys: string, guild: string, data: any): ReturnCache<void>;
|
|
22
23
|
patch(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
23
|
-
remove(id: string | string[], guild: string): import("
|
|
24
|
+
remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
24
25
|
keys(guild: string): ReturnCache<string[]>;
|
|
25
26
|
values(guild: string): ReturnCache<(T & {
|
|
26
27
|
guild_id: string;
|
|
27
28
|
})[]>;
|
|
28
29
|
count(guild: string): ReturnCache<number>;
|
|
29
30
|
contains(id: string, guild: string): ReturnCache<boolean>;
|
|
30
|
-
getToRelationship(guild: string): import("
|
|
31
|
-
addToRelationship(id: string | string[], guild: string): import("
|
|
32
|
-
removeToRelationship(id: string | string[], guild: string): import("
|
|
33
|
-
removeRelationship(id: string | string[]): import("
|
|
31
|
+
getToRelationship(guild: string): import("../../../common").Awaitable<string[]>;
|
|
32
|
+
addToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
33
|
+
removeToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
34
|
+
removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
34
35
|
hashId(id: string): string;
|
|
35
36
|
hashGuildId(guild: string, id: string): string;
|
|
36
37
|
}
|
|
@@ -17,7 +17,8 @@ class GuildBasedResource {
|
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
19
|
parse(data, id, guild_id) {
|
|
20
|
-
data.id
|
|
20
|
+
if (!data.id)
|
|
21
|
+
data.id = id;
|
|
21
22
|
data.guild_id = guild_id;
|
|
22
23
|
return data;
|
|
23
24
|
}
|
|
@@ -36,27 +37,27 @@ class GuildBasedResource {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
get(id, guild) {
|
|
39
|
-
return this.adapter.get(this.hashGuildId(
|
|
40
|
+
return this.adapter.get(this.hashGuildId(guild, id));
|
|
40
41
|
}
|
|
41
42
|
bulk(ids, guild) {
|
|
42
|
-
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashGuildId(
|
|
43
|
+
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashGuildId(guild, id)))).then(x => x.filter(y => y));
|
|
43
44
|
}
|
|
44
45
|
set(__keys, guild, data) {
|
|
45
46
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
46
47
|
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(
|
|
48
|
+
return [this.hashGuildId(guild, key), this.parse(value, key, guild)];
|
|
48
49
|
})));
|
|
49
50
|
}
|
|
50
51
|
patch(__keys, guild, data) {
|
|
51
52
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
52
|
-
return (0, common_1.fakePromise)(this.adapter.get(keys.map(([key]) => this.hashGuildId(
|
|
53
|
+
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
54
|
const oldData = oldDatas.find(x => x.id === key) ?? {};
|
|
54
|
-
return [this.hashGuildId(
|
|
55
|
+
return [this.hashGuildId(guild, key), this.parse({ ...oldData, ...value }, key, guild)];
|
|
55
56
|
}))));
|
|
56
57
|
}
|
|
57
58
|
remove(id, guild) {
|
|
58
59
|
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(
|
|
60
|
+
return (0, common_1.fakePromise)(this.removeToRelationship(ids, guild)).then(() => this.adapter.remove(ids.map(x => this.hashGuildId(guild, x))));
|
|
60
61
|
}
|
|
61
62
|
keys(guild) {
|
|
62
63
|
return this.adapter.scan(this.hashGuildId(guild, '*'), true);
|
|
@@ -1,14 +1,15 @@
|
|
|
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 GuildRelatedResource<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
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("
|
|
12
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
12
13
|
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
|
|
13
14
|
get(id: string): ReturnCache<(T & {
|
|
14
15
|
guild_id: string;
|
|
@@ -20,16 +21,16 @@ export declare class GuildRelatedResource<T = any> {
|
|
|
20
21
|
set(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
21
22
|
patch(__keys: string, guild?: string, data?: any): ReturnCache<void>;
|
|
22
23
|
patch(__keys: [string, any][], guild?: string): ReturnCache<void>;
|
|
23
|
-
remove(id: string | string[], guild: string): import("
|
|
24
|
+
remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
24
25
|
keys(guild: string): ReturnCache<string[]>;
|
|
25
26
|
values(guild: string): ReturnCache<(T & {
|
|
26
27
|
guild_id: string;
|
|
27
28
|
})[]>;
|
|
28
|
-
count(to: string): import("
|
|
29
|
-
contains(id: string, guild: string): import("
|
|
30
|
-
getToRelationship(guild: string): import("
|
|
31
|
-
addToRelationship(id: string | string[], guild: string): import("
|
|
32
|
-
removeToRelationship(id: string | string[], guild: string): import("
|
|
33
|
-
removeRelationship(id: string | string[]): import("
|
|
29
|
+
count(to: string): import("../../../common").Awaitable<number>;
|
|
30
|
+
contains(id: string, guild: string): import("../../../common").Awaitable<boolean>;
|
|
31
|
+
getToRelationship(guild: string): import("../../../common").Awaitable<string[]>;
|
|
32
|
+
addToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
33
|
+
removeToRelationship(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
34
|
+
removeRelationship(id: string | string[]): import("../../../common").Awaitable<void>;
|
|
34
35
|
hashId(id: string): string;
|
|
35
36
|
}
|
|
@@ -17,7 +17,8 @@ class GuildRelatedResource {
|
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
19
|
parse(data, id, guild_id) {
|
|
20
|
-
data.id
|
|
20
|
+
if (!data.id)
|
|
21
|
+
data.id = id;
|
|
21
22
|
data.guild_id = guild_id;
|
|
22
23
|
return data;
|
|
23
24
|
}
|
|
@@ -72,7 +73,7 @@ class GuildRelatedResource {
|
|
|
72
73
|
: (0, common_1.fakePromise)(this.adapter.getToRelationship(this.hashId(guild))).then(keys => this.adapter.get(keys.map(x => `${this.namespace}.${x}`)));
|
|
73
74
|
}
|
|
74
75
|
count(to) {
|
|
75
|
-
return this.adapter.count(this.hashId(to));
|
|
76
|
+
return to === '*' ? (0, common_1.fakePromise)(this.keys(to)).then(x => x.length) : this.adapter.count(this.hashId(to));
|
|
76
77
|
}
|
|
77
78
|
contains(id, guild) {
|
|
78
79
|
return this.adapter.contains(this.hashId(guild), id);
|