@stoatx/client 0.2.2 → 0.3.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.cts CHANGED
@@ -48,10 +48,10 @@ declare class RESTManager {
48
48
  */
49
49
  uploadFile(filename: string, fileBuffer: Buffer | Blob): Promise<string>;
50
50
  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>;
51
+ post(endpoint: string, body?: any): Promise<any>;
52
+ patch(endpoint: string, body?: any): Promise<any>;
53
+ delete(endpoint: string, body?: any): Promise<any>;
54
+ put(endpoint: string, body?: any): Promise<any>;
55
55
  }
56
56
 
57
57
  /**
@@ -343,15 +343,6 @@ declare class MemberManager extends BaseManager<string, Member> {
343
343
  * await server.members.unban("1234567890");
344
344
  */
345
345
  unban(member: MemberResolvable): Promise<void>;
346
- /**
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
350
- * @example
351
- * // Timeout a member for 10 minutes
352
- * await server.members.setTimeout("1234567890", 10 * 60 * 1000);
353
- */
354
- setTimeout(member: MemberResolvable, duration: number): Promise<void>;
355
346
  [util.inspect.custom](): Collection<string, Member>;
356
347
  }
357
348
 
@@ -440,6 +431,209 @@ declare class GroupChannel extends BaseChannel {
440
431
  [util.inspect.custom](_depth: number, options: util.InspectOptions, inspect: typeof util.inspect): string;
441
432
  }
442
433
 
434
+ type UserResolvable = User | string;
435
+ interface UserEditOptions {
436
+ avatar?: string | null;
437
+ displayName?: string | null;
438
+ profile?: UserProfile;
439
+ status?: UserStatus;
440
+ }
441
+ declare class UserManager extends BaseManager<string, User> {
442
+ constructor(client: Client, limit?: number);
443
+ /**
444
+ * Tell BaseManager how to find the ID for Users
445
+ */
446
+ protected extractId(data: any): string;
447
+ /**
448
+ * Tell BaseManager how to build a User
449
+ */
450
+ protected construct(data: any): User;
451
+ /**
452
+ * Resolves a UserResolvable to a User object from the cache.
453
+ */
454
+ resolve(user: UserResolvable): User | undefined;
455
+ /**
456
+ * Extracts ID from a UserResolvable.
457
+ * @param user The UserResolvable to extract the ID from.
458
+ * @returns The extracted user ID.
459
+ * @throws TypeError if an invalid type is provided.
460
+ */
461
+ resolveId(user: UserResolvable): string;
462
+ /**
463
+ * Fetches a User.
464
+ * @param user The ID or mention to fetch
465
+ * @param force Skip the cache check and force an API request
466
+ * @returns The fetched User object
467
+ * @throws Error if the user cannot be found or fetched
468
+ * @throws TypeError if invalid UserResolvable is provided
469
+ * @example
470
+ * // Fetch a user by ID
471
+ * const user = await client.users.fetch("01JE2MM759J5D7CHJF084R7MJ2");
472
+ * console.log(user.username);
473
+ *
474
+ * // Fetch a user by mention
475
+ * const user = await client.users.fetch("<@01JE2MM759J5D7CHJF084R7MJ2>");
476
+ * console.log(user.username);
477
+ *
478
+ * // Force fetch a user, bypassing the cache
479
+ * const user = await client.users.fetch("01JE2MM759J5D7CHJF084R7MJ2", true);
480
+ * console.log(user.username);
481
+ */
482
+ fetch(user: UserResolvable, force?: boolean): Promise<User>;
483
+ /**
484
+ * Fetch the current user (the bot itself).
485
+ * @returns The fetched User object representing the current user.
486
+ * @throws Error if the user cannot be fetched.
487
+ * @example
488
+ * // Fetch the current user (the bot itself)
489
+ * const me = await client.users.fetchMe();
490
+ * console.log(`Logged in as ${me.tag}`);
491
+ */
492
+ fetchMe(): Promise<User>;
493
+ /**
494
+ * Edits the currently authenticated user (the bot itself).
495
+ * @param options The fields to update (avatar, status, profile, etc.).
496
+ * @returns A promise that resolves to the updated User object.
497
+ * @throws {TypeError} If invalid options are provided.
498
+ * @throws {Error} If the API request fails.
499
+ * @example
500
+ * // Update the bot's status and presence
501
+ * await client.users.editMe({
502
+ * status: { text: "Watching the server", presence: "Online" }
503
+ * });
504
+ *
505
+ * // Clear the bot's avatar and display name
506
+ * await client.users.editMe({ avatar: null, displayName: null });
507
+ */
508
+ editMe(options: UserEditOptions): Promise<User>;
509
+ /**
510
+ * The DM between the client's user and a user
511
+ *
512
+ * @param {string} userId The user id
513
+ * @returns {?DMChannel}
514
+ * @private
515
+ */
516
+ dmChannel(userId: string): DMChannel | null;
517
+ /**
518
+ * Creates a DM channel between the client's user and another user.
519
+ * @param user The UserResolvable to create a DM with.
520
+ * @param options Additional options for DM creation.
521
+ * @param options.force If true, forces the creation of a new DM channel even if one already exists.
522
+ * @returns A promise that resolves to the created DMChannel object.
523
+ * @throws {TypeError} If an invalid UserResolvable is provided.
524
+ * @throws {Error} If the API request fails.
525
+ * @example
526
+ * // Create a DM with a user by ID
527
+ * const dm = await client.users.createDM("1234567890");
528
+ * console.log(`DM channel ID: ${dm.id}`);
529
+ */
530
+ createDM(user: UserResolvable, { force }?: {
531
+ force?: boolean | undefined;
532
+ }): Promise<DMChannel>;
533
+ }
534
+
535
+ type MessageResolvable = Message | string;
536
+ interface MessageFetchOptions {
537
+ limit?: number;
538
+ before?: string;
539
+ after?: string;
540
+ sort?: "Relevance" | "Latest" | "Oldest";
541
+ nearby?: string;
542
+ includeUsers?: boolean;
543
+ }
544
+ declare class MessageManager extends BaseManager<string, Message> {
545
+ channel: BaseChannel;
546
+ constructor(client: Client, channel: BaseChannel, limit?: number);
547
+ /**
548
+ * Tell BaseManager how to find the ID for Messages
549
+ */
550
+ protected extractId(data: any): string;
551
+ /**
552
+ * Tell BaseManager how to build a Message
553
+ */
554
+ protected construct(data: any): Message;
555
+ fetch(id: string): Promise<Message>;
556
+ /**
557
+ * Fetches multiple messages from the channel using specific filter parameters.
558
+ * @param options The query parameters to filter the fetched messages.
559
+ * @returns A promise that resolves to a Collection of fetched Messages.
560
+ * @throws {Error} If the API request fails.
561
+ * @example
562
+ * // Fetch the last 50 messages in the channel
563
+ * const messages = await channel.messages.fetchMany({ limit: 50, sort: "Latest" });
564
+ *
565
+ * // Fetch 20 messages before a specific message ID
566
+ * const history = await channel.messages.fetchMany({ limit: 20, before: "01H..." });
567
+ */
568
+ fetchMany(options?: MessageFetchOptions): Promise<Collection<string, Message>>;
569
+ resolveId(message: MessageResolvable): string;
570
+ /**
571
+ * Sends a new message to this channel.
572
+ * @param contentOrOptions The string content or message options payload.
573
+ * @returns A promise that resolves to the sent Message.
574
+ */
575
+ send(contentOrOptions: MessageOptions | string): Promise<Message>;
576
+ /**
577
+ * Edits an existing message.
578
+ * @param message The MessageResolvable (object or ID) to edit.
579
+ * @param contentOrOptions The new content or options.
580
+ * @returns A promise that resolves to the updated Message.
581
+ */
582
+ edit(message: MessageResolvable, contentOrOptions: string | MessageOptions): Promise<Message>;
583
+ /**
584
+ * Deletes a message from the channel.
585
+ * @param message The MessageResolvable to delete.
586
+ */
587
+ delete(message: MessageResolvable): Promise<void>;
588
+ /**
589
+ * Pins a message in the channel.
590
+ * @param message The MessageResolvable to pin.
591
+ */
592
+ pin(message: MessageResolvable): Promise<void>;
593
+ /**
594
+ * Unpins a message in the channel.
595
+ * @param message The MessageResolvable to unpin.
596
+ */
597
+ unpin(message: MessageResolvable): Promise<void>;
598
+ /**
599
+ * React to a message
600
+ * @param message The MessageResolvable to react to.
601
+ * @param reaction The emoji to react with. Can be a Unicode emoji or a custom emoji ID.
602
+ * @throws {Error} If the API request fails.
603
+ * @example
604
+ * await channel.messages.react(messageId, "👍");
605
+ * await channel.messages.react(messageId, "customEmojiId");
606
+ */
607
+ react(message: MessageResolvable, reaction: string): Promise<void>;
608
+ /**
609
+ * Remove a reaction(s) from a message
610
+ * Requires ManageMessages if changing others' reactions.
611
+ * @param reaction The emoji to remove. Can be a unicode emoji or a custom emoji ID.
612
+ * @param message The MessageResolvable to remove the reaction from.
613
+ * @param userId The ID of the user whose reaction to remove. If not provided, removes the current user's reaction.
614
+ * @param removeAll Remove all reactions of this type.
615
+ * @throws {Error} If both userId and removeAll are provided, or if the API request fails.
616
+ * @example
617
+ * // Remove the current user's reaction
618
+ * await channel.messages.removeReaction(messageId, "👍");
619
+ * // Remove a specific user's reaction
620
+ * await channel.messages.removeReaction(messageId, "👍", userId);
621
+ * // Remove all reactions of this type
622
+ * await channel.messages.removeReaction(messageId, "👍", undefined, true);
623
+ */
624
+ removeReaction(message: MessageResolvable, reaction: string, userId?: UserResolvable, removeAll?: boolean): Promise<void>;
625
+ /**
626
+ * Remove all reactions from a message
627
+ * Requires ManageMessages permission.
628
+ * @param message The MessageResolvable to clear reactions from.
629
+ * @throws {Error} If the API request fails.
630
+ * @example
631
+ * await channel.messages.clearReactions(messageId);
632
+ */
633
+ clearReactions(message: MessageResolvable): Promise<void>;
634
+ [util.inspect.custom](): Collection<string, Message>;
635
+ }
636
+
443
637
  type ChannelResolvable = BaseChannel | string;
444
638
  interface ChannelEditOptions {
445
639
  name?: string;
@@ -485,7 +679,7 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
485
679
  /**
486
680
  * Fetches a Channel from the API or resolves it from the local cache.
487
681
  * @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.
682
+ * @param force Whether to skip the cache check and force a direct API request. Defaults to false.
489
683
  * @returns A promise that resolves to the fetched BaseChannel object.
490
684
  * @throws {TypeError} If an invalid ChannelResolvable is provided.
491
685
  * @throws {Error} If the API request fails.
@@ -540,6 +734,33 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
540
734
  * await client.channels.delete("01H...");
541
735
  */
542
736
  delete(channel: ChannelResolvable): Promise<void>;
737
+ /**
738
+ * Pin a message
739
+ * @param id Channel ID
740
+ * @param messageId Message ID
741
+ * @throws {Error} If the API request fails.
742
+ * @example
743
+ * await client.channels.pin("CHANNEL_ID", "MESSAGE_ID");
744
+ */
745
+ pin(id: string, messageId: string): Promise<void>;
746
+ /**
747
+ * Unpin a message
748
+ * @param id Channel ID
749
+ * @param messageId Message ID
750
+ * @throws {Error} If the API request fails
751
+ * @example
752
+ * await client.channels.unpin("CHANNEL_ID", "MESSAGE_ID");
753
+ */
754
+ unpin(id: string, messageId: string): Promise<void>;
755
+ /**
756
+ * Bulk delete up to 100 messages
757
+ * @param id Channel ID
758
+ * @param messages An array of MessageResolvable
759
+ * @throws {Error} If the API request fails
760
+ * @example
761
+ * await client.channels.bulkDelete("CHANNEL_ID", ["MESSAGE_ID_1", "MESSAGE_ID_2", "MESSAGE_ID_3"]);
762
+ */
763
+ bulkDelete(id: string, messages: MessageResolvable[]): Promise<void>;
543
764
  }
544
765
 
545
766
  declare class TextChannel extends BaseChannel {
@@ -580,72 +801,174 @@ declare class TextChannel extends BaseChannel {
580
801
  * await channel.setDefaultPermissions(["ViewChannel", "ReadMessageHistory"]);
581
802
  */
582
803
  setDefaultPermissions(permissions: PermissionResolvable): Promise<this>;
804
+ /**
805
+ * Edits the category of this channel. Only applicable to server channels.
806
+ * @param category The ID of the category to move this channel into, or "default" to remove from any category.
807
+ * @returns The updated TextChannel with the new category.
808
+ * @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.
809
+ * @example
810
+ * // Move this channel into a category
811
+ * await channel.setCategory("CATEGORY_ID");
812
+ * // Remove this channel from its category
813
+ * await channel.setCategory("default");
814
+ */
815
+ setCategory(category: string): Promise<TextChannel>;
816
+ /**
817
+ * Sets the position of this channel within its current category.
818
+ * @param position The new index position for the channel within its category.
819
+ * @returns The updated TextChannel.
820
+ * @throws {Error} If the channel is not in a category, or if the API request fails.
821
+ * @example
822
+ * // Move channel to the top of its category
823
+ * await channel.setPosition(0);
824
+ */
825
+ setPosition(position: number): Promise<TextChannel>;
826
+ /**
827
+ * Edit the description of this channel
828
+ * @param description
829
+ * @throws {Error} If the API request fails
830
+ * @returns The updated TextChannel
831
+ * @example
832
+ * // Set the channel description
833
+ * await channel.setDescription("This is a channel about cats!");
834
+ * // Remove the channel description
835
+ * await channel.setDescription(null);
836
+ */
837
+ setDescription(description: string | null): Promise<TextChannel>;
838
+ /**
839
+ * Edit the name of this channel
840
+ * @param name
841
+ * @throws {Error} If the API request fails
842
+ * @returns The updated TextChannel
843
+ * @example
844
+ * await channel.setName("New Name");
845
+ */
846
+ setName(name: string): Promise<TextChannel>;
847
+ /**
848
+ * Set whether this channel is NSFW
849
+ * @param nsfw
850
+ * @throws {Error} If the API request fails
851
+ * @returns The updated TextChannel
852
+ * @example
853
+ * // Mark the channel as NSFW
854
+ * await channel.setNSFW(true);
855
+ * // Mark the channel as SFW
856
+ * await channel.setNSFW(false);
857
+ */
858
+ setNSFW(nsfw: boolean): Promise<TextChannel>;
859
+ /**
860
+ * Set the channel slowmode in seconds
861
+ * @param slowmode
862
+ * @throws {Error} If the API request fails
863
+ * @returns The updated TextChannel
864
+ * @example
865
+ * // Set the slowmode to 5 seconds
866
+ * await channel.setSlowmode(5);
867
+ * // Remove slowmode
868
+ * await channel.setSlowmode(0);
869
+ */
870
+ setSlowmode(slowmode: number): Promise<TextChannel>;
871
+ /**
872
+ * Set the channel Icon
873
+ * @param id Autumn ID to use
874
+ * @throws {Error} If the API request fails
875
+ * @returns The updated TextChannel
876
+ * @example
877
+ * await channel.setIcon("123");
878
+ * // Remove the channel icon
879
+ * await channel.setIcon(null);
880
+ */
881
+ setIcon(id: string | null): Promise<TextChannel>;
583
882
  }
584
883
 
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;
884
+ /**
885
+ * Options to be passed to a Collector
886
+ */
887
+ interface CollectorOptions<V> {
888
+ /** The filter applied to this collector */
889
+ filter?: (item: V, ...args: any[]) => boolean;
890
+ /** How long to run the collector for in milliseconds */
891
+ time?: number;
892
+ /** How long to stop the collector after inactivity in milliseconds */
893
+ idle?: number;
894
+ /** Whether to dispose data when it's deleted */
895
+ dispose?: boolean;
593
896
  }
594
- declare class MessageManager extends BaseManager<string, Message> {
595
- channel: BaseChannel;
596
- constructor(client: Client, channel: BaseChannel, limit?: number);
897
+ /**
898
+ * Abstract class for defining a new Collector
899
+ */
900
+ declare abstract class Collector<K, V> extends EventEmitter {
901
+ readonly client: Client;
902
+ filter: (item: V, ...args: any[]) => boolean;
903
+ options: CollectorOptions<V>;
904
+ collected: Collection<K, V>;
905
+ ended: boolean;
906
+ private _timeout;
907
+ private _idletimeout;
908
+ protected constructor(client: Client, options?: CollectorOptions<V>);
597
909
  /**
598
- * Tell BaseManager how to find the ID for Messages
910
+ * Evaluates an item and possibly passes it to the collector
599
911
  */
600
- protected extractId(data: any): string;
912
+ handleCollect(item: V, ...args: any[]): void;
601
913
  /**
602
- * Tell BaseManager how to build a Message
914
+ * Evaluates an item and possibly removes it from the collector
603
915
  */
604
- protected construct(data: any): Message;
605
- fetch(id: string): Promise<Message>;
916
+ handleDispose(item: V, ...args: any[]): void;
606
917
  /**
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..." });
918
+ * Stops the collector.
617
919
  */
618
- fetchMany(options?: MessageFetchOptions): Promise<Collection<string, Message>>;
619
- resolveId(message: MessageResolvable): string;
920
+ stop(reason?: string): void;
620
921
  /**
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.
922
+ * Check if we should end upon collecting/disposing
624
923
  */
625
- send(contentOrOptions: MessageOptions | string): Promise<Message>;
924
+ checkEnd(): void;
626
925
  /**
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.
926
+ * Check if there's a reason to end
631
927
  */
632
- edit(message: MessageResolvable, contentOrOptions: string | MessageOptions): Promise<Message>;
928
+ endReason(): string | null;
633
929
  /**
634
- * Deletes a message from the channel.
635
- * @param message The MessageResolvable to delete.
930
+ * Returns a key if the item should be collected, or null to skip
636
931
  */
637
- delete(message: MessageResolvable): Promise<void>;
932
+ abstract collect(item: V, ...args: any[]): K | null;
638
933
  /**
639
- * Pins a message in the channel.
640
- * @param message The MessageResolvable to pin.
934
+ * Returns a key if the item should be disposed, or null to skip
641
935
  */
642
- pin(message: MessageResolvable): Promise<void>;
936
+ abstract dispose(item: V, ...args: any[]): K | null;
643
937
  /**
644
- * Unpins a message in the channel.
645
- * @param message The MessageResolvable to unpin.
938
+ * Allows iterating over collected items asynchronously.
939
+ * @example
940
+ * for await (const [id, message] of collector) {
941
+ * console.log(`Received message: ${message.content}`);
942
+ * }
646
943
  */
647
- unpin(message: MessageResolvable): Promise<void>;
648
- [util.inspect.custom](): Collection<string, Message>;
944
+ [Symbol.asyncIterator](): AsyncIterableIterator<[K, V]>;
945
+ }
946
+
947
+ /**
948
+ * Options to be passed to a MessageCollector
949
+ */
950
+ interface MessageCollectorOptions extends CollectorOptions<Message> {
951
+ /** The maximum number of messages to collect */
952
+ max?: number;
953
+ /** The maximum number of messages to process (both matching and non-matching the filter) */
954
+ maxProcessed?: number;
955
+ }
956
+ /**
957
+ * Collects messages on a channel.
958
+ */
959
+ declare class MessageCollector extends Collector<string, Message> {
960
+ channel: BaseChannel;
961
+ channelId: string;
962
+ total: number;
963
+ processed: number;
964
+ constructor(channel: BaseChannel, options?: MessageCollectorOptions);
965
+ collect(message: Message): string | null;
966
+ dispose(message: Message | {
967
+ id: string;
968
+ channelId: string;
969
+ }): string | null;
970
+ handleCollect(message: Message): void;
971
+ endReason(): string | null;
649
972
  }
650
973
 
651
974
  declare enum ChannelType {
@@ -675,21 +998,87 @@ declare abstract class BaseChannel extends Base {
675
998
  * await channel.send({ content: "Here is an embed", embeds: [myEmbed] });
676
999
  */
677
1000
  send(contentOrOptions: string | MessageOptions): Promise<Message>;
678
- fetch(force?: boolean): Promise<this>;
1001
+ /**
1002
+ * Fetch this channel
1003
+ * @param force Whether to skip the cache check and force a direct API request. Defaults to false
1004
+ * @throws {Error} If the API request fails
1005
+ * @returns {BaseChannel}
1006
+ * @example
1007
+ * // Force fetch channel to update its data
1008
+ * await channel.fetch(true);
1009
+ */
1010
+ fetch(force?: boolean): Promise<BaseChannel>;
679
1011
  /**
680
1012
  * Fetches multiple messages from this channel.
681
1013
  * @param options The query parameters to filter the messages.
1014
+ * @throws {Error} If the API request fails
1015
+ * @returns A Collection of Messages, keyed by their ID.
1016
+ * @example
1017
+ * // Fetch the last 50 messages in the channel
1018
+ * const messages = await channel.fetchMessages({ limit: 50 });
1019
+ * console.log(`Fetched ${messages.size} messages`);
1020
+ * // Fetch messages before a specific message ID
1021
+ * const messages = await channel.fetchMessages({ before: "MESSAGE_ID" });
1022
+ * console.log(`Fetched ${messages.size} messages sent before the specified message`);
1023
+ * // Fetch messages after a specific message ID
1024
+ * const messages = await channel.fetchMessages({ after: "MESSAGE_ID" });
1025
+ * console.log(`Fetched ${messages.size} messages sent after the specified message`);
1026
+ * // Fetch messages around a specific message ID
1027
+ * const messages = await channel.fetchMessages({ around: "MESSAGE_ID", limit: 10 });
1028
+ * console.log(`Fetched ${messages.size} messages sent around the specified message`);
682
1029
  */
683
1030
  fetchMessages(options?: MessageFetchOptions): Promise<Collection<string, Message>>;
684
1031
  /**
685
1032
  * Edits this channel.
686
1033
  * @param options The fields to update
1034
+ * @throws {Error} If the API request fails
1035
+ * @returns BaseChannel
1036
+ * @example
1037
+ * // Edit the channel's name
1038
+ * await channel.edit({name: "New Cool Name"});
687
1039
  */
688
- edit(options: ChannelEditOptions): Promise<this>;
1040
+ edit(options: ChannelEditOptions): Promise<BaseChannel>;
689
1041
  /**
690
1042
  * Deletes this channel.
1043
+ * @throws {Error} If the API request fails
1044
+ * @example
1045
+ * // Delete the channel
1046
+ * await channel.delete();
691
1047
  */
692
1048
  delete(): Promise<void>;
1049
+ /**
1050
+ * Bulk delete messages from this channel
1051
+ * @param messages MessageResolvable to delete
1052
+ * @throws {Error} If the API request fails
1053
+ * @example
1054
+ * // Delete messages by their ID's
1055
+ * await channel.bulkDelete(["MESSAGE_ID_1", "MESSAGE_ID_2", "MESSAGE_ID_3"]);
1056
+ * // Delete messages by their Message objects
1057
+ * await channel.bulkDelete([message1, message2, message3]);
1058
+ */
1059
+ bulkDelete(messages: MessageResolvable[]): Promise<void>;
1060
+ /**
1061
+ * Creates a MessageCollector to collect messages in this channel.
1062
+ * @param options The options for the collector.
1063
+ * @returns The instantiated MessageCollector
1064
+ * @example
1065
+ * const collector = channel.createMessageCollector({ filter: m => m.authorId === '123', time: 15000 });
1066
+ * collector.on('collect', m => console.log(`Collected ${m.content}`));
1067
+ * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
1068
+ */
1069
+ createMessageCollector(options?: MessageCollectorOptions): MessageCollector;
1070
+ /**
1071
+ * Awaits messages in this channel that meet certain criteria.
1072
+ * @param options The options for the collector.
1073
+ * @returns A promise that resolves to a collection of messages.
1074
+ * @example
1075
+ * // Await !vote messages
1076
+ * const filter = m => m.content.startsWith('!vote');
1077
+ * channel.awaitMessages({ filter, max: 4, time: 60000 })
1078
+ * .then(collected => console.log(collected.size))
1079
+ * .catch(console.error);
1080
+ */
1081
+ awaitMessages(options?: MessageCollectorOptions): Promise<Collection<string, Message>>;
693
1082
  isText(): this is TextChannel;
694
1083
  isDM(): this is DMChannel;
695
1084
  isGroup(): this is GroupChannel;
@@ -1028,6 +1417,35 @@ declare class ServerManager extends BaseManager<string, Server> {
1028
1417
  [util.inspect.custom](): Collection<string, Server>;
1029
1418
  }
1030
1419
 
1420
+ interface EmojiParent {
1421
+ id: string;
1422
+ type: "Server";
1423
+ }
1424
+ declare class Emoji extends Base {
1425
+ creatorId: string;
1426
+ name: string;
1427
+ parent: EmojiParent;
1428
+ animated: boolean;
1429
+ nsfw: boolean;
1430
+ constructor(client: Client, data: any);
1431
+ _patch(data: any): void;
1432
+ }
1433
+
1434
+ declare class EmojiManager extends BaseManager<string, Emoji> {
1435
+ server?: Server | undefined;
1436
+ constructor(client: Client, server?: Server | undefined, limit?: number);
1437
+ /**
1438
+ * Tell BaseManager how to find the ID for Emojis
1439
+ */
1440
+ protected extractId(data: any): string;
1441
+ /**
1442
+ * Tell BaseManager how to build an Emoji
1443
+ */
1444
+ protected construct(data: any): Emoji;
1445
+ fetch(id: string): Promise<Emoji>;
1446
+ [util.inspect.custom](): Collection<string, Emoji>;
1447
+ }
1448
+
1031
1449
  interface Categories {
1032
1450
  channels: string[];
1033
1451
  id: string;
@@ -1051,6 +1469,7 @@ declare class Server extends Base {
1051
1469
  roles: RoleManager;
1052
1470
  bans: ServerBanManager;
1053
1471
  invites: ServerInviteManager;
1472
+ emojis: EmojiManager;
1054
1473
  constructor(client: Client, data: any);
1055
1474
  /**
1056
1475
  * Updates the server instance with new data without losing the object reference.
@@ -1168,6 +1587,18 @@ declare class Member extends Base {
1168
1587
  * await member.setTimeout(600000);
1169
1588
  */
1170
1589
  setTimeout(duration: number): Promise<void>;
1590
+ /**
1591
+ * Send a message to this member.
1592
+ * @param options The content or options for the message to send.
1593
+ * @returns A promise that resolves to the sent Message object.
1594
+ * @throws {Error} If the API request fails.
1595
+ * @example
1596
+ * // Send a message to this member
1597
+ * const message = await member.send("Hello!");
1598
+ * console.log(`Sent message ID: ${message.id}`);
1599
+ */
1600
+ send(options: string | MessageOptions): Promise<Message>;
1601
+ setNickname(nickname: string): Promise<Member>;
1171
1602
  /** Checks if the member has a specific permission */
1172
1603
  hasPermission(permission: PermissionResolvable): boolean;
1173
1604
  /**
@@ -1175,7 +1606,15 @@ declare class Member extends Base {
1175
1606
  * @param options The options to edit the member with (nickname, roles, timeout, etc.)
1176
1607
  * @returns A promise that resolves to the updated Member.
1177
1608
  */
1178
- edit(options: MemberEditOptions): Promise<this>;
1609
+ edit(options: MemberEditOptions): Promise<Member>;
1610
+ /**
1611
+ * When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
1612
+ * @returns {string}
1613
+ * @example
1614
+ * // Logs: Hello from <@01JE2MM759J5D7CHJF084R7MJ2>!
1615
+ * console.log(`Hello from ${member}!`);
1616
+ */
1617
+ toString(): string;
1179
1618
  /**
1180
1619
  * Kick this member from the server.
1181
1620
  */
@@ -1208,6 +1647,48 @@ declare class EmbedBuilder {
1208
1647
  toJSON(): TextEmbedData;
1209
1648
  }
1210
1649
 
1650
+ declare class MessageReaction {
1651
+ client: Client;
1652
+ message: Message | {
1653
+ id: string;
1654
+ channelId: string;
1655
+ };
1656
+ emoji: Emoji | string;
1657
+ users: Collection<string, User | {
1658
+ id: string;
1659
+ }>;
1660
+ constructor(client: Client, data: {
1661
+ message: Message | {
1662
+ id: string;
1663
+ channelId: string;
1664
+ };
1665
+ emojiId: string;
1666
+ users?: string[];
1667
+ });
1668
+ get count(): number;
1669
+ remove(): Promise<void>;
1670
+ [util.inspect.custom](): string;
1671
+ }
1672
+
1673
+ interface ReactionCollectorOptions extends CollectorOptions<MessageReaction> {
1674
+ /** The maximum number of reactions to collect */
1675
+ max?: number;
1676
+ /** The maximum number of users to collect reactions from */
1677
+ maxUsers?: number;
1678
+ }
1679
+ declare class ReactionCollector extends Collector<string, MessageReaction> {
1680
+ message: Message;
1681
+ messageId: string;
1682
+ total: number;
1683
+ users: Set<string>;
1684
+ constructor(message: Message, options?: ReactionCollectorOptions);
1685
+ collect(reaction: MessageReaction): string | null;
1686
+ dispose(reaction: MessageReaction): string | null;
1687
+ private handleMessageReact;
1688
+ private handleMessageUnreact;
1689
+ endReason(): string | null;
1690
+ }
1691
+
1211
1692
  interface MessageOptions {
1212
1693
  content?: string;
1213
1694
  embeds?: (TextEmbedData | EmbedBuilder)[];
@@ -1244,7 +1725,7 @@ declare class Message extends Base {
1244
1725
  masquerade: Masquerade | null;
1245
1726
  mentions: string[];
1246
1727
  pinned: boolean;
1247
- reactions: any[];
1728
+ reactions: Record<string, string[]>;
1248
1729
  replies: string[];
1249
1730
  role_mentions: string[];
1250
1731
  constructor(client: Client, data: any);
@@ -1266,119 +1747,71 @@ declare class Message extends Base {
1266
1747
  * Unpins this message.
1267
1748
  */
1268
1749
  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
1750
  /**
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
- /**
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
1751
+ * React to this message
1752
+ * @param reaction The emoji to react with. Can be a Unicode emoji or a custom emoji ID.
1753
+ * @throws {Error} If the API request fails.
1318
1754
  * @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);
1755
+ * await message.react("👍");
1756
+ * await message.react("customEmojiId");
1330
1757
  */
1331
- fetch(user: UserResolvable, force?: boolean): Promise<User>;
1758
+ react(reaction: string): Promise<void>;
1332
1759
  /**
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.
1760
+ * Remove a reaction from this message
1761
+ * @param reaction The emoji to remove. Can be a Unicode emoji or a custom emoji ID.
1762
+ * @param userId The ID of the user whose reaction to remove. If not provided, removes the current user's reaction.
1763
+ * @param removeAll Remove all reactions of this type.
1764
+ * @throws {Error} If both userId and removeAll are provided, or if the API request fails.
1336
1765
  * @example
1337
- * // Fetch the current user (the bot itself)
1338
- * const me = await client.users.fetchMe();
1339
- * console.log(`Logged in as ${me.tag}`);
1766
+ * // Remove the current user's reaction
1767
+ * await message.removeReaction("👍");
1768
+ * // Remove a specific user's reaction
1769
+ * await message.removeReaction("👍", userId);
1770
+ * // Remove all reactions of this type
1771
+ * await message.removeReaction("👍", undefined, true);
1340
1772
  */
1341
- fetchMe(): Promise<User>;
1773
+ removeReaction(reaction: string, userId?: UserResolvable, removeAll?: boolean): Promise<void>;
1342
1774
  /**
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.
1775
+ * Remove all reactions from this message
1347
1776
  * @throws {Error} If the API request fails.
1348
1777
  * @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 });
1778
+ * await message.clearReactions();
1356
1779
  */
1357
- editMe(options: UserEditOptions): Promise<User>;
1780
+ clearReactions(): Promise<void>;
1358
1781
  /**
1359
- * The DM between the client's user and a user
1360
- *
1361
- * @param {string} userId The user id
1362
- * @returns {?DMChannel}
1363
- * @private
1782
+ * Creates a ReactionCollector to collect reactions on this message.
1783
+ * @param options The options for the collector.
1784
+ * @returns A new ReactionCollector instance.
1785
+ * @example
1786
+ * const collector = message.createReactionCollector({ time: 15000 });
1787
+ * collector.on('collect', (reaction) => console.log(`Collected ${reaction.emojiId} from ${reaction.userId}`));
1788
+ * collector.on('end', (collected) => console.log(`Collected ${collected.size} items`));
1364
1789
  */
1365
- dmChannel(userId: string): DMChannel | null;
1790
+ createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
1366
1791
  /**
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.
1792
+ * Awaits reactions on this message.
1793
+ * @param options The options for the collector.
1794
+ * @returns A promise that resolves to a collection of reactions collected.
1374
1795
  * @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}`);
1796
+ * // Await reactions
1797
+ * const filter = (reaction) => reaction.emoji.id === '123' && reaction.users.has(author.id);
1798
+ * message.awaitReactions({ filter, max: 1, time: 60000 })
1799
+ * .then(collected => console.log(collected.size))
1800
+ * .catch(console.error);
1378
1801
  */
1379
- createDM(user: UserResolvable, { force }?: {
1380
- force?: boolean | undefined;
1381
- }): Promise<DMChannel>;
1802
+ awaitReactions(options?: ReactionCollectorOptions): Promise<Collection<string, MessageReaction>>;
1803
+ /** Gets the Channel object from cache */
1804
+ get channel(): BaseChannel | undefined;
1805
+ /** Gets the Global User object from cache */
1806
+ get author(): User | undefined;
1807
+ /** Gets the Server Member object (if sent in a server) */
1808
+ get member(): Member | undefined;
1809
+ /** Gets the Server ID if this message was sent in a server channel */
1810
+ get serverId(): string | undefined;
1811
+ /** Gets the Server object from cache */
1812
+ get server(): Server | undefined;
1813
+ _patch(data: any): void;
1814
+ [util.inspect.custom](depth: number, options: util.InspectOptions, inspect: typeof util.inspect): string;
1382
1815
  }
1383
1816
 
1384
1817
  /**
@@ -1412,6 +1845,18 @@ interface ClientEvents {
1412
1845
  id: string;
1413
1846
  channelId: string;
1414
1847
  }];
1848
+ messageReact: [message: Message | {
1849
+ id: string;
1850
+ channelId: string;
1851
+ }, emojiId: string, userId: string];
1852
+ messageUnreact: [message: Message | {
1853
+ id: string;
1854
+ channelId: string;
1855
+ }, emojiId: string, userId: string];
1856
+ messageRemoveReaction: [message: Message | {
1857
+ id: string;
1858
+ channelId: string;
1859
+ }, emojiId: string];
1415
1860
  error: [error: Error];
1416
1861
  debug: [message: string];
1417
1862
  raw: [data: any];
@@ -1431,6 +1876,7 @@ interface ClientOptions {
1431
1876
  users?: number;
1432
1877
  servers?: number;
1433
1878
  channels?: number;
1879
+ emojis?: number;
1434
1880
  };
1435
1881
  }
1436
1882
  declare class Client extends EventEmitter {
@@ -1441,6 +1887,7 @@ declare class Client extends EventEmitter {
1441
1887
  servers: ServerManager;
1442
1888
  users: UserManager;
1443
1889
  sweepers: SweeperManager;
1890
+ emojis: EmojiManager;
1444
1891
  user: ClientUser | null;
1445
1892
  constructor(options?: ClientOptions);
1446
1893
  /**
@@ -1459,4 +1906,4 @@ declare class UnknownChannel extends BaseChannel {
1459
1906
  constructor(client: Client, data: any);
1460
1907
  }
1461
1908
 
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 };
1909
+ 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, 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 };