seyfert 0.1.0 → 1.0.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 (193) hide show
  1. package/README.md +19 -30
  2. package/lib/api/CDN.d.ts +0 -8
  3. package/lib/api/CDN.js +7 -13
  4. package/lib/api/Router.d.ts +2 -2
  5. package/lib/api/Router.js +1 -1
  6. package/lib/api/Routes/applications.d.ts +1 -1
  7. package/lib/api/Routes/channels.d.ts +1 -1
  8. package/lib/api/Routes/gateway.d.ts +1 -1
  9. package/lib/api/Routes/guilds.d.ts +1 -1
  10. package/lib/api/Routes/interactions.d.ts +1 -1
  11. package/lib/api/Routes/invites.d.ts +1 -1
  12. package/lib/api/Routes/stage-instances.d.ts +1 -1
  13. package/lib/api/Routes/stickers.d.ts +1 -1
  14. package/lib/api/Routes/users.d.ts +1 -1
  15. package/lib/api/Routes/voice.d.ts +1 -1
  16. package/lib/api/Routes/webhooks.d.ts +1 -1
  17. package/lib/api/api.d.ts +39 -0
  18. package/lib/api/api.js +318 -0
  19. package/lib/api/bucket.d.ts +19 -0
  20. package/lib/api/bucket.js +71 -0
  21. package/lib/api/index.d.ts +1 -1
  22. package/lib/api/index.js +1 -1
  23. package/lib/api/shared.d.ts +31 -5
  24. package/lib/api/shared.js +2 -7
  25. package/lib/api/utils/constants.d.ts +1 -30
  26. package/lib/api/utils/constants.js +2 -41
  27. package/lib/api/utils/types.d.ts +1 -320
  28. package/lib/api/utils/utils.d.ts +0 -38
  29. package/lib/api/utils/utils.js +1 -139
  30. package/lib/builders/ActionRow.js +1 -1
  31. package/lib/builders/Attachment.d.ts +14 -6
  32. package/lib/builders/Attachment.js +30 -7
  33. package/lib/builders/Button.d.ts +3 -12
  34. package/lib/builders/Button.js +0 -11
  35. package/lib/builders/{MessageEmbed.d.ts → Embed.d.ts} +15 -15
  36. package/lib/builders/{MessageEmbed.js → Embed.js} +16 -16
  37. package/lib/builders/Modal.js +1 -1
  38. package/lib/builders/SelectMenu.d.ts +14 -15
  39. package/lib/builders/SelectMenu.js +19 -18
  40. package/lib/builders/index.d.ts +1 -1
  41. package/lib/builders/index.js +1 -1
  42. package/lib/builders/types.d.ts +2 -2
  43. package/lib/cache/adapters/default.js +2 -2
  44. package/lib/cache/adapters/redis.d.ts +2 -3
  45. package/lib/cache/adapters/redis.js +13 -5
  46. package/lib/cache/adapters/workeradapter.d.ts +9 -1
  47. package/lib/cache/adapters/workeradapter.js +7 -3
  48. package/lib/cache/index.d.ts +20 -6
  49. package/lib/cache/index.js +26 -10
  50. package/lib/cache/resources/channels.d.ts +6 -2
  51. package/lib/cache/resources/channels.js +12 -6
  52. package/lib/cache/resources/default/base.d.ts +17 -16
  53. package/lib/cache/resources/default/base.js +25 -24
  54. package/lib/cache/resources/default/guild-based.d.ts +22 -19
  55. package/lib/cache/resources/default/guild-based.js +32 -31
  56. package/lib/cache/resources/default/guild-related.d.ts +22 -19
  57. package/lib/cache/resources/default/guild-related.js +37 -43
  58. package/lib/cache/resources/emojis.d.ts +4 -2
  59. package/lib/cache/resources/emojis.js +8 -6
  60. package/lib/cache/resources/guilds.d.ts +4 -2
  61. package/lib/cache/resources/guilds.js +15 -8
  62. package/lib/cache/resources/members.d.ts +4 -2
  63. package/lib/cache/resources/members.js +16 -13
  64. package/lib/cache/resources/overwrites.d.ts +25 -0
  65. package/lib/cache/resources/overwrites.js +39 -0
  66. package/lib/cache/resources/presence.js +3 -4
  67. package/lib/cache/resources/roles.d.ts +4 -2
  68. package/lib/cache/resources/roles.js +8 -6
  69. package/lib/cache/resources/stickers.d.ts +4 -2
  70. package/lib/cache/resources/stickers.js +8 -6
  71. package/lib/cache/resources/threads.d.ts +4 -2
  72. package/lib/cache/resources/threads.js +8 -6
  73. package/lib/cache/resources/users.d.ts +4 -2
  74. package/lib/cache/resources/users.js +8 -6
  75. package/lib/cache/resources/voice-states.d.ts +3 -3
  76. package/lib/cache/resources/voice-states.js +6 -7
  77. package/lib/client/base.d.ts +49 -16
  78. package/lib/client/base.js +21 -17
  79. package/lib/client/client.d.ts +14 -3
  80. package/lib/client/client.js +21 -21
  81. package/lib/client/httpclient.d.ts +3 -5
  82. package/lib/client/httpclient.js +29 -16
  83. package/lib/client/{oninteraction.d.ts → oninteractioncreate.d.ts} +1 -1
  84. package/lib/client/{oninteraction.js → oninteractioncreate.js} +34 -23
  85. package/lib/client/onmessagecreate.d.ts +3 -0
  86. package/lib/client/onmessagecreate.js +337 -0
  87. package/lib/client/workerclient.d.ts +5 -1
  88. package/lib/client/workerclient.js +67 -44
  89. package/lib/collection.d.ts +1 -1
  90. package/lib/collection.js +9 -6
  91. package/lib/commands/applications/chat.d.ts +32 -25
  92. package/lib/commands/applications/chat.js +51 -34
  93. package/lib/commands/applications/chatcontext.d.ts +34 -16
  94. package/lib/commands/applications/chatcontext.js +99 -20
  95. package/lib/commands/applications/menu.d.ts +9 -8
  96. package/lib/commands/applications/menu.js +14 -5
  97. package/lib/commands/applications/menucontext.d.ts +27 -10
  98. package/lib/commands/applications/menucontext.js +51 -7
  99. package/lib/commands/applications/options.d.ts +13 -13
  100. package/lib/commands/applications/shared.d.ts +7 -2
  101. package/lib/commands/decorators.d.ts +14 -14
  102. package/lib/commands/decorators.js +9 -5
  103. package/lib/commands/handler.d.ts +2 -1
  104. package/lib/commands/handler.js +60 -14
  105. package/lib/commands/index.d.ts +1 -1
  106. package/lib/commands/index.js +2 -1
  107. package/lib/commands/optionresolver.d.ts +6 -5
  108. package/lib/commands/optionresolver.js +10 -6
  109. package/lib/common/bot/watcher.d.ts +3 -3
  110. package/lib/common/bot/watcher.js +3 -1
  111. package/lib/common/index.d.ts +1 -1
  112. package/lib/common/index.js +2 -1
  113. package/lib/common/it/logger.d.ts +11 -0
  114. package/lib/common/it/logger.js +51 -2
  115. package/lib/common/it/utils.d.ts +3 -13
  116. package/lib/common/it/utils.js +9 -30
  117. package/lib/common/shorters/channels.d.ts +55 -5
  118. package/lib/common/shorters/channels.js +59 -0
  119. package/lib/common/shorters/guilds.d.ts +5 -2
  120. package/lib/common/shorters/guilds.js +18 -0
  121. package/lib/common/shorters/messages.js +0 -2
  122. package/lib/common/shorters/overwrites.d.ts +29 -0
  123. package/lib/common/shorters/overwrites.js +63 -0
  124. package/lib/common/shorters/roles.js +3 -3
  125. package/lib/common/shorters/webhook.d.ts +2 -2
  126. package/lib/common/types/util.d.ts +2 -1
  127. package/lib/common/types/write.d.ts +3 -7
  128. package/lib/components/handler.d.ts +12 -18
  129. package/lib/components/handler.js +58 -103
  130. package/lib/components/index.d.ts +0 -1
  131. package/lib/components/index.js +0 -1
  132. package/lib/components/listener.d.ts +2 -2
  133. package/lib/components/listener.js +2 -3
  134. package/lib/events/event.d.ts +2 -2
  135. package/lib/events/handler.d.ts +3 -2
  136. package/lib/events/handler.js +14 -6
  137. package/lib/events/hooks/dispatch.d.ts +2 -1
  138. package/lib/events/hooks/dispatch.js +5 -1
  139. package/lib/events/hooks/thread.d.ts +63 -63
  140. package/lib/index.d.ts +8 -5
  141. package/lib/index.js +20 -10
  142. package/lib/langs/handler.d.ts +6 -4
  143. package/lib/langs/handler.js +10 -8
  144. package/lib/langs/router.d.ts +8 -9
  145. package/lib/langs/router.js +5 -5
  146. package/lib/structures/ClientUser.d.ts +1 -16
  147. package/lib/structures/ClientUser.js +0 -31
  148. package/lib/structures/Guild.d.ts +1 -1
  149. package/lib/structures/GuildMember.d.ts +12 -0
  150. package/lib/structures/GuildMember.js +14 -0
  151. package/lib/structures/GuildRole.d.ts +4 -2
  152. package/lib/structures/GuildRole.js +4 -1
  153. package/lib/structures/GuildTemplate.js +1 -1
  154. package/lib/structures/Interaction.d.ts +2 -0
  155. package/lib/structures/Interaction.js +12 -13
  156. package/lib/structures/Message.d.ts +7 -2
  157. package/lib/structures/Message.js +6 -3
  158. package/lib/structures/Sticker.d.ts +1 -1
  159. package/lib/structures/Sticker.js +1 -1
  160. package/lib/structures/User.d.ts +5 -0
  161. package/lib/structures/User.js +3 -0
  162. package/lib/structures/Webhook.d.ts +1 -1
  163. package/lib/structures/Webhook.js +1 -1
  164. package/lib/structures/channels.d.ts +45 -6
  165. package/lib/structures/channels.js +23 -7
  166. package/lib/structures/extra/BitField.d.ts +9 -6
  167. package/lib/structures/extra/BitField.js +27 -3
  168. package/lib/structures/extra/Permissions.d.ts +6 -1
  169. package/lib/structures/extra/Permissions.js +7 -0
  170. package/lib/websocket/discord/basesocket.js +0 -1
  171. package/lib/websocket/discord/workermanager.d.ts +9 -1
  172. package/lib/websocket/discord/workermanager.js +21 -13
  173. package/package.json +21 -20
  174. package/lib/api/REST.d.ts +0 -127
  175. package/lib/api/REST.js +0 -424
  176. package/lib/api/errors/DiscordAPIError.d.ts +0 -51
  177. package/lib/api/errors/DiscordAPIError.js +0 -81
  178. package/lib/api/errors/HTTPError.d.ts +0 -20
  179. package/lib/api/errors/HTTPError.js +0 -28
  180. package/lib/api/errors/RateLimitError.d.ts +0 -19
  181. package/lib/api/errors/RateLimitError.js +0 -37
  182. package/lib/api/handlers/BurstHandler.d.ts +0 -51
  183. package/lib/api/handlers/BurstHandler.js +0 -124
  184. package/lib/api/handlers/SequentialHandler.d.ts +0 -81
  185. package/lib/api/handlers/SequentialHandler.js +0 -365
  186. package/lib/api/handlers/Shared.d.ts +0 -14
  187. package/lib/api/handlers/Shared.js +0 -125
  188. package/lib/api/interfaces/Handler.d.ts +0 -21
  189. package/lib/api/interfaces/Handler.js +0 -2
  190. package/lib/websocket/discord/handlemessage.d.ts +0 -0
  191. package/lib/websocket/discord/handlemessage.js +0 -1
  192. package/lib/websocket/discord/memberUpdate.d.ts +0 -16
  193. package/lib/websocket/discord/memberUpdate.js +0 -47
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseResource = void 0;
4
+ const common_1 = require("../../../common");
4
5
  class BaseResource {
5
6
  cache;
6
7
  client;
@@ -21,52 +22,52 @@ class BaseResource {
21
22
  get adapter() {
22
23
  return this.cache.adapter;
23
24
  }
24
- async removeIfNI(intent, id) {
25
+ removeIfNI(intent, id) {
25
26
  if (!this.cache.hasIntent(intent)) {
26
- await this.remove(id);
27
+ return this.remove(id);
27
28
  }
29
+ return;
28
30
  }
29
- async setIfNI(intent, id, data) {
31
+ setIfNI(intent, id, data) {
30
32
  if (!this.cache.hasIntent(intent)) {
31
- await this.set(id, data);
32
- return data;
33
+ return (0, common_1.fakePromise)(this.set(id, data)).then(() => data);
33
34
  }
34
35
  }
35
- async get(id) {
36
+ get(id) {
36
37
  return this.adapter.get(this.hashId(id));
37
38
  }
38
- async set(id, data) {
39
- await this.addToRelationship(id);
40
- await this.adapter.set(this.hashId(id), data);
39
+ bulk(ids) {
40
+ return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashId(id)))).then(x => x.filter(y => y));
41
41
  }
42
- async patch(id, data) {
43
- await this.addToRelationship(id);
44
- await this.adapter.patch(false, this.hashId(id), data);
42
+ set(id, data) {
43
+ return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.set(this.hashId(id), data));
45
44
  }
46
- async remove(id) {
47
- await this.removeToRelationship(id);
48
- await this.adapter.remove(this.hashId(id));
45
+ patch(id, data) {
46
+ return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.patch(false, this.hashId(id), data));
49
47
  }
50
- async keys() {
48
+ remove(id) {
49
+ return (0, common_1.fakePromise)(this.removeToRelationship(id)).then(() => this.adapter.remove(this.hashId(id)));
50
+ }
51
+ keys() {
51
52
  return this.adapter.keys(this.namespace);
52
53
  }
53
- async values() {
54
+ values() {
54
55
  return this.adapter.values(this.namespace);
55
56
  }
56
- async count() {
57
+ count() {
57
58
  return this.adapter.count(this.namespace);
58
59
  }
59
- async contains(id) {
60
+ contains(id) {
60
61
  return this.adapter.contains(this.namespace, id);
61
62
  }
62
- async getToRelationship() {
63
+ getToRelationship() {
63
64
  return this.adapter.getToRelationship(this.namespace);
64
65
  }
65
- async addToRelationship(id) {
66
- await this.adapter.addToRelationship(this.namespace, id);
66
+ addToRelationship(id) {
67
+ return this.adapter.addToRelationship(this.namespace, id);
67
68
  }
68
- async removeToRelationship(id) {
69
- await this.adapter.removeToRelationship(this.namespace, id);
69
+ removeToRelationship(id) {
70
+ return this.adapter.removeToRelationship(this.namespace, id);
70
71
  }
71
72
  hashId(id) {
72
73
  return `${this.namespace}.${id}`;
@@ -1,33 +1,36 @@
1
1
  import type { BaseClient } from '../../../client/base';
2
- import type { GatewayIntentBits } from '../../../common';
3
- import type { Cache } from '../../index';
2
+ import { type GatewayIntentBits } from '../../../common';
3
+ import type { Cache, ReturnCache } from '../../index';
4
4
  export declare class GuildBasedResource<T = any> {
5
5
  protected cache: Cache;
6
6
  client: BaseClient;
7
7
  namespace: string;
8
8
  constructor(cache: Cache, client?: BaseClient);
9
- parse(data: any, _id: string, guild_id: string): any;
9
+ parse(data: any, id: string, guild_id: string): any;
10
10
  get adapter(): import("../../index").Adapter;
11
- removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): Promise<void>;
12
- setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): Promise<any>;
13
- get(id: string, guild: string): Promise<(T & {
11
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
12
+ setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
13
+ get(id: string, guild: string): ReturnCache<(T & {
14
14
  guild_id: string;
15
15
  }) | undefined>;
16
- set(__keys: string, guild: string, data: any): Promise<void>;
17
- set(__keys: [string, any][], guild: string): Promise<void>;
18
- patch(__keys: string, guild: string, data: any): Promise<void>;
19
- patch(__keys: [string, any][], guild: string): Promise<void>;
20
- remove(id: string | string[], guild: string): Promise<void>;
21
- keys(guild: string): Promise<string[]>;
22
- values(guild: string): Promise<(T & {
16
+ bulk(ids: string[], guild: string): ReturnCache<(T & {
23
17
  guild_id: string;
24
18
  })[]>;
25
- count(guild: string): Promise<number>;
26
- contains(id: string, guild: string): Promise<boolean>;
27
- getToRelationship(guild: string): Promise<string[]>;
28
- addToRelationship(id: string | string[], guild: string): Promise<void>;
29
- removeToRelationship(id: string | string[], guild: string): Promise<void>;
30
- removeRelationship(id: string | string[]): Promise<void>;
19
+ set(__keys: string, guild: string, data: any): ReturnCache<void>;
20
+ set(__keys: [string, any][], guild: string): ReturnCache<void>;
21
+ patch(__keys: string, guild: string, data: any): ReturnCache<void>;
22
+ patch(__keys: [string, any][], guild: string): ReturnCache<void>;
23
+ remove(id: string | string[], guild: string): import("../../index").RPV<void>;
24
+ keys(guild: string): ReturnCache<string[]>;
25
+ values(guild: string): ReturnCache<(T & {
26
+ guild_id: string;
27
+ })[]>;
28
+ count(guild: string): ReturnCache<number>;
29
+ contains(id: string, guild: string): ReturnCache<boolean>;
30
+ getToRelationship(guild: string): import("../../index").RPV<string[]>;
31
+ addToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
32
+ removeToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
33
+ removeRelationship(id: string | string[]): import("../../index").RPV<void>;
31
34
  hashId(id: string): string;
32
35
  hashGuildId(guild: string, id: string): string;
33
36
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GuildBasedResource = void 0;
4
+ const common_1 = require("../../../common");
4
5
  class GuildBasedResource {
5
6
  cache;
6
7
  client;
@@ -15,71 +16,71 @@ class GuildBasedResource {
15
16
  __setClient(client) {
16
17
  this.client = client;
17
18
  }
18
- parse(data, _id, guild_id) {
19
+ parse(data, id, guild_id) {
20
+ data.id = id;
19
21
  data.guild_id = guild_id;
20
22
  return data;
21
23
  }
22
24
  get adapter() {
23
25
  return this.cache.adapter;
24
26
  }
25
- async removeIfNI(intent, id, guildId) {
27
+ removeIfNI(intent, id, guildId) {
26
28
  if (!this.cache.hasIntent(intent)) {
27
- await this.remove(id, guildId);
29
+ return this.remove(id, guildId);
28
30
  }
31
+ return;
29
32
  }
30
- async setIfNI(intent, id, guildId, data) {
33
+ setIfNI(intent, id, guildId, data) {
31
34
  if (!this.cache.hasIntent(intent)) {
32
- await this.set(id, guildId, data);
33
- return data;
35
+ return (0, common_1.fakePromise)(this.set(id, guildId, data)).then(() => data);
34
36
  }
35
37
  }
36
- async get(id, guild) {
38
+ get(id, guild) {
37
39
  return this.adapter.get(this.hashGuildId(id, guild));
38
40
  }
39
- async set(__keys, guild, data) {
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));
43
+ }
44
+ set(__keys, guild, data) {
40
45
  const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
41
- await this.addToRelationship(keys.map(x => x[0]), guild);
42
- await this.adapter.set(keys.map(([key, value]) => {
46
+ return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
43
47
  return [this.hashGuildId(key, guild), this.parse(value, key, guild)];
44
- }));
48
+ })));
45
49
  }
46
- async patch(__keys, guild, data) {
50
+ patch(__keys, guild, data) {
47
51
  const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
48
- const oldDatas = await this.adapter.get(keys.map(([key]) => this.hashGuildId(key, guild)));
49
- await this.addToRelationship(keys.map(x => x[0]), guild);
50
- await this.adapter.set(keys.map(([key, value]) => {
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]) => {
51
53
  const oldData = oldDatas.find(x => x.id === key) ?? {};
52
54
  return [this.hashGuildId(key, guild), this.parse({ ...oldData, ...value }, key, guild)];
53
- }));
55
+ }))));
54
56
  }
55
- async remove(id, guild) {
57
+ remove(id, guild) {
56
58
  const ids = Array.isArray(id) ? id : [id];
57
- await this.removeToRelationship(ids, guild);
58
- await 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(x, guild))));
59
60
  }
60
- async keys(guild) {
61
+ keys(guild) {
61
62
  return this.adapter.scan(this.hashGuildId(guild, '*'), true);
62
63
  }
63
- async values(guild) {
64
+ values(guild) {
64
65
  return this.adapter.scan(this.hashGuildId(guild, '*'));
65
66
  }
66
- async count(guild) {
67
- return (await this.adapter.scan(this.hashGuildId(guild, '*'), true)).length;
67
+ count(guild) {
68
+ return (0, common_1.fakePromise)(this.adapter.scan(this.hashGuildId(guild, '*'), true)).then(data => data.length);
68
69
  }
69
- async contains(id, guild) {
70
+ contains(id, guild) {
70
71
  return this.adapter.contains(this.hashId(guild), id);
71
72
  }
72
- async getToRelationship(guild) {
73
+ getToRelationship(guild) {
73
74
  return this.adapter.getToRelationship(this.hashId(guild));
74
75
  }
75
- async addToRelationship(id, guild) {
76
- await this.adapter.addToRelationship(this.hashId(guild), id);
76
+ addToRelationship(id, guild) {
77
+ return this.adapter.addToRelationship(this.hashId(guild), id);
77
78
  }
78
- async removeToRelationship(id, guild) {
79
- await this.adapter.removeToRelationship(this.hashId(guild), id);
79
+ removeToRelationship(id, guild) {
80
+ return this.adapter.removeToRelationship(this.hashId(guild), id);
80
81
  }
81
- async removeRelationship(id) {
82
- await this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
82
+ removeRelationship(id) {
83
+ return this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
83
84
  }
84
85
  hashId(id) {
85
86
  return `${this.namespace}.${id}`;
@@ -1,32 +1,35 @@
1
1
  import type { BaseClient } from '../../../client/base';
2
- import type { GatewayIntentBits } from '../../../common';
3
- import type { Cache } from '../../index';
2
+ import { type GatewayIntentBits } from '../../../common';
3
+ import type { Cache, ReturnCache } from '../../index';
4
4
  export declare class GuildRelatedResource<T = any> {
5
5
  protected cache: Cache;
6
6
  client: BaseClient;
7
7
  namespace: string;
8
8
  constructor(cache: Cache, client?: BaseClient);
9
- parse(data: any, _id: string, guild_id: string): any;
9
+ parse(data: any, id: string, guild_id: string): any;
10
10
  get adapter(): import("../../index").Adapter;
11
- removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): Promise<void>;
12
- setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): Promise<any>;
13
- get(id: string): Promise<(T & {
11
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
12
+ setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
13
+ get(id: string): ReturnCache<(T & {
14
14
  guild_id: string;
15
15
  }) | undefined>;
16
- set(__keys: string, guild: string, data: any): Promise<void>;
17
- set(__keys: [string, any][], guild: string): Promise<void>;
18
- patch(__keys: string, guild?: string, data?: any): Promise<void>;
19
- patch(__keys: [string, any][], guild?: string): Promise<void>;
20
- remove(id: string | string[], guild: string): Promise<void>;
21
- keys(guild: string): Promise<string[]>;
22
- values(guild: string): Promise<(T & {
16
+ bulk(ids: string[]): ReturnCache<(T & {
23
17
  guild_id: string;
24
18
  })[]>;
25
- count(to: string): Promise<number>;
26
- contains(id: string, guild: string): Promise<boolean>;
27
- getToRelationship(guild: string): Promise<string[]>;
28
- addToRelationship(id: string | string[], guild: string): Promise<void>;
29
- removeToRelationship(id: string | string[], guild: string): Promise<void>;
30
- removeRelationship(id: string | string[]): Promise<void>;
19
+ set(__keys: string, guild: string, data: any): ReturnCache<void>;
20
+ set(__keys: [string, any][], guild: string): ReturnCache<void>;
21
+ patch(__keys: string, guild?: string, data?: any): ReturnCache<void>;
22
+ patch(__keys: [string, any][], guild?: string): ReturnCache<void>;
23
+ remove(id: string | string[], guild: string): import("../../index").RPV<void>;
24
+ keys(guild: string): ReturnCache<string[]>;
25
+ values(guild: string): ReturnCache<(T & {
26
+ guild_id: string;
27
+ })[]>;
28
+ count(to: string): import("../../index").RPV<number>;
29
+ contains(id: string, guild: string): import("../../index").RPV<boolean>;
30
+ getToRelationship(guild: string): import("../../index").RPV<string[]>;
31
+ addToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
32
+ removeToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
33
+ removeRelationship(id: string | string[]): import("../../index").RPV<void>;
31
34
  hashId(id: string): string;
32
35
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GuildRelatedResource = void 0;
4
+ const common_1 = require("../../../common");
4
5
  class GuildRelatedResource {
5
6
  cache;
6
7
  client;
@@ -15,85 +16,78 @@ class GuildRelatedResource {
15
16
  __setClient(client) {
16
17
  this.client = client;
17
18
  }
18
- parse(data, _id, guild_id) {
19
+ parse(data, id, guild_id) {
20
+ data.id = id;
19
21
  data.guild_id = guild_id;
20
22
  return data;
21
23
  }
22
24
  get adapter() {
23
25
  return this.cache.adapter;
24
26
  }
25
- async removeIfNI(intent, id, guildId) {
27
+ removeIfNI(intent, id, guildId) {
26
28
  if (!this.cache.hasIntent(intent)) {
27
- await this.remove(id, guildId);
29
+ return this.remove(id, guildId);
28
30
  }
29
31
  }
30
- async setIfNI(intent, id, guildId, data) {
32
+ setIfNI(intent, id, guildId, data) {
31
33
  if (!this.cache.hasIntent(intent)) {
32
- await this.set(id, guildId, data);
33
- return data;
34
+ return (0, common_1.fakePromise)(this.set(id, guildId, data)).then(() => data);
34
35
  }
35
36
  }
36
- async get(id) {
37
+ get(id) {
37
38
  return this.adapter.get(this.hashId(id));
38
39
  }
39
- async set(__keys, guild, data) {
40
+ bulk(ids) {
41
+ return (0, common_1.fakePromise)(this.adapter.get(ids.map(x => this.hashId(x)))).then(x => x.filter(y => y));
42
+ }
43
+ set(__keys, guild, data) {
40
44
  const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
41
- await this.addToRelationship(keys.map(x => x[0]), guild);
42
- await this.adapter.set(keys.map(([key, value]) => {
45
+ return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
43
46
  return [this.hashId(key), this.parse(value, key, guild)];
44
- }));
47
+ })));
45
48
  }
46
- async patch(__keys, guild, data) {
49
+ patch(__keys, guild, data) {
47
50
  const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
48
51
  if (guild) {
49
- await this.addToRelationship(keys.map(x => x[0]), guild);
50
- await this.adapter.patch(false, keys.map(([key, value]) => {
52
+ return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.patch(false, keys.map(([key, value]) => {
51
53
  return [this.hashId(key), this.parse(value, key, guild)];
52
- }));
53
- }
54
- else {
55
- await this.adapter.patch(true, keys.map(([key, value]) => {
56
- return [this.hashId(key), value];
57
- }));
54
+ })));
58
55
  }
56
+ return (0, common_1.fakePromise)(this.adapter.patch(true, keys.map(([key, value]) => {
57
+ return [this.hashId(key), value];
58
+ }))).then(x => x);
59
59
  }
60
- async remove(id, guild) {
60
+ remove(id, guild) {
61
61
  const ids = Array.isArray(id) ? id : [id];
62
- await this.removeToRelationship(ids, guild);
63
- await this.adapter.remove(ids.map(x => this.hashId(x)));
62
+ return (0, common_1.fakePromise)(this.removeToRelationship(ids, guild)).then(() => this.adapter.remove(ids.map(x => this.hashId(x))));
64
63
  }
65
- async keys(guild) {
64
+ keys(guild) {
66
65
  return guild === '*'
67
- ? await this.adapter.scan(this.hashId(guild), true)
68
- : (async () => {
69
- return (await this.adapter.getToRelationship(this.hashId(guild))).map(x => `${this.namespace}.${x}`);
70
- })();
66
+ ? this.adapter.scan(this.hashId(guild), true)
67
+ : (0, common_1.fakePromise)(this.adapter.getToRelationship(this.hashId(guild))).then(keys => keys.map(x => `${this.namespace}.${x}`));
71
68
  }
72
- async values(guild) {
69
+ values(guild) {
73
70
  return guild === '*'
74
- ? await this.adapter.scan(this.hashId(guild))
75
- : (async () => {
76
- const keys = (await this.adapter.getToRelationship(this.hashId(guild))).map(x => `${this.namespace}.${x}`);
77
- return this.adapter.get(keys);
78
- })();
71
+ ? (0, common_1.fakePromise)(this.adapter.scan(this.hashId(guild))).then(x => x)
72
+ : (0, common_1.fakePromise)(this.adapter.getToRelationship(this.hashId(guild))).then(keys => this.adapter.get(keys.map(x => `${this.namespace}.${x}`)));
79
73
  }
80
- async count(to) {
74
+ count(to) {
81
75
  return this.adapter.count(this.hashId(to));
82
76
  }
83
- async contains(id, guild) {
77
+ contains(id, guild) {
84
78
  return this.adapter.contains(this.hashId(guild), id);
85
79
  }
86
- async getToRelationship(guild) {
80
+ getToRelationship(guild) {
87
81
  return this.adapter.getToRelationship(this.hashId(guild));
88
82
  }
89
- async addToRelationship(id, guild) {
90
- await this.adapter.addToRelationship(this.hashId(guild), id);
83
+ addToRelationship(id, guild) {
84
+ return this.adapter.addToRelationship(this.hashId(guild), id);
91
85
  }
92
- async removeToRelationship(id, guild) {
93
- await this.adapter.removeToRelationship(this.hashId(guild), id);
86
+ removeToRelationship(id, guild) {
87
+ return this.adapter.removeToRelationship(this.hashId(guild), id);
94
88
  }
95
- async removeRelationship(id) {
96
- await this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
89
+ removeRelationship(id) {
90
+ return this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
97
91
  }
98
92
  hashId(id) {
99
93
  return `${this.namespace}.${id}`;
@@ -1,7 +1,9 @@
1
+ import type { ReturnCache } from '../..';
1
2
  import { GuildEmoji } from '../../structures';
2
3
  import { GuildRelatedResource } from './default/guild-related';
3
4
  export declare class Emojis extends GuildRelatedResource {
4
5
  namespace: string;
5
- get(id: string): Promise<GuildEmoji | undefined>;
6
- values(guild: string): Promise<GuildEmoji[]>;
6
+ get(id: string): ReturnCache<GuildEmoji | undefined>;
7
+ bulk(ids: string[]): ReturnCache<GuildEmoji[]>;
8
+ values(guild: string): ReturnCache<GuildEmoji[]>;
7
9
  }
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Emojis = void 0;
4
+ const common_1 = require("../../common");
4
5
  const structures_1 = require("../../structures");
5
6
  const guild_related_1 = require("./default/guild-related");
6
7
  class Emojis extends guild_related_1.GuildRelatedResource {
7
8
  namespace = 'emoji';
8
- async get(id) {
9
- const rawEmoji = await super.get(id);
10
- return rawEmoji ? new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id) : undefined;
9
+ get(id) {
10
+ return (0, common_1.fakePromise)(super.get(id)).then(rawEmoji => rawEmoji ? new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id) : undefined);
11
11
  }
12
- async values(guild) {
13
- const emojis = (await super.values(guild));
14
- return emojis.map(rawEmoji => new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id));
12
+ bulk(ids) {
13
+ return (0, common_1.fakePromise)(super.bulk(ids)).then(emojis => emojis.map(rawEmoji => new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id)));
14
+ }
15
+ values(guild) {
16
+ return (0, common_1.fakePromise)(super.values(guild)).then(emojis => emojis.map(rawEmoji => new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id)));
15
17
  }
16
18
  }
17
19
  exports.Emojis = Emojis;
@@ -1,9 +1,11 @@
1
+ import type { ReturnCache } from '..';
1
2
  import { Guild } from '../../structures';
2
3
  import { BaseResource } from './default/base';
3
4
  export declare class Guilds extends BaseResource {
4
5
  namespace: string;
5
- get(id: string): Promise<Guild<'cached'> | undefined>;
6
- values(): Promise<Guild<"cached">[]>;
6
+ get(id: string): ReturnCache<Guild<'cached'> | undefined>;
7
+ bulk(ids: string[]): ReturnCache<Guild<'cached'>[]>;
8
+ values(): ReturnCache<Guild<'cached'>[]>;
7
9
  remove(id: string): Promise<void>;
8
10
  set(id: string, data: any): Promise<void>;
9
11
  patch(id: string, data: any): Promise<void>;
@@ -6,16 +6,17 @@ const structures_1 = require("../../structures");
6
6
  const base_1 = require("./default/base");
7
7
  class Guilds extends base_1.BaseResource {
8
8
  namespace = 'guild';
9
- async get(id) {
10
- const guild = (await super.get(id));
11
- return guild ? new structures_1.Guild(this.client, guild) : undefined;
9
+ get(id) {
10
+ return (0, common_1.fakePromise)(super.get(id)).then(guild => (guild ? new structures_1.Guild(this.client, guild) : undefined));
12
11
  }
13
- async values() {
14
- const guilds = (await super.values());
15
- return guilds.map(x => new structures_1.Guild(this.client, x));
12
+ bulk(ids) {
13
+ return (0, common_1.fakePromise)(super.bulk(ids)).then(guilds => guilds.map(x => new structures_1.Guild(this.client, x)));
14
+ }
15
+ values() {
16
+ return (0, common_1.fakePromise)(super.values()).then(guilds => guilds.map(x => new structures_1.Guild(this.client, x)));
16
17
  }
17
18
  async remove(id) {
18
- await this.cache.adapter.remove((0, common_1.fastFlat)(await Promise.all([
19
+ await this.cache.adapter.remove((await Promise.all([
19
20
  this.cache.members?.keys(id) ?? [],
20
21
  this.cache.roles?.keys(id) ?? [],
21
22
  this.cache.channels?.keys(id) ?? [],
@@ -25,7 +26,7 @@ class Guilds extends base_1.BaseResource {
25
26
  this.cache.presences?.keys(id) ?? [],
26
27
  this.cache.threads?.keys(id) ?? [],
27
28
  this.cache.stageInstances?.keys(id) ?? [],
28
- ])));
29
+ ])).flat());
29
30
  await this.cache.adapter.removeRelationship([
30
31
  this.cache.members?.hashId(id),
31
32
  this.cache.roles?.hashId(id),
@@ -53,6 +54,8 @@ class Guilds extends base_1.BaseResource {
53
54
  }
54
55
  for (const channel of data.channels ?? []) {
55
56
  bulkData.push(['channels', channel, channel.id, id]);
57
+ if (channel.permission_overwrites?.length)
58
+ bulkData.push(['overwrites', channel.permission_overwrites, channel.id, id]);
56
59
  }
57
60
  for (const emoji of data.emojis ?? []) {
58
61
  bulkData.push(['emojis', emoji, emoji.id, id]);
@@ -91,6 +94,10 @@ class Guilds extends base_1.BaseResource {
91
94
  for (const channel of data.channels ?? []) {
92
95
  bulkData.push(['channels', channel, channel.id, id]);
93
96
  }
97
+ for (const channel of data.channels ?? []) {
98
+ if (channel.permission_overwrites?.length)
99
+ bulkData.push(['overwrites', channel.permission_overwrites, channel.id, id]);
100
+ }
94
101
  for (const emoji of data.emojis ?? []) {
95
102
  bulkData.push(['emojis', emoji, emoji.id, id]);
96
103
  }
@@ -1,10 +1,12 @@
1
+ import type { ReturnCache } from '../..';
1
2
  import { GuildMember } from '../../structures';
2
3
  import { GuildBasedResource } from './default/guild-based';
3
4
  export declare class Members extends GuildBasedResource {
4
5
  namespace: string;
5
6
  parse(data: any, key: string, guild_id: string): any;
6
- get(id: string, guild: string): Promise<GuildMember | undefined>;
7
- values(guild: string): Promise<GuildMember[]>;
7
+ get(id: string, guild: string): ReturnCache<GuildMember | undefined>;
8
+ bulk(ids: string[], guild: string): ReturnCache<GuildMember[]>;
9
+ values(guild: string): ReturnCache<GuildMember[]>;
8
10
  set(memberId: string, guildId: string, data: any): Promise<void>;
9
11
  set(memberId_dataArray: [string, any][], guildId: string): Promise<void>;
10
12
  }
@@ -1,30 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Members = void 0;
4
+ const common_1 = require("../../common");
4
5
  const structures_1 = require("../../structures");
5
6
  const guild_based_1 = require("./default/guild-based");
6
7
  class Members extends guild_based_1.GuildBasedResource {
7
8
  namespace = 'member';
8
9
  parse(data, key, guild_id) {
9
- data.guild_id = guild_id;
10
- data.id = data.user?.id ?? key;
11
- const { user, ...obj } = data;
12
- return obj;
10
+ const { user, ...rest } = super.parse(data, data.user?.id ?? key, guild_id);
11
+ return rest;
13
12
  }
14
- async get(id, guild) {
15
- const rawMember = (await super.get(id, guild));
16
- const user = await this.client.cache.users?.get(id);
17
- return rawMember && user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
13
+ get(id, guild) {
14
+ return (0, common_1.fakePromise)(super.get(id, guild)).then(rawMember => (0, common_1.fakePromise)(this.client.cache.users?.get(id)).then(user => rawMember && user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined));
18
15
  }
19
- async values(guild) {
20
- const members = await super.values(guild);
21
- const users = (await this.client.cache.users?.values()) ?? [];
22
- return members
16
+ bulk(ids, guild) {
17
+ return (0, common_1.fakePromise)(super.bulk(ids, guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.bulk(ids) ?? []).then(users => members
23
18
  .map(rawMember => {
24
19
  const user = users.find(x => x.id === rawMember.id);
25
20
  return user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
26
21
  })
27
- .filter(Boolean);
22
+ .filter(Boolean)));
23
+ }
24
+ values(guild) {
25
+ return (0, common_1.fakePromise)(super.values(guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.values() ?? []).then(users => members
26
+ .map(rawMember => {
27
+ const user = users.find(x => x.id === rawMember.id);
28
+ return user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
29
+ })
30
+ .filter(Boolean)));
28
31
  }
29
32
  async set(__keys, guild, data) {
30
33
  const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
@@ -0,0 +1,25 @@
1
+ import type { ReturnCache } from '../..';
2
+ import { PermissionsBitField } from '../../structures/extra/Permissions';
3
+ import { GuildRelatedResource } from './default/guild-related';
4
+ export declare class Overwrites extends GuildRelatedResource {
5
+ namespace: string;
6
+ parse(data: any, _id: string, _guild_id: string): any;
7
+ get(id: string): ReturnCache<{
8
+ type: number;
9
+ id: string;
10
+ deny: PermissionsBitField;
11
+ allow: PermissionsBitField;
12
+ }[] | undefined>;
13
+ values(guild: string): ReturnCache<{
14
+ type: number;
15
+ id: string;
16
+ deny: PermissionsBitField;
17
+ allow: PermissionsBitField;
18
+ }[][]>;
19
+ bulk(ids: string[]): ReturnCache<{
20
+ type: number;
21
+ id: string;
22
+ deny: PermissionsBitField;
23
+ allow: PermissionsBitField;
24
+ }[][]>;
25
+ }