seyfert 1.0.1 → 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.
Files changed (103) hide show
  1. package/lib/api/CDN.d.ts +1 -1
  2. package/lib/api/CDN.js +0 -2
  3. package/lib/api/Router.js +2 -2
  4. package/lib/api/Routes/applications.d.ts +29 -33
  5. package/lib/api/Routes/channels.d.ts +11 -17
  6. package/lib/api/Routes/interactions.d.ts +3 -7
  7. package/lib/api/Routes/webhooks.d.ts +4 -6
  8. package/lib/builders/Attachment.d.ts +2 -3
  9. package/lib/cache/adapters/redis.js +6 -0
  10. package/lib/cache/adapters/workeradapter.d.ts +4 -4
  11. package/lib/cache/adapters/workeradapter.js +10 -5
  12. package/lib/cache/index.d.ts +4 -5
  13. package/lib/cache/index.js +4 -3
  14. package/lib/cache/resources/default/base.d.ts +2 -1
  15. package/lib/cache/resources/default/guild-based.d.ts +2 -1
  16. package/lib/cache/resources/default/guild-based.js +6 -6
  17. package/lib/cache/resources/default/guild-related.d.ts +2 -1
  18. package/lib/cache/resources/default/guild-related.js +1 -1
  19. package/lib/cache/resources/guilds.js +2 -1
  20. package/lib/cache/resources/overwrites.d.ts +1 -1
  21. package/lib/cache/resources/overwrites.js +7 -1
  22. package/lib/client/base.d.ts +18 -170
  23. package/lib/client/base.js +11 -14
  24. package/lib/client/client.d.ts +5 -0
  25. package/lib/client/client.js +4 -1
  26. package/lib/client/oninteractioncreate.js +2 -2
  27. package/lib/client/onmessagecreate.js +188 -152
  28. package/lib/client/workerclient.d.ts +1 -0
  29. package/lib/client/workerclient.js +36 -15
  30. package/lib/collection.js +2 -2
  31. package/lib/commands/applications/chat.d.ts +15 -7
  32. package/lib/commands/applications/chat.js +7 -7
  33. package/lib/commands/applications/chatcontext.d.ts +5 -3
  34. package/lib/commands/applications/chatcontext.js +6 -1
  35. package/lib/commands/applications/menu.d.ts +5 -1
  36. package/lib/commands/applications/menu.js +4 -0
  37. package/lib/commands/applications/menucontext.d.ts +4 -2
  38. package/lib/commands/applications/menucontext.js +6 -1
  39. package/lib/commands/applications/options.d.ts +1 -2
  40. package/lib/commands/decorators.d.ts +17 -5
  41. package/lib/commands/decorators.js +17 -7
  42. package/lib/commands/handler.d.ts +5 -5
  43. package/lib/commands/handler.js +40 -36
  44. package/lib/commands/optionresolver.d.ts +11 -4
  45. package/lib/commands/optionresolver.js +6 -4
  46. package/lib/common/index.d.ts +7 -0
  47. package/lib/common/index.js +7 -0
  48. package/lib/common/it/utils.js +2 -0
  49. package/lib/common/shorters/channels.d.ts +67 -129
  50. package/lib/common/shorters/channels.js +119 -135
  51. package/lib/common/shorters/emojis.d.ts +47 -0
  52. package/lib/common/shorters/emojis.js +80 -0
  53. package/lib/common/shorters/guilds.d.ts +22 -249
  54. package/lib/common/shorters/guilds.js +51 -140
  55. package/lib/common/shorters/members.d.ts +82 -108
  56. package/lib/common/shorters/members.js +151 -166
  57. package/lib/common/shorters/messages.d.ts +11 -23
  58. package/lib/common/shorters/messages.js +58 -104
  59. package/lib/common/shorters/reactions.d.ts +10 -0
  60. package/lib/common/shorters/reactions.js +45 -0
  61. package/lib/common/shorters/roles.d.ts +39 -7
  62. package/lib/common/shorters/roles.js +74 -42
  63. package/lib/common/shorters/templates.d.ts +6 -8
  64. package/lib/common/shorters/templates.js +17 -21
  65. package/lib/common/shorters/users.d.ts +4 -0
  66. package/lib/common/shorters/users.js +30 -0
  67. package/lib/common/shorters/webhook.d.ts +62 -26
  68. package/lib/common/shorters/webhook.js +113 -58
  69. package/lib/common/types/options.d.ts +2 -2
  70. package/lib/components/handler.d.ts +10 -7
  71. package/lib/components/handler.js +20 -5
  72. package/lib/index.d.ts +4 -2
  73. package/lib/langs/handler.js +7 -2
  74. package/lib/structures/AutoModerationRule.d.ts +2 -2
  75. package/lib/structures/ClientUser.d.ts +2 -2
  76. package/lib/structures/Guild.d.ts +2 -2
  77. package/lib/structures/GuildEmoji.d.ts +4 -4
  78. package/lib/structures/GuildEmoji.js +7 -7
  79. package/lib/structures/GuildMember.d.ts +6 -6
  80. package/lib/structures/GuildMember.js +2 -2
  81. package/lib/structures/GuildPreview.d.ts +2 -2
  82. package/lib/structures/GuildRole.d.ts +2 -2
  83. package/lib/structures/GuildTemplate.d.ts +2 -2
  84. package/lib/structures/Interaction.d.ts +7 -8
  85. package/lib/structures/Interaction.js +1 -1
  86. package/lib/structures/Message.d.ts +7 -6
  87. package/lib/structures/Message.js +7 -4
  88. package/lib/structures/Sticker.d.ts +2 -2
  89. package/lib/structures/Webhook.d.ts +2 -2
  90. package/lib/structures/Webhook.js +3 -3
  91. package/lib/structures/channels.d.ts +19 -20
  92. package/lib/structures/channels.js +13 -25
  93. package/lib/structures/extra/Base.d.ts +1 -2
  94. package/lib/structures/extra/DiscordBase.d.ts +2 -2
  95. package/lib/websocket/constants/index.js +1 -0
  96. package/lib/websocket/discord/shard.js +4 -2
  97. package/lib/websocket/discord/sharder.d.ts +3 -0
  98. package/lib/websocket/discord/sharder.js +12 -5
  99. package/lib/websocket/discord/shared.d.ts +1 -0
  100. package/lib/websocket/discord/worker.d.ts +2 -1
  101. package/lib/websocket/discord/workermanager.d.ts +8 -3
  102. package/lib/websocket/discord/workermanager.js +78 -30
  103. package/package.json +8 -6
package/lib/api/CDN.d.ts CHANGED
@@ -36,7 +36,7 @@ export interface MakeURLOptions {
36
36
  *
37
37
  * @defaultValue `'webp'`
38
38
  */
39
- extension?: string | undefined;
39
+ extension?: ImageExtension | StickerExtension | undefined;
40
40
  /**
41
41
  * The size specified in the image URL
42
42
  */
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.filter(x => x != null)]);
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.filter(x => x != null)]);
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, RESTGetAPIApplicationCommandsQuery>): Promise<RESTGetAPIApplicationCommandsResult>;
30
- post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIApplicationCommandsJSONBody>): Promise<RESTPostAPIApplicationCommandsResult>;
31
- put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationCommandsJSONBody>): Promise<RESTPutAPIApplicationCommandsResult>;
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<RESTGetAPIApplicationCommandResult>;
34
- patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIApplicationCommandJSONBody>): Promise<RESTPatchAPIApplicationCommandResult>;
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
- 'role-connections': {
39
- metadata: {
40
- get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIApplicationRoleConnectionMetadataResult>;
41
- put(args: RestArguments<ProxyRequestMethod.Put, RESTPutAPIApplicationRoleConnectionMetadataJSONBody>): Promise<RESTPutAPIApplicationRoleConnectionMetadataResult>;
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
- (id: '@me'): {
11
- threads: {
12
- archived: {
13
- private: {
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
- (id: string): {
45
- put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelRecipientJSONBody>): Promise<RESTPutAPIChannelRecipientResult>;
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
- (id: string): {
61
- put(args?: RestArguments<ProxyRequestMethod.Put, RESTPutAPIChannelPermissionJSONBody>): Promise<RESTPutAPIChannelPermissionResult>;
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
- (id: string): {
7
- (token: string): {
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
- (id: string | '@original'): {
22
- get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIWebhookWithTokenMessageResult>;
23
- patch(args: RestArguments<ProxyRequestMethod.Patch, RESTPatchAPIWebhookWithTokenMessageJSONBody>): Promise<RESTPatchAPIWebhookWithTokenMessageResult>;
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: BaseClient, data: APIAttachment);
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) {
@@ -3,18 +3,18 @@
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node" />
5
5
  /// <reference types="node" />
6
- /// <reference types="node" />
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
- readonly parent: MessagePort;
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(parent: MessagePort);
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
- parent;
7
+ workerData;
8
8
  isAsync = true;
9
9
  promises = new Map();
10
- constructor(parent) {
11
- this.parent = parent;
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
- node_worker_threads_1.parentPort.postMessage({
22
+ this.postMessage({
18
23
  type: 'CACHE_REQUEST',
19
24
  args,
20
25
  nonce,
21
26
  method,
22
- workerId: node_worker_threads_1.workerData.workerId,
27
+ workerId: this.workerData.workerId,
23
28
  });
24
29
  let resolve = (_) => {
25
30
  /**/
@@ -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 { BaseClient } from '../client/base';
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?: BaseClient);
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
  } & {
@@ -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(id, guildId), this[type].parse(data, id, guildId)]);
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(id, guildId), this[type].parse(data, id, guildId)]);
291
+ allData.push([this[type].hashGuildId(guildId, id), this[type].parse(data, id, guildId)]);
291
292
  }
292
293
  break;
293
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?: BaseClient);
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?: BaseClient);
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(id, guild));
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(id, guild)))).then(x => x.filter(y => y));
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(key, guild), this.parse(value, key, guild)];
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(key, guild)))).then(oldDatas => (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
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(key, guild), this.parse({ ...oldData, ...value }, key, guild)];
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(x, guild))));
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);
@@ -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 GuildRelatedResource<T = any> {
5
6
  protected cache: Cache;
6
7
  client: BaseClient;
7
8
  namespace: string;
8
- constructor(cache: Cache, client?: BaseClient);
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>;
@@ -72,7 +72,7 @@ class GuildRelatedResource {
72
72
  : (0, common_1.fakePromise)(this.adapter.getToRelationship(this.hashId(guild))).then(keys => this.adapter.get(keys.map(x => `${this.namespace}.${x}`)));
73
73
  }
74
74
  count(to) {
75
- return this.adapter.count(this.hashId(to));
75
+ return to === '*' ? (0, common_1.fakePromise)(this.keys(to)).then(x => x.length) : this.adapter.count(this.hashId(to));
76
76
  }
77
77
  contains(id, guild) {
78
78
  return this.adapter.contains(this.hashId(guild), id);
@@ -95,8 +95,9 @@ class Guilds extends base_1.BaseResource {
95
95
  bulkData.push(['channels', channel, channel.id, id]);
96
96
  }
97
97
  for (const channel of data.channels ?? []) {
98
- if (channel.permission_overwrites?.length)
98
+ if (channel.permission_overwrites?.length) {
99
99
  bulkData.push(['overwrites', channel.permission_overwrites, channel.id, id]);
100
+ }
100
101
  }
101
102
  for (const emoji of data.emojis ?? []) {
102
103
  bulkData.push(['emojis', emoji, emoji.id, id]);
@@ -3,7 +3,7 @@ import { PermissionsBitField } from '../../structures/extra/Permissions';
3
3
  import { GuildRelatedResource } from './default/guild-related';
4
4
  export declare class Overwrites extends GuildRelatedResource {
5
5
  namespace: string;
6
- parse(data: any, _id: string, _guild_id: string): any;
6
+ parse(data: any[], _id: string, guild_id: string): any[];
7
7
  get(id: string): ReturnCache<{
8
8
  type: number;
9
9
  id: string;
@@ -6,7 +6,10 @@ const Permissions_1 = require("../../structures/extra/Permissions");
6
6
  const guild_related_1 = require("./default/guild-related");
7
7
  class Overwrites extends guild_related_1.GuildRelatedResource {
8
8
  namespace = 'overwrite';
9
- parse(data, _id, _guild_id) {
9
+ parse(data, _id, guild_id) {
10
+ data.forEach(x => {
11
+ x.guild_id = guild_id;
12
+ });
10
13
  return data;
11
14
  }
12
15
  get(id) {
@@ -16,6 +19,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
16
19
  deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
17
20
  id: rawOverwrite.id,
18
21
  type: rawOverwrite.type,
22
+ guildId: rawOverwrite.guild_id,
19
23
  }))
20
24
  : undefined);
21
25
  }
@@ -25,6 +29,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
25
29
  deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
26
30
  id: rawOverwrite.id,
27
31
  type: rawOverwrite.type,
32
+ guildId: rawOverwrite.guild_id,
28
33
  }))));
29
34
  }
30
35
  bulk(ids) {
@@ -33,6 +38,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
33
38
  deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
34
39
  id: rawOverwrite.id,
35
40
  type: rawOverwrite.type,
41
+ guildId: rawOverwrite.guild_id,
36
42
  }))));
37
43
  }
38
44
  }