seyfert 2.1.0 → 2.1.1-dev-11316886063.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 (241) hide show
  1. package/lib/api/Router.d.ts +2 -2
  2. package/lib/api/Router.js +2 -1
  3. package/lib/api/Routes/applications.d.ts +29 -30
  4. package/lib/api/Routes/cdn.d.ts +6 -1
  5. package/lib/api/Routes/channels.d.ts +44 -45
  6. package/lib/api/Routes/gateway.d.ts +3 -4
  7. package/lib/api/Routes/guilds.d.ts +81 -80
  8. package/lib/api/Routes/index.d.ts +3 -1
  9. package/lib/api/Routes/interactions.d.ts +6 -6
  10. package/lib/api/Routes/invites.d.ts +3 -4
  11. package/lib/api/Routes/skus.d.ts +4 -5
  12. package/lib/api/Routes/soundboard.d.ts +23 -0
  13. package/lib/api/Routes/soundboard.js +2 -0
  14. package/lib/api/Routes/stage-instances.d.ts +5 -6
  15. package/lib/api/Routes/stickers.d.ts +3 -4
  16. package/lib/api/Routes/users.d.ts +11 -12
  17. package/lib/api/Routes/voice.d.ts +2 -3
  18. package/lib/api/Routes/webhooks.d.ts +16 -15
  19. package/lib/api/api.d.ts +17 -11
  20. package/lib/api/api.js +12 -10
  21. package/lib/api/shared.d.ts +1 -1
  22. package/lib/api/utils/constants.d.ts +2 -0
  23. package/lib/api/utils/constants.js +2 -1
  24. package/lib/builders/ActionRow.d.ts +1 -1
  25. package/lib/builders/Attachment.d.ts +2 -2
  26. package/lib/builders/Attachment.js +1 -1
  27. package/lib/builders/Button.d.ts +1 -1
  28. package/lib/builders/Button.js +1 -1
  29. package/lib/builders/Embed.d.ts +1 -1
  30. package/lib/builders/Embed.js +2 -2
  31. package/lib/builders/Modal.d.ts +1 -1
  32. package/lib/builders/Poll.d.ts +1 -1
  33. package/lib/builders/Poll.js +1 -1
  34. package/lib/builders/SelectMenu.d.ts +1 -1
  35. package/lib/builders/SelectMenu.js +1 -1
  36. package/lib/builders/types.d.ts +2 -1
  37. package/lib/cache/adapters/default.js +5 -3
  38. package/lib/cache/adapters/limited.d.ts +1 -2
  39. package/lib/cache/adapters/limited.js +34 -30
  40. package/lib/cache/adapters/workeradapter.js +3 -1
  41. package/lib/cache/index.d.ts +8 -11
  42. package/lib/cache/index.js +38 -37
  43. package/lib/cache/resources/bans.d.ts +2 -2
  44. package/lib/cache/resources/bans.js +1 -1
  45. package/lib/cache/resources/channels.d.ts +1 -1
  46. package/lib/cache/resources/default/guild-related.d.ts +1 -2
  47. package/lib/cache/resources/emojis.d.ts +2 -2
  48. package/lib/cache/resources/emojis.js +1 -1
  49. package/lib/cache/resources/guilds.d.ts +2 -2
  50. package/lib/cache/resources/guilds.js +7 -11
  51. package/lib/cache/resources/members.d.ts +2 -2
  52. package/lib/cache/resources/members.js +1 -1
  53. package/lib/cache/resources/messages.d.ts +2 -2
  54. package/lib/cache/resources/messages.js +3 -3
  55. package/lib/cache/resources/overwrites.d.ts +1 -1
  56. package/lib/cache/resources/roles.d.ts +2 -2
  57. package/lib/cache/resources/roles.js +1 -1
  58. package/lib/cache/resources/stickers.d.ts +2 -2
  59. package/lib/cache/resources/stickers.js +1 -1
  60. package/lib/cache/resources/users.d.ts +2 -2
  61. package/lib/cache/resources/users.js +1 -1
  62. package/lib/cache/resources/voice-states.d.ts +2 -2
  63. package/lib/cache/resources/voice-states.js +1 -1
  64. package/lib/client/base.d.ts +9 -14
  65. package/lib/client/base.js +43 -44
  66. package/lib/client/client.d.ts +3 -7
  67. package/lib/client/client.js +24 -41
  68. package/lib/client/collectors.js +1 -1
  69. package/lib/client/httpclient.d.ts +1 -1
  70. package/lib/client/transformers.d.ts +37 -34
  71. package/lib/client/transformers.js +66 -63
  72. package/lib/client/workerclient.d.ts +10 -11
  73. package/lib/client/workerclient.js +180 -75
  74. package/lib/collection.d.ts +3 -3
  75. package/lib/commands/applications/chat.d.ts +12 -32
  76. package/lib/commands/applications/chat.js +5 -6
  77. package/lib/commands/applications/chatcontext.d.ts +6 -6
  78. package/lib/commands/applications/chatcontext.js +16 -8
  79. package/lib/commands/applications/entryPoint.d.ts +1 -1
  80. package/lib/commands/applications/entrycontext.d.ts +6 -6
  81. package/lib/commands/applications/entrycontext.js +4 -4
  82. package/lib/commands/applications/menu.d.ts +1 -1
  83. package/lib/commands/applications/menucontext.d.ts +5 -5
  84. package/lib/commands/applications/menucontext.js +6 -6
  85. package/lib/commands/applications/options.d.ts +104 -28
  86. package/lib/commands/applications/options.js +4 -4
  87. package/lib/commands/applications/shared.d.ts +5 -2
  88. package/lib/commands/basecontext.d.ts +1 -1
  89. package/lib/commands/decorators.d.ts +10 -10
  90. package/lib/commands/decorators.js +5 -4
  91. package/lib/commands/handle.d.ts +9 -9
  92. package/lib/commands/handle.js +94 -68
  93. package/lib/commands/handler.d.ts +5 -5
  94. package/lib/commands/handler.js +21 -17
  95. package/lib/commands/optionresolver.d.ts +4 -4
  96. package/lib/commands/optionresolver.js +3 -3
  97. package/lib/common/it/formatter.d.ts +21 -21
  98. package/lib/common/it/formatter.js +40 -41
  99. package/lib/common/it/logger.js +1 -1
  100. package/lib/common/it/utils.d.ts +4 -3
  101. package/lib/common/it/utils.js +52 -27
  102. package/lib/common/shorters/application.d.ts +2 -3
  103. package/lib/common/shorters/application.js +3 -3
  104. package/lib/common/shorters/bans.js +1 -1
  105. package/lib/common/shorters/channels.d.ts +3 -3
  106. package/lib/common/shorters/channels.js +3 -3
  107. package/lib/common/shorters/emojis.js +4 -4
  108. package/lib/common/shorters/guilds.d.ts +3 -3
  109. package/lib/common/shorters/guilds.js +5 -9
  110. package/lib/common/shorters/interaction.d.ts +3 -3
  111. package/lib/common/shorters/interaction.js +6 -5
  112. package/lib/common/shorters/members.d.ts +4 -5
  113. package/lib/common/shorters/members.js +6 -7
  114. package/lib/common/shorters/messages.d.ts +1 -1
  115. package/lib/common/shorters/messages.js +4 -4
  116. package/lib/common/shorters/reactions.d.ts +1 -1
  117. package/lib/common/shorters/reactions.js +1 -1
  118. package/lib/common/shorters/roles.js +1 -1
  119. package/lib/common/shorters/templates.js +2 -2
  120. package/lib/common/shorters/threads.d.ts +1 -1
  121. package/lib/common/shorters/threads.js +17 -11
  122. package/lib/common/shorters/webhook.d.ts +1 -1
  123. package/lib/common/shorters/webhook.js +4 -4
  124. package/lib/common/types/options.d.ts +2 -2
  125. package/lib/common/types/resolvables.d.ts +1 -1
  126. package/lib/common/types/util.d.ts +4 -1
  127. package/lib/common/types/write.d.ts +1 -1
  128. package/lib/components/BaseComponent.js +1 -1
  129. package/lib/components/ButtonComponent.d.ts +1 -1
  130. package/lib/components/componentcommand.d.ts +1 -1
  131. package/lib/components/componentcontext.d.ts +4 -4
  132. package/lib/components/componentcontext.js +1 -1
  133. package/lib/components/handler.d.ts +10 -8
  134. package/lib/components/handler.js +16 -13
  135. package/lib/components/index.js +2 -1
  136. package/lib/components/modalcontext.d.ts +2 -2
  137. package/lib/components/modalcontext.js +1 -1
  138. package/lib/deps/mixer.d.ts +1 -1
  139. package/lib/events/handler.d.ts +5 -5
  140. package/lib/events/handler.js +66 -16
  141. package/lib/events/hooks/application_command.d.ts +1 -1
  142. package/lib/events/hooks/auto_moderation.d.ts +1 -1
  143. package/lib/events/hooks/auto_moderation.js +1 -1
  144. package/lib/events/hooks/channel.d.ts +1 -1
  145. package/lib/events/hooks/dispatch.d.ts +1 -1
  146. package/lib/events/hooks/entitlement.d.ts +4 -5
  147. package/lib/events/hooks/entitlement.js +4 -4
  148. package/lib/events/hooks/guild.d.ts +3 -3
  149. package/lib/events/hooks/guild.js +1 -1
  150. package/lib/events/hooks/index.d.ts +1 -0
  151. package/lib/events/hooks/index.js +1 -0
  152. package/lib/events/hooks/integration.d.ts +1 -1
  153. package/lib/events/hooks/integration.js +1 -1
  154. package/lib/events/hooks/interactions.d.ts +3 -3
  155. package/lib/events/hooks/invite.d.ts +1 -1
  156. package/lib/events/hooks/message.d.ts +3 -3
  157. package/lib/events/hooks/message.js +1 -1
  158. package/lib/events/hooks/presence.d.ts +2 -2
  159. package/lib/events/hooks/soundboard.d.ts +155 -0
  160. package/lib/events/hooks/soundboard.js +28 -0
  161. package/lib/events/hooks/stage.d.ts +2 -2
  162. package/lib/events/hooks/thread.d.ts +2 -2
  163. package/lib/events/hooks/thread.js +2 -2
  164. package/lib/events/hooks/typing.d.ts +1 -1
  165. package/lib/events/hooks/typing.js +1 -1
  166. package/lib/events/hooks/user.d.ts +2 -2
  167. package/lib/events/hooks/voice.d.ts +2 -2
  168. package/lib/events/hooks/voice.js +1 -1
  169. package/lib/events/hooks/webhook.d.ts +1 -1
  170. package/lib/index.d.ts +2 -2
  171. package/lib/index.js +3 -5
  172. package/lib/langs/handler.d.ts +2 -2
  173. package/lib/structures/Guild.d.ts +7 -4
  174. package/lib/structures/Guild.js +1 -1
  175. package/lib/structures/GuildBan.d.ts +1 -1
  176. package/lib/structures/GuildMember.d.ts +7 -5
  177. package/lib/structures/GuildMember.js +5 -3
  178. package/lib/structures/GuildRole.d.ts +1 -1
  179. package/lib/structures/GuildTemplate.d.ts +1 -1
  180. package/lib/structures/Interaction.d.ts +17 -14
  181. package/lib/structures/Interaction.js +28 -21
  182. package/lib/structures/Message.d.ts +4 -7
  183. package/lib/structures/Message.js +5 -5
  184. package/lib/structures/Poll.d.ts +3 -3
  185. package/lib/structures/Sticker.d.ts +2 -2
  186. package/lib/structures/Sticker.js +1 -1
  187. package/lib/structures/VoiceState.d.ts +2 -1
  188. package/lib/structures/VoiceState.js +1 -1
  189. package/lib/structures/Webhook.d.ts +3 -3
  190. package/lib/structures/Webhook.js +1 -1
  191. package/lib/structures/channels.d.ts +4 -4
  192. package/lib/structures/channels.js +6 -5
  193. package/lib/structures/extra/BitField.d.ts +3 -3
  194. package/lib/structures/extra/BitField.js +34 -33
  195. package/lib/structures/extra/DiscordBase.js +1 -1
  196. package/lib/structures/extra/Permissions.d.ts +2 -0
  197. package/lib/structures/extra/Permissions.js +21 -0
  198. package/lib/types/gateway.d.ts +53 -5
  199. package/lib/types/payloads/_interactions/base.d.ts +1 -1
  200. package/lib/types/payloads/channel.d.ts +2 -2
  201. package/lib/types/payloads/guild.d.ts +9 -1
  202. package/lib/types/payloads/guild.js +8 -0
  203. package/lib/types/payloads/index.d.ts +1 -0
  204. package/lib/types/payloads/index.js +1 -0
  205. package/lib/types/payloads/soundboard.d.ts +23 -0
  206. package/lib/types/payloads/soundboard.js +5 -0
  207. package/lib/types/payloads/user.js +0 -1
  208. package/lib/types/rest/application.d.ts +3 -3
  209. package/lib/types/rest/auditLog.d.ts +1 -1
  210. package/lib/types/rest/channel.d.ts +2 -2
  211. package/lib/types/rest/guild.d.ts +2 -2
  212. package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
  213. package/lib/types/rest/index.d.ts +1 -0
  214. package/lib/types/rest/index.js +1 -0
  215. package/lib/types/rest/oauth2.d.ts +1 -1
  216. package/lib/types/rest/poll.d.ts +1 -1
  217. package/lib/types/rest/soundboard.d.ts +64 -0
  218. package/lib/types/rest/soundboard.js +2 -0
  219. package/lib/types/rest/stageInstance.d.ts +1 -1
  220. package/lib/types/rest/template.d.ts +1 -1
  221. package/lib/types/rest/user.d.ts +1 -1
  222. package/lib/types/rest/webhook.d.ts +1 -1
  223. package/lib/types/utils/index.d.ts +11 -2
  224. package/lib/types/utils/index.js +10 -2
  225. package/lib/websocket/SharedTypes.d.ts +11 -2
  226. package/lib/websocket/constants/index.js +0 -10
  227. package/lib/websocket/discord/basesocket.d.ts +1 -1
  228. package/lib/websocket/discord/shard.d.ts +1 -1
  229. package/lib/websocket/discord/shard.js +25 -16
  230. package/lib/websocket/discord/sharder.d.ts +9 -6
  231. package/lib/websocket/discord/sharder.js +91 -74
  232. package/lib/websocket/discord/shared.d.ts +3 -14
  233. package/lib/websocket/discord/socket/custom.js +19 -6
  234. package/lib/websocket/discord/worker.d.ts +8 -2
  235. package/lib/websocket/discord/workermanager.d.ts +42 -17
  236. package/lib/websocket/discord/workermanager.js +144 -37
  237. package/lib/websocket/structures/timeout.d.ts +4 -5
  238. package/lib/websocket/structures/timeout.js +23 -24
  239. package/package.json +72 -70
  240. package/lib/cache/resources/threads.d.ts +0 -14
  241. package/lib/cache/resources/threads.js +0 -32
@@ -7,11 +7,11 @@ const cache_1 = require("../cache");
7
7
  const shared_1 = require("../commands/applications/shared");
8
8
  const handler_1 = require("../commands/handler");
9
9
  const common_1 = require("../common");
10
- const handler_2 = require("../components/handler");
11
- const handler_3 = require("../langs/handler");
12
10
  const node_fs_1 = require("node:fs");
13
- const bans_1 = require("../common/shorters/bans");
14
11
  const handle_1 = require("../commands/handle");
12
+ const bans_1 = require("../common/shorters/bans");
13
+ const handler_2 = require("../components/handler");
14
+ const handler_3 = require("../langs/handler");
15
15
  class BaseClient {
16
16
  rest;
17
17
  cache;
@@ -103,6 +103,9 @@ class BaseClient {
103
103
  },
104
104
  }, options);
105
105
  }
106
+ get proxy() {
107
+ return this.rest.proxy;
108
+ }
106
109
  set botId(id) {
107
110
  this._botId = id;
108
111
  }
@@ -115,57 +118,48 @@ class BaseClient {
115
118
  get applicationId() {
116
119
  return this._applicationId ?? this.botId;
117
120
  }
118
- get proxy() {
119
- return new api_1.Router(this.rest).createProxy();
120
- }
121
- setServices({ rest, cache, langs, middlewares, handlers, handleCommand }) {
121
+ setServices({ rest, cache, langs, middlewares, handleCommand }) {
122
122
  if (rest) {
123
123
  this.rest = rest;
124
124
  }
125
125
  if (cache) {
126
- this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache?.adapter ?? this.cache?.adapter ?? new cache_1.MemoryAdapter(), (typeof cache.disabledCache === 'boolean' ? { onPacket: cache.disabledCache } : cache.disabledCache) ??
127
- this.cache?.disabledCache ??
128
- [], this);
129
- }
130
- if (middlewares) {
131
- this.middlewares = middlewares;
132
- }
133
- if (handlers) {
134
- if ('components' in handlers) {
135
- if (!handlers.components) {
136
- this.components = undefined;
137
- }
138
- else if (typeof handlers.components === 'function') {
139
- this.components ??= new handler_2.ComponentHandler(this.logger, this);
140
- }
141
- else {
142
- this.components = handlers.components;
126
+ const caches = [
127
+ 'bans',
128
+ 'channels',
129
+ 'emojis',
130
+ 'guilds',
131
+ 'members',
132
+ 'messages',
133
+ 'onPacket',
134
+ 'overwrites',
135
+ 'presences',
136
+ 'roles',
137
+ 'stageInstances',
138
+ 'stickers',
139
+ 'users',
140
+ 'voiceStates',
141
+ ];
142
+ let disabledCache = this.cache?.disabledCache ?? {};
143
+ if (typeof cache.disabledCache === 'boolean') {
144
+ for (const i of caches) {
145
+ disabledCache[i] = cache.disabledCache;
143
146
  }
144
147
  }
145
- if ('commands' in handlers) {
146
- if (!handlers.commands) {
147
- this.commands = undefined;
148
- }
149
- else if (typeof handlers.commands === 'object') {
150
- this.commands ??= new handler_1.CommandHandler(this.logger, this);
151
- }
152
- else {
153
- this.commands = handlers.commands;
148
+ else if (typeof cache.disabledCache === 'function') {
149
+ for (const i of caches) {
150
+ disabledCache[i] = cache.disabledCache(i);
154
151
  }
155
152
  }
156
- if ('langs' in handlers) {
157
- if (!handlers.langs) {
158
- this.langs = undefined;
159
- }
160
- else if (typeof handlers.langs === 'function') {
161
- this.langs ??= new handler_3.LangsHandler(this.logger);
162
- }
163
- else {
164
- this.langs = handlers.langs;
165
- }
153
+ else if (typeof cache.disabledCache === 'object') {
154
+ disabledCache = cache.disabledCache;
166
155
  }
156
+ this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache?.adapter ?? this.cache?.adapter ?? new cache_1.MemoryAdapter(), disabledCache, this);
157
+ }
158
+ if (middlewares) {
159
+ this.middlewares = middlewares;
167
160
  }
168
161
  if (langs) {
162
+ this.langs ??= new handler_3.LangsHandler(this.logger);
169
163
  if (langs.default)
170
164
  this.langs.defaultLang = langs.default;
171
165
  if (langs.aliases)
@@ -292,7 +286,12 @@ class BaseClient {
292
286
  async getRC() {
293
287
  const seyfertConfig = (BaseClient._seyfertCfWorkerConfig ||
294
288
  (await this.options?.getRC?.()) ||
295
- (await Promise.any(['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].map(ext => (0, common_1.magicImport)((0, node_path_1.join)(process.cwd(), `seyfert.config${ext}`)).then(x => x.default ?? x)))));
289
+ (await Promise.any(['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].map(ext => (0, common_1.magicImport)((0, node_path_1.join)(process.cwd(), `seyfert.config${ext}`)).then(x => x.default ?? x))).catch((e) => {
290
+ if (e.errors.every((err) => err.stack?.includes('ERR_MODULE_NOT_FOUND'))) {
291
+ throw new Error('No seyfert.config file found');
292
+ }
293
+ throw e.errors.find((err) => !err.stack?.includes('ERR_MODULE_NOT_FOUND')) ?? e.errors[0];
294
+ })));
296
295
  const { locations, debug, ...env } = seyfertConfig;
297
296
  const obj = {
298
297
  debug: !!debug,
@@ -1,7 +1,7 @@
1
- import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from '../types';
2
1
  import type { CommandContext, Message } from '..';
3
2
  import { type Awaitable, type DeepPartial, type If } from '../common';
4
3
  import { EventHandler } from '../events';
4
+ import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from '../types';
5
5
  import { ShardManager, type ShardManagerOptions } from '../websocket';
6
6
  import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
7
7
  import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
@@ -23,9 +23,6 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
23
23
  constructor(options?: ClientOptions);
24
24
  setServices({ gateway, ...rest }: ServicesOptions & {
25
25
  gateway?: ShardManager;
26
- handlers?: ServicesOptions['handlers'] & {
27
- events?: EventHandler['callback'];
28
- };
29
26
  }): void;
30
27
  loadEvents(dir?: string): Promise<void>;
31
28
  protected execute(options?: {
@@ -52,8 +49,7 @@ export interface ClientOptions extends BaseClientOptions {
52
49
  reply?: (ctx: CommandContext) => boolean;
53
50
  };
54
51
  handlePayload?: ShardManagerOptions['handlePayload'];
55
- resharding?: {
56
- interval: number;
57
- percentage: number;
52
+ resharding?: Omit<NonNullable<ShardManagerOptions['resharding']>, 'getInfo'> & {
53
+ getInfo?: NonNullable<ShardManagerOptions['resharding']>['getInfo'];
58
54
  };
59
55
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
- const types_1 = require("../types");
5
4
  const common_1 = require("../common");
6
5
  const events_1 = require("../events");
6
+ const types_1 = require("../types");
7
7
  const websocket_1 = require("../websocket");
8
8
  const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
9
9
  const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
@@ -33,17 +33,6 @@ class Client extends base_1.BaseClient {
33
33
  };
34
34
  this.gateway = gateway;
35
35
  }
36
- if (rest.handlers && 'events' in rest.handlers) {
37
- if (!rest.handlers.events) {
38
- this.events = undefined;
39
- }
40
- else if (typeof rest.handlers.events === 'function') {
41
- this.events = new events_1.EventHandler(this);
42
- }
43
- else {
44
- this.events = rest.handlers.events;
45
- }
46
- }
47
36
  }
48
37
  async loadEvents(dir) {
49
38
  dir ??= await this.getRC().then(x => x.events);
@@ -101,22 +90,9 @@ class Client extends base_1.BaseClient {
101
90
  },
102
91
  compress: this.options?.gateway?.compress,
103
92
  resharding: {
104
- getInfo: () => this.proxy.gateway.bot.get(),
105
- interval: this.options?.resharding?.interval ?? 0,
106
- percentage: this.options?.resharding?.percentage ?? 0,
107
- reloadGuilds: ids => {
108
- this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
109
- },
110
- onGuild: id => {
111
- if (this.__handleGuilds) {
112
- const index = this.__handleGuilds.indexOf(id);
113
- if (index === -1)
114
- return false;
115
- this.__handleGuilds.splice(index, 1);
116
- return true;
117
- }
118
- return false;
119
- },
93
+ getInfo: this.options.resharding?.getInfo ?? (() => this.proxy.gateway.bot.get()),
94
+ interval: this.options?.resharding?.interval,
95
+ percentage: this.options?.resharding?.percentage,
120
96
  },
121
97
  });
122
98
  }
@@ -134,18 +110,22 @@ class Client extends base_1.BaseClient {
134
110
  this.collectors.run('RAW', packet, this),
135
111
  ]); //ignore promise
136
112
  switch (packet.t) {
137
- //// Cases where we must obtain the old data before updating
113
+ // Cases where we must obtain the old data before updating
138
114
  case 'GUILD_MEMBER_UPDATE':
139
- if (!this.memberUpdateHandler.check(packet.d)) {
140
- return;
115
+ {
116
+ if (!this.memberUpdateHandler.check(packet.d)) {
117
+ return;
118
+ }
119
+ await this.events?.execute(packet.t, packet, this, shardId);
141
120
  }
142
- await this.events?.execute(packet.t, packet, this, shardId);
143
121
  break;
144
122
  case 'PRESENCE_UPDATE':
145
- if (!this.presenceUpdateHandler.check(packet.d)) {
146
- return;
123
+ {
124
+ if (!this.presenceUpdateHandler.check(packet.d)) {
125
+ return;
126
+ }
127
+ await this.events?.execute(packet.t, packet, this, shardId);
147
128
  }
148
- await this.events?.execute(packet.t, packet, this, shardId);
149
129
  break;
150
130
  case 'GUILD_DELETE':
151
131
  case 'GUILD_CREATE': {
@@ -167,12 +147,16 @@ class Client extends base_1.BaseClient {
167
147
  default: {
168
148
  switch (packet.t) {
169
149
  case 'INTERACTION_CREATE':
170
- await this.events?.execute(packet.t, packet, this, shardId);
171
- await this.handleCommand.interaction(packet.d, shardId);
150
+ {
151
+ await this.events?.execute(packet.t, packet, this, shardId);
152
+ await this.handleCommand.interaction(packet.d, shardId);
153
+ }
172
154
  break;
173
155
  case 'MESSAGE_CREATE':
174
- await this.events?.execute(packet.t, packet, this, shardId);
175
- await this.handleCommand.message(packet.d, shardId);
156
+ {
157
+ await this.events?.execute(packet.t, packet, this, shardId);
158
+ await this.handleCommand.message(packet.d, shardId);
159
+ }
176
160
  break;
177
161
  case 'READY': {
178
162
  const ids = packet.d.guilds.map(x => x.id);
@@ -180,8 +164,7 @@ class Client extends base_1.BaseClient {
180
164
  this.botId = packet.d.user.id;
181
165
  this.applicationId = packet.d.application.id;
182
166
  this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
183
- if (!(this.__handleGuilds?.length &&
184
- (this.gateway.options.intents & types_1.GatewayIntentBits.Guilds) === types_1.GatewayIntentBits.Guilds)) {
167
+ if (!(0, common_1.hasIntent)(this.gateway.options.intents, types_1.GatewayIntentBits.Guilds)) {
185
168
  if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
186
169
  await this.events?.runEvent('BOT_READY', this, this.me, -1);
187
170
  }
@@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Collectors = void 0;
27
- const node_crypto_1 = require("node:crypto");
28
27
  const node_console_1 = require("node:console");
28
+ const node_crypto_1 = require("node:crypto");
29
29
  const RawEvents = __importStar(require("../events/hooks"));
30
30
  class Collectors {
31
31
  values = new Map();
@@ -1,5 +1,5 @@
1
- import type { APIInteractionResponse, APIInteraction } from '../types';
2
1
  import type { DeepPartial } from '../common';
2
+ import type { APIInteraction, APIInteractionResponse } from '../types';
3
3
  import type { BaseClientOptions, StartOptions } from './base';
4
4
  import { BaseClient } from './base';
5
5
  export declare class HttpClient extends BaseClient {
@@ -1,8 +1,9 @@
1
- import type { ChannelType } from '../types';
2
1
  import { type CustomStructures, OptionResolver } from '../commands';
3
- import { AnonymousGuild, AutoModerationRule, BaseChannel, BaseGuildChannel, CategoryChannel, ClientUser, DMChannel, DirectoryChannel, ForumChannel, Guild, GuildEmoji, GuildMember, GuildRole, GuildTemplate, InteractionGuildMember, MediaChannel, Message, NewsChannel, Poll, StageChannel, Sticker, TextGuildChannel, ThreadChannel, User, VoiceChannel, VoiceState, Webhook, WebhookMessage } from '../structures';
4
2
  import type { StructStates } from '../common/';
3
+ import { AnonymousGuild, AutoModerationRule, BaseChannel, BaseGuildChannel, CategoryChannel, ClientUser, DMChannel, DirectoryChannel, ForumChannel, Guild, GuildEmoji, GuildMember, GuildRole, GuildTemplate, InteractionGuildMember, MediaChannel, Message, NewsChannel, Poll, StageChannel, Sticker, TextGuildChannel, ThreadChannel, User, VoiceChannel, VoiceState, Webhook, WebhookMessage } from '../structures';
4
+ import { Entitlement } from '../structures/Entitlement';
5
5
  import { GuildBan } from '../structures/GuildBan';
6
+ import type { ChannelType } from '../types';
6
7
  export type PollStructure = InferCustomStructure<Poll, 'Poll'>;
7
8
  export type ClientUserStructure = InferCustomStructure<ClientUser, 'ClientUser'>;
8
9
  export type AnonymousGuildStructure = InferCustomStructure<AnonymousGuild, 'AnonymousGuild'>;
@@ -33,36 +34,38 @@ export type UserStructure = InferCustomStructure<User, 'User'>;
33
34
  export type VoiceStateStructure = InferCustomStructure<VoiceState, 'VoiceState'>;
34
35
  export type WebhookStructure = InferCustomStructure<Webhook, 'Webhook'>;
35
36
  export type OptionResolverStructure = InferCustomStructure<OptionResolver, 'OptionResolver'>;
36
- export declare class Transformers {
37
- static AnonymousGuild(...args: ConstructorParameters<typeof AnonymousGuild>): AnonymousGuildStructure;
38
- static AutoModerationRule(...args: ConstructorParameters<typeof AutoModerationRule>): AutoModerationRuleStructure;
39
- static BaseChannel(...args: ConstructorParameters<typeof BaseChannel>): BaseChannelStructure;
40
- static BaseGuildChannel(...args: ConstructorParameters<typeof BaseGuildChannel>): BaseGuildChannelStructure;
41
- static TextGuildChannel(...args: ConstructorParameters<typeof TextGuildChannel>): TextGuildChannelStructure;
42
- static DMChannel(...args: ConstructorParameters<typeof DMChannel>): DMChannelStructure;
43
- static VoiceChannel(...args: ConstructorParameters<typeof VoiceChannel>): VoiceChannelStructure;
44
- static StageChannel(...args: ConstructorParameters<typeof StageChannel>): StageChannelStructure;
45
- static MediaChannel(...args: ConstructorParameters<typeof MediaChannel>): MediaChannelStructure;
46
- static ForumChannel(...args: ConstructorParameters<typeof ForumChannel>): ForumChannelStructure;
47
- static ThreadChannel(...args: ConstructorParameters<typeof ThreadChannel>): ThreadChannelStructure;
48
- static CategoryChannel(...args: ConstructorParameters<typeof CategoryChannel>): CategoryChannelStructure;
49
- static NewsChannel(...args: ConstructorParameters<typeof NewsChannel>): NewsChannelStructure;
50
- static DirectoryChannel(...args: ConstructorParameters<typeof DirectoryChannel>): DirectoryChannelStructure;
51
- static ClientUser(...args: ConstructorParameters<typeof ClientUser>): ClientUserStructure;
52
- static Guild<State extends StructStates = 'api'>(...args: ConstructorParameters<typeof Guild>): GuildStructure<State>;
53
- static GuildBan(...args: ConstructorParameters<typeof GuildBan>): GuildBanStructure;
54
- static GuildEmoji(...args: ConstructorParameters<typeof GuildEmoji>): GuildEmojiStructure;
55
- static GuildMember(...args: ConstructorParameters<typeof GuildMember>): GuildMemberStructure;
56
- static InteractionGuildMember(...args: ConstructorParameters<typeof InteractionGuildMember>): InteractionGuildMemberStructure;
57
- static GuildRole(...args: ConstructorParameters<typeof GuildRole>): GuildRoleStructure;
58
- static GuildTemplate(...args: ConstructorParameters<typeof GuildTemplate>): GuildTemplateStructure;
59
- static Message(...args: ConstructorParameters<typeof Message>): MessageStructure;
60
- static WebhookMessage(...args: ConstructorParameters<typeof WebhookMessage>): WebhookMessageStructure;
61
- static Poll(...args: ConstructorParameters<typeof Poll>): PollStructure;
62
- static Sticker(...args: ConstructorParameters<typeof Sticker>): StickerStructure;
63
- static User(...args: ConstructorParameters<typeof User>): UserStructure;
64
- static VoiceState(...args: ConstructorParameters<typeof VoiceState>): VoiceStateStructure;
65
- static Webhook(...args: ConstructorParameters<typeof Webhook>): WebhookStructure;
66
- static OptionResolver(...args: ConstructorParameters<typeof OptionResolver>): OptionResolverStructure;
67
- }
37
+ export type EntitlementStructure = InferCustomStructure<Entitlement, 'Entitlement'>;
38
+ export declare const Transformers: {
39
+ AnonymousGuild(client: import("../commands").UsingClient, data: import("../types").APIPartialGuild): AnonymousGuildStructure;
40
+ AutoModerationRule(client: import("../commands").UsingClient, data: import("../types").APIAutoModerationRule): AutoModerationRuleStructure;
41
+ BaseChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): BaseChannelStructure;
42
+ BaseGuildChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): BaseGuildChannelStructure;
43
+ TextGuildChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): TextGuildChannelStructure;
44
+ DMChannel(...args: ConstructorParameters<typeof DMChannel>): DMChannelStructure;
45
+ VoiceChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): VoiceChannelStructure;
46
+ StageChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): StageChannelStructure;
47
+ MediaChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): MediaChannelStructure;
48
+ ForumChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): ForumChannelStructure;
49
+ ThreadChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): ThreadChannelStructure;
50
+ CategoryChannel(...args: ConstructorParameters<typeof CategoryChannel>): CategoryChannelStructure;
51
+ NewsChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): NewsChannelStructure;
52
+ DirectoryChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): DirectoryChannelStructure;
53
+ ClientUser(client: import("../commands").UsingClient, data: import("../types").APIUser, application: Pick<import("../types").APIApplication, "id" | "flags">): ClientUserStructure;
54
+ Guild<State extends StructStates = "api">(client: import("../commands").UsingClient, data: import("../types").APIGuild | import("../types").GatewayGuildCreateDispatchData): GuildStructure<State>;
55
+ GuildBan(client: import("../commands").UsingClient, data: import("../types").APIBan, guildId: string): GuildBanStructure;
56
+ GuildEmoji(client: import("../commands").UsingClient, data: import("../types").APIEmoji, guildId: string): GuildEmojiStructure;
57
+ GuildMember(client: import("../commands").UsingClient, data: import("../structures").GuildMemberData, user: import("../types").APIUser, guildId: string): GuildMemberStructure;
58
+ InteractionGuildMember(client: import("../commands").UsingClient, data: import("../types").APIInteractionDataResolvedGuildMember, user: import("../types").APIUser, guildId: string): InteractionGuildMemberStructure;
59
+ GuildRole(client: import("../commands").UsingClient, data: import("../types").APIRole, guildId: string): GuildRoleStructure;
60
+ GuildTemplate(client: import("../commands").UsingClient, data: import("../types").APITemplate): GuildTemplateStructure;
61
+ Message(client: import("../commands").UsingClient, data: import("../structures").MessageData): MessageStructure;
62
+ WebhookMessage(client: import("../commands").UsingClient, data: import("../structures").MessageData, webhookId: string, webhookToken: string): WebhookMessageStructure;
63
+ Poll(client: import("../commands").UsingClient, data: import("../types").APIPoll, channelId: string, messageId: string): PollStructure;
64
+ Sticker(client: import("../commands").UsingClient, data: import("../types").APISticker): StickerStructure;
65
+ User(client: import("../commands").UsingClient, data: import("../types").APIUser): UserStructure;
66
+ VoiceState(client: import("../commands").UsingClient, data: import("../types").APIVoiceState): VoiceStateStructure;
67
+ Webhook(client: import("../commands").UsingClient, data: import("../types").APIWebhook): WebhookStructure;
68
+ OptionResolver(client: import("../commands").UsingClient, options: import("../types").APIApplicationCommandInteractionDataOption[], parent?: import("../commands").Command | undefined, guildId?: string | undefined, resolved?: import("../commands").ContextOptionsResolved | undefined): OptionResolverStructure;
69
+ Entitlement(client: import("../commands").UsingClient, data: import("../types").APIEntitlement): EntitlementStructure;
70
+ };
68
71
  export type InferCustomStructure<T, N extends string> = CustomStructures extends Record<N, infer P> ? P : T;
@@ -3,97 +3,100 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Transformers = void 0;
4
4
  const commands_1 = require("../commands");
5
5
  const structures_1 = require("../structures");
6
+ const Entitlement_1 = require("../structures/Entitlement");
6
7
  const GuildBan_1 = require("../structures/GuildBan");
7
- class Transformers {
8
- static AnonymousGuild(...args) {
8
+ exports.Transformers = {
9
+ AnonymousGuild(...args) {
9
10
  return new structures_1.AnonymousGuild(...args);
10
- }
11
- static AutoModerationRule(...args) {
11
+ },
12
+ AutoModerationRule(...args) {
12
13
  return new structures_1.AutoModerationRule(...args);
13
- }
14
- static BaseChannel(...args) {
14
+ },
15
+ BaseChannel(...args) {
15
16
  return new structures_1.BaseChannel(...args);
16
- }
17
- static BaseGuildChannel(...args) {
17
+ },
18
+ BaseGuildChannel(...args) {
18
19
  return new structures_1.BaseGuildChannel(...args);
19
- }
20
- static TextGuildChannel(...args) {
20
+ },
21
+ TextGuildChannel(...args) {
21
22
  return new structures_1.TextGuildChannel(...args);
22
- }
23
- static DMChannel(...args) {
23
+ },
24
+ DMChannel(...args) {
24
25
  return new structures_1.DMChannel(...args);
25
- }
26
- static VoiceChannel(...args) {
26
+ },
27
+ VoiceChannel(...args) {
27
28
  return new structures_1.VoiceChannel(...args);
28
- }
29
- static StageChannel(...args) {
29
+ },
30
+ StageChannel(...args) {
30
31
  return new structures_1.StageChannel(...args);
31
- }
32
- static MediaChannel(...args) {
32
+ },
33
+ MediaChannel(...args) {
33
34
  return new structures_1.MediaChannel(...args);
34
- }
35
- static ForumChannel(...args) {
35
+ },
36
+ ForumChannel(...args) {
36
37
  return new structures_1.ForumChannel(...args);
37
- }
38
- static ThreadChannel(...args) {
38
+ },
39
+ ThreadChannel(...args) {
39
40
  return new structures_1.ThreadChannel(...args);
40
- }
41
- static CategoryChannel(...args) {
41
+ },
42
+ CategoryChannel(...args) {
42
43
  return new structures_1.CategoryChannel(...args);
43
- }
44
- static NewsChannel(...args) {
44
+ },
45
+ NewsChannel(...args) {
45
46
  return new structures_1.NewsChannel(...args);
46
- }
47
- static DirectoryChannel(...args) {
47
+ },
48
+ DirectoryChannel(...args) {
48
49
  return new structures_1.DirectoryChannel(...args);
49
- }
50
- static ClientUser(...args) {
50
+ },
51
+ ClientUser(...args) {
51
52
  return new structures_1.ClientUser(...args);
52
- }
53
- static Guild(...args) {
53
+ },
54
+ Guild(...args) {
54
55
  return new structures_1.Guild(...args);
55
- }
56
- static GuildBan(...args) {
56
+ },
57
+ GuildBan(...args) {
57
58
  return new GuildBan_1.GuildBan(...args);
58
- }
59
- static GuildEmoji(...args) {
59
+ },
60
+ GuildEmoji(...args) {
60
61
  return new structures_1.GuildEmoji(...args);
61
- }
62
- static GuildMember(...args) {
62
+ },
63
+ GuildMember(...args) {
63
64
  return new structures_1.GuildMember(...args);
64
- }
65
- static InteractionGuildMember(...args) {
65
+ },
66
+ InteractionGuildMember(...args) {
66
67
  return new structures_1.InteractionGuildMember(...args);
67
- }
68
- static GuildRole(...args) {
68
+ },
69
+ GuildRole(...args) {
69
70
  return new structures_1.GuildRole(...args);
70
- }
71
- static GuildTemplate(...args) {
71
+ },
72
+ GuildTemplate(...args) {
72
73
  return new structures_1.GuildTemplate(...args);
73
- }
74
- static Message(...args) {
74
+ },
75
+ Message(...args) {
75
76
  return new structures_1.Message(...args);
76
- }
77
- static WebhookMessage(...args) {
77
+ },
78
+ WebhookMessage(...args) {
78
79
  return new structures_1.WebhookMessage(...args);
79
- }
80
- static Poll(...args) {
80
+ },
81
+ Poll(...args) {
81
82
  return new structures_1.Poll(...args);
82
- }
83
- static Sticker(...args) {
83
+ },
84
+ Sticker(...args) {
84
85
  return new structures_1.Sticker(...args);
85
- }
86
- static User(...args) {
86
+ },
87
+ User(...args) {
87
88
  return new structures_1.User(...args);
88
- }
89
- static VoiceState(...args) {
89
+ },
90
+ VoiceState(...args) {
90
91
  return new structures_1.VoiceState(...args);
91
- }
92
- static Webhook(...args) {
92
+ },
93
+ Webhook(...args) {
93
94
  return new structures_1.Webhook(...args);
94
- }
95
- static OptionResolver(...args) {
95
+ },
96
+ OptionResolver(...args) {
96
97
  return new commands_1.OptionResolver(...args);
97
- }
98
- }
99
- exports.Transformers = Transformers;
98
+ },
99
+ Entitlement(...args) {
100
+ return new Entitlement_1.Entitlement(...args);
101
+ },
102
+ };
@@ -1,18 +1,19 @@
1
- import { type GatewayDispatchPayload } from '../types';
2
1
  import { type DeepPartial, type When } from '../common';
3
2
  import { EventHandler } from '../events';
3
+ import { type GatewayDispatchPayload } from '../types';
4
4
  import { Shard, type ShardManagerOptions, type WorkerData } from '../websocket';
5
- import type { WorkerShardInfo } from '../websocket/discord/worker';
5
+ import type { WorkerMessage, WorkerShardInfo } from '../websocket/discord/worker';
6
6
  import type { ManagerMessages } from '../websocket/discord/workermanager';
7
7
  import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
8
8
  import { BaseClient } from './base';
9
9
  import type { Client, ClientOptions } from './client';
10
- import { Collectors } from './collectors';
11
- import { type ClientUserStructure } from './transformers';
12
10
  import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
13
11
  import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
12
+ import { Collectors } from './collectors';
13
+ import { type ClientUserStructure } from './transformers';
14
14
  export declare class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
15
15
  private __handleGuilds?;
16
+ private __handleGuildsResharding?;
16
17
  memberUpdateHandler: MemberUpdateHandler;
17
18
  presenceUpdateHandler: PresenceUpdateHandler;
18
19
  collectors: Collectors;
@@ -23,25 +24,23 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
23
24
  timeout: NodeJS.Timeout;
24
25
  }>;
25
26
  shards: Map<number, Shard>;
27
+ resharding: Map<number, Shard>;
28
+ private _ready?;
26
29
  private __setServicesCache?;
27
30
  options: WorkerClientOptions;
28
31
  constructor(options?: WorkerClientOptions);
29
32
  get workerId(): number;
30
33
  get latency(): number;
31
- setServices({ ...rest }: ServicesOptions & {
32
- handlers?: ServicesOptions['handlers'] & {
33
- events?: EventHandler['callback'];
34
- };
35
- }): void;
34
+ setServices(rest: ServicesOptions): void;
36
35
  setWorkerData(data: WorkerData): void;
37
36
  get workerData(): WorkerData;
38
37
  start(options?: Omit<DeepPartial<StartOptions>, 'httpConnection' | 'token' | 'connection'>): Promise<void>;
39
38
  loadEvents(dir?: string): Promise<void>;
40
- postMessage(body: unknown): unknown;
39
+ postMessage(body: WorkerMessage): unknown;
41
40
  handleManagerMessages(data: ManagerMessages): Promise<any>;
42
41
  private generateNonce;
43
42
  private generateSendPromise;
44
- tellWorker(workerId: number, func: (_: this) => {}): Promise<unknown>;
43
+ tellWorker(workerId: number, func: (_: this) => any): Promise<unknown>;
45
44
  protected onPacket(packet: GatewayDispatchPayload, shardId: number): Promise<void>;
46
45
  }
47
46
  export declare function generateShardInfo(shard: Shard): WorkerShardInfo;