@stoatx/client 0.2.1 → 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.cjs +950 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +618 -172
- package/dist/index.d.ts +618 -172
- package/dist/index.js +944 -126
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
52
|
-
patch(endpoint: string, body
|
|
53
|
-
delete(endpoint: string): Promise<any>;
|
|
54
|
-
put(endpoint: string, body
|
|
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
|
/**
|
|
@@ -218,7 +218,7 @@ declare class Collection<K, V> extends Map<K, V> {
|
|
|
218
218
|
*/
|
|
219
219
|
declare abstract class BaseManager<K, Holds> {
|
|
220
220
|
cache: Collection<K, Holds>;
|
|
221
|
-
|
|
221
|
+
client: Client;
|
|
222
222
|
protected constructor(client: Client, limit?: number);
|
|
223
223
|
/**
|
|
224
224
|
* Defines how to extract the unique ID from a raw API payload.
|
|
@@ -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;
|
|
@@ -458,7 +652,6 @@ interface ChannelRolePermissionOptions {
|
|
|
458
652
|
deny?: PermissionResolvable;
|
|
459
653
|
}
|
|
460
654
|
declare class ChannelManager extends BaseManager<string, BaseChannel> {
|
|
461
|
-
client: Client;
|
|
462
655
|
/**
|
|
463
656
|
* Manages API methods and caching for all channels globally.
|
|
464
657
|
* @param client The active Client instance.
|
|
@@ -486,7 +679,7 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
|
|
|
486
679
|
/**
|
|
487
680
|
* Fetches a Channel from the API or resolves it from the local cache.
|
|
488
681
|
* @param channel The ID, mention, or Channel object to fetch.
|
|
489
|
-
* @param force Whether to skip the cache check and force a direct API request. Defaults to
|
|
682
|
+
* @param force Whether to skip the cache check and force a direct API request. Defaults to false.
|
|
490
683
|
* @returns A promise that resolves to the fetched BaseChannel object.
|
|
491
684
|
* @throws {TypeError} If an invalid ChannelResolvable is provided.
|
|
492
685
|
* @throws {Error} If the API request fails.
|
|
@@ -541,6 +734,33 @@ declare class ChannelManager extends BaseManager<string, BaseChannel> {
|
|
|
541
734
|
* await client.channels.delete("01H...");
|
|
542
735
|
*/
|
|
543
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>;
|
|
544
764
|
}
|
|
545
765
|
|
|
546
766
|
declare class TextChannel extends BaseChannel {
|
|
@@ -581,72 +801,174 @@ declare class TextChannel extends BaseChannel {
|
|
|
581
801
|
* await channel.setDefaultPermissions(["ViewChannel", "ReadMessageHistory"]);
|
|
582
802
|
*/
|
|
583
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>;
|
|
584
882
|
}
|
|
585
883
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
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;
|
|
594
896
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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>);
|
|
598
909
|
/**
|
|
599
|
-
*
|
|
910
|
+
* Evaluates an item and possibly passes it to the collector
|
|
600
911
|
*/
|
|
601
|
-
|
|
912
|
+
handleCollect(item: V, ...args: any[]): void;
|
|
602
913
|
/**
|
|
603
|
-
*
|
|
914
|
+
* Evaluates an item and possibly removes it from the collector
|
|
604
915
|
*/
|
|
605
|
-
|
|
606
|
-
fetch(id: string): Promise<Message>;
|
|
916
|
+
handleDispose(item: V, ...args: any[]): void;
|
|
607
917
|
/**
|
|
608
|
-
*
|
|
609
|
-
* @param options The query parameters to filter the fetched messages.
|
|
610
|
-
* @returns A promise that resolves to a Collection of fetched Messages.
|
|
611
|
-
* @throws {Error} If the API request fails.
|
|
612
|
-
* @example
|
|
613
|
-
* // Fetch the last 50 messages in the channel
|
|
614
|
-
* const messages = await channel.messages.fetchMany({ limit: 50, sort: "Latest" });
|
|
615
|
-
*
|
|
616
|
-
* // Fetch 20 messages before a specific message ID
|
|
617
|
-
* const history = await channel.messages.fetchMany({ limit: 20, before: "01H..." });
|
|
918
|
+
* Stops the collector.
|
|
618
919
|
*/
|
|
619
|
-
|
|
620
|
-
resolveId(message: MessageResolvable): string;
|
|
920
|
+
stop(reason?: string): void;
|
|
621
921
|
/**
|
|
622
|
-
*
|
|
623
|
-
* @param contentOrOptions The string content or message options payload.
|
|
624
|
-
* @returns A promise that resolves to the sent Message.
|
|
922
|
+
* Check if we should end upon collecting/disposing
|
|
625
923
|
*/
|
|
626
|
-
|
|
924
|
+
checkEnd(): void;
|
|
627
925
|
/**
|
|
628
|
-
*
|
|
629
|
-
* @param message The MessageResolvable (object or ID) to edit.
|
|
630
|
-
* @param contentOrOptions The new content or options.
|
|
631
|
-
* @returns A promise that resolves to the updated Message.
|
|
926
|
+
* Check if there's a reason to end
|
|
632
927
|
*/
|
|
633
|
-
|
|
928
|
+
endReason(): string | null;
|
|
634
929
|
/**
|
|
635
|
-
*
|
|
636
|
-
* @param message The MessageResolvable to delete.
|
|
930
|
+
* Returns a key if the item should be collected, or null to skip
|
|
637
931
|
*/
|
|
638
|
-
|
|
932
|
+
abstract collect(item: V, ...args: any[]): K | null;
|
|
639
933
|
/**
|
|
640
|
-
*
|
|
641
|
-
* @param message The MessageResolvable to pin.
|
|
934
|
+
* Returns a key if the item should be disposed, or null to skip
|
|
642
935
|
*/
|
|
643
|
-
|
|
936
|
+
abstract dispose(item: V, ...args: any[]): K | null;
|
|
644
937
|
/**
|
|
645
|
-
*
|
|
646
|
-
* @
|
|
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
|
+
* }
|
|
647
943
|
*/
|
|
648
|
-
|
|
649
|
-
|
|
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;
|
|
650
972
|
}
|
|
651
973
|
|
|
652
974
|
declare enum ChannelType {
|
|
@@ -676,29 +998,95 @@ declare abstract class BaseChannel extends Base {
|
|
|
676
998
|
* await channel.send({ content: "Here is an embed", embeds: [myEmbed] });
|
|
677
999
|
*/
|
|
678
1000
|
send(contentOrOptions: string | MessageOptions): Promise<Message>;
|
|
679
|
-
|
|
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>;
|
|
680
1011
|
/**
|
|
681
1012
|
* Fetches multiple messages from this channel.
|
|
682
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`);
|
|
683
1029
|
*/
|
|
684
1030
|
fetchMessages(options?: MessageFetchOptions): Promise<Collection<string, Message>>;
|
|
685
1031
|
/**
|
|
686
1032
|
* Edits this channel.
|
|
687
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"});
|
|
688
1039
|
*/
|
|
689
|
-
edit(options: ChannelEditOptions): Promise<
|
|
1040
|
+
edit(options: ChannelEditOptions): Promise<BaseChannel>;
|
|
690
1041
|
/**
|
|
691
1042
|
* Deletes this channel.
|
|
1043
|
+
* @throws {Error} If the API request fails
|
|
1044
|
+
* @example
|
|
1045
|
+
* // Delete the channel
|
|
1046
|
+
* await channel.delete();
|
|
692
1047
|
*/
|
|
693
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>>;
|
|
694
1082
|
isText(): this is TextChannel;
|
|
695
1083
|
isDM(): this is DMChannel;
|
|
696
1084
|
isGroup(): this is GroupChannel;
|
|
697
1085
|
}
|
|
698
1086
|
|
|
699
1087
|
declare class ServerChannelManager {
|
|
700
|
-
|
|
701
|
-
|
|
1088
|
+
client: Client;
|
|
1089
|
+
server: Server;
|
|
702
1090
|
constructor(client: Client, server: Server);
|
|
703
1091
|
get cache(): Collection<string, BaseChannel>;
|
|
704
1092
|
/**
|
|
@@ -815,7 +1203,7 @@ interface RolePermissionOptions {
|
|
|
815
1203
|
}
|
|
816
1204
|
type RoleResolvable = Role | string;
|
|
817
1205
|
declare class RoleManager extends BaseManager<string, Role> {
|
|
818
|
-
|
|
1206
|
+
server: Server;
|
|
819
1207
|
/**
|
|
820
1208
|
* Manages API methods and caching for server roles.
|
|
821
1209
|
*/
|
|
@@ -1029,6 +1417,35 @@ declare class ServerManager extends BaseManager<string, Server> {
|
|
|
1029
1417
|
[util.inspect.custom](): Collection<string, Server>;
|
|
1030
1418
|
}
|
|
1031
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
|
+
|
|
1032
1449
|
interface Categories {
|
|
1033
1450
|
channels: string[];
|
|
1034
1451
|
id: string;
|
|
@@ -1052,6 +1469,7 @@ declare class Server extends Base {
|
|
|
1052
1469
|
roles: RoleManager;
|
|
1053
1470
|
bans: ServerBanManager;
|
|
1054
1471
|
invites: ServerInviteManager;
|
|
1472
|
+
emojis: EmojiManager;
|
|
1055
1473
|
constructor(client: Client, data: any);
|
|
1056
1474
|
/**
|
|
1057
1475
|
* Updates the server instance with new data without losing the object reference.
|
|
@@ -1075,7 +1493,7 @@ declare class Server extends Base {
|
|
|
1075
1493
|
}
|
|
1076
1494
|
|
|
1077
1495
|
declare class MemberRoleManager {
|
|
1078
|
-
|
|
1496
|
+
member: Member;
|
|
1079
1497
|
constructor(member: Member);
|
|
1080
1498
|
/**
|
|
1081
1499
|
* Gets a Collection of the actual Role objects this member has.
|
|
@@ -1169,6 +1587,18 @@ declare class Member extends Base {
|
|
|
1169
1587
|
* await member.setTimeout(600000);
|
|
1170
1588
|
*/
|
|
1171
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>;
|
|
1172
1602
|
/** Checks if the member has a specific permission */
|
|
1173
1603
|
hasPermission(permission: PermissionResolvable): boolean;
|
|
1174
1604
|
/**
|
|
@@ -1176,7 +1606,15 @@ declare class Member extends Base {
|
|
|
1176
1606
|
* @param options The options to edit the member with (nickname, roles, timeout, etc.)
|
|
1177
1607
|
* @returns A promise that resolves to the updated Member.
|
|
1178
1608
|
*/
|
|
1179
|
-
edit(options: MemberEditOptions): Promise<
|
|
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;
|
|
1180
1618
|
/**
|
|
1181
1619
|
* Kick this member from the server.
|
|
1182
1620
|
*/
|
|
@@ -1209,6 +1647,48 @@ declare class EmbedBuilder {
|
|
|
1209
1647
|
toJSON(): TextEmbedData;
|
|
1210
1648
|
}
|
|
1211
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
|
+
|
|
1212
1692
|
interface MessageOptions {
|
|
1213
1693
|
content?: string;
|
|
1214
1694
|
embeds?: (TextEmbedData | EmbedBuilder)[];
|
|
@@ -1245,7 +1725,7 @@ declare class Message extends Base {
|
|
|
1245
1725
|
masquerade: Masquerade | null;
|
|
1246
1726
|
mentions: string[];
|
|
1247
1727
|
pinned: boolean;
|
|
1248
|
-
reactions:
|
|
1728
|
+
reactions: Record<string, string[]>;
|
|
1249
1729
|
replies: string[];
|
|
1250
1730
|
role_mentions: string[];
|
|
1251
1731
|
constructor(client: Client, data: any);
|
|
@@ -1267,119 +1747,71 @@ declare class Message extends Base {
|
|
|
1267
1747
|
* Unpins this message.
|
|
1268
1748
|
*/
|
|
1269
1749
|
unpin(): Promise<void>;
|
|
1270
|
-
/** Gets the Channel object from cache */
|
|
1271
|
-
get channel(): BaseChannel | undefined;
|
|
1272
|
-
/** Gets the Global User object from cache */
|
|
1273
|
-
get author(): User | undefined;
|
|
1274
|
-
/** Gets the Server Member object (if sent in a server) */
|
|
1275
|
-
get member(): Member | undefined;
|
|
1276
|
-
/** Gets the Server ID if this message was sent in a server channel */
|
|
1277
|
-
get serverId(): string | undefined;
|
|
1278
|
-
/** Gets the Server object from cache */
|
|
1279
|
-
get server(): Server | undefined;
|
|
1280
|
-
_patch(data: any): void;
|
|
1281
|
-
[util.inspect.custom](depth: number, options: util.InspectOptions, inspect: typeof util.inspect): string;
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
type UserResolvable = User | string;
|
|
1285
|
-
interface UserEditOptions {
|
|
1286
|
-
avatar?: string | null;
|
|
1287
|
-
displayName?: string | null;
|
|
1288
|
-
profile?: UserProfile;
|
|
1289
|
-
status?: UserStatus;
|
|
1290
|
-
}
|
|
1291
|
-
declare class UserManager extends BaseManager<string, User> {
|
|
1292
|
-
constructor(client: Client, limit?: number);
|
|
1293
|
-
/**
|
|
1294
|
-
* Tell BaseManager how to find the ID for Users
|
|
1295
|
-
*/
|
|
1296
|
-
protected extractId(data: any): string;
|
|
1297
|
-
/**
|
|
1298
|
-
* Tell BaseManager how to build a User
|
|
1299
|
-
*/
|
|
1300
|
-
protected construct(data: any): User;
|
|
1301
|
-
/**
|
|
1302
|
-
* Resolves a UserResolvable to a User object from the cache.
|
|
1303
|
-
*/
|
|
1304
|
-
resolve(user: UserResolvable): User | undefined;
|
|
1305
|
-
/**
|
|
1306
|
-
* Extracts ID from a UserResolvable.
|
|
1307
|
-
* @param user The UserResolvable to extract the ID from.
|
|
1308
|
-
* @returns The extracted user ID.
|
|
1309
|
-
* @throws TypeError if an invalid type is provided.
|
|
1310
|
-
*/
|
|
1311
|
-
resolveId(user: UserResolvable): string;
|
|
1312
1750
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
* @param
|
|
1315
|
-
* @
|
|
1316
|
-
* @returns The fetched User object
|
|
1317
|
-
* @throws Error if the user cannot be found or fetched
|
|
1318
|
-
* @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.
|
|
1319
1754
|
* @example
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
* console.log(user.username);
|
|
1323
|
-
*
|
|
1324
|
-
* // Fetch a user by mention
|
|
1325
|
-
* const user = await client.users.fetch("<@01JE2MM759J5D7CHJF084R7MJ2>");
|
|
1326
|
-
* console.log(user.username);
|
|
1327
|
-
*
|
|
1328
|
-
* // Force fetch a user, bypassing the cache
|
|
1329
|
-
* const user = await client.users.fetch("01JE2MM759J5D7CHJF084R7MJ2", true);
|
|
1330
|
-
* console.log(user.username);
|
|
1755
|
+
* await message.react("👍");
|
|
1756
|
+
* await message.react("customEmojiId");
|
|
1331
1757
|
*/
|
|
1332
|
-
|
|
1758
|
+
react(reaction: string): Promise<void>;
|
|
1333
1759
|
/**
|
|
1334
|
-
*
|
|
1335
|
-
* @
|
|
1336
|
-
* @
|
|
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.
|
|
1337
1765
|
* @example
|
|
1338
|
-
* //
|
|
1339
|
-
*
|
|
1340
|
-
*
|
|
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);
|
|
1341
1772
|
*/
|
|
1342
|
-
|
|
1773
|
+
removeReaction(reaction: string, userId?: UserResolvable, removeAll?: boolean): Promise<void>;
|
|
1343
1774
|
/**
|
|
1344
|
-
*
|
|
1345
|
-
* @param options The fields to update (avatar, status, profile, etc.).
|
|
1346
|
-
* @returns A promise that resolves to the updated User object.
|
|
1347
|
-
* @throws {TypeError} If invalid options are provided.
|
|
1775
|
+
* Remove all reactions from this message
|
|
1348
1776
|
* @throws {Error} If the API request fails.
|
|
1349
1777
|
* @example
|
|
1350
|
-
*
|
|
1351
|
-
* await client.users.editMe({
|
|
1352
|
-
* status: { text: "Watching the server", presence: "Online" }
|
|
1353
|
-
* });
|
|
1354
|
-
*
|
|
1355
|
-
* // Clear the bot's avatar and display name
|
|
1356
|
-
* await client.users.editMe({ avatar: null, displayName: null });
|
|
1778
|
+
* await message.clearReactions();
|
|
1357
1779
|
*/
|
|
1358
|
-
|
|
1780
|
+
clearReactions(): Promise<void>;
|
|
1359
1781
|
/**
|
|
1360
|
-
*
|
|
1361
|
-
*
|
|
1362
|
-
* @
|
|
1363
|
-
* @
|
|
1364
|
-
*
|
|
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`));
|
|
1365
1789
|
*/
|
|
1366
|
-
|
|
1790
|
+
createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector;
|
|
1367
1791
|
/**
|
|
1368
|
-
*
|
|
1369
|
-
* @param
|
|
1370
|
-
* @
|
|
1371
|
-
* @param options.force If true, forces the creation of a new DM channel even if one already exists.
|
|
1372
|
-
* @returns A promise that resolves to the created DMChannel object.
|
|
1373
|
-
* @throws {TypeError} If an invalid UserResolvable is provided.
|
|
1374
|
-
* @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.
|
|
1375
1795
|
* @example
|
|
1376
|
-
* //
|
|
1377
|
-
* const
|
|
1378
|
-
*
|
|
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);
|
|
1379
1801
|
*/
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
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;
|
|
1383
1815
|
}
|
|
1384
1816
|
|
|
1385
1817
|
/**
|
|
@@ -1396,9 +1828,9 @@ interface SweeperOptions {
|
|
|
1396
1828
|
};
|
|
1397
1829
|
}
|
|
1398
1830
|
declare class SweeperManager {
|
|
1399
|
-
private client;
|
|
1400
|
-
private options;
|
|
1401
1831
|
private messageInterval;
|
|
1832
|
+
client: Client;
|
|
1833
|
+
options: SweeperOptions;
|
|
1402
1834
|
constructor(client: Client, options: SweeperOptions);
|
|
1403
1835
|
start(): void;
|
|
1404
1836
|
private sweepMessages;
|
|
@@ -1413,6 +1845,18 @@ interface ClientEvents {
|
|
|
1413
1845
|
id: string;
|
|
1414
1846
|
channelId: string;
|
|
1415
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];
|
|
1416
1860
|
error: [error: Error];
|
|
1417
1861
|
debug: [message: string];
|
|
1418
1862
|
raw: [data: any];
|
|
@@ -1432,6 +1876,7 @@ interface ClientOptions {
|
|
|
1432
1876
|
users?: number;
|
|
1433
1877
|
servers?: number;
|
|
1434
1878
|
channels?: number;
|
|
1879
|
+
emojis?: number;
|
|
1435
1880
|
};
|
|
1436
1881
|
}
|
|
1437
1882
|
declare class Client extends EventEmitter {
|
|
@@ -1442,6 +1887,7 @@ declare class Client extends EventEmitter {
|
|
|
1442
1887
|
servers: ServerManager;
|
|
1443
1888
|
users: UserManager;
|
|
1444
1889
|
sweepers: SweeperManager;
|
|
1890
|
+
emojis: EmojiManager;
|
|
1445
1891
|
user: ClientUser | null;
|
|
1446
1892
|
constructor(options?: ClientOptions);
|
|
1447
1893
|
/**
|
|
@@ -1460,4 +1906,4 @@ declare class UnknownChannel extends BaseChannel {
|
|
|
1460
1906
|
constructor(client: Client, data: any);
|
|
1461
1907
|
}
|
|
1462
1908
|
|
|
1463
|
-
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 };
|