@stoatx/client 0.2.2 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -18,6 +18,28 @@ declare class GatewayManager {
18
18
  disconnect(): void;
19
19
  }
20
20
 
21
+ type CDNTag = "attachments" | "avatars" | "backgrounds" | "icons" | "banners" | "emojis";
22
+ declare class AttachmentBuilder {
23
+ readonly filename: string | undefined;
24
+ readonly file: Buffer | Blob;
25
+ /**
26
+ * Creates a new AttachmentBuilder with the given file and optional filename.
27
+ * @param file The file data as a Buffer or Blob.
28
+ * @param filename An optional filename to use for the uploaded file. If not provided, the CDN will assign a default name.
29
+ * Providing a filename can help with organization and debugging, but is not strictly required.
30
+ * @example
31
+ * // Create an attachment from a Buffer with a custom filename
32
+ * const buffer = Buffer.from("Hello, world!");
33
+ * const attachment = new AttachmentBuilder(buffer, "greeting.txt");
34
+ */
35
+ constructor(file: Buffer | Blob, filename?: string);
36
+ /**
37
+ * Uploads this attachment to the Stoat CDN and returns the resulting file ID.
38
+ * @internal — use `resolveAttachment()` instead of calling this directly.
39
+ */
40
+ upload(rest: RESTManager, tag: CDNTag): Promise<string>;
41
+ }
42
+
21
43
  /**
22
44
  * Custom Error class for Stoat API failures
23
45
  */
@@ -46,12 +68,12 @@ declare class RESTManager {
46
68
  /**
47
69
  * Uploads a file to Stoat's CDN and returns the File ID
48
70
  */
49
- uploadFile(filename: string, fileBuffer: Buffer | Blob): Promise<string>;
71
+ uploadFile(tag: CDNTag, fileBuffer: Buffer | Blob, filename?: string): Promise<string>;
50
72
  get(endpoint: string): Promise<any>;
51
- post(endpoint: string, body: any): Promise<any>;
52
- patch(endpoint: string, body: any): Promise<any>;
53
- delete(endpoint: string): Promise<any>;
54
- put(endpoint: string, body: any): Promise<any>;
73
+ post(endpoint: string, body?: any): Promise<any>;
74
+ patch(endpoint: string, body?: any): Promise<any>;
75
+ delete(endpoint: string, body?: any): Promise<any>;
76
+ put(endpoint: string, body?: any): Promise<any>;
55
77
  }
56
78
 
57
79
  /**
@@ -343,16 +365,142 @@ declare class MemberManager extends BaseManager<string, Member> {
343
365
  * await server.members.unban("1234567890");
344
366
  */
345
367
  unban(member: MemberResolvable): Promise<void>;
368
+ [util.inspect.custom](): Collection<string, Member>;
369
+ }
370
+
371
+ type BitFieldResolvable = number | string | bigint | BitField | BitFieldResolvable[];
372
+ declare class BitField {
373
+ static Flags: Record<string, number | bigint>;
374
+ static DefaultBit: number | bigint;
375
+ bitfield: number | bigint;
376
+ constructor(bits?: BitFieldResolvable);
377
+ /**
378
+ * Checks whether this bitfield has any of the given bits set.
379
+ *
380
+ * @param bit The bit(s) to test against.
381
+ * @returns `true` if at least one of the provided bits is set.
382
+ *
383
+ * @example
384
+ * perms.any(['SendMessage', 'ManageChannel']); // true if either is set
385
+ */
386
+ any(bit: BitFieldResolvable): boolean;
346
387
  /**
347
- * Timeouts a member in the server for a specified duration.
348
- * @param member The MemberResolvable to timeout
349
- * @param duration The duration of the timeout in milliseconds
388
+ * Checks whether this bitfield is exactly equal to the given bit value.
389
+ *
390
+ * @param bit The bit(s) to compare against.
391
+ * @returns `true` if the resolved bit value is identical to this bitfield.
392
+ *
350
393
  * @example
351
- * // Timeout a member for 10 minutes
352
- * await server.members.setTimeout("1234567890", 10 * 60 * 1000);
394
+ * new Permissions(0n).equals(0n); // true
353
395
  */
354
- setTimeout(member: MemberResolvable, duration: number): Promise<void>;
355
- [util.inspect.custom](): Collection<string, Member>;
396
+ equals(bit: BitFieldResolvable): boolean;
397
+ /**
398
+ * Checks whether this bitfield has *all* of the given bits set.
399
+ *
400
+ * @param bit The bit(s) to check for.
401
+ * @returns `true` if every provided bit is set in this bitfield.
402
+ *
403
+ * @example
404
+ * perms.has('SendMessage');
405
+ * perms.has(['SendMessage', 'ViewChannel']); // true only if both are set
406
+ */
407
+ has(bit: BitFieldResolvable, ..._hasParams: any[]): boolean;
408
+ /**
409
+ * Returns the flag names present in `bits` that are *missing* from this bitfield.
410
+ *
411
+ * @param bits The bits to check against.
412
+ * @returns An array of flag name strings that are in `bits` but not in this bitfield.
413
+ *
414
+ * @example
415
+ * // If perms only has SendMessage:
416
+ * perms.missing(['SendMessage', 'ManageChannel']); // ['ManageChannel']
417
+ */
418
+ missing(bits: BitFieldResolvable, ...hasParams: any[]): string[];
419
+ /**
420
+ * Freezes this BitField instance, making it immutable.
421
+ * Subsequent calls to `add()` or `remove()` will return a new instance instead of mutating this one.
422
+ *
423
+ * @returns This instance, frozen.
424
+ */
425
+ freeze(): Readonly<this>;
426
+ /**
427
+ * Adds one or more bits to this bitfield.
428
+ * If the instance is frozen, returns a new BitField with the bits added.
429
+ *
430
+ * @param bits The bit(s) to add.
431
+ * @returns This instance (or a new one if frozen), with the bits added.
432
+ *
433
+ * @example
434
+ * perms.add('SendMessage', 'ViewChannel');
435
+ */
436
+ add(...bits: BitFieldResolvable[]): this;
437
+ /**
438
+ * Removes one or more bits from this bitfield.
439
+ * If the instance is frozen, returns a new BitField with the bits removed.
440
+ *
441
+ * @param bits The bit(s) to remove.
442
+ * @returns This instance (or a new one if frozen), with the bits cleared.
443
+ *
444
+ * @example
445
+ * perms.remove('ManageChannel');
446
+ */
447
+ remove(...bits: BitFieldResolvable[]): this;
448
+ /**
449
+ * Serializes this bitfield to a plain object mapping each flag name to a boolean
450
+ * indicating whether that flag is set.
451
+ *
452
+ * @returns A record of `{ [flagName]: boolean }` for all defined flags.
453
+ *
454
+ * @example
455
+ * perms.serialize();
456
+ * // { SendMessage: true, ManageChannel: false, ... }
457
+ */
458
+ serialize(...hasParams: any[]): Record<string, boolean>;
459
+ /**
460
+ * Returns an array of flag names that are set in this bitfield.
461
+ *
462
+ * @returns An array of string flag names.
463
+ *
464
+ * @example
465
+ * perms.toArray(); // ['SendMessage', 'ViewChannel']
466
+ */
467
+ toArray(...hasParams: any[]): string[];
468
+ /**
469
+ * Returns the bitfield value as a JSON-safe primitive.
470
+ * Numbers are returned as-is; bigints are converted to their string representation
471
+ * to avoid JSON serialization errors.
472
+ */
473
+ toJSON(): number | string;
474
+ /**
475
+ * Returns the underlying numeric value of this bitfield.
476
+ * Allows BitField instances to be used directly in arithmetic expressions.
477
+ */
478
+ valueOf(): number | bigint;
479
+ /**
480
+ * Iterates over the names of all flags that are set in this bitfield.
481
+ *
482
+ * @example
483
+ * for (const flag of perms) {
484
+ * console.log(flag); // 'SendMessage', 'ViewChannel', etc.
485
+ * }
486
+ */
487
+ [Symbol.iterator](...hasParams: any[]): IterableIterator<string>;
488
+ /**
489
+ * Resolves a {@link BitFieldResolvable} into a raw `number | bigint`.
490
+ *
491
+ * Resolution rules (in order):
492
+ * - `undefined` → `DefaultBit`
493
+ * - A number or bigint matching `DefaultBit`'s type and >= 0 → returned as-is
494
+ * - A `BitField` instance → its `.bitfield` value
495
+ * - An array → each element resolved and OR'd together
496
+ * - A numeric string → parsed as `BigInt` or `Number` depending on `DefaultBit`'s type
497
+ * - A named string flag → looked up in `Flags`
498
+ * - Anything else → throws `RangeError`
499
+ *
500
+ * @param bit The value to resolve.
501
+ * @throws {RangeError} If the value cannot be resolved to a valid bit.
502
+ */
503
+ static resolve(bit?: BitFieldResolvable): number | bigint;
356
504
  }
357
505
 
358
506
  declare const PermissionFlags: {
@@ -392,16 +540,16 @@ declare const PermissionFlags: {
392
540
  readonly GrantAllSafe: 4503599627370495n;
393
541
  };
394
542
  type PermissionString = keyof typeof PermissionFlags;
395
- type PermissionResolvable = bigint | PermissionString | PermissionResolvable[];
396
- declare class Permissions {
397
- /**
398
- * Converts a string, BigInt, or array of strings into a single BigInt
399
- */
400
- static resolve(permission: PermissionResolvable): bigint;
401
- /**
402
- * Checks if a specific permission bit exists
403
- */
404
- static has(totalPermissions: bigint, permissionToCheck: PermissionResolvable): boolean;
543
+ type PermissionResolvable = PermissionString | bigint | number | Permissions | PermissionResolvable[];
544
+ declare class Permissions extends BitField {
545
+ static Flags: Record<string, number | bigint>;
546
+ static DefaultBit: bigint;
547
+ static resolve(bit?: PermissionResolvable): bigint;
548
+ has(bit: PermissionResolvable): boolean;
549
+ any(bit: PermissionResolvable): boolean;
550
+ missing(bits: PermissionResolvable): PermissionString[];
551
+ add(...bits: PermissionResolvable[]): this;
552
+ remove(...bits: PermissionResolvable[]): this;
405
553
  }
406
554
 
407
555
  declare class DMChannel extends BaseChannel {
@@ -440,12 +588,215 @@ declare class GroupChannel extends BaseChannel {
440
588
  [util.inspect.custom](_depth: number, options: util.InspectOptions, inspect: typeof util.inspect): string;
441
589
  }
442
590
 
591
+ type UserResolvable = User | string;
592
+ interface UserEditOptions {
593
+ avatar?: string | null;
594
+ displayName?: string | null;
595
+ profile?: UserProfile;
596
+ status?: UserStatus;
597
+ }
598
+ declare class UserManager extends BaseManager<string, User> {
599
+ constructor(client: Client, limit?: number);
600
+ /**
601
+ * Tell BaseManager how to find the ID for Users
602
+ */
603
+ protected extractId(data: any): string;
604
+ /**
605
+ * Tell BaseManager how to build a User
606
+ */
607
+ protected construct(data: any): User;
608
+ /**
609
+ * Resolves a UserResolvable to a User object from the cache.
610
+ */
611
+ resolve(user: UserResolvable): User | undefined;
612
+ /**
613
+ * Extracts ID from a UserResolvable.
614
+ * @param user The UserResolvable to extract the ID from.
615
+ * @returns The extracted user ID.
616
+ * @throws TypeError if an invalid type is provided.
617
+ */
618
+ resolveId(user: UserResolvable): string;
619
+ /**
620
+ * Fetches a User.
621
+ * @param user The ID or mention to fetch
622
+ * @param force Skip the cache check and force an API request
623
+ * @returns The fetched User object
624
+ * @throws Error if the user cannot be found or fetched
625
+ * @throws TypeError if invalid UserResolvable is provided
626
+ * @example
627
+ * // Fetch a user by ID
628
+ * const user = await client.users.fetch("01JE2MM759J5D7CHJF084R7MJ2");
629
+ * console.log(user.username);
630
+ *
631
+ * // Fetch a user by mention
632
+ * const user = await client.users.fetch("<@01JE2MM759J5D7CHJF084R7MJ2>");
633
+ * console.log(user.username);
634
+ *
635
+ * // Force fetch a user, bypassing the cache
636
+ * const user = await client.users.fetch("01JE2MM759J5D7CHJF084R7MJ2", true);
637
+ * console.log(user.username);
638
+ */
639
+ fetch(user: UserResolvable, force?: boolean): Promise<User>;
640
+ /**
641
+ * Fetch the current user (the bot itself).
642
+ * @returns The fetched User object representing the current user.
643
+ * @throws Error if the user cannot be fetched.
644
+ * @example
645
+ * // Fetch the current user (the bot itself)
646
+ * const me = await client.users.fetchMe();
647
+ * console.log(`Logged in as ${me.tag}`);
648
+ */
649
+ fetchMe(): Promise<User>;
650
+ /**
651
+ * Edits the currently authenticated user (the bot itself).
652
+ * @param options The fields to update (avatar, status, profile, etc.).
653
+ * @returns A promise that resolves to the updated User object.
654
+ * @throws {TypeError} If invalid options are provided.
655
+ * @throws {Error} If the API request fails.
656
+ * @example
657
+ * // Update the bot's status and presence
658
+ * await client.users.editMe({
659
+ * status: { text: "Watching the server", presence: "Online" }
660
+ * });
661
+ *
662
+ * // Clear the bot's avatar and display name
663
+ * await client.users.editMe({ avatar: null, displayName: null });
664
+ */
665
+ editMe(options: UserEditOptions): Promise<User>;
666
+ /**
667
+ * The DM between the client's user and a user
668
+ *
669
+ * @param {string} userId The user id
670
+ * @returns {?DMChannel}
671
+ * @private
672
+ */
673
+ dmChannel(userId: string): DMChannel | null;
674
+ /**
675
+ * Creates a DM channel between the client's user and another user.
676
+ * @param user The UserResolvable to create a DM with.
677
+ * @param options Additional options for DM creation.
678
+ * @param options.force If true, forces the creation of a new DM channel even if one already exists.
679
+ * @returns A promise that resolves to the created DMChannel object.
680
+ * @throws {TypeError} If an invalid UserResolvable is provided.
681
+ * @throws {Error} If the API request fails.
682
+ * @example
683
+ * // Create a DM with a user by ID
684
+ * const dm = await client.users.createDM("1234567890");
685
+ * console.log(`DM channel ID: ${dm.id}`);
686
+ */
687
+ createDM(user: UserResolvable, { force }?: {
688
+ force?: boolean | undefined;
689
+ }): Promise<DMChannel>;
690
+ }
691
+
692
+ type MessageResolvable = Message | string;
693
+ interface MessageFetchOptions {
694
+ limit?: number;
695
+ before?: string;
696
+ after?: string;
697
+ sort?: "Relevance" | "Latest" | "Oldest";
698
+ nearby?: string;
699
+ includeUsers?: boolean;
700
+ }
701
+ declare class MessageManager extends BaseManager<string, Message> {
702
+ channel: BaseChannel;
703
+ constructor(client: Client, channel: BaseChannel, limit?: number);
704
+ /**
705
+ * Tell BaseManager how to find the ID for Messages
706
+ */
707
+ protected extractId(data: any): string;
708
+ /**
709
+ * Tell BaseManager how to build a Message
710
+ */
711
+ protected construct(data: any): Message;
712
+ fetch(id: string): Promise<Message>;
713
+ /**
714
+ * Fetches multiple messages from the channel using specific filter parameters.
715
+ * @param options The query parameters to filter the fetched messages.
716
+ * @returns A promise that resolves to a Collection of fetched Messages.
717
+ * @throws {Error} If the API request fails.
718
+ * @example
719
+ * // Fetch the last 50 messages in the channel
720
+ * const messages = await channel.messages.fetchMany({ limit: 50, sort: "Latest" });
721
+ *
722
+ * // Fetch 20 messages before a specific message ID
723
+ * const history = await channel.messages.fetchMany({ limit: 20, before: "01H..." });
724
+ */
725
+ fetchMany(options?: MessageFetchOptions): Promise<Collection<string, Message>>;
726
+ resolveId(message: MessageResolvable): string;
727
+ /**
728
+ * Sends a new message to this channel.
729
+ * @param contentOrOptions The string content or message options payload.
730
+ * @returns A promise that resolves to the sent Message.
731
+ */
732
+ send(contentOrOptions: MessageOptions | string): Promise<Message>;
733
+ /**
734
+ * Edits an existing message.
735
+ * @param message The MessageResolvable (object or ID) to edit.
736
+ * @param contentOrOptions The new content or options.
737
+ * @returns A promise that resolves to the updated Message.
738
+ */
739
+ edit(message: MessageResolvable, contentOrOptions: string | MessageOptions): Promise<Message>;
740
+ /**
741
+ * Deletes a message from the channel.
742
+ * @param message The MessageResolvable to delete.
743
+ */
744
+ delete(message: MessageResolvable): Promise<void>;
745
+ /**
746
+ * Pins a message in the channel.
747
+ * @param message The MessageResolvable to pin.
748
+ */
749
+ pin(message: MessageResolvable): Promise<void>;
750
+ /**
751
+ * Unpins a message in the channel.
752
+ * @param message The MessageResolvable to unpin.
753
+ */
754
+ unpin(message: MessageResolvable): Promise<void>;
755
+ /**
756
+ * React to a message
757
+ * @param message The MessageResolvable to react to.
758
+ * @param reaction The emoji to react with. Can be a Unicode emoji or a custom emoji ID.
759
+ * @throws {Error} If the API request fails.
760
+ * @example
761
+ * await channel.messages.react(messageId, "👍");
762
+ * await channel.messages.react(messageId, "customEmojiId");
763
+ */
764
+ react(message: MessageResolvable, reaction: string): Promise<void>;
765
+ /**
766
+ * Remove a reaction(s) from a message
767
+ * Requires ManageMessages if changing others' reactions.
768
+ * @param reaction The emoji to remove. Can be a unicode emoji or a custom emoji ID.
769
+ * @param message The MessageResolvable to remove the reaction from.
770
+ * @param userId The ID of the user whose reaction to remove. If not provided, removes the current user's reaction.
771
+ * @param removeAll Remove all reactions of this type.
772
+ * @throws {Error} If both userId and removeAll are provided, or if the API request fails.
773
+ * @example
774
+ * // Remove the current user's reaction
775
+ * await channel.messages.removeReaction(messageId, "👍");
776
+ * // Remove a specific user's reaction
777
+ * await channel.messages.removeReaction(messageId, "👍", userId);
778
+ * // Remove all reactions of this type
779
+ * await channel.messages.removeReaction(messageId, "👍", undefined, true);
780
+ */
781
+ removeReaction(message: MessageResolvable, reaction: string, userId?: UserResolvable, removeAll?: boolean): Promise<void>;
782
+ /**
783
+ * Remove all reactions from a message
784
+ * Requires ManageMessages permission.
785
+ * @param message The MessageResolvable to clear reactions from.
786
+ * @throws {Error} If the API request fails.
787
+ * @example
788
+ * await channel.messages.clearReactions(messageId);
789
+ */
790
+ clearReactions(message: MessageResolvable): Promise<void>;
791
+ [util.inspect.custom](): Collection<string, Message>;
792
+ }
793
+
443
794
  type ChannelResolvable = BaseChannel | string;
444
795
  interface ChannelEditOptions {
445
796
  name?: string;
446
797
  description?: string | null;
447
798
  owner?: string;
448
- icon?: string | null;
799
+ icon?: string | AttachmentBuilder | null;
449
800
  nsfw?: boolean;
450
801
  archived?: boolean;
451
802
  voice?: {
@@ -485,7 +836,7 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
485
836
  /**
486
837
  * Fetches a Channel from the API or resolves it from the local cache.
487
838
  * @param channel The ID, mention, or Channel object to fetch.
488
- * @param force Whether to skip the cache check and force a direct API request. Defaults to true.
839
+ * @param force Whether to skip the cache check and force a direct API request. Defaults to false.
489
840
  * @returns A promise that resolves to the fetched BaseChannel object.
490
841
  * @throws {TypeError} If an invalid ChannelResolvable is provided.
491
842
  * @throws {Error} If the API request fails.
@@ -540,6 +891,33 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
540
891
  * await client.channels.delete("01H...");
541
892
  */
542
893
  delete(channel: ChannelResolvable): Promise<void>;
894
+ /**
895
+ * Pin a message
896
+ * @param id Channel ID
897
+ * @param messageId Message ID
898
+ * @throws {Error} If the API request fails.
899
+ * @example
900
+ * await client.channels.pin("CHANNEL_ID", "MESSAGE_ID");
901
+ */
902
+ pin(id: string, messageId: string): Promise<void>;
903
+ /**
904
+ * Unpin a message
905
+ * @param id Channel ID
906
+ * @param messageId Message ID
907
+ * @throws {Error} If the API request fails
908
+ * @example
909
+ * await client.channels.unpin("CHANNEL_ID", "MESSAGE_ID");
910
+ */
911
+ unpin(id: string, messageId: string): Promise<void>;
912
+ /**
913
+ * Bulk delete up to 100 messages
914
+ * @param id Channel ID
915
+ * @param messages An array of MessageResolvable
916
+ * @throws {Error} If the API request fails
917
+ * @example
918
+ * await client.channels.bulkDelete("CHANNEL_ID", ["MESSAGE_ID_1", "MESSAGE_ID_2", "MESSAGE_ID_3"]);
919
+ */
920
+ bulkDelete(id: string, messages: MessageResolvable[]): Promise<void>;
543
921
  }
544
922
 
545
923
  declare class TextChannel extends BaseChannel {
@@ -580,72 +958,174 @@ declare class TextChannel extends BaseChannel {
580
958
  * await channel.setDefaultPermissions(["ViewChannel", "ReadMessageHistory"]);
581
959
  */
582
960
  setDefaultPermissions(permissions: PermissionResolvable): Promise<this>;
961
+ /**
962
+ * Edits the category of this channel. Only applicable to server channels.
963
+ * @param category The ID of the category to move this channel into, or "default" to remove from any category.
964
+ * @returns The updated TextChannel with the new category.
965
+ * @throws {Error} If the channel is not a server channel, if the category is not found in the server, or if the API request fails.
966
+ * @example
967
+ * // Move this channel into a category
968
+ * await channel.setCategory("CATEGORY_ID");
969
+ * // Remove this channel from its category
970
+ * await channel.setCategory("default");
971
+ */
972
+ setCategory(category: string): Promise<TextChannel>;
973
+ /**
974
+ * Sets the position of this channel within its current category.
975
+ * @param position The new index position for the channel within its category.
976
+ * @returns The updated TextChannel.
977
+ * @throws {Error} If the channel is not in a category, or if the API request fails.
978
+ * @example
979
+ * // Move channel to the top of its category
980
+ * await channel.setPosition(0);
981
+ */
982
+ setPosition(position: number): Promise<TextChannel>;
983
+ /**
984
+ * Edit the description of this channel
985
+ * @param description
986
+ * @throws {Error} If the API request fails
987
+ * @returns The updated TextChannel
988
+ * @example
989
+ * // Set the channel description
990
+ * await channel.setDescription("This is a channel about cats!");
991
+ * // Remove the channel description
992
+ * await channel.setDescription(null);
993
+ */
994
+ setDescription(description: string | null): Promise<TextChannel>;
995
+ /**
996
+ * Edit the name of this channel
997
+ * @param name
998
+ * @throws {Error} If the API request fails
999
+ * @returns The updated TextChannel
1000
+ * @example
1001
+ * await channel.setName("New Name");
1002
+ */
1003
+ setName(name: string): Promise<TextChannel>;
1004
+ /**
1005
+ * Set whether this channel is NSFW
1006
+ * @param nsfw
1007
+ * @throws {Error} If the API request fails
1008
+ * @returns The updated TextChannel
1009
+ * @example
1010
+ * // Mark the channel as NSFW
1011
+ * await channel.setNSFW(true);
1012
+ * // Mark the channel as SFW
1013
+ * await channel.setNSFW(false);
1014
+ */
1015
+ setNSFW(nsfw: boolean): Promise<TextChannel>;
1016
+ /**
1017
+ * Set the channel slowmode in seconds
1018
+ * @param slowmode
1019
+ * @throws {Error} If the API request fails
1020
+ * @returns The updated TextChannel
1021
+ * @example
1022
+ * // Set the slowmode to 5 seconds
1023
+ * await channel.setSlowmode(5);
1024
+ * // Remove slowmode
1025
+ * await channel.setSlowmode(0);
1026
+ */
1027
+ setSlowmode(slowmode: number): Promise<TextChannel>;
1028
+ /**
1029
+ * Set the channel Icon
1030
+ * @param id Autumn ID to use
1031
+ * @throws {Error} If the API request fails
1032
+ * @returns The updated TextChannel
1033
+ * @example
1034
+ * await channel.setIcon("123");
1035
+ * // Remove the channel icon
1036
+ * await channel.setIcon(null);
1037
+ */
1038
+ setIcon(id: string | null): Promise<TextChannel>;
583
1039
  }
584
-
585
- type MessageResolvable = Message | string;
586
- interface MessageFetchOptions {
587
- limit?: number;
588
- before?: string;
589
- after?: string;
590
- sort?: "Relevance" | "Latest" | "Oldest";
591
- nearby?: string;
592
- includeUsers?: boolean;
593
- }
594
- declare class MessageManager extends BaseManager<string, Message> {
595
- channel: BaseChannel;
596
- constructor(client: Client, channel: BaseChannel, limit?: number);
1040
+
1041
+ /**
1042
+ * Options to be passed to a Collector
1043
+ */
1044
+ interface CollectorOptions<V> {
1045
+ /** The filter applied to this collector */
1046
+ filter?: (item: V, ...args: any[]) => boolean;
1047
+ /** How long to run the collector for in milliseconds */
1048
+ time?: number;
1049
+ /** How long to stop the collector after inactivity in milliseconds */
1050
+ idle?: number;
1051
+ /** Whether to dispose data when it's deleted */
1052
+ dispose?: boolean;
1053
+ }
1054
+ /**
1055
+ * Abstract class for defining a new Collector
1056
+ */
1057
+ declare abstract class Collector<K, V> extends EventEmitter {
1058
+ readonly client: Client;
1059
+ filter: (item: V, ...args: any[]) => boolean;
1060
+ options: CollectorOptions<V>;
1061
+ collected: Collection<K, V>;
1062
+ ended: boolean;
1063
+ private _timeout;
1064
+ private _idletimeout;
1065
+ protected constructor(client: Client, options?: CollectorOptions<V>);
597
1066
  /**
598
- * Tell BaseManager how to find the ID for Messages
1067
+ * Evaluates an item and possibly passes it to the collector
599
1068
  */
600
- protected extractId(data: any): string;
1069
+ handleCollect(item: V, ...args: any[]): void;
601
1070
  /**
602
- * Tell BaseManager how to build a Message
1071
+ * Evaluates an item and possibly removes it from the collector
603
1072
  */
604
- protected construct(data: any): Message;
605
- fetch(id: string): Promise<Message>;
1073
+ handleDispose(item: V, ...args: any[]): void;
606
1074
  /**
607
- * Fetches multiple messages from the channel using specific filter parameters.
608
- * @param options The query parameters to filter the fetched messages.
609
- * @returns A promise that resolves to a Collection of fetched Messages.
610
- * @throws {Error} If the API request fails.
611
- * @example
612
- * // Fetch the last 50 messages in the channel
613
- * const messages = await channel.messages.fetchMany({ limit: 50, sort: "Latest" });
614
- *
615
- * // Fetch 20 messages before a specific message ID
616
- * const history = await channel.messages.fetchMany({ limit: 20, before: "01H..." });
1075
+ * Stops the collector.
617
1076
  */
618
- fetchMany(options?: MessageFetchOptions): Promise<Collection<string, Message>>;
619
- resolveId(message: MessageResolvable): string;
1077
+ stop(reason?: string): void;
620
1078
  /**
621
- * Sends a new message to this channel.
622
- * @param contentOrOptions The string content or message options payload.
623
- * @returns A promise that resolves to the sent Message.
1079
+ * Check if we should end upon collecting/disposing
624
1080
  */
625
- send(contentOrOptions: MessageOptions | string): Promise<Message>;
1081
+ checkEnd(): void;
626
1082
  /**
627
- * Edits an existing message.
628
- * @param message The MessageResolvable (object or ID) to edit.
629
- * @param contentOrOptions The new content or options.
630
- * @returns A promise that resolves to the updated Message.
1083
+ * Check if there's a reason to end
631
1084
  */
632
- edit(message: MessageResolvable, contentOrOptions: string | MessageOptions): Promise<Message>;
1085
+ endReason(): string | null;
633
1086
  /**
634
- * Deletes a message from the channel.
635
- * @param message The MessageResolvable to delete.
1087
+ * Returns a key if the item should be collected, or null to skip
636
1088
  */
637
- delete(message: MessageResolvable): Promise<void>;
1089
+ abstract collect(item: V, ...args: any[]): K | null;
638
1090
  /**
639
- * Pins a message in the channel.
640
- * @param message The MessageResolvable to pin.
1091
+ * Returns a key if the item should be disposed, or null to skip
641
1092
  */
642
- pin(message: MessageResolvable): Promise<void>;
1093
+ abstract dispose(item: V, ...args: any[]): K | null;
643
1094
  /**
644
- * Unpins a message in the channel.
645
- * @param message The MessageResolvable to unpin.
1095
+ * Allows iterating over collected items asynchronously.
1096
+ * @example
1097
+ * for await (const [id, message] of collector) {
1098
+ * console.log(`Received message: ${message.content}`);
1099
+ * }
646
1100
  */
647
- unpin(message: MessageResolvable): Promise<void>;
648
- [util.inspect.custom](): Collection<string, Message>;
1101
+ [Symbol.asyncIterator](): AsyncIterableIterator<[K, V]>;
1102
+ }
1103
+
1104
+ /**
1105
+ * Options to be passed to a MessageCollector
1106
+ */
1107
+ interface MessageCollectorOptions extends CollectorOptions<Message> {
1108
+ /** The maximum number of messages to collect */
1109
+ max?: number;
1110
+ /** The maximum number of messages to process (both matching and non-matching the filter) */
1111
+ maxProcessed?: number;
1112
+ }
1113
+ /**
1114
+ * Collects messages on a channel.
1115
+ */
1116
+ declare class MessageCollector extends Collector<string, Message> {
1117
+ channel: BaseChannel;
1118
+ channelId: string;
1119
+ total: number;
1120
+ processed: number;
1121
+ constructor(channel: BaseChannel, options?: MessageCollectorOptions);
1122
+ collect(message: Message): string | null;
1123
+ dispose(message: Message | {
1124
+ id: string;
1125
+ channelId: string;
1126
+ }): string | null;
1127
+ handleCollect(message: Message): void;
1128
+ endReason(): string | null;
649
1129
  }
650
1130
 
651
1131
  declare enum ChannelType {
@@ -675,21 +1155,87 @@ declare abstract class BaseChannel extends Base {
675
1155
  * await channel.send({ content: "Here is an embed", embeds: [myEmbed] });
676
1156
  */
677
1157
  send(contentOrOptions: string | MessageOptions): Promise<Message>;
678
- fetch(force?: boolean): Promise<this>;
1158
+ /**
1159
+ * Fetch this channel
1160
+ * @param force Whether to skip the cache check and force a direct API request. Defaults to false
1161
+ * @throws {Error} If the API request fails
1162
+ * @returns {BaseChannel}
1163
+ * @example
1164
+ * // Force fetch channel to update its data
1165
+ * await channel.fetch(true);
1166
+ */
1167
+ fetch(force?: boolean): Promise<BaseChannel>;
679
1168
  /**
680
1169
  * Fetches multiple messages from this channel.
681
1170
  * @param options The query parameters to filter the messages.
1171
+ * @throws {Error} If the API request fails
1172
+ * @returns A Collection of Messages, keyed by their ID.
1173
+ * @example
1174
+ * // Fetch the last 50 messages in the channel
1175
+ * const messages = await channel.fetchMessages({ limit: 50 });
1176
+ * console.log(`Fetched ${messages.size} messages`);
1177
+ * // Fetch messages before a specific message ID
1178
+ * const messages = await channel.fetchMessages({ before: "MESSAGE_ID" });
1179
+ * console.log(`Fetched ${messages.size} messages sent before the specified message`);
1180
+ * // Fetch messages after a specific message ID
1181
+ * const messages = await channel.fetchMessages({ after: "MESSAGE_ID" });
1182
+ * console.log(`Fetched ${messages.size} messages sent after the specified message`);
1183
+ * // Fetch messages around a specific message ID
1184
+ * const messages = await channel.fetchMessages({ around: "MESSAGE_ID", limit: 10 });
1185
+ * console.log(`Fetched ${messages.size} messages sent around the specified message`);
682
1186
  */
683
1187
  fetchMessages(options?: MessageFetchOptions): Promise<Collection<string, Message>>;
684
1188
  /**
685
1189
  * Edits this channel.
686
1190
  * @param options The fields to update
1191
+ * @throws {Error} If the API request fails
1192
+ * @returns BaseChannel
1193
+ * @example
1194
+ * // Edit the channel's name
1195
+ * await channel.edit({name: "New Cool Name"});
687
1196
  */
688
- edit(options: ChannelEditOptions): Promise<this>;
1197
+ edit(options: ChannelEditOptions): Promise<BaseChannel>;
689
1198
  /**
690
1199
  * Deletes this channel.
1200
+ * @throws {Error} If the API request fails
1201
+ * @example
1202
+ * // Delete the channel
1203
+ * await channel.delete();
691
1204
  */
692
1205
  delete(): Promise<void>;
1206
+ /**
1207
+ * Bulk delete messages from this channel
1208
+ * @param messages MessageResolvable to delete
1209
+ * @throws {Error} If the API request fails
1210
+ * @example
1211
+ * // Delete messages by their ID's
1212
+ * await channel.bulkDelete(["MESSAGE_ID_1", "MESSAGE_ID_2", "MESSAGE_ID_3"]);
1213
+ * // Delete messages by their Message objects
1214
+ * await channel.bulkDelete([message1, message2, message3]);
1215
+ */
1216
+ bulkDelete(messages: MessageResolvable[]): Promise<void>;
1217
+ /**
1218
+ * Creates a MessageCollector to collect messages in this channel.
1219
+ * @param options The options for the collector.
1220
+ * @returns The instantiated MessageCollector
1221
+ * @example
1222
+ * const collector = channel.createMessageCollector({ filter: m => m.authorId === '123', time: 15000 });
1223
+ * collector.on('collect', m => console.log(`Collected ${m.content}`));
1224
+ * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
1225
+ */
1226
+ createMessageCollector(options?: MessageCollectorOptions): MessageCollector;
1227
+ /**
1228
+ * Awaits messages in this channel that meet certain criteria.
1229
+ * @param options The options for the collector.
1230
+ * @returns A promise that resolves to a collection of messages.
1231
+ * @example
1232
+ * // Await !vote messages
1233
+ * const filter = m => m.content.startsWith('!vote');
1234
+ * channel.awaitMessages({ filter, max: 4, time: 60000 })
1235
+ * .then(collected => console.log(collected.size))
1236
+ * .catch(console.error);
1237
+ */
1238
+ awaitMessages(options?: MessageCollectorOptions): Promise<Collection<string, Message>>;
693
1239
  isText(): this is TextChannel;
694
1240
  isDM(): this is DMChannel;
695
1241
  isGroup(): this is GroupChannel;
@@ -715,7 +1261,8 @@ declare class Role extends Base {
715
1261
  color: string | null;
716
1262
  hoist: boolean;
717
1263
  rank: number;
718
- permissions: bigint;
1264
+ icon: Attachment | null;
1265
+ private _permissions;
719
1266
  constructor(client: Client, data: any, serverId: string);
720
1267
  /**
721
1268
  * Updates the role instance with new data without losing the object reference.
@@ -728,11 +1275,9 @@ declare class Role extends Base {
728
1275
  */
729
1276
  get server(): Server | undefined;
730
1277
  /**
731
- * Checks whether this role has a specific permission.
732
- * @param permission The permission to check for.
733
- * @returns True if the role has the permission.
1278
+ * Permissions for this role
734
1279
  */
735
- hasPermission(permission: PermissionResolvable): boolean;
1280
+ get permissions(): Permissions;
736
1281
  /**
737
1282
  * Fetches this role directly from the API to ensure data is up to date.
738
1283
  * @param force Whether to skip the cache check and force a direct API request. Defaults to false.
@@ -744,7 +1289,7 @@ declare class Role extends Base {
744
1289
  * await role.fetch();
745
1290
  * console.log(`Role updated, current name: ${role.name}`);
746
1291
  */
747
- fetch(force?: boolean): Promise<this>;
1292
+ fetch(force?: boolean): Promise<Role>;
748
1293
  /**
749
1294
  * Edits the role with the given options. Only the fields provided in the options will be updated; all other fields will remain unchanged.
750
1295
  * @param options The fields to update.
@@ -753,12 +1298,12 @@ declare class Role extends Base {
753
1298
  * @throws {Error} If the API request fails (e.g., lack of permissions).
754
1299
  * @example
755
1300
  * // Change the role's name and color
756
- * await role.edit({ name: "Senior Admin", colour: "#FFD700" });
1301
+ * await role.edit({ name: "Senior Admin", color: "#FFD700" });
757
1302
  *
758
1303
  * // Remove the custom color from the role
759
- * await role.edit({ colour: null });
1304
+ * await role.edit({ color: null });
760
1305
  */
761
- edit(options: RoleEditOptions): Promise<this>;
1306
+ edit(options: RoleEditOptions): Promise<Role>;
762
1307
  /**
763
1308
  * Deletes this Role from the server.
764
1309
  * @throws {Error} If the role cannot be deleted (e.g., lack of permissions).
@@ -779,7 +1324,7 @@ declare class Role extends Base {
779
1324
  * allow: ["ManageChannel", "SendMessage"]
780
1325
  * });
781
1326
  */
782
- setPermissions(options: RolePermissionOptions): Promise<this>;
1327
+ setPermissions(options: RolePermissionOptions): Promise<Role>;
783
1328
  /**
784
1329
  * Updates the hierarchical position of this role.
785
1330
  * Automatically reconstructs the role array and performs a bulk update.
@@ -791,7 +1336,66 @@ declare class Role extends Base {
791
1336
  * await role.setPosition(2);
792
1337
  * console.log(`Role moved to rank: ${role.rank}`);
793
1338
  */
794
- setPosition(newPosition: number): Promise<this>;
1339
+ setPosition(newPosition: number): Promise<Role>;
1340
+ /**
1341
+ * Change the name for this role
1342
+ * @param name The new name for the role
1343
+ * @returns A promise that resolves to this updated Role object.
1344
+ * @throws {Error} If API request fails.
1345
+ * @example
1346
+ * // Change the role's name
1347
+ * await role.setName("New Role Name");
1348
+ * console.log(`Role's new name: ${role.name}`);
1349
+ */
1350
+ setName(name: string): Promise<Role>;
1351
+ /**
1352
+ * Change the color for this role, it can be a HEX or CSS colours
1353
+ * @param {[string]} color The new color for the role
1354
+ * @returns A promise that resolves to this updated Role object.
1355
+ * @throws {Error} If API request fails
1356
+ * @example
1357
+ * // Change the role's color
1358
+ * await role.setColour("#FF0000");
1359
+ * console.log(`Role's new color: ${role.color}`);
1360
+ *
1361
+ * // Use CSS color linear-graident
1362
+ * await role.setColour("linear-gradient(90deg, #FF0000, #0000FF)");
1363
+ * console.log(`Role's new color: ${role.color}`);
1364
+ *
1365
+ * // Remove the custom color from the role
1366
+ * await role.setColour(null);
1367
+ * console.log(`Role's color removed, current color: ${role.color}`);
1368
+ */
1369
+ setColor(color: string | null): Promise<Role>;
1370
+ /**
1371
+ * Edit the icon of this role
1372
+ * @param icon Autumn ID for the new icon, or null to remove the custom icon
1373
+ * @returns A promise that resolves to this updated Role object.
1374
+ * @throws {Error} If API request fails
1375
+ * @example
1376
+ * // Set a new icon for the role
1377
+ * await role.setIcon("AUTUMN_ID_FOR_ICON");
1378
+ * console.log(`Role's new icon: ${role.icon}`);
1379
+ *
1380
+ * // Use AttachmentBuilder to upload a new icon file
1381
+ * import { readFile } from "node:fs/promises";
1382
+ * const iconFile = await readFile("./a.jpg");
1383
+ * const attachment = new AttachmentBuilder(iconFile, "a.jpg");
1384
+ * await role.setIcon(attachment);
1385
+ * console.log(`Role's new icon: ${role.icon}`);
1386
+ */
1387
+ setIcon(icon: string | AttachmentBuilder | null): Promise<Role>;
1388
+ /**
1389
+ * Change the hoist status for this role
1390
+ * @param hoist The new hoist status for the role
1391
+ * @returns A promise that resolves to this updated Role object.
1392
+ * @throws {Error} If API request fails
1393
+ * @example
1394
+ * // Enable hoisting for the role
1395
+ * await role.setHoist(true);
1396
+ * console.log(`Role is now hoisted: ${role.hoist}`);
1397
+ */
1398
+ setHoist(hoist: boolean): Promise<Role>;
795
1399
  /**
796
1400
  * Customizer for Node.js `console.log` and `util.inspect`.
797
1401
  * Hides the cyclic client reference and raw serverId for a cleaner output.
@@ -805,8 +1409,9 @@ interface RoleCreateOptions {
805
1409
  }
806
1410
  interface RoleEditOptions {
807
1411
  name?: string;
808
- colour?: string | null;
1412
+ color?: string | null;
809
1413
  hoist?: boolean;
1414
+ icon?: string | AttachmentBuilder | null;
810
1415
  }
811
1416
  interface RolePermissionOptions {
812
1417
  allow?: PermissionResolvable;
@@ -884,7 +1489,7 @@ declare class RoleManager extends BaseManager<string, Role> {
884
1489
  fetch(role: RoleResolvable, force?: boolean): Promise<Role>;
885
1490
  /**
886
1491
  * Edits an existing role in the server.
887
- * @param role The RoleResolvable to edit.
1492
+ * @param role The {@link RoleResolvable} to edit.
888
1493
  * @param options The fields to update.
889
1494
  * @returns A promise that resolves to the updated Role.
890
1495
  * @throws {TypeError} If invalid options or RoleResolvable are provided.
@@ -1028,6 +1633,35 @@ declare class ServerManager extends BaseManager<string, Server> {
1028
1633
  [util.inspect.custom](): Collection<string, Server>;
1029
1634
  }
1030
1635
 
1636
+ interface EmojiParent {
1637
+ id: string;
1638
+ type: "Server";
1639
+ }
1640
+ declare class Emoji extends Base {
1641
+ creatorId: string;
1642
+ name: string;
1643
+ parent: EmojiParent;
1644
+ animated: boolean;
1645
+ nsfw: boolean;
1646
+ constructor(client: Client, data: any);
1647
+ _patch(data: any): void;
1648
+ }
1649
+
1650
+ declare class EmojiManager extends BaseManager<string, Emoji> {
1651
+ server?: Server | undefined;
1652
+ constructor(client: Client, server?: Server | undefined, limit?: number);
1653
+ /**
1654
+ * Tell BaseManager how to find the ID for Emojis
1655
+ */
1656
+ protected extractId(data: any): string;
1657
+ /**
1658
+ * Tell BaseManager how to build an Emoji
1659
+ */
1660
+ protected construct(data: any): Emoji;
1661
+ fetch(id: string): Promise<Emoji>;
1662
+ [util.inspect.custom](): Collection<string, Emoji>;
1663
+ }
1664
+
1031
1665
  interface Categories {
1032
1666
  channels: string[];
1033
1667
  id: string;
@@ -1051,6 +1685,7 @@ declare class Server extends Base {
1051
1685
  roles: RoleManager;
1052
1686
  bans: ServerBanManager;
1053
1687
  invites: ServerInviteManager;
1688
+ emojis: EmojiManager;
1054
1689
  constructor(client: Client, data: any);
1055
1690
  /**
1056
1691
  * Updates the server instance with new data without losing the object reference.
@@ -1133,7 +1768,7 @@ declare class Member extends Base {
1133
1768
  /** Gets the Server object this member belongs to */
1134
1769
  get server(): Server | undefined;
1135
1770
  /** Calculates the member's total permissions using BigInt */
1136
- get permissions(): bigint;
1771
+ get permissions(): Permissions;
1137
1772
  /** Get avatar URL for this member, or null if they don't have one.
1138
1773
  * @example
1139
1774
  * // Get a member's avatar URL
@@ -1168,14 +1803,32 @@ declare class Member extends Base {
1168
1803
  * await member.setTimeout(600000);
1169
1804
  */
1170
1805
  setTimeout(duration: number): Promise<void>;
1171
- /** Checks if the member has a specific permission */
1172
- hasPermission(permission: PermissionResolvable): boolean;
1806
+ /**
1807
+ * Send a message to this member.
1808
+ * @param options The content or options for the message to send.
1809
+ * @returns A promise that resolves to the sent Message object.
1810
+ * @throws {Error} If the API request fails.
1811
+ * @example
1812
+ * // Send a message to this member
1813
+ * const message = await member.send("Hello!");
1814
+ * console.log(`Sent message ID: ${message.id}`);
1815
+ */
1816
+ send(options: string | MessageOptions): Promise<Message>;
1817
+ setNickname(nickname: string): Promise<Member>;
1173
1818
  /**
1174
1819
  * Edit this member.
1175
1820
  * @param options The options to edit the member with (nickname, roles, timeout, etc.)
1176
1821
  * @returns A promise that resolves to the updated Member.
1177
1822
  */
1178
- edit(options: MemberEditOptions): Promise<this>;
1823
+ edit(options: MemberEditOptions): Promise<Member>;
1824
+ /**
1825
+ * When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
1826
+ * @returns {string}
1827
+ * @example
1828
+ * // Logs: Hello from <@01JE2MM759J5D7CHJF084R7MJ2>!
1829
+ * console.log(`Hello from ${member}!`);
1830
+ */
1831
+ toString(): string;
1179
1832
  /**
1180
1833
  * Kick this member from the server.
1181
1834
  */
@@ -1208,10 +1861,52 @@ declare class EmbedBuilder {
1208
1861
  toJSON(): TextEmbedData;
1209
1862
  }
1210
1863
 
1864
+ declare class MessageReaction {
1865
+ client: Client;
1866
+ message: Message | {
1867
+ id: string;
1868
+ channelId: string;
1869
+ };
1870
+ emoji: Emoji | string;
1871
+ users: Collection<string, User | {
1872
+ id: string;
1873
+ }>;
1874
+ constructor(client: Client, data: {
1875
+ message: Message | {
1876
+ id: string;
1877
+ channelId: string;
1878
+ };
1879
+ emojiId: string;
1880
+ users?: string[];
1881
+ });
1882
+ get count(): number;
1883
+ remove(): Promise<void>;
1884
+ [util.inspect.custom](): string;
1885
+ }
1886
+
1887
+ interface ReactionCollectorOptions extends CollectorOptions<MessageReaction> {
1888
+ /** The maximum number of reactions to collect */
1889
+ max?: number;
1890
+ /** The maximum number of users to collect reactions from */
1891
+ maxUsers?: number;
1892
+ }
1893
+ declare class ReactionCollector extends Collector<string, MessageReaction> {
1894
+ message: Message;
1895
+ messageId: string;
1896
+ total: number;
1897
+ users: Set<string>;
1898
+ constructor(message: Message, options?: ReactionCollectorOptions);
1899
+ collect(reaction: MessageReaction): string | null;
1900
+ dispose(reaction: MessageReaction): string | null;
1901
+ private handleMessageReact;
1902
+ private handleMessageUnreact;
1903
+ endReason(): string | null;
1904
+ }
1905
+
1211
1906
  interface MessageOptions {
1212
1907
  content?: string;
1213
1908
  embeds?: (TextEmbedData | EmbedBuilder)[];
1214
- attachments?: string[];
1909
+ attachments?: string[] | AttachmentBuilder[];
1215
1910
  interactions?: any[];
1216
1911
  flags?: number;
1217
1912
  masquerade?: Masquerade;
@@ -1244,7 +1939,7 @@ declare class Message extends Base {
1244
1939
  masquerade: Masquerade | null;
1245
1940
  mentions: string[];
1246
1941
  pinned: boolean;
1247
- reactions: any[];
1942
+ reactions: Record<string, string[]>;
1248
1943
  replies: string[];
1249
1944
  role_mentions: string[];
1250
1945
  constructor(client: Client, data: any);
@@ -1266,119 +1961,71 @@ declare class Message extends Base {
1266
1961
  * Unpins this message.
1267
1962
  */
1268
1963
  unpin(): Promise<void>;
1269
- /** Gets the Channel object from cache */
1270
- get channel(): BaseChannel | undefined;
1271
- /** Gets the Global User object from cache */
1272
- get author(): User | undefined;
1273
- /** Gets the Server Member object (if sent in a server) */
1274
- get member(): Member | undefined;
1275
- /** Gets the Server ID if this message was sent in a server channel */
1276
- get serverId(): string | undefined;
1277
- /** Gets the Server object from cache */
1278
- get server(): Server | undefined;
1279
- _patch(data: any): void;
1280
- [util.inspect.custom](depth: number, options: util.InspectOptions, inspect: typeof util.inspect): string;
1281
- }
1282
-
1283
- type UserResolvable = User | string;
1284
- interface UserEditOptions {
1285
- avatar?: string | null;
1286
- displayName?: string | null;
1287
- profile?: UserProfile;
1288
- status?: UserStatus;
1289
- }
1290
- declare class UserManager extends BaseManager<string, User> {
1291
- constructor(client: Client, limit?: number);
1292
- /**
1293
- * Tell BaseManager how to find the ID for Users
1294
- */
1295
- protected extractId(data: any): string;
1296
- /**
1297
- * Tell BaseManager how to build a User
1298
- */
1299
- protected construct(data: any): User;
1300
- /**
1301
- * Resolves a UserResolvable to a User object from the cache.
1302
- */
1303
- resolve(user: UserResolvable): User | undefined;
1304
- /**
1305
- * Extracts ID from a UserResolvable.
1306
- * @param user The UserResolvable to extract the ID from.
1307
- * @returns The extracted user ID.
1308
- * @throws TypeError if an invalid type is provided.
1309
- */
1310
- resolveId(user: UserResolvable): string;
1311
1964
  /**
1312
- * Fetches a User.
1313
- * @param user The ID or mention to fetch
1314
- * @param force Skip the cache check and force an API request
1315
- * @returns The fetched User object
1316
- * @throws Error if the user cannot be found or fetched
1317
- * @throws TypeError if invalid UserResolvable is provided
1965
+ * React to this message
1966
+ * @param reaction The emoji to react with. Can be a Unicode emoji or a custom emoji ID.
1967
+ * @throws {Error} If the API request fails.
1318
1968
  * @example
1319
- * // Fetch a user by ID
1320
- * const user = await client.users.fetch("01JE2MM759J5D7CHJF084R7MJ2");
1321
- * console.log(user.username);
1322
- *
1323
- * // Fetch a user by mention
1324
- * const user = await client.users.fetch("<@01JE2MM759J5D7CHJF084R7MJ2>");
1325
- * console.log(user.username);
1326
- *
1327
- * // Force fetch a user, bypassing the cache
1328
- * const user = await client.users.fetch("01JE2MM759J5D7CHJF084R7MJ2", true);
1329
- * console.log(user.username);
1969
+ * await message.react("👍");
1970
+ * await message.react("customEmojiId");
1330
1971
  */
1331
- fetch(user: UserResolvable, force?: boolean): Promise<User>;
1972
+ react(reaction: string): Promise<void>;
1332
1973
  /**
1333
- * Fetch the current user (the bot itself).
1334
- * @returns The fetched User object representing the current user.
1335
- * @throws Error if the user cannot be fetched.
1974
+ * Remove a reaction from this message
1975
+ * @param reaction The emoji to remove. Can be a Unicode emoji or a custom emoji ID.
1976
+ * @param userId The ID of the user whose reaction to remove. If not provided, removes the current user's reaction.
1977
+ * @param removeAll Remove all reactions of this type.
1978
+ * @throws {Error} If both userId and removeAll are provided, or if the API request fails.
1336
1979
  * @example
1337
- * // Fetch the current user (the bot itself)
1338
- * const me = await client.users.fetchMe();
1339
- * console.log(`Logged in as ${me.tag}`);
1980
+ * // Remove the current user's reaction
1981
+ * await message.removeReaction("👍");
1982
+ * // Remove a specific user's reaction
1983
+ * await message.removeReaction("👍", userId);
1984
+ * // Remove all reactions of this type
1985
+ * await message.removeReaction("👍", undefined, true);
1340
1986
  */
1341
- fetchMe(): Promise<User>;
1987
+ removeReaction(reaction: string, userId?: UserResolvable, removeAll?: boolean): Promise<void>;
1342
1988
  /**
1343
- * Edits the currently authenticated user (the bot itself).
1344
- * @param options The fields to update (avatar, status, profile, etc.).
1345
- * @returns A promise that resolves to the updated User object.
1346
- * @throws {TypeError} If invalid options are provided.
1989
+ * Remove all reactions from this message
1347
1990
  * @throws {Error} If the API request fails.
1348
1991
  * @example
1349
- * // Update the bot's status and presence
1350
- * await client.users.editMe({
1351
- * status: { text: "Watching the server", presence: "Online" }
1352
- * });
1353
- *
1354
- * // Clear the bot's avatar and display name
1355
- * await client.users.editMe({ avatar: null, displayName: null });
1992
+ * await message.clearReactions();
1356
1993
  */
1357
- editMe(options: UserEditOptions): Promise<User>;
1994
+ clearReactions(): Promise<void>;
1358
1995
  /**
1359
- * The DM between the client's user and a user
1360
- *
1361
- * @param {string} userId The user id
1362
- * @returns {?DMChannel}
1363
- * @private
1996
+ * Creates a ReactionCollector to collect reactions on this message.
1997
+ * @param options The options for the collector.
1998
+ * @returns A new ReactionCollector instance.
1999
+ * @example
2000
+ * const collector = message.createReactionCollector({ time: 15000 });
2001
+ * collector.on('collect', (reaction) => console.log(`Collected ${reaction.emojiId} from ${reaction.userId}`));
2002
+ * collector.on('end', (collected) => console.log(`Collected ${collected.size} items`));
1364
2003
  */
1365
- dmChannel(userId: string): DMChannel | null;
2004
+ createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
1366
2005
  /**
1367
- * Creates a DM channel between the client's user and another user.
1368
- * @param user The UserResolvable to create a DM with.
1369
- * @param options Additional options for DM creation.
1370
- * @param options.force If true, forces the creation of a new DM channel even if one already exists.
1371
- * @returns A promise that resolves to the created DMChannel object.
1372
- * @throws {TypeError} If an invalid UserResolvable is provided.
1373
- * @throws {Error} If the API request fails.
2006
+ * Awaits reactions on this message.
2007
+ * @param options The options for the collector.
2008
+ * @returns A promise that resolves to a collection of reactions collected.
1374
2009
  * @example
1375
- * // Create a DM with a user by ID
1376
- * const dm = await client.users.createDM("1234567890");
1377
- * console.log(`DM channel ID: ${dm.id}`);
2010
+ * // Await reactions
2011
+ * const filter = (reaction) => reaction.emoji.id === '123' && reaction.users.has(author.id);
2012
+ * message.awaitReactions({ filter, max: 1, time: 60000 })
2013
+ * .then(collected => console.log(collected.size))
2014
+ * .catch(console.error);
1378
2015
  */
1379
- createDM(user: UserResolvable, { force }?: {
1380
- force?: boolean | undefined;
1381
- }): Promise<DMChannel>;
2016
+ awaitReactions(options?: ReactionCollectorOptions): Promise<Collection<string, MessageReaction>>;
2017
+ /** Gets the Channel object from cache */
2018
+ get channel(): BaseChannel | undefined;
2019
+ /** Gets the Global User object from cache */
2020
+ get author(): User | undefined;
2021
+ /** Gets the Server Member object (if sent in a server) */
2022
+ get member(): Member | undefined;
2023
+ /** Gets the Server ID if this message was sent in a server channel */
2024
+ get serverId(): string | undefined;
2025
+ /** Gets the Server object from cache */
2026
+ get server(): Server | undefined;
2027
+ _patch(data: any): void;
2028
+ [util.inspect.custom](depth: number, options: util.InspectOptions, inspect: typeof util.inspect): string;
1382
2029
  }
1383
2030
 
1384
2031
  /**
@@ -1412,6 +2059,18 @@ interface ClientEvents {
1412
2059
  id: string;
1413
2060
  channelId: string;
1414
2061
  }];
2062
+ messageReact: [message: Message | {
2063
+ id: string;
2064
+ channelId: string;
2065
+ }, emojiId: string, userId: string];
2066
+ messageUnreact: [message: Message | {
2067
+ id: string;
2068
+ channelId: string;
2069
+ }, emojiId: string, userId: string];
2070
+ messageRemoveReaction: [message: Message | {
2071
+ id: string;
2072
+ channelId: string;
2073
+ }, emojiId: string];
1415
2074
  error: [error: Error];
1416
2075
  debug: [message: string];
1417
2076
  raw: [data: any];
@@ -1431,6 +2090,7 @@ interface ClientOptions {
1431
2090
  users?: number;
1432
2091
  servers?: number;
1433
2092
  channels?: number;
2093
+ emojis?: number;
1434
2094
  };
1435
2095
  }
1436
2096
  declare class Client extends EventEmitter {
@@ -1441,6 +2101,7 @@ declare class Client extends EventEmitter {
1441
2101
  servers: ServerManager;
1442
2102
  users: UserManager;
1443
2103
  sweepers: SweeperManager;
2104
+ emojis: EmojiManager;
1444
2105
  user: ClientUser | null;
1445
2106
  constructor(options?: ClientOptions);
1446
2107
  /**
@@ -1459,4 +2120,4 @@ declare class UnknownChannel extends BaseChannel {
1459
2120
  constructor(client: Client, data: any);
1460
2121
  }
1461
2122
 
1462
- export { Attachment, type AttachmentMetadata, Base, BaseChannel, type BotInformation, type Categories, type ChannelCreateOptions, type ChannelEditOptions, ChannelManager, type ChannelResolvable, type ChannelRolePermissionOptions, ChannelType, Client, type ClientEvents, type ClientOptions, ClientUser, Collection, DMChannel, EmbedBuilder, type FetchMembersOptions, GatewayManager, type Interaction, type Masquerade, Member, type MemberBanOptions, type MemberEditOptions, MemberManager, type MemberResolvable, Message, type MessageFetchOptions, MessageManager, type MessageOptions, type MessageResolvable, PermissionFlags, type PermissionResolvable, type PermissionString, Permissions, RESTManager, type ReplyIntent, Role, type RoleCreateOptions, type RoleEditOptions, RoleManager, type RolePermissionOptions, type RoleResolvable, Server, ServerChannelManager, type ServerEditOptions, ServerManager, StoatAPIError, SweeperManager, type SweeperOptions, TextChannel, type TextEmbedData, UnknownChannel, User, type UserEditOptions, UserManager, UserPresence, type UserProfile, UserRelationship, type UserResolvable, type UserStatus };
2123
+ export { Attachment, AttachmentBuilder, type AttachmentMetadata, Base, BaseChannel, BitField, type BitFieldResolvable, type BotInformation, type CDNTag, type Categories, type ChannelCreateOptions, type ChannelEditOptions, ChannelManager, type ChannelResolvable, type ChannelRolePermissionOptions, ChannelType, Client, type ClientEvents, type ClientOptions, ClientUser, Collection, Collector, type CollectorOptions, DMChannel, EmbedBuilder, Emoji, EmojiManager, type EmojiParent, type FetchMembersOptions, GatewayManager, type Interaction, type Masquerade, Member, type MemberBanOptions, type MemberEditOptions, MemberManager, type MemberResolvable, Message, MessageCollector, type MessageCollectorOptions, type MessageFetchOptions, MessageManager, type MessageOptions, MessageReaction, type MessageResolvable, PermissionFlags, type PermissionResolvable, type PermissionString, Permissions, RESTManager, ReactionCollector, type ReactionCollectorOptions, type ReplyIntent, Role, type RoleCreateOptions, type RoleEditOptions, RoleManager, type RolePermissionOptions, type RoleResolvable, Server, ServerChannelManager, type ServerEditOptions, ServerManager, StoatAPIError, SweeperManager, type SweeperOptions, TextChannel, type TextEmbedData, UnknownChannel, User, type UserEditOptions, UserManager, UserPresence, type UserProfile, UserRelationship, type UserResolvable, type UserStatus };