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
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Overwrites = void 0;
4
+ const utils_1 = require("../../common/it/utils");
5
+ const Permissions_1 = require("../../structures/extra/Permissions");
6
+ const guild_related_1 = require("./default/guild-related");
7
+ class Overwrites extends guild_related_1.GuildRelatedResource {
8
+ namespace = 'overwrite';
9
+ parse(data, _id, _guild_id) {
10
+ return data;
11
+ }
12
+ get(id) {
13
+ return (0, utils_1.fakePromise)(super.get(id)).then(rawOverwrites => rawOverwrites
14
+ ? rawOverwrites.map(rawOverwrite => ({
15
+ allow: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.allow)),
16
+ deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
17
+ id: rawOverwrite.id,
18
+ type: rawOverwrite.type,
19
+ }))
20
+ : undefined);
21
+ }
22
+ values(guild) {
23
+ return (0, utils_1.fakePromise)(super.values(guild)).then(values => values.map(rawOverwrites => rawOverwrites.map(rawOverwrite => ({
24
+ allow: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.allow)),
25
+ deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
26
+ id: rawOverwrite.id,
27
+ type: rawOverwrite.type,
28
+ }))));
29
+ }
30
+ bulk(ids) {
31
+ return (0, utils_1.fakePromise)(super.bulk(ids)).then(values => values.map(rawOverwrites => rawOverwrites.map(rawOverwrite => ({
32
+ allow: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.allow)),
33
+ deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
34
+ id: rawOverwrite.id,
35
+ type: rawOverwrite.type,
36
+ }))));
37
+ }
38
+ }
39
+ exports.Overwrites = Overwrites;
@@ -5,10 +5,9 @@ const guild_related_1 = require("./default/guild-related");
5
5
  class Presences extends guild_related_1.GuildRelatedResource {
6
6
  namespace = 'presence';
7
7
  parse(data, key, guild_id) {
8
- super.parse(data, key, guild_id);
9
- data.user_id = data.user?.id ?? key;
10
- data.user = undefined;
11
- return data;
8
+ const { user, ...rest } = super.parse(data, key, guild_id);
9
+ rest.user_id ??= key;
10
+ return rest;
12
11
  }
13
12
  }
14
13
  exports.Presences = Presences;
@@ -1,7 +1,9 @@
1
+ import type { ReturnCache } from '../..';
1
2
  import { GuildRole } from '../../structures';
2
3
  import { GuildRelatedResource } from './default/guild-related';
3
4
  export declare class Roles extends GuildRelatedResource {
4
5
  namespace: string;
5
- get(id: string): Promise<GuildRole | undefined>;
6
- values(guild: string): Promise<GuildRole[]>;
6
+ get(id: string): ReturnCache<GuildRole | undefined>;
7
+ bulk(ids: string[]): ReturnCache<GuildRole[]>;
8
+ values(guild: string): ReturnCache<GuildRole[]>;
7
9
  }
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Roles = 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 Roles extends guild_related_1.GuildRelatedResource {
7
8
  namespace = 'role';
8
- async get(id) {
9
- const rawRole = await super.get(id);
10
- return rawRole ? new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id) : undefined;
9
+ get(id) {
10
+ return (0, common_1.fakePromise)(super.get(id)).then(rawRole => rawRole ? new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id) : undefined);
11
11
  }
12
- async values(guild) {
13
- const roles = await super.values(guild);
14
- return roles.map(rawRole => new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id));
12
+ bulk(ids) {
13
+ return (0, common_1.fakePromise)(super.bulk(ids)).then(roles => roles.map(rawRole => new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id)));
14
+ }
15
+ values(guild) {
16
+ return (0, common_1.fakePromise)(super.values(guild)).then(roles => roles.map(rawRole => new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id)));
15
17
  }
16
18
  }
17
19
  exports.Roles = Roles;
@@ -1,7 +1,9 @@
1
+ import type { ReturnCache } from '../..';
1
2
  import { Sticker } from '../../structures';
2
3
  import { GuildRelatedResource } from './default/guild-related';
3
4
  export declare class Stickers extends GuildRelatedResource {
4
5
  namespace: string;
5
- get(id: string): Promise<Sticker | undefined>;
6
- values(guild: string): Promise<Sticker[]>;
6
+ get(id: string): ReturnCache<Sticker | undefined>;
7
+ bulk(ids: string[]): ReturnCache<Sticker[]>;
8
+ values(guild: string): ReturnCache<Sticker[]>;
7
9
  }
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Stickers = 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 Stickers extends guild_related_1.GuildRelatedResource {
7
8
  namespace = 'sticker';
8
- async get(id) {
9
- const rawSticker = (await super.get(id));
10
- return rawSticker ? new structures_1.Sticker(this.client, rawSticker) : undefined;
9
+ get(id) {
10
+ return (0, common_1.fakePromise)(super.get(id)).then(rawSticker => rawSticker ? new structures_1.Sticker(this.client, rawSticker) : undefined);
11
11
  }
12
- async values(guild) {
13
- const emojis = (await super.values(guild));
14
- return emojis.map(rawSticker => new structures_1.Sticker(this.client, rawSticker));
12
+ bulk(ids) {
13
+ return (0, common_1.fakePromise)(super.bulk(ids)).then(emojis => emojis.map(rawSticker => new structures_1.Sticker(this.client, rawSticker)));
14
+ }
15
+ values(guild) {
16
+ return (0, common_1.fakePromise)(super.values(guild)).then(emojis => emojis.map(rawSticker => new structures_1.Sticker(this.client, rawSticker)));
15
17
  }
16
18
  }
17
19
  exports.Stickers = Stickers;
@@ -1,7 +1,9 @@
1
+ import type { ReturnCache } from '../..';
1
2
  import { ThreadChannel } from '../../structures';
2
3
  import { GuildRelatedResource } from './default/guild-related';
3
4
  export declare class Threads extends GuildRelatedResource {
4
5
  namespace: string;
5
- get(id: string): Promise<ThreadChannel | undefined>;
6
- values(guild: string): Promise<ThreadChannel[]>;
6
+ get(id: string): ReturnCache<ThreadChannel | undefined>;
7
+ bulk(ids: string[]): ReturnCache<ThreadChannel[]>;
8
+ values(guild: string): ReturnCache<ThreadChannel[]>;
7
9
  }
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Threads = 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 Threads extends guild_related_1.GuildRelatedResource {
7
8
  namespace = 'thread';
8
- async get(id) {
9
- const rawThread = (await super.get(id));
10
- return rawThread ? new structures_1.ThreadChannel(this.client, rawThread) : undefined;
9
+ get(id) {
10
+ return (0, common_1.fakePromise)(super.get(id)).then(rawThread => rawThread ? new structures_1.ThreadChannel(this.client, rawThread) : undefined);
11
11
  }
12
- async values(guild) {
13
- const members = (await super.values(guild));
14
- return members.map(rawThread => new structures_1.ThreadChannel(this.client, rawThread));
12
+ bulk(ids) {
13
+ return (0, common_1.fakePromise)(super.bulk(ids)).then(threads => threads.map(rawThread => new structures_1.ThreadChannel(this.client, rawThread)));
14
+ }
15
+ values(guild) {
16
+ return (0, common_1.fakePromise)(super.values(guild)).then(threads => threads.map(rawThread => new structures_1.ThreadChannel(this.client, rawThread)));
15
17
  }
16
18
  }
17
19
  exports.Threads = Threads;
@@ -1,7 +1,9 @@
1
+ import type { ReturnCache } from '../..';
1
2
  import { User } from '../../structures';
2
3
  import { BaseResource } from './default/base';
3
4
  export declare class Users extends BaseResource {
4
5
  namespace: string;
5
- get(id: string): Promise<User | undefined>;
6
- values(): Promise<User[]>;
6
+ get(id: string): ReturnCache<User | undefined>;
7
+ bulk(ids: string[]): ReturnCache<User[]>;
8
+ values(): ReturnCache<User[]>;
7
9
  }
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Users = void 0;
4
+ const common_1 = require("../../common");
4
5
  const structures_1 = require("../../structures");
5
6
  const base_1 = require("./default/base");
6
7
  class Users extends base_1.BaseResource {
7
8
  namespace = 'user';
8
- async get(id) {
9
- const rawUser = (await super.get(id));
10
- return rawUser ? new structures_1.User(this.client, rawUser) : undefined;
9
+ get(id) {
10
+ return (0, common_1.fakePromise)(super.get(id)).then(rawUser => (rawUser ? new structures_1.User(this.client, rawUser) : undefined));
11
11
  }
12
- async values() {
13
- const members = (await super.values());
14
- return members.map(rawUser => new structures_1.User(this.client, rawUser));
12
+ bulk(ids) {
13
+ return (0, common_1.fakePromise)(super.bulk(ids)).then(users => users.map(rawUser => new structures_1.User(this.client, rawUser)));
14
+ }
15
+ values() {
16
+ return (0, common_1.fakePromise)(super.values()).then(users => users.map(rawUser => new structures_1.User(this.client, rawUser)));
15
17
  }
16
18
  }
17
19
  exports.Users = Users;
@@ -1,8 +1,8 @@
1
1
  import type { GatewayVoiceState } from '../../common';
2
- import { GuildRelatedResource } from './default/guild-related';
3
- export declare class VoiceStates extends GuildRelatedResource<VoiceStateResource> {
2
+ import { GuildBasedResource } from './default/guild-based';
3
+ export declare class VoiceStates extends GuildBasedResource<VoiceStateResource> {
4
4
  namespace: string;
5
- parse(data: any, _id: string, guild_id: string): VoiceStateResource;
5
+ parse(data: any, id: string, guild_id: string): VoiceStateResource;
6
6
  }
7
7
  export type VoiceStateResource = Omit<GatewayVoiceState, 'member'> & {
8
8
  guild_id: string;
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VoiceStates = void 0;
4
- const guild_related_1 = require("./default/guild-related");
5
- class VoiceStates extends guild_related_1.GuildRelatedResource {
6
- namespace = 'voice-state';
7
- parse(data, _id, guild_id) {
8
- data.guild_id = guild_id;
9
- delete data.member;
10
- return data;
4
+ const guild_based_1 = require("./default/guild-based");
5
+ class VoiceStates extends guild_based_1.GuildBasedResource {
6
+ namespace = 'voice_state';
7
+ parse(data, id, guild_id) {
8
+ const { member, ...rest } = super.parse(data, id, guild_id);
9
+ return rest;
11
10
  }
12
11
  }
13
12
  exports.VoiceStates = VoiceStates;
@@ -1,22 +1,22 @@
1
- import { REST } from '../api';
1
+ import { ApiHandler } from '../api';
2
2
  import type { Adapter } from '../cache';
3
3
  import { Cache } from '../cache';
4
4
  import type { RegisteredMiddlewares } from '../commands';
5
- import type { DefaultLocale, MiddlewareContext } from '../commands/applications/shared';
5
+ import type { MiddlewareContext } from '../commands/applications/shared';
6
6
  import { CommandHandler } from '../commands/handler';
7
- import { Logger, type MakeRequired } from '../common';
7
+ import { Logger, type LocaleString, type MakeRequired } from '../common';
8
8
  import type { DeepPartial, IntentStrings, OmitInsert } from '../common/types/util';
9
9
  import { ComponentHandler } from '../components/handler';
10
10
  import { LangsHandler } from '../langs/handler';
11
11
  import type { ChatInputCommandInteraction, MessageCommandInteraction, UserCommandInteraction } from '../structures';
12
12
  export declare class BaseClient {
13
- rest: REST;
13
+ rest: ApiHandler;
14
14
  cache: Cache;
15
15
  users: {
16
16
  createDM: (userId: string, force?: boolean) => Promise<import("../structures").DMChannel>;
17
17
  deleteDM: (userId: string, reason?: string | undefined) => Promise<import("../structures").DMChannel>;
18
18
  fetch: (userId: string, force?: boolean) => Promise<import("../structures").User>;
19
- write: (userId: string, body: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
19
+ write: (userId: string, body: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
20
20
  };
21
21
  channels: {
22
22
  fetch: (id: string, force?: boolean | undefined) => Promise<import("../structures").AllChannels>;
@@ -34,11 +34,38 @@ export declare class BaseClient {
34
34
  set: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
35
35
  delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
36
36
  };
37
+ overwrites: {
38
+ memberPermissions: (channelId: string, member: import("../structures").GuildMember, checkAdmin?: boolean) => Promise<import("../structures/extra/Permissions").PermissionsBitField>;
39
+ overwritesFor: (channelId: string, member: import("../structures").GuildMember) => Promise<{
40
+ everyone: {
41
+ type: number;
42
+ id: string;
43
+ deny: import("../structures/extra/Permissions").PermissionsBitField;
44
+ allow: import("../structures/extra/Permissions").PermissionsBitField;
45
+ } | undefined;
46
+ roles: {
47
+ type: number;
48
+ id: string;
49
+ deny: import("../structures/extra/Permissions").PermissionsBitField;
50
+ allow: import("../structures/extra/Permissions").PermissionsBitField;
51
+ }[];
52
+ member: {
53
+ type: number;
54
+ id: string;
55
+ deny: import("../structures/extra/Permissions").PermissionsBitField;
56
+ allow: import("../structures/extra/Permissions").PermissionsBitField;
57
+ } | undefined;
58
+ }>;
59
+ rolePermissions: (channelId: string, role: import("../structures").GuildRole, checkAdmin?: boolean) => Promise<import("../structures/extra/Permissions").PermissionsBitField>;
60
+ };
37
61
  };
38
62
  guilds: {
39
63
  create: (body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildsJSONBody) => Promise<import("../structures").Guild<"api">>;
40
64
  fetch: (id: string, force?: boolean) => Promise<import("../structures").Guild<"cached"> | import("../structures").Guild<"api">>;
41
65
  widgetURL: (id: string, style?: import("discord-api-types/payloads/v10/guild").GuildWidgetStyle | undefined) => Promise<import("discord-api-types/payloads/v10/guild").APIGuildWidgetSettings>;
66
+ list: (query?: import("discord-api-types/rest/v10/user").RESTGetAPICurrentUserGuildsQuery | undefined) => Promise<import("../structures").AnonymousGuild[]>;
67
+ fetchSelf: (id: string) => Promise<import("../structures").GuildMember>;
68
+ leave: (id: string) => Promise<void | undefined>;
42
69
  channels: {
43
70
  list: (guildId: string, force?: boolean) => Promise<import("../structures").AllChannels[]>;
44
71
  fetch: (guildId: string, channelId: string, force?: boolean | undefined) => Promise<import("../structures").AllChannels>;
@@ -80,8 +107,8 @@ export declare class BaseClient {
80
107
  };
81
108
  };
82
109
  messages: {
83
- write: (channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
84
- edit: (messageId: string, channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
110
+ write: (channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
111
+ edit: (messageId: string, channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
85
112
  crosspost: (messageId: string, channelId: string, reason?: string | undefined) => Promise<import("../structures").Message>;
86
113
  delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<void>;
87
114
  fetch: (messageId: string, channelId: string) => Promise<import("../structures").Message>;
@@ -120,11 +147,11 @@ export declare class BaseClient {
120
147
  fetch: (webhookId: string, token?: string | undefined) => Promise<import("../structures").Webhook>;
121
148
  messages: {
122
149
  write: (webhookId: string, token: string, { body: data, ...payload }: {
123
- body: Omit<import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenJSONBody, "embeds" | "components"> & import("../common").ResolverProps;
150
+ body: Omit<import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenJSONBody, "components" | "embeds"> & import("../common").ResolverProps;
124
151
  query?: import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenQuery | undefined;
125
152
  }) => Promise<import("../structures").WebhookMessage | null>;
126
153
  edit: (webhookId: string, token: string, { messageId, body: data, ...json }: {
127
- body: Omit<import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps;
154
+ body: Omit<import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps;
128
155
  messageId: string;
129
156
  query?: import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenMessageQuery | undefined;
130
157
  }) => Promise<import("../structures").WebhookMessage>;
@@ -149,8 +176,8 @@ export declare class BaseClient {
149
176
  };
150
177
  debugger?: Logger;
151
178
  logger: Logger;
152
- commands: CommandHandler;
153
179
  langs: LangsHandler;
180
+ commands: CommandHandler;
154
181
  components: ComponentHandler;
155
182
  private _applicationId?;
156
183
  private _botId?;
@@ -164,15 +191,17 @@ export declare class BaseClient {
164
191
  set applicationId(id: string);
165
192
  get applicationId(): string;
166
193
  get proxy(): import("../api").APIRoutes;
167
- setServices({ rest, cache, defaultLang, middlewares }: ServicesOptions): void;
194
+ setServices({ rest, cache, langs, middlewares }: ServicesOptions): void;
168
195
  protected execute(..._options: unknown[]): Promise<void>;
169
196
  start(options?: Pick<DeepPartial<StartOptions>, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise<void>;
170
197
  protected onPacket(..._packet: unknown[]): Promise<void>;
171
198
  uploadCommands(applicationId?: string): Promise<void>;
172
199
  loadCommands(dir?: string): Promise<void>;
173
200
  loadComponents(dir?: string): Promise<void>;
174
- t(locale: string): DefaultLocale;
175
201
  loadLangs(dir?: string): Promise<void>;
202
+ t(locale: string): import("..").__InternalParseLocale<import("../commands").DefaultLocale> & {
203
+ get(locale?: string | undefined): import("../commands").DefaultLocale;
204
+ };
176
205
  getRC<T extends InternalRuntimeConfigHTTP | InternalRuntimeConfig = InternalRuntimeConfigHTTP | InternalRuntimeConfig>(): Promise<{
177
206
  debug: boolean;
178
207
  } & Omit<T, "debug" | "locations"> & {
@@ -180,9 +209,9 @@ export declare class BaseClient {
180
209
  langs: string | undefined;
181
210
  events: string | undefined;
182
211
  components: string | undefined;
212
+ commands: string | undefined;
183
213
  base: string;
184
214
  output: string;
185
- commands: string;
186
215
  }>;
187
216
  }
188
217
  export interface BaseClientOptions {
@@ -208,7 +237,7 @@ interface RC extends Variables {
208
237
  locations: {
209
238
  base: string;
210
239
  output: string;
211
- commands: string;
240
+ commands?: string;
212
241
  langs?: string;
213
242
  templates?: string;
214
243
  events?: string;
@@ -233,12 +262,16 @@ export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
233
262
  intents?: IntentStrings | number;
234
263
  }>;
235
264
  export type ServicesOptions = {
236
- rest?: REST;
265
+ rest?: ApiHandler;
237
266
  cache?: {
238
267
  adapter: Adapter;
239
268
  disabledCache?: Cache['disabledCache'];
269
+ asyncCache?: boolean;
270
+ };
271
+ langs?: {
272
+ default?: string;
273
+ aliases?: Record<string, LocaleString[]>;
240
274
  };
241
- defaultLang?: string;
242
275
  middlewares?: Record<string, MiddlewareContext>;
243
276
  };
244
277
  export {};
@@ -14,8 +14,6 @@ const webhook_1 = require("../common/shorters/webhook");
14
14
  const handler_2 = require("../components/handler");
15
15
  const handler_3 = require("../langs/handler");
16
16
  class BaseClient {
17
- /** @internal */
18
- __handleGuilds = new Set();
19
17
  rest;
20
18
  cache;
21
19
  users = new common_1.UsersShorter(this).users;
@@ -30,8 +28,8 @@ class BaseClient {
30
28
  logger = new common_1.Logger({
31
29
  name: '[Seyfert]',
32
30
  });
33
- commands = new handler_1.CommandHandler(this.logger);
34
31
  langs = new handler_3.LangsHandler(this.logger);
32
+ commands = new handler_1.CommandHandler(this.logger, this);
35
33
  components = new handler_2.ComponentHandler(this.logger, this);
36
34
  _applicationId;
37
35
  _botId;
@@ -63,15 +61,18 @@ class BaseClient {
63
61
  get proxy() {
64
62
  return new api_1.Router(this.rest).createProxy();
65
63
  }
66
- setServices({ rest, cache, defaultLang, middlewares }) {
64
+ setServices({ rest, cache, langs, middlewares }) {
67
65
  if (rest) {
68
66
  this.rest = rest;
69
67
  }
70
68
  if (cache) {
71
- this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache.adapter, cache.disabledCache ?? this.cache?.disabledCache, this);
69
+ this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache.adapter, cache.asyncCache ?? this.cache?.asyncCache, cache.disabledCache ?? this.cache?.disabledCache, this);
72
70
  }
73
- if (defaultLang) {
74
- this.langs.defaultLang = defaultLang;
71
+ if (langs) {
72
+ if (langs.default)
73
+ this.langs.defaultLang = langs.default;
74
+ if (langs.aliases)
75
+ this.langs.aliases = Object.entries(langs.aliases);
75
76
  }
76
77
  if (middlewares) {
77
78
  this.middlewares = middlewares;
@@ -99,13 +100,15 @@ class BaseClient {
99
100
  const token = options?.token ?? tokenRC;
100
101
  if (!this.rest) {
101
102
  BaseClient.assertString(token, 'token is not a string');
102
- this.rest = new api_1.REST({
103
+ this.rest = new api_1.ApiHandler({
103
104
  token,
104
- debug: false, //(await this.getRC()).debug,
105
+ baseUrl: 'api/v10',
106
+ domain: 'https://discord.com',
107
+ debug: (await this.getRC()).debug,
105
108
  });
106
109
  }
107
110
  if (!this.cache) {
108
- this.cache = new cache_1.Cache(0, new cache_1.MemoryAdapter(), [], this);
111
+ this.cache = new cache_1.Cache(0, new cache_1.MemoryAdapter(), false, [], this);
109
112
  }
110
113
  else {
111
114
  this.cache.__setClient(this);
@@ -139,9 +142,10 @@ class BaseClient {
139
142
  }
140
143
  async loadCommands(dir) {
141
144
  dir ??= await this.getRC().then(x => x.commands);
142
- BaseClient.assertString(dir);
143
- await this.commands.load(dir, this);
144
- this.logger.info('CommandHandler loaded');
145
+ if (dir) {
146
+ await this.commands.load(dir, this);
147
+ this.logger.info('CommandHandler loaded');
148
+ }
145
149
  }
146
150
  async loadComponents(dir) {
147
151
  dir ??= await this.getRC().then(x => x.components);
@@ -150,9 +154,6 @@ class BaseClient {
150
154
  this.logger.info('ComponentHandler loaded');
151
155
  }
152
156
  }
153
- t(locale) {
154
- return this.langs.get(locale);
155
- }
156
157
  async loadLangs(dir) {
157
158
  dir ??= await this.getRC().then(x => x.langs);
158
159
  if (dir) {
@@ -160,6 +161,9 @@ class BaseClient {
160
161
  this.logger.info('LangsHandler loaded');
161
162
  }
162
163
  }
164
+ t(locale) {
165
+ return this.langs.get(locale);
166
+ }
163
167
  async getRC() {
164
168
  const { locations, debug, ...env } = (await (0, common_1.magicImport)((0, node_path_1.join)(process.cwd(), 'seyfert.config.js')).then(x => x.default ?? x));
165
169
  return {
@@ -169,9 +173,9 @@ class BaseClient {
169
173
  langs: locations.langs ? (0, node_path_1.join)(process.cwd(), locations.output, locations.langs) : undefined,
170
174
  events: 'events' in locations && locations.events ? (0, node_path_1.join)(process.cwd(), locations.output, locations.events) : undefined,
171
175
  components: locations.components ? (0, node_path_1.join)(process.cwd(), locations.output, locations.components) : undefined,
176
+ commands: locations.commands ? (0, node_path_1.join)(process.cwd(), locations.output, locations.commands) : undefined,
172
177
  base: (0, node_path_1.join)(process.cwd(), locations.base),
173
178
  output: (0, node_path_1.join)(process.cwd(), locations.output),
174
- commands: (0, node_path_1.join)(process.cwd(), locations.output, locations.commands),
175
179
  };
176
180
  }
177
181
  }
@@ -1,12 +1,14 @@
1
+ import type { Command, CommandContext, Message, SubCommand } from '..';
1
2
  import type { DeepPartial, GatewayDispatchPayload, GatewayPresenceUpdateData, If } from '../common';
2
3
  import { EventHandler } from '../events';
3
4
  import { ClientUser } from '../structures';
4
- import { ShardManager } from '../websocket';
5
+ import { ShardManager, type ShardManagerOptions } from '../websocket';
5
6
  import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
6
7
  import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
7
8
  import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
8
9
  import { BaseClient } from './base';
9
10
  export declare class Client<Ready extends boolean = boolean> extends BaseClient {
11
+ private __handleGuilds?;
10
12
  gateway: ShardManager;
11
13
  events: EventHandler;
12
14
  me: If<Ready, ClientUser>;
@@ -27,6 +29,15 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
27
29
  }
28
30
  export interface ClientOptions extends BaseClientOptions {
29
31
  presence?: (shardId: number) => GatewayPresenceUpdateData;
30
- shardStart?: number;
31
- shardEnd?: number;
32
+ shards?: {
33
+ start: number;
34
+ end: number;
35
+ };
36
+ commands?: {
37
+ prefix: (message: Message) => Promise<string[]> | string[];
38
+ deferReplyResponse?: (ctx: CommandContext) => Parameters<Message['write']>[0];
39
+ reply?: (ctx: CommandContext) => boolean;
40
+ argsParser?: (content: string, command: SubCommand | Command) => Record<string, string>;
41
+ };
42
+ handlePayload?: ShardManagerOptions['handlePayload'];
32
43
  }