@fluxerjs/core 2.0.1 → 2.0.3

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.
@@ -1,4 +1,4 @@
1
- export { a2 as Message, a8 as MessageEditOptions, af as MessageSendOptions, ar as PartialMessage, aB as ReplyOptions } from './subpath-message-Acbzr5HA.mjs';
1
+ export { a2 as Message, a8 as MessageEditOptions, af as MessageSendOptions, ar as PartialMessage, aB as ReplyOptions } from './subpath-message-CWiBEUUV.mjs';
2
2
  import '@fluxerjs/collection';
3
3
  import '@fluxerjs/types';
4
4
  import 'events';
package/dist/message.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { a2 as Message, a8 as MessageEditOptions, af as MessageSendOptions, ar as PartialMessage, aB as ReplyOptions } from './subpath-message-Acbzr5HA.js';
1
+ export { a2 as Message, a8 as MessageEditOptions, af as MessageSendOptions, ar as PartialMessage, aB as ReplyOptions } from './subpath-message-CWiBEUUV.js';
2
2
  import '@fluxerjs/collection';
3
3
  import '@fluxerjs/types';
4
4
  import 'events';
package/dist/message.js CHANGED
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(subpath_message_exports);
27
27
  // src/structures/message/Message.ts
28
28
  var import_collection2 = require("@fluxerjs/collection");
29
29
  var import_builders3 = require("@fluxerjs/builders");
30
- var import_types5 = require("@fluxerjs/types");
30
+ var import_types6 = require("@fluxerjs/types");
31
31
 
32
32
  // src/client/sdkOptions.ts
33
33
  function toMessageAttachmentEditWire(attachments) {
@@ -233,6 +233,68 @@ async function prepareMessagePostPayload(options, defaults) {
233
233
  var import_events = require("events");
234
234
  var import_collection = require("@fluxerjs/collection");
235
235
 
236
+ // src/structures/MessageReaction.ts
237
+ var import_types3 = require("@fluxerjs/types");
238
+ var import_rest = require("@fluxerjs/rest");
239
+
240
+ // src/structures/Base.ts
241
+ var Base = class {
242
+ };
243
+
244
+ // src/structures/MessageReaction.ts
245
+ var MessageReaction = class extends Base {
246
+ client;
247
+ messageId;
248
+ channelId;
249
+ guildId;
250
+ emoji;
251
+ /** Raw gateway payload for low-level access. */
252
+ _data;
253
+ constructor(client, data) {
254
+ super();
255
+ this.client = client;
256
+ this._data = data;
257
+ this.messageId = data.message_id;
258
+ this.channelId = data.channel_id;
259
+ this.guildId = data.guild_id ?? null;
260
+ this.emoji = {
261
+ name: data.emoji.name,
262
+ ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
263
+ ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
264
+ };
265
+ }
266
+ /** Emoji as a string: unicode or "name:id" for custom. */
267
+ get emojiIdentifier() {
268
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
269
+ }
270
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
271
+ get guild() {
272
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
273
+ }
274
+ /**
275
+ * Fetch the message this reaction belongs to.
276
+ * Use when you need to edit, delete, or otherwise interact with the message.
277
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
278
+ */
279
+ async fetchMessage() {
280
+ try {
281
+ const data = await this.client.rest.get(
282
+ import_types3.Routes.channelMessage(this.channelId, this.messageId)
283
+ );
284
+ return new Message(this.client, data);
285
+ } catch (err) {
286
+ if (err instanceof import_rest.RateLimitError) throw err;
287
+ if (err instanceof import_rest.FluxerAPIError && err.statusCode === 404) {
288
+ throw new import_util2.FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
289
+ code: import_util.ErrorCodes.MessageNotFound,
290
+ cause: err
291
+ });
292
+ }
293
+ throw err instanceof import_util2.FluxerError ? err : new import_util2.FluxerError(String(err), { cause: err });
294
+ }
295
+ }
296
+ };
297
+
236
298
  // src/util/Events.ts
237
299
  var Events = {
238
300
  Ready: "ready",
@@ -246,6 +308,8 @@ var Events = {
246
308
  MessageReactionRemoveAll: "messageReactionRemoveAll",
247
309
  MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
248
310
  GuildCreate: "guildCreate",
311
+ GuildAvailable: "guildAvailable",
312
+ GuildUnavailable: "guildUnavailable",
249
313
  GuildUpdate: "guildUpdate",
250
314
  GuildDelete: "guildDelete",
251
315
  GuildBanAdd: "guildBanAdd",
@@ -294,7 +358,8 @@ var ReactionCollector = class extends import_events.EventEmitter {
294
358
  collected = new import_collection.Collection();
295
359
  _timeout = null;
296
360
  _ended = false;
297
- _listener;
361
+ _onAdd;
362
+ _onAddMany;
298
363
  constructor(client, messageId, channelId, options = {}) {
299
364
  super();
300
365
  this.client = client;
@@ -305,27 +370,58 @@ var ReactionCollector = class extends import_events.EventEmitter {
305
370
  time: options.time ?? 0,
306
371
  max: options.max ?? 0
307
372
  };
308
- this._listener = (payload) => {
373
+ this._onAdd = (payload) => {
309
374
  if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
310
375
  return;
311
376
  }
312
- if (!this.options.filter(payload.reaction, payload.user)) return;
313
- const key = `${payload.userId}:${payload.reaction.emoji.id ?? payload.reaction.emoji.name}`;
314
- this.collected.set(key, { reaction: payload.reaction, user: payload.user });
315
- this.emit("collect", payload.reaction, payload.user);
316
- if (this.options.max > 0 && this.collected.size >= this.options.max) {
317
- this.stop("limit");
377
+ this._collect(payload.reaction, payload.user, payload.userId);
378
+ };
379
+ this._onAddMany = (payload) => {
380
+ if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
381
+ return;
382
+ }
383
+ for (const entry of payload.reactions) {
384
+ if (this._ended) return;
385
+ const reaction = new MessageReaction(this.client, {
386
+ message_id: payload.messageId,
387
+ channel_id: payload.channelId,
388
+ guild_id: payload.guildId ?? void 0,
389
+ user_id: entry.userId,
390
+ emoji: {
391
+ name: entry.emoji.name,
392
+ ...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
393
+ ...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
394
+ }
395
+ });
396
+ const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
397
+ id: entry.userId,
398
+ username: "Unknown",
399
+ discriminator: "0"
400
+ });
401
+ this._collect(reaction, user, entry.userId);
318
402
  }
319
403
  };
320
- this.client.on(Events.MessageReactionAdd, this._listener);
404
+ this.client.on(Events.MessageReactionAdd, this._onAdd);
405
+ this.client.on(Events.MessageReactionAddMany, this._onAddMany);
321
406
  if (this.options.time > 0) {
322
407
  this._timeout = setTimeout(() => this.stop("time"), this.options.time);
323
408
  }
324
409
  }
410
+ _collect(reaction, user, userId) {
411
+ if (this._ended) return;
412
+ if (!this.options.filter(reaction, user)) return;
413
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
414
+ this.collected.set(key, { reaction, user });
415
+ this.emit("collect", reaction, user);
416
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
417
+ this.stop("limit");
418
+ }
419
+ }
325
420
  stop(reason = "user") {
326
421
  if (this._ended) return;
327
422
  this._ended = true;
328
- this.client.off(Events.MessageReactionAdd, this._listener);
423
+ this.client.off(Events.MessageReactionAdd, this._onAdd);
424
+ this.client.off(Events.MessageReactionAddMany, this._onAddMany);
329
425
  if (this._timeout) {
330
426
  clearTimeout(this._timeout);
331
427
  this._timeout = null;
@@ -340,30 +436,26 @@ var ReactionCollector = class extends import_events.EventEmitter {
340
436
  }
341
437
  };
342
438
 
343
- // src/structures/Base.ts
344
- var Base = class {
345
- };
346
-
347
439
  // src/structures/message/reactions.ts
348
- var import_types3 = require("@fluxerjs/types");
440
+ var import_types4 = require("@fluxerjs/types");
349
441
  async function emojiPath(message, emoji) {
350
442
  return message.client.resolveEmoji(emoji, message.guildId);
351
443
  }
352
444
  async function reactToMessage(message, emoji) {
353
445
  const e = await emojiPath(message, emoji);
354
- await message.client.rest.put(import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e));
446
+ await message.client.rest.put(import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e));
355
447
  }
356
448
  async function removeMessageReaction(message, emoji, userId) {
357
449
  const e = await emojiPath(message, emoji);
358
- const route = userId ? import_types3.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types3.Routes.channelMessageReactionMe(message.channelId, message.id, e);
450
+ const route = userId ? import_types4.Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : import_types4.Routes.channelMessageReactionMe(message.channelId, message.id, e);
359
451
  await message.client.rest.delete(route);
360
452
  }
361
453
  async function removeAllMessageReactions(message) {
362
- await message.client.rest.delete(import_types3.Routes.channelMessageReactions(message.channelId, message.id));
454
+ await message.client.rest.delete(import_types4.Routes.channelMessageReactions(message.channelId, message.id));
363
455
  }
364
456
  async function removeMessageReactionEmoji(message, emoji) {
365
457
  const e = await emojiPath(message, emoji);
366
- await message.client.rest.delete(import_types3.Routes.channelMessageReaction(message.channelId, message.id, e));
458
+ await message.client.rest.delete(import_types4.Routes.channelMessageReaction(message.channelId, message.id, e));
367
459
  }
368
460
  async function fetchMessageReactionUsers(message, emoji, options) {
369
461
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -374,7 +466,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
374
466
  if (options?.limit != null) params.set("limit", String(options.limit));
375
467
  if (options?.after) params.set("after", options.after);
376
468
  const qs = params.toString();
377
- const route = import_types3.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs ? `?${qs}` : "");
469
+ const route = import_types4.Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs ? `?${qs}` : "");
378
470
  const data = await message.client.rest.get(route);
379
471
  if (Array.isArray(data)) {
380
472
  return {
@@ -393,7 +485,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
393
485
 
394
486
  // src/structures/message/send.ts
395
487
  var import_builders2 = require("@fluxerjs/builders");
396
- var import_types4 = require("@fluxerjs/types");
488
+ var import_types5 = require("@fluxerjs/types");
397
489
  function toReplyTarget(ref) {
398
490
  return {
399
491
  channelId: ref.channel_id,
@@ -427,7 +519,7 @@ function asReplyTarget(value) {
427
519
  }
428
520
  async function sendPrepared(message, payload) {
429
521
  const data = await message.client.rest.post(
430
- import_types4.Routes.channelMessages(message.channelId),
522
+ import_types5.Routes.channelMessages(message.channelId),
431
523
  payload
432
524
  );
433
525
  message.client._addMessageToCache(message.channelId, data);
@@ -546,7 +638,7 @@ var Message = class _Message extends Base {
546
638
  this.pinned = data.pinned;
547
639
  this.attachments = new import_collection2.Collection();
548
640
  for (const a of data.attachments ?? []) this.attachments.set(a.id, a);
549
- this.type = data.type ?? import_types5.MessageType.Default;
641
+ this.type = data.type ?? import_types6.MessageType.Default;
550
642
  this.flags = data.flags ?? 0;
551
643
  this.mentionEveryone = data.mention_everyone ?? false;
552
644
  this.tts = data.tts ?? false;
@@ -604,7 +696,7 @@ var Message = class _Message extends Base {
604
696
  if (options.attachments !== void 0) {
605
697
  body.attachments = toMessageAttachmentEditWire(options.attachments);
606
698
  }
607
- const data = await this.client.rest.patch(import_types5.Routes.channelMessage(this.channelId, this.id), {
699
+ const data = await this.client.rest.patch(import_types6.Routes.channelMessage(this.channelId, this.id), {
608
700
  body
609
701
  });
610
702
  const updated = new _Message(this.client, data);
@@ -621,25 +713,25 @@ var Message = class _Message extends Base {
621
713
  }
622
714
  /** Delete this message. */
623
715
  async delete() {
624
- await this.client.rest.delete(import_types5.Routes.channelMessage(this.channelId, this.id));
716
+ await this.client.rest.delete(import_types6.Routes.channelMessage(this.channelId, this.id));
625
717
  this.client._removeMessageFromCache(this.channelId, this.id);
626
718
  }
627
719
  /** Delete a specific attachment from this message. */
628
720
  async deleteAttachment(attachmentId) {
629
721
  await this.client.rest.delete(
630
- import_types5.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
722
+ import_types6.Routes.channelMessageAttachment(this.channelId, this.id, attachmentId),
631
723
  { auth: true }
632
724
  );
633
725
  this.attachments.delete(attachmentId);
634
726
  }
635
727
  /** Pin this message in the channel. */
636
728
  async pin() {
637
- await this.client.rest.put(import_types5.Routes.channelPinMessage(this.channelId, this.id));
729
+ await this.client.rest.put(import_types6.Routes.channelPinMessage(this.channelId, this.id));
638
730
  this.pinned = true;
639
731
  }
640
732
  /** Unpin this message from the channel. */
641
733
  async unpin() {
642
- await this.client.rest.delete(import_types5.Routes.channelPinMessage(this.channelId, this.id));
734
+ await this.client.rest.delete(import_types6.Routes.channelPinMessage(this.channelId, this.id));
643
735
  this.pinned = false;
644
736
  }
645
737
  /** React to this message with an emoji. */
package/dist/message.mjs CHANGED
@@ -3,7 +3,7 @@ import { Collection as Collection2 } from "@fluxerjs/collection";
3
3
  import { EmbedBuilder as EmbedBuilder2 } from "@fluxerjs/builders";
4
4
  import {
5
5
  MessageType,
6
- Routes as Routes3
6
+ Routes as Routes4
7
7
  } from "@fluxerjs/types";
8
8
 
9
9
  // src/client/sdkOptions.ts
@@ -210,6 +210,68 @@ async function prepareMessagePostPayload(options, defaults) {
210
210
  import { EventEmitter } from "events";
211
211
  import { Collection } from "@fluxerjs/collection";
212
212
 
213
+ // src/structures/MessageReaction.ts
214
+ import { Routes } from "@fluxerjs/types";
215
+ import { FluxerAPIError, RateLimitError } from "@fluxerjs/rest";
216
+
217
+ // src/structures/Base.ts
218
+ var Base = class {
219
+ };
220
+
221
+ // src/structures/MessageReaction.ts
222
+ var MessageReaction = class extends Base {
223
+ client;
224
+ messageId;
225
+ channelId;
226
+ guildId;
227
+ emoji;
228
+ /** Raw gateway payload for low-level access. */
229
+ _data;
230
+ constructor(client, data) {
231
+ super();
232
+ this.client = client;
233
+ this._data = data;
234
+ this.messageId = data.message_id;
235
+ this.channelId = data.channel_id;
236
+ this.guildId = data.guild_id ?? null;
237
+ this.emoji = {
238
+ name: data.emoji.name,
239
+ ...data.emoji.id !== void 0 ? { id: data.emoji.id } : {},
240
+ ...data.emoji.animated !== void 0 ? { animated: data.emoji.animated } : {}
241
+ };
242
+ }
243
+ /** Emoji as a string: unicode or "name:id" for custom. */
244
+ get emojiIdentifier() {
245
+ return this.emoji.id ? `${this.emoji.name}:${this.emoji.id}` : this.emoji.name;
246
+ }
247
+ /** Guild where this reaction was added. Resolved from cache; null for DMs or if not cached. */
248
+ get guild() {
249
+ return this.guildId ? this.client.guilds.get(this.guildId) ?? null : null;
250
+ }
251
+ /**
252
+ * Fetch the message this reaction belongs to.
253
+ * Use when you need to edit, delete, or otherwise interact with the message.
254
+ * @throws FluxerError with MESSAGE_NOT_FOUND if the message does not exist
255
+ */
256
+ async fetchMessage() {
257
+ try {
258
+ const data = await this.client.rest.get(
259
+ Routes.channelMessage(this.channelId, this.messageId)
260
+ );
261
+ return new Message(this.client, data);
262
+ } catch (err) {
263
+ if (err instanceof RateLimitError) throw err;
264
+ if (err instanceof FluxerAPIError && err.statusCode === 404) {
265
+ throw new FluxerError(`Message ${this.messageId} not found in channel ${this.channelId}`, {
266
+ code: ErrorCodes.MessageNotFound,
267
+ cause: err
268
+ });
269
+ }
270
+ throw err instanceof FluxerError ? err : new FluxerError(String(err), { cause: err });
271
+ }
272
+ }
273
+ };
274
+
213
275
  // src/util/Events.ts
214
276
  var Events = {
215
277
  Ready: "ready",
@@ -223,6 +285,8 @@ var Events = {
223
285
  MessageReactionRemoveAll: "messageReactionRemoveAll",
224
286
  MessageReactionRemoveEmoji: "messageReactionRemoveEmoji",
225
287
  GuildCreate: "guildCreate",
288
+ GuildAvailable: "guildAvailable",
289
+ GuildUnavailable: "guildUnavailable",
226
290
  GuildUpdate: "guildUpdate",
227
291
  GuildDelete: "guildDelete",
228
292
  GuildBanAdd: "guildBanAdd",
@@ -271,7 +335,8 @@ var ReactionCollector = class extends EventEmitter {
271
335
  collected = new Collection();
272
336
  _timeout = null;
273
337
  _ended = false;
274
- _listener;
338
+ _onAdd;
339
+ _onAddMany;
275
340
  constructor(client, messageId, channelId, options = {}) {
276
341
  super();
277
342
  this.client = client;
@@ -282,27 +347,58 @@ var ReactionCollector = class extends EventEmitter {
282
347
  time: options.time ?? 0,
283
348
  max: options.max ?? 0
284
349
  };
285
- this._listener = (payload) => {
350
+ this._onAdd = (payload) => {
286
351
  if (this._ended || payload.reaction.messageId !== this.messageId || payload.channelId !== this.channelId) {
287
352
  return;
288
353
  }
289
- if (!this.options.filter(payload.reaction, payload.user)) return;
290
- const key = `${payload.userId}:${payload.reaction.emoji.id ?? payload.reaction.emoji.name}`;
291
- this.collected.set(key, { reaction: payload.reaction, user: payload.user });
292
- this.emit("collect", payload.reaction, payload.user);
293
- if (this.options.max > 0 && this.collected.size >= this.options.max) {
294
- this.stop("limit");
354
+ this._collect(payload.reaction, payload.user, payload.userId);
355
+ };
356
+ this._onAddMany = (payload) => {
357
+ if (this._ended || payload.messageId !== this.messageId || payload.channelId !== this.channelId) {
358
+ return;
359
+ }
360
+ for (const entry of payload.reactions) {
361
+ if (this._ended) return;
362
+ const reaction = new MessageReaction(this.client, {
363
+ message_id: payload.messageId,
364
+ channel_id: payload.channelId,
365
+ guild_id: payload.guildId ?? void 0,
366
+ user_id: entry.userId,
367
+ emoji: {
368
+ name: entry.emoji.name,
369
+ ...entry.emoji.id !== void 0 ? { id: entry.emoji.id } : {},
370
+ ...entry.emoji.animated !== void 0 ? { animated: entry.emoji.animated } : {}
371
+ }
372
+ });
373
+ const user = entry.member?.user ?? this.client.users.get(entry.userId) ?? this.client.getOrCreateUser({
374
+ id: entry.userId,
375
+ username: "Unknown",
376
+ discriminator: "0"
377
+ });
378
+ this._collect(reaction, user, entry.userId);
295
379
  }
296
380
  };
297
- this.client.on(Events.MessageReactionAdd, this._listener);
381
+ this.client.on(Events.MessageReactionAdd, this._onAdd);
382
+ this.client.on(Events.MessageReactionAddMany, this._onAddMany);
298
383
  if (this.options.time > 0) {
299
384
  this._timeout = setTimeout(() => this.stop("time"), this.options.time);
300
385
  }
301
386
  }
387
+ _collect(reaction, user, userId) {
388
+ if (this._ended) return;
389
+ if (!this.options.filter(reaction, user)) return;
390
+ const key = `${userId}:${reaction.emoji.id ?? reaction.emoji.name}`;
391
+ this.collected.set(key, { reaction, user });
392
+ this.emit("collect", reaction, user);
393
+ if (this.options.max > 0 && this.collected.size >= this.options.max) {
394
+ this.stop("limit");
395
+ }
396
+ }
302
397
  stop(reason = "user") {
303
398
  if (this._ended) return;
304
399
  this._ended = true;
305
- this.client.off(Events.MessageReactionAdd, this._listener);
400
+ this.client.off(Events.MessageReactionAdd, this._onAdd);
401
+ this.client.off(Events.MessageReactionAddMany, this._onAddMany);
306
402
  if (this._timeout) {
307
403
  clearTimeout(this._timeout);
308
404
  this._timeout = null;
@@ -317,30 +413,26 @@ var ReactionCollector = class extends EventEmitter {
317
413
  }
318
414
  };
319
415
 
320
- // src/structures/Base.ts
321
- var Base = class {
322
- };
323
-
324
416
  // src/structures/message/reactions.ts
325
- import { Routes } from "@fluxerjs/types";
417
+ import { Routes as Routes2 } from "@fluxerjs/types";
326
418
  async function emojiPath(message, emoji) {
327
419
  return message.client.resolveEmoji(emoji, message.guildId);
328
420
  }
329
421
  async function reactToMessage(message, emoji) {
330
422
  const e = await emojiPath(message, emoji);
331
- await message.client.rest.put(Routes.channelMessageReactionMe(message.channelId, message.id, e));
423
+ await message.client.rest.put(Routes2.channelMessageReactionMe(message.channelId, message.id, e));
332
424
  }
333
425
  async function removeMessageReaction(message, emoji, userId) {
334
426
  const e = await emojiPath(message, emoji);
335
- const route = userId ? Routes.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes.channelMessageReactionMe(message.channelId, message.id, e);
427
+ const route = userId ? Routes2.channelMessageReactionUser(message.channelId, message.id, e, userId) : Routes2.channelMessageReactionMe(message.channelId, message.id, e);
336
428
  await message.client.rest.delete(route);
337
429
  }
338
430
  async function removeAllMessageReactions(message) {
339
- await message.client.rest.delete(Routes.channelMessageReactions(message.channelId, message.id));
431
+ await message.client.rest.delete(Routes2.channelMessageReactions(message.channelId, message.id));
340
432
  }
341
433
  async function removeMessageReactionEmoji(message, emoji) {
342
434
  const e = await emojiPath(message, emoji);
343
- await message.client.rest.delete(Routes.channelMessageReaction(message.channelId, message.id, e));
435
+ await message.client.rest.delete(Routes2.channelMessageReaction(message.channelId, message.id, e));
344
436
  }
345
437
  async function fetchMessageReactionUsers(message, emoji, options) {
346
438
  return (await fetchMessageReactionUsersPage(message, emoji, options)).users;
@@ -351,7 +443,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
351
443
  if (options?.limit != null) params.set("limit", String(options.limit));
352
444
  if (options?.after) params.set("after", options.after);
353
445
  const qs = params.toString();
354
- const route = Routes.channelMessageReactionUsers(message.channelId, message.id, e) + (qs ? `?${qs}` : "");
446
+ const route = Routes2.channelMessageReactionUsers(message.channelId, message.id, e) + (qs ? `?${qs}` : "");
355
447
  const data = await message.client.rest.get(route);
356
448
  if (Array.isArray(data)) {
357
449
  return {
@@ -370,7 +462,7 @@ async function fetchMessageReactionUsersPage(message, emoji, options) {
370
462
 
371
463
  // src/structures/message/send.ts
372
464
  import { MessagePayload as MessagePayloadBuilder } from "@fluxerjs/builders";
373
- import { Routes as Routes2 } from "@fluxerjs/types";
465
+ import { Routes as Routes3 } from "@fluxerjs/types";
374
466
  function toReplyTarget(ref) {
375
467
  return {
376
468
  channelId: ref.channel_id,
@@ -404,7 +496,7 @@ function asReplyTarget(value) {
404
496
  }
405
497
  async function sendPrepared(message, payload) {
406
498
  const data = await message.client.rest.post(
407
- Routes2.channelMessages(message.channelId),
499
+ Routes3.channelMessages(message.channelId),
408
500
  payload
409
501
  );
410
502
  message.client._addMessageToCache(message.channelId, data);
@@ -581,7 +673,7 @@ var Message = class _Message extends Base {
581
673
  if (options.attachments !== void 0) {
582
674
  body.attachments = toMessageAttachmentEditWire(options.attachments);
583
675
  }
584
- const data = await this.client.rest.patch(Routes3.channelMessage(this.channelId, this.id), {
676
+ const data = await this.client.rest.patch(Routes4.channelMessage(this.channelId, this.id), {
585
677
  body
586
678
  });
587
679
  const updated = new _Message(this.client, data);
@@ -598,25 +690,25 @@ var Message = class _Message extends Base {
598
690
  }
599
691
  /** Delete this message. */
600
692
  async delete() {
601
- await this.client.rest.delete(Routes3.channelMessage(this.channelId, this.id));
693
+ await this.client.rest.delete(Routes4.channelMessage(this.channelId, this.id));
602
694
  this.client._removeMessageFromCache(this.channelId, this.id);
603
695
  }
604
696
  /** Delete a specific attachment from this message. */
605
697
  async deleteAttachment(attachmentId) {
606
698
  await this.client.rest.delete(
607
- Routes3.channelMessageAttachment(this.channelId, this.id, attachmentId),
699
+ Routes4.channelMessageAttachment(this.channelId, this.id, attachmentId),
608
700
  { auth: true }
609
701
  );
610
702
  this.attachments.delete(attachmentId);
611
703
  }
612
704
  /** Pin this message in the channel. */
613
705
  async pin() {
614
- await this.client.rest.put(Routes3.channelPinMessage(this.channelId, this.id));
706
+ await this.client.rest.put(Routes4.channelPinMessage(this.channelId, this.id));
615
707
  this.pinned = true;
616
708
  }
617
709
  /** Unpin this message from the channel. */
618
710
  async unpin() {
619
- await this.client.rest.delete(Routes3.channelPinMessage(this.channelId, this.id));
711
+ await this.client.rest.delete(Routes4.channelPinMessage(this.channelId, this.id));
620
712
  this.pinned = false;
621
713
  }
622
714
  /** React to this message with an emoji. */
@@ -715,10 +715,10 @@ declare class User extends Base {
715
715
  createDM(): Promise<DMChannel>;
716
716
  /**
717
717
  * Send a DM to this user.
718
- * @param options - Message content or {@link MessageSendOptions}
718
+ * @param options - {@link MessagePrepareInput}
719
719
  * @returns Sent message
720
720
  */
721
- send(options: MessageSendOptions): Promise<Message>;
721
+ send(options: MessagePrepareInput): Promise<Message>;
722
722
  }
723
723
 
724
724
  /** Represents a ban in a guild. */
@@ -1002,6 +1002,8 @@ declare class Guild extends Base {
1002
1002
  readonly client: Client;
1003
1003
  /** Snowflake ID of this guild. */
1004
1004
  readonly id: string;
1005
+ /** Whether the guild is currently available through the gateway. */
1006
+ available: boolean;
1005
1007
  /** Guild name. */
1006
1008
  name: string;
1007
1009
  /** Icon hash (use {@link iconURL} to get full CDN URL). */
@@ -1593,6 +1595,10 @@ interface ReactionCollectorEvents {
1593
1595
  }
1594
1596
  /**
1595
1597
  * Collects reactions on a message. Use message.createReactionCollector().
1598
+ *
1599
+ * Listens to both {@link Events.MessageReactionAdd} and {@link Events.MessageReactionAddMany}
1600
+ * (gateway may batch rapid reactions into ADD_MANY instead of individual ADD events).
1601
+ *
1596
1602
  * @example
1597
1603
  * const collector = message.createReactionCollector({ filter: (r, u) => u.id === userId, time: 10000 });
1598
1604
  * collector.on('collect', (reaction, user) => console.log(user.username, 'reacted', reaction.emoji.name));
@@ -1606,8 +1612,10 @@ declare class ReactionCollector extends EventEmitter {
1606
1612
  readonly collected: Collection<string, CollectedReaction>;
1607
1613
  private _timeout;
1608
1614
  private _ended;
1609
- private _listener;
1615
+ private readonly _onAdd;
1616
+ private readonly _onAddMany;
1610
1617
  constructor(client: Client, messageId: string, channelId: string, options?: ReactionCollectorOptions);
1618
+ private _collect;
1611
1619
  stop(reason?: ReactionCollectorEndReason): void;
1612
1620
  on<K extends keyof ReactionCollectorEvents>(event: K, listener: (...args: ReactionCollectorEvents[K]) => void): this;
1613
1621
  emit<K extends keyof ReactionCollectorEvents>(event: K, ...args: ReactionCollectorEvents[K]): boolean;
@@ -2392,6 +2400,8 @@ declare const Events: {
2392
2400
  readonly MessageReactionRemoveAll: "messageReactionRemoveAll";
2393
2401
  readonly MessageReactionRemoveEmoji: "messageReactionRemoveEmoji";
2394
2402
  readonly GuildCreate: "guildCreate";
2403
+ readonly GuildAvailable: "guildAvailable";
2404
+ readonly GuildUnavailable: "guildUnavailable";
2395
2405
  readonly GuildUpdate: "guildUpdate";
2396
2406
  readonly GuildDelete: "guildDelete";
2397
2407
  readonly GuildBanAdd: "guildBanAdd";
@@ -2460,6 +2470,8 @@ interface ClientEvents {
2460
2470
  [Events.MessageReactionRemoveAll]: [payload: MessageReactionRemoveAllPayload];
2461
2471
  [Events.MessageReactionRemoveEmoji]: [payload: MessageReactionRemoveEmojiPayload];
2462
2472
  [Events.GuildCreate]: [guild: Guild];
2473
+ [Events.GuildAvailable]: [guild: Guild];
2474
+ [Events.GuildUnavailable]: [guild: Guild];
2463
2475
  [Events.GuildUpdate]: [oldGuild: Guild, newGuild: Guild];
2464
2476
  [Events.GuildDelete]: [guild: Guild];
2465
2477
  /** Emitted when any channel type is created. */
@@ -715,10 +715,10 @@ declare class User extends Base {
715
715
  createDM(): Promise<DMChannel>;
716
716
  /**
717
717
  * Send a DM to this user.
718
- * @param options - Message content or {@link MessageSendOptions}
718
+ * @param options - {@link MessagePrepareInput}
719
719
  * @returns Sent message
720
720
  */
721
- send(options: MessageSendOptions): Promise<Message>;
721
+ send(options: MessagePrepareInput): Promise<Message>;
722
722
  }
723
723
 
724
724
  /** Represents a ban in a guild. */
@@ -1002,6 +1002,8 @@ declare class Guild extends Base {
1002
1002
  readonly client: Client;
1003
1003
  /** Snowflake ID of this guild. */
1004
1004
  readonly id: string;
1005
+ /** Whether the guild is currently available through the gateway. */
1006
+ available: boolean;
1005
1007
  /** Guild name. */
1006
1008
  name: string;
1007
1009
  /** Icon hash (use {@link iconURL} to get full CDN URL). */
@@ -1593,6 +1595,10 @@ interface ReactionCollectorEvents {
1593
1595
  }
1594
1596
  /**
1595
1597
  * Collects reactions on a message. Use message.createReactionCollector().
1598
+ *
1599
+ * Listens to both {@link Events.MessageReactionAdd} and {@link Events.MessageReactionAddMany}
1600
+ * (gateway may batch rapid reactions into ADD_MANY instead of individual ADD events).
1601
+ *
1596
1602
  * @example
1597
1603
  * const collector = message.createReactionCollector({ filter: (r, u) => u.id === userId, time: 10000 });
1598
1604
  * collector.on('collect', (reaction, user) => console.log(user.username, 'reacted', reaction.emoji.name));
@@ -1606,8 +1612,10 @@ declare class ReactionCollector extends EventEmitter {
1606
1612
  readonly collected: Collection<string, CollectedReaction>;
1607
1613
  private _timeout;
1608
1614
  private _ended;
1609
- private _listener;
1615
+ private readonly _onAdd;
1616
+ private readonly _onAddMany;
1610
1617
  constructor(client: Client, messageId: string, channelId: string, options?: ReactionCollectorOptions);
1618
+ private _collect;
1611
1619
  stop(reason?: ReactionCollectorEndReason): void;
1612
1620
  on<K extends keyof ReactionCollectorEvents>(event: K, listener: (...args: ReactionCollectorEvents[K]) => void): this;
1613
1621
  emit<K extends keyof ReactionCollectorEvents>(event: K, ...args: ReactionCollectorEvents[K]): boolean;
@@ -2392,6 +2400,8 @@ declare const Events: {
2392
2400
  readonly MessageReactionRemoveAll: "messageReactionRemoveAll";
2393
2401
  readonly MessageReactionRemoveEmoji: "messageReactionRemoveEmoji";
2394
2402
  readonly GuildCreate: "guildCreate";
2403
+ readonly GuildAvailable: "guildAvailable";
2404
+ readonly GuildUnavailable: "guildUnavailable";
2395
2405
  readonly GuildUpdate: "guildUpdate";
2396
2406
  readonly GuildDelete: "guildDelete";
2397
2407
  readonly GuildBanAdd: "guildBanAdd";
@@ -2460,6 +2470,8 @@ interface ClientEvents {
2460
2470
  [Events.MessageReactionRemoveAll]: [payload: MessageReactionRemoveAllPayload];
2461
2471
  [Events.MessageReactionRemoveEmoji]: [payload: MessageReactionRemoveEmojiPayload];
2462
2472
  [Events.GuildCreate]: [guild: Guild];
2473
+ [Events.GuildAvailable]: [guild: Guild];
2474
+ [Events.GuildUnavailable]: [guild: Guild];
2463
2475
  [Events.GuildUpdate]: [oldGuild: Guild, newGuild: Guild];
2464
2476
  [Events.GuildDelete]: [guild: Guild];
2465
2477
  /** Emitted when any channel type is created. */