seyfert 2.1.1-dev-12247418720.0 → 2.1.1-dev-12309212345.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 (42) hide show
  1. package/lib/cache/index.d.ts +1 -1
  2. package/lib/cache/index.js +6 -4
  3. package/lib/client/base.d.ts +3 -4
  4. package/lib/client/base.js +6 -9
  5. package/lib/client/client.d.ts +1 -2
  6. package/lib/client/client.js +17 -36
  7. package/lib/client/workerclient.d.ts +1 -4
  8. package/lib/client/workerclient.js +32 -81
  9. package/lib/commands/applications/chatcontext.js +1 -1
  10. package/lib/commands/applications/entrycontext.d.ts +1 -1
  11. package/lib/commands/applications/menucontext.d.ts +1 -1
  12. package/lib/commands/handle.js +5 -5
  13. package/lib/common/it/utils.d.ts +1 -0
  14. package/lib/common/it/utils.js +6 -0
  15. package/lib/common/shorters/bans.js +2 -2
  16. package/lib/common/shorters/guilds.d.ts +2 -2
  17. package/lib/common/shorters/interaction.d.ts +2 -2
  18. package/lib/common/shorters/interaction.js +1 -1
  19. package/lib/common/shorters/members.js +1 -1
  20. package/lib/common/shorters/messages.d.ts +1 -1
  21. package/lib/common/shorters/messages.js +7 -2
  22. package/lib/components/componentcontext.d.ts +1 -1
  23. package/lib/components/modalcontext.d.ts +1 -1
  24. package/lib/components/modalcontext.js +1 -1
  25. package/lib/events/handler.js +5 -5
  26. package/lib/events/hooks/custom.d.ts +5 -1
  27. package/lib/events/hooks/custom.js +14 -1
  28. package/lib/structures/Guild.d.ts +1 -2
  29. package/lib/structures/Interaction.d.ts +2 -2
  30. package/lib/structures/Interaction.js +1 -1
  31. package/lib/structures/Message.d.ts +1 -1
  32. package/lib/structures/Message.js +2 -2
  33. package/lib/structures/channels.d.ts +3 -3
  34. package/lib/structures/channels.js +1 -1
  35. package/lib/types/gateway.d.ts +12 -1
  36. package/lib/types/utils/index.d.ts +6 -5
  37. package/lib/types/utils/index.js +5 -4
  38. package/lib/websocket/discord/shard.d.ts +7 -5
  39. package/lib/websocket/discord/shard.js +60 -30
  40. package/lib/websocket/discord/sharder.d.ts +1 -1
  41. package/lib/websocket/discord/workermanager.js +3 -3
  42. package/package.json +1 -1
@@ -16,8 +16,8 @@ import { type GatewayDispatchPayload, GatewayIntentBits } from '../types';
16
16
  import { Messages } from './resources/messages';
17
17
  import { Overwrites } from './resources/overwrites';
18
18
  export { BaseResource } from './resources/default/base';
19
- export { GuildRelatedResource } from './resources/default/guild-related';
20
19
  export { GuildBasedResource } from './resources/default/guild-based';
20
+ export { GuildRelatedResource } from './resources/default/guild-related';
21
21
  export type InferAsyncCache = InternalOptions extends {
22
22
  asyncCache: infer P;
23
23
  } ? P : false;
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Cache = exports.GuildBasedResource = exports.GuildRelatedResource = exports.BaseResource = void 0;
17
+ exports.Cache = exports.GuildRelatedResource = exports.GuildBasedResource = exports.BaseResource = void 0;
18
18
  const common_1 = require("../common");
19
19
  const guilds_1 = require("./resources/guilds");
20
20
  const users_1 = require("./resources/users");
@@ -32,10 +32,10 @@ const messages_1 = require("./resources/messages");
32
32
  const overwrites_1 = require("./resources/overwrites");
33
33
  var base_1 = require("./resources/default/base");
34
34
  Object.defineProperty(exports, "BaseResource", { enumerable: true, get: function () { return base_1.BaseResource; } });
35
- var guild_related_1 = require("./resources/default/guild-related");
36
- Object.defineProperty(exports, "GuildRelatedResource", { enumerable: true, get: function () { return guild_related_1.GuildRelatedResource; } });
37
35
  var guild_based_1 = require("./resources/default/guild-based");
38
36
  Object.defineProperty(exports, "GuildBasedResource", { enumerable: true, get: function () { return guild_based_1.GuildBasedResource; } });
37
+ var guild_related_1 = require("./resources/default/guild-related");
38
+ Object.defineProperty(exports, "GuildRelatedResource", { enumerable: true, get: function () { return guild_related_1.GuildRelatedResource; } });
39
39
  __exportStar(require("./adapters/index"), exports);
40
40
  class Cache {
41
41
  intents;
@@ -117,7 +117,7 @@ class Cache {
117
117
  return this.hasIntent('DirectMessages');
118
118
  }
119
119
  get hasBansIntent() {
120
- return this.hasIntent('GuildBans');
120
+ return this.hasIntent('GuildModeration');
121
121
  }
122
122
  async bulkGet(keys) {
123
123
  const allData = {};
@@ -321,9 +321,11 @@ class Cache {
321
321
  break;
322
322
  case 'GUILD_CREATE':
323
323
  case 'GUILD_UPDATE':
324
+ case 'RAW_GUILD_CREATE':
324
325
  await this.guilds?.patch(event.d.id, { unavailable: false, ...event.d });
325
326
  break;
326
327
  case 'GUILD_DELETE':
328
+ case 'RAW_GUILD_DELETE':
327
329
  if (event.d.unavailable) {
328
330
  await this.guilds?.patch(event.d.id, event.d);
329
331
  }
@@ -37,14 +37,13 @@ export declare class BaseClient {
37
37
  soundboards: SoundboardShorter;
38
38
  debugger?: Logger;
39
39
  logger: Logger;
40
- langs?: LangsHandler | undefined;
41
- commands?: CommandHandler | undefined;
42
- components?: ComponentHandler | undefined;
40
+ langs: LangsHandler;
41
+ commands: CommandHandler;
42
+ components: ComponentHandler;
43
43
  handleCommand: HandleCommand;
44
44
  private _applicationId?;
45
45
  private _botId?;
46
46
  middlewares?: Record<string, MiddlewareContext>;
47
- protected static assertString(value: unknown, message?: string): asserts value is string;
48
47
  protected static getBotIdFromToken(token: string): string;
49
48
  options: BaseClientOptions;
50
49
  constructor(options?: BaseClientOptions);
@@ -45,11 +45,6 @@ class BaseClient {
45
45
  _applicationId;
46
46
  _botId;
47
47
  middlewares;
48
- static assertString(value, message) {
49
- if (!(typeof value === 'string' && value !== '')) {
50
- throw new Error(message ?? 'Value is not a string');
51
- }
52
- }
53
48
  static getBotIdFromToken(token) {
54
49
  return Buffer.from(token.split('.')[0], 'base64').toString('ascii');
55
50
  }
@@ -191,7 +186,7 @@ class BaseClient {
191
186
  await this.loadComponents(options.componentsDir);
192
187
  const { token: tokenRC, debug } = await this.getRC();
193
188
  const token = options.token ?? tokenRC;
194
- BaseClient.assertString(token, 'token is not a string');
189
+ (0, common_1.assertString)(token, 'token is not a string');
195
190
  if (this.rest.options.token === 'INVALID')
196
191
  this.rest.options.token = token;
197
192
  this.rest.debug = debug;
@@ -248,14 +243,16 @@ class BaseClient {
248
243
  return should;
249
244
  }
250
245
  syncCachePath(cachePath) {
251
- return node_fs_1.promises.writeFile(cachePath, JSON.stringify(this.commands.values.filter(cmd => !('ignore' in cmd) || cmd.ignore !== shared_1.IgnoreCommand.Slash).map(x => x.toJSON())));
246
+ return node_fs_1.promises.writeFile(cachePath, JSON.stringify(this.commands.values
247
+ .filter(cmd => !('ignore' in cmd) || cmd.ignore !== shared_1.IgnoreCommand.Slash)
248
+ .map(x => x.toJSON())));
252
249
  }
253
250
  async uploadCommands({ applicationId, cachePath } = {}) {
254
251
  applicationId ??= await this.getRC().then(x => x.applicationId ?? this.applicationId);
255
- BaseClient.assertString(applicationId, 'applicationId is not a string');
252
+ (0, common_1.assertString)(applicationId, 'applicationId is not a string');
256
253
  const commands = this.commands.values;
257
254
  const filter = (0, common_1.filterSplit)(commands, command => ('guildId' in command ? !command.guildId : true));
258
- if (this.commands?.entryPoint) {
255
+ if (this.commands.entryPoint) {
259
256
  filter.expect.push(this.commands.entryPoint);
260
257
  }
261
258
  if (!cachePath || (await this.shouldUploadCommands(cachePath)))
@@ -10,7 +10,6 @@ import { BaseClient } from './base';
10
10
  import { Collectors } from './collectors';
11
11
  import { type ClientUserStructure, type MessageStructure } from './transformers';
12
12
  export declare class Client<Ready extends boolean = boolean> extends BaseClient {
13
- private __handleGuilds?;
14
13
  gateway: ShardManager;
15
14
  me: If<Ready, ClientUserStructure>;
16
15
  options: Omit<ClientOptions, 'commands'> & {
@@ -19,7 +18,7 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
19
18
  memberUpdateHandler: MemberUpdateHandler;
20
19
  presenceUpdateHandler: PresenceUpdateHandler;
21
20
  collectors: Collectors;
22
- events?: EventHandler | undefined;
21
+ events: EventHandler;
23
22
  constructor(options?: ClientOptions);
24
23
  setServices({ gateway, ...rest }: ServicesOptions & {
25
24
  gateway?: ShardManager;
@@ -11,7 +11,6 @@ const collectors_1 = require("./collectors");
11
11
  const transformers_1 = require("./transformers");
12
12
  let parentPort;
13
13
  class Client extends base_1.BaseClient {
14
- __handleGuilds;
15
14
  gateway;
16
15
  me;
17
16
  memberUpdateHandler = new memberUpdate_1.MemberUpdateHandler();
@@ -35,7 +34,7 @@ class Client extends base_1.BaseClient {
35
34
  }
36
35
  async loadEvents(dir) {
37
36
  dir ??= await this.getRC().then(x => ('events' in x.locations ? x.locations.events : undefined));
38
- if (dir && this.events) {
37
+ if (dir) {
39
38
  await this.events.load(dir);
40
39
  this.logger.info('EventHandler loaded');
41
40
  }
@@ -70,7 +69,7 @@ class Client extends base_1.BaseClient {
70
69
  const intents = options?.connection?.intents ?? intentsRC;
71
70
  this.cache.intents = intents;
72
71
  if (!this.gateway) {
73
- base_1.BaseClient.assertString(token, 'token is not a string');
72
+ (0, common_1.assertString)(token, 'token is not a string');
74
73
  this.gateway = new websocket_1.ShardManager({
75
74
  token,
76
75
  info: await this.proxy.gateway.bot.get(),
@@ -105,7 +104,7 @@ class Client extends base_1.BaseClient {
105
104
  }
106
105
  async onPacket(shardId, packet) {
107
106
  Promise.allSettled([
108
- this.events?.runEvent('RAW', this, packet, shardId, false),
107
+ this.events.runEvent('RAW', this, packet, shardId, false),
109
108
  this.collectors.run('RAW', packet, this),
110
109
  ]); //ignore promise
111
110
  switch (packet.t) {
@@ -114,7 +113,7 @@ class Client extends base_1.BaseClient {
114
113
  if (!this.memberUpdateHandler.check(packet.d)) {
115
114
  return;
116
115
  }
117
- await this.events?.execute(packet, this, shardId);
116
+ await this.events.execute(packet, this, shardId);
118
117
  }
119
118
  break;
120
119
  case 'PRESENCE_UPDATE':
@@ -122,60 +121,42 @@ class Client extends base_1.BaseClient {
122
121
  if (!this.presenceUpdateHandler.check(packet.d)) {
123
122
  return;
124
123
  }
125
- await this.events?.execute(packet, this, shardId);
124
+ await this.events.execute(packet, this, shardId);
126
125
  }
127
126
  break;
128
- case 'GUILD_DELETE':
129
- case 'GUILD_CREATE': {
130
- if (this.__handleGuilds?.includes(packet.d.id)) {
131
- this.__handleGuilds?.splice(this.__handleGuilds.indexOf(packet.d.id), 1);
132
- if (!this.__handleGuilds?.length && [...this.gateway.values()].every(shard => shard.data.session_id)) {
133
- delete this.__handleGuilds;
134
- await this.cache.onPacket(packet);
135
- return this.events?.runEvent('BOT_READY', this, this.me, -1);
136
- }
137
- if (!this.__handleGuilds?.length)
138
- delete this.__handleGuilds;
139
- return this.cache.onPacket(packet);
140
- }
141
- await this.events?.execute(packet, this, shardId);
142
- break;
143
- }
144
127
  //rest of the events
145
128
  default: {
146
129
  switch (packet.t) {
147
130
  case 'INTERACTION_CREATE':
148
131
  {
149
- await this.events?.execute(packet, this, shardId);
132
+ await this.events.execute(packet, this, shardId);
150
133
  await this.handleCommand.interaction(packet.d, shardId);
151
134
  }
152
135
  break;
153
136
  case 'MESSAGE_CREATE':
154
137
  {
155
- await this.events?.execute(packet, this, shardId);
138
+ await this.events.execute(packet, this, shardId);
156
139
  await this.handleCommand.message(packet.d, shardId);
157
140
  }
158
141
  break;
159
142
  case 'READY': {
160
- const ids = packet.d.guilds.map(x => x.id);
161
- if ((0, common_1.hasIntent)(this.gateway.options.intents, 'Guilds')) {
162
- this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
163
- }
164
143
  this.botId = packet.d.user.id;
165
144
  this.applicationId = packet.d.application.id;
166
145
  this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
167
- if (!this.__handleGuilds?.length) {
168
- if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
169
- await this.events?.runEvent('BOT_READY', this, this.me, -1);
170
- }
171
- delete this.__handleGuilds;
172
- }
173
146
  this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
174
- await this.events?.execute(packet, this, shardId);
147
+ await this.events.execute(packet, this, shardId);
175
148
  break;
176
149
  }
150
+ case 'GUILDS_READY':
151
+ {
152
+ await this.events.execute(packet, this, shardId);
153
+ if ([...this.gateway.values()].every(shard => shard.isReady)) {
154
+ await this.events.runEvent('BOT_READY', this, this.me, -1);
155
+ }
156
+ }
157
+ break;
177
158
  default:
178
- await this.events?.execute(packet, this, shardId);
159
+ await this.events.execute(packet, this, shardId);
179
160
  break;
180
161
  }
181
162
  break;
@@ -13,12 +13,10 @@ import type { ShardData } from '../websocket/discord/shared';
13
13
  import { Collectors } from './collectors';
14
14
  import { type ClientUserStructure } from './transformers';
15
15
  export declare class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
16
- private __handleGuilds?;
17
- private __handleGuildsResharding?;
18
16
  memberUpdateHandler: MemberUpdateHandler;
19
17
  presenceUpdateHandler: PresenceUpdateHandler;
20
18
  collectors: Collectors;
21
- events?: EventHandler | undefined;
19
+ events: EventHandler;
22
20
  me: When<Ready, ClientUserStructure>;
23
21
  promises: Map<string, {
24
22
  resolve: (value: any) => void;
@@ -26,7 +24,6 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
26
24
  }>;
27
25
  shards: Map<number, Shard>;
28
26
  resharding: Map<number, Shard>;
29
- private _ready?;
30
27
  options: WorkerClientOptions;
31
28
  constructor(options?: WorkerClientOptions);
32
29
  get workerId(): number;
@@ -36,8 +36,6 @@ catch {
36
36
  //
37
37
  }
38
38
  class WorkerClient extends base_1.BaseClient {
39
- __handleGuilds;
40
- __handleGuildsResharding;
41
39
  memberUpdateHandler = new memberUpdate_1.MemberUpdateHandler();
42
40
  presenceUpdateHandler = new presenceUpdate_1.PresenceUpdateHandler();
43
41
  collectors = new collectors_1.Collectors();
@@ -46,7 +44,6 @@ class WorkerClient extends base_1.BaseClient {
46
44
  promises = new Map();
47
45
  shards = new Map();
48
46
  resharding = new Map();
49
- _ready;
50
47
  constructor(options) {
51
48
  super(options);
52
49
  if (options?.postMessage) {
@@ -111,15 +108,12 @@ class WorkerClient extends base_1.BaseClient {
111
108
  type: workerData.resharding ? 'WORKER_START_RESHARDING' : 'WORKER_START',
112
109
  workerId: workerData.workerId,
113
110
  });
114
- if (workerData.resharding) {
115
- this.__handleGuildsResharding = [];
116
- }
117
111
  await super.start(options);
118
112
  await this.loadEvents(options.eventsDir);
119
113
  }
120
114
  async loadEvents(dir) {
121
- dir ??= await this.getRC().then(x => ('events' in x.locations ? x.locations.events : undefined));
122
- if (dir && this.events) {
115
+ dir ??= await this.getRC().then(x => x.locations.events);
116
+ if (dir) {
123
117
  await this.events.load(dir);
124
118
  this.logger.info('EventHandler loaded');
125
119
  }
@@ -199,28 +193,10 @@ class WorkerClient extends base_1.BaseClient {
199
193
  ...this.options.gateway?.properties,
200
194
  },
201
195
  handlePayload(_, payload) {
202
- if (payload.t === 'GUILD_CREATE' || payload.t === 'GUILD_DELETE') {
203
- const indexOf = self.__handleGuildsResharding.indexOf(payload.d.id);
204
- if (indexOf !== -1) {
205
- self.__handleGuildsResharding.splice(indexOf, 1);
206
- if (!self.__handleGuildsResharding?.length && shardsConnected === workerData.shards.length) {
207
- delete self.__handleGuildsResharding;
208
- self.postMessage({
209
- type: 'WORKER_READY_RESHARDING',
210
- workerId: workerData.workerId,
211
- });
212
- }
213
- }
214
- }
215
- if (payload.t !== 'READY')
216
- return;
217
- shardsConnected++;
218
- const ids = payload.d.guilds.map(x => x.id);
219
- if ((0, common_1.hasIntent)(workerData.intents, 'Guilds')) {
220
- self.__handleGuildsResharding = self.__handleGuildsResharding?.concat(ids) ?? ids;
196
+ if (payload.t === 'READY') {
197
+ shardsConnected++;
221
198
  }
222
- if (shardsConnected === workerData.shards.length && !self.__handleGuildsResharding?.length) {
223
- delete self.__handleGuildsResharding;
199
+ else if (payload.t === 'GUILDS_READY' && shardsConnected === workerData.shards.length) {
224
200
  self.postMessage({
225
201
  type: 'WORKER_READY_RESHARDING',
226
202
  workerId: workerData.workerId,
@@ -281,7 +257,7 @@ class WorkerClient extends base_1.BaseClient {
281
257
  }
282
258
  break;
283
259
  case 'BOT_READY':
284
- await this.events?.runEvent('BOT_READY', this, this.me, -1);
260
+ await this.events.runEvent('BOT_READY', this, this.me, -1);
285
261
  break;
286
262
  case 'API_RESPONSE':
287
263
  {
@@ -326,7 +302,6 @@ class WorkerClient extends base_1.BaseClient {
326
302
  break;
327
303
  case 'WORKER_ALREADY_EXISTS_RESHARDING':
328
304
  {
329
- this.__handleGuildsResharding = [];
330
305
  this.postMessage({
331
306
  type: 'WORKER_START_RESHARDING',
332
307
  workerId: workerData.workerId,
@@ -440,7 +415,7 @@ class WorkerClient extends base_1.BaseClient {
440
415
  }
441
416
  async onPacket(packet, shardId) {
442
417
  Promise.allSettled([
443
- this.events?.runEvent('RAW', this, packet, shardId, false),
418
+ this.events.runEvent('RAW', this, packet, shardId, false),
444
419
  this.collectors.run('RAW', packet, this),
445
420
  ]); //ignore promise
446
421
  switch (packet.t) {
@@ -449,7 +424,7 @@ class WorkerClient extends base_1.BaseClient {
449
424
  if (!this.memberUpdateHandler.check(packet.d)) {
450
425
  return;
451
426
  }
452
- await this.events?.execute(packet, this, shardId);
427
+ await this.events.execute(packet, this, shardId);
453
428
  }
454
429
  break;
455
430
  case 'PRESENCE_UPDATE':
@@ -457,76 +432,52 @@ class WorkerClient extends base_1.BaseClient {
457
432
  if (!this.presenceUpdateHandler.check(packet.d)) {
458
433
  return;
459
434
  }
460
- await this.events?.execute(packet, this, shardId);
461
- }
462
- break;
463
- case 'GUILD_DELETE':
464
- case 'GUILD_CREATE': {
465
- if (this.__handleGuilds?.includes(packet.d.id)) {
466
- this.__handleGuilds?.splice(this.__handleGuilds.indexOf(packet.d.id), 1);
467
- if (!this.__handleGuilds?.length && [...this.shards.values()].every(shard => shard.data.session_id)) {
468
- delete this.__handleGuilds;
469
- await this.cache.onPacket(packet);
470
- this.postMessage({
471
- type: 'WORKER_READY',
472
- workerId: this.workerId,
473
- });
474
- return this.events?.runEvent('WORKER_READY', this, this.me, -1);
475
- }
476
- if (!this.__handleGuilds?.length)
477
- delete this.__handleGuilds;
478
- return this.cache.onPacket(packet);
435
+ await this.events.execute(packet, this, shardId);
479
436
  }
480
- await this.events?.execute(packet, this, shardId);
481
437
  break;
482
- }
483
438
  default: {
484
439
  switch (packet.t) {
485
440
  case 'INTERACTION_CREATE':
486
441
  {
487
- await this.events?.execute(packet, this, shardId);
442
+ await this.events.execute(packet, this, shardId);
488
443
  await this.handleCommand.interaction(packet.d, shardId);
489
444
  }
490
445
  break;
491
446
  case 'MESSAGE_CREATE':
492
447
  {
493
- await this.events?.execute(packet, this, shardId);
448
+ await this.events.execute(packet, this, shardId);
494
449
  await this.handleCommand.message(packet.d, shardId);
495
450
  }
496
451
  break;
497
- case 'READY':
452
+ case 'READY': {
453
+ this.botId = packet.d.user.id;
454
+ this.applicationId = packet.d.application.id;
455
+ this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
456
+ if ([...this.shards.values()].every(shard => shard.data.session_id)) {
457
+ this.postMessage({
458
+ type: 'WORKER_SHARDS_CONNECTED',
459
+ workerId: this.workerId,
460
+ });
461
+ await this.events.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1);
462
+ }
463
+ await this.events.execute(packet, this, shardId);
464
+ this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
465
+ break;
466
+ }
467
+ case 'GUILDS_READY':
498
468
  {
499
- const ids = packet.d.guilds.map(x => x.id);
500
- if ((0, common_1.hasIntent)(this.workerData.intents, 'Guilds')) {
501
- this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
502
- }
503
- this.botId = packet.d.user.id;
504
- this.applicationId = packet.d.application.id;
505
- this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
506
- await this.events?.execute(packet, this, shardId);
507
- if (!this._ready && [...this.shards.values()].every(shard => shard.data.session_id)) {
508
- this._ready = true;
469
+ if ([...this.shards.values()].every(shard => shard.isReady)) {
509
470
  this.postMessage({
510
- type: 'WORKER_SHARDS_CONNECTED',
471
+ type: 'WORKER_READY',
511
472
  workerId: this.workerId,
512
473
  });
513
- await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1);
514
- }
515
- if (!this.__handleGuilds?.length) {
516
- if ([...this.shards.values()].every(shard => shard.data.session_id)) {
517
- this.postMessage({
518
- type: 'WORKER_READY',
519
- workerId: this.workerId,
520
- });
521
- await this.events?.runEvent('WORKER_READY', this, this.me, -1);
522
- }
523
- delete this.__handleGuilds;
474
+ await this.events.runEvent('WORKER_READY', this, this.me, -1);
524
475
  }
525
- this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
476
+ await this.events.execute(packet, this, shardId);
526
477
  }
527
478
  break;
528
479
  default:
529
- await this.events?.execute(packet, this, shardId);
480
+ await this.events.execute(packet, this, shardId);
530
481
  break;
531
482
  }
532
483
  break;
@@ -32,7 +32,7 @@ class CommandContext extends basecontext_1.BaseContext {
32
32
  return this.client.proxy;
33
33
  }
34
34
  get t() {
35
- return this.client.t(this.interaction?.locale ?? this.client.langs?.defaultLang ?? 'en-US');
35
+ return this.client.t(this.interaction?.locale ?? this.client.langs.defaultLang ?? 'en-US');
36
36
  }
37
37
  get fullCommandName() {
38
38
  return this.resolver.fullCommandName;
@@ -24,7 +24,7 @@ export declare class EntryPointContext<M extends keyof RegisteredMiddlewares = n
24
24
  modal(body: ModalCreateBodyRequest): Promise<undefined>;
25
25
  deferReply<WR extends boolean = false>(ephemeral?: boolean, withResponse?: WR): Promise<import("../../common").When<WR, import("../..").WebhookMessage, undefined>>;
26
26
  editResponse(body: InteractionMessageUpdateBodyRequest): Promise<import("../..").WebhookMessage>;
27
- deleteResponse(): Promise<void | undefined>;
27
+ deleteResponse(): Promise<void>;
28
28
  editOrReply<WR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR): Promise<import("../../common").When<WR, import("../..").WebhookMessage, void>>;
29
29
  fetchResponse(): Promise<import("../..").WebhookMessage>;
30
30
  channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
@@ -25,7 +25,7 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
25
25
  modal(body: ModalCreateBodyRequest): Promise<undefined>;
26
26
  deferReply<WR extends boolean = false>(ephemeral?: boolean, withResponse?: WR): Promise<import("../../common").When<WR, import("../..").WebhookMessage, undefined>>;
27
27
  editResponse(body: InteractionMessageUpdateBodyRequest): Promise<import("../..").WebhookMessage>;
28
- deleteResponse(): Promise<void | undefined>;
28
+ deleteResponse(): Promise<void>;
29
29
  editOrReply<WR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR): Promise<import("../../common").When<WR, import("../..").WebhookMessage, void>>;
30
30
  fetchResponse(): Promise<import("../..").WebhookMessage>;
31
31
  channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
@@ -148,14 +148,14 @@ class HandleCommand {
148
148
  const context = new components_1.ModalContext(this.client, interaction);
149
149
  const extended = this.client.options?.context?.(interaction) ?? {};
150
150
  Object.assign(context, extended);
151
- await this.client.components?.executeModal(context);
151
+ await this.client.components.executeModal(context);
152
152
  }
153
153
  async messageComponent(interaction) {
154
154
  //@ts-expect-error
155
155
  const context = new components_1.ComponentContext(this.client, interaction);
156
156
  const extended = this.client.options?.context?.(interaction) ?? {};
157
157
  Object.assign(context, extended);
158
- await this.client.components?.executeComponent(context);
158
+ await this.client.components.executeComponent(context);
159
159
  }
160
160
  async interaction(body, shardId, __reply) {
161
161
  this.client.debugger?.debug(`[${types_1.InteractionType[body.type] ?? body.type}] Interaction received.`);
@@ -185,7 +185,7 @@ class HandleCommand {
185
185
  break;
186
186
  }
187
187
  case types_1.ApplicationCommandType.PrimaryEntryPoint: {
188
- const command = this.client.commands?.entryPoint;
188
+ const command = this.client.commands.entryPoint;
189
189
  if (!command?.run)
190
190
  return;
191
191
  const interaction = structures_1.BaseInteraction.from(this.client, body, __reply);
@@ -214,7 +214,7 @@ class HandleCommand {
214
214
  case types_1.InteractionType.ModalSubmit:
215
215
  {
216
216
  const interaction = structures_1.BaseInteraction.from(this.client, body, __reply);
217
- if (this.client.components?.hasModal(interaction)) {
217
+ if (this.client.components.hasModal(interaction)) {
218
218
  await this.client.components.onModalSubmit(interaction);
219
219
  }
220
220
  else
@@ -224,7 +224,7 @@ class HandleCommand {
224
224
  case types_1.InteractionType.MessageComponent:
225
225
  {
226
226
  const interaction = structures_1.BaseInteraction.from(this.client, body, __reply);
227
- if (this.client.components?.hasComponent(body.message.id, interaction.customId)) {
227
+ if (this.client.components.hasComponent(body.message.id, interaction.customId)) {
228
228
  await this.client.components.onComponent(body.message.id, interaction);
229
229
  }
230
230
  else
@@ -120,3 +120,4 @@ export declare function hasProps<T extends Record<any, any>>(target: T, props: T
120
120
  export declare function hasIntent(intents: number, target: keyof typeof GatewayIntentBits | GatewayIntentBits): boolean;
121
121
  export declare function toArrayBuffer(buffer: Buffer): ArrayBuffer;
122
122
  export declare function toBuffer(arrayBuffer: ArrayBuffer): Buffer<ArrayBuffer>;
123
+ export declare function assertString(value: unknown, message?: string): asserts value is string;
@@ -21,6 +21,7 @@ exports.hasProps = hasProps;
21
21
  exports.hasIntent = hasIntent;
22
22
  exports.toArrayBuffer = toArrayBuffer;
23
23
  exports.toBuffer = toBuffer;
24
+ exports.assertString = assertString;
24
25
  const node_fs_1 = require("node:fs");
25
26
  const node_path_1 = require("node:path");
26
27
  const __1 = require("..");
@@ -385,3 +386,8 @@ function toBuffer(arrayBuffer) {
385
386
  }
386
387
  return buffer;
387
388
  }
389
+ function assertString(value, message) {
390
+ if (!(typeof value === 'string' && value !== '')) {
391
+ throw new Error(message ?? 'Value is not a string');
392
+ }
393
+ }
@@ -13,7 +13,7 @@ class BanShorter extends base_1.BaseShorter {
13
13
  async bulkCreate(guildId, body, reason) {
14
14
  const bans = await this.client.proxy.guilds(guildId)['bulk-bans'].post({ reason, body });
15
15
  for (const id of bans.banned_users)
16
- this.client.cache.members?.removeIfNI('GuildBans', id, guildId);
16
+ this.client.cache.members?.removeIfNI('GuildModeration', id, guildId);
17
17
  return bans;
18
18
  }
19
19
  /**
@@ -34,7 +34,7 @@ class BanShorter extends base_1.BaseShorter {
34
34
  */
35
35
  async create(guildId, memberId, body, reason) {
36
36
  await this.client.proxy.guilds(guildId).bans(memberId).put({ reason, body });
37
- await this.client.cache.members?.removeIfNI('GuildBans', memberId, guildId);
37
+ await this.client.cache.members?.removeIfNI('GuildModeration', memberId, guildId);
38
38
  }
39
39
  /**
40
40
  * Fetches a ban from the guild.
@@ -1,5 +1,5 @@
1
1
  import { type GuildStructure } from '../../client/transformers';
2
- import { BaseChannel, type CreateStickerBodyRequest, Guild, GuildMember } from '../../structures';
2
+ import { type CreateStickerBodyRequest, Guild, GuildMember } from '../../structures';
3
3
  import type { GuildWidgetStyle, RESTGetAPICurrentUserGuildsQuery, RESTPatchAPIAutoModerationRuleJSONBody, RESTPatchAPIChannelJSONBody, RESTPatchAPIGuildChannelPositionsJSONBody, RESTPatchAPIGuildJSONBody, RESTPatchAPIGuildStickerJSONBody, RESTPostAPIAutoModerationRuleJSONBody, RESTPostAPIGuildChannelJSONBody, RESTPostAPIGuildsJSONBody } from '../../types';
4
4
  import { BaseShorter } from './base';
5
5
  export declare class GuildShorter extends BaseShorter {
@@ -46,7 +46,7 @@ export declare class GuildShorter extends BaseShorter {
46
46
  * @param force Whether to force fetching the channel from the API even if it exists in the cache.
47
47
  * @returns A Promise that resolves to the fetched channel.
48
48
  */
49
- fetch: (guildId: string, channelId: string, force?: boolean) => Promise<import("../../types").APIGuildCategoryChannel | import("../../types").APIGuildStageVoiceChannel | import("../../types").APIGuildVoiceChannel | import("../../types").APINewsChannel | import("../../types").APITextChannel | BaseChannel<import("../../types").ChannelType> | import("../../structures").DMChannel | import("../../structures").CategoryChannel>;
49
+ fetch: (guildId: string, channelId: string, force?: boolean) => Promise<import("../../structures").AllChannels>;
50
50
  /**
51
51
  * Creates a new channel in the guild.
52
52
  * @param guildId The ID of the guild.
@@ -7,7 +7,7 @@ export declare class InteractionShorter extends BaseShorter {
7
7
  fetchOriginal(token: string): Promise<import("../..").WebhookMessage>;
8
8
  editMessage(token: string, messageId: string, body: InteractionMessageUpdateBodyRequest): Promise<import("../..").WebhookMessage>;
9
9
  editOriginal(token: string, body: InteractionMessageUpdateBodyRequest): Promise<import("../..").WebhookMessage>;
10
- deleteResponse(token: string, messageId: string): Promise<void | undefined>;
11
- deleteOriginal(token: string): Promise<void | undefined>;
10
+ deleteResponse(token: string, messageId: string): Promise<void>;
11
+ deleteOriginal(token: string): Promise<void>;
12
12
  followup(token: string, { files, ...body }: MessageWebhookCreateBodyRequest): Promise<import("../..").WebhookMessage>;
13
13
  }
@@ -48,7 +48,7 @@ class InteractionShorter extends base_1.BaseShorter {
48
48
  .webhooks(this.client.applicationId)(token)
49
49
  .messages(messageId)
50
50
  .delete()
51
- .then(() => this.client.components?.deleteValue(messageId, 'messageDelete'));
51
+ .then(() => this.client.components.deleteValue(messageId, 'messageDelete'));
52
52
  }
53
53
  deleteOriginal(token) {
54
54
  return this.deleteResponse(token, '@original');
@@ -61,7 +61,7 @@ class MemberShorter extends base_1.BaseShorter {
61
61
  */
62
62
  async ban(guildId, memberId, body, reason) {
63
63
  await this.client.proxy.guilds(guildId).bans(memberId).put({ reason, body });
64
- await this.client.cache.members?.removeIfNI('GuildBans', memberId, guildId);
64
+ await this.client.cache.members?.removeIfNI('GuildModeration', memberId, guildId);
65
65
  }
66
66
  /**
67
67
  * Kicks a member from the guild.