-
Notifications
You must be signed in to change notification settings - Fork 417
/
index.d.ts
3657 lines (3538 loc) · 139 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { EventEmitter } from "events";
import { Duplex, Readable as ReadableStream, Stream } from "stream";
import { Agent as HTTPSAgent } from "https";
import { IncomingMessage, ClientRequest } from "http";
import OpusScript = require("opusscript"); // Thanks TypeScript
import { URL } from "url";
import { Socket as DgramSocket } from "dgram";
import * as WebSocket from "ws";
declare function Eris(token: string, options?: Eris.ClientOptions): Eris.Client;
declare namespace Eris {
export const Constants: Constants;
export const VERSION: string;
// TYPES
// Cache
interface Uncached { id: string }
// Channel
type AnyChannel = AnyGuildChannel | PrivateChannel;
type AnyGuildChannel = GuildTextableChannel | AnyVoiceChannel | CategoryChannel | StoreChannel;
type AnyThreadChannel = NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | ThreadChannel;
type AnyVoiceChannel = VoiceChannel | StageChannel;
type GuildTextableChannel = TextChannel | NewsChannel;
type GuildTextableWithThread = GuildTextableChannel | AnyThreadChannel;
type InviteChannel = InvitePartialChannel | Exclude<AnyGuildChannel, CategoryChannel | AnyThreadChannel>;
type PossiblyUncachedTextable = Textable | Uncached;
type PossiblyUncachedTextableChannel = TextableChannel | Uncached;
type TextableChannel = (GuildTextable & GuildTextableChannel) | (ThreadTextable & AnyThreadChannel) | (Textable & PrivateChannel);
type VideoQualityMode = Constants["VideoQualityModes"][keyof Constants["VideoQualityModes"]];
type ChannelTypes = GuildChannelTypes | PrivateChannelTypes;
type GuildChannelTypes = Exclude<Constants["ChannelTypes"][keyof Constants["ChannelTypes"]], PrivateChannelTypes>;
type TextChannelTypes = GuildTextChannelTypes | PrivateChannelTypes;
type GuildTextChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "GUILD_TEXT" | "GUILD_NEWS">];
type GuildThreadChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "GUILD_NEWS_THREAD" | "GUILD_PRIVATE_THREAD" | "GUILD_PUBLIC_THREAD">];
type GuildPublicThreadChannelTypes = Exclude<GuildThreadChannelTypes, Constants["ChannelTypes"]["GUILD_PRIVATE_THREAD"]>;
type GuildVoiceChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "GUILD_VOICE" | "GUILD_STAGE">];
type PrivateChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "DM" | "GROUP_DM">];
// Command
type CommandGenerator = CommandGeneratorFunction | MessageContent | MessageContent[] | CommandGeneratorFunction[];
type CommandGeneratorFunction = (msg: Message, args: string[]) => GeneratorFunctionReturn;
type GeneratorFunctionReturn = Promise<MessageContent> | Promise<void> | MessageContent | void;
type GenericCheckFunction<T> = (msg: Message) => T | Promise<T>;
type ReactionButtonsFilterFunction = (msg: Message, emoji: Emoji, userID: string) => boolean;
type ReactionButtonsGenerator = ReactionButtonsGeneratorFunction | MessageContent | MessageContent[] | ReactionButtonsGeneratorFunction[];
type ReactionButtonsGeneratorFunction = (msg: Message, args: string[], userID: string) => GeneratorFunctionReturn;
// Gateway/REST
type IntentStrings = keyof Constants["Intents"];
type ReconnectDelayFunction = (lastDelay: number, attempts: number) => number;
type RequestMethod = "GET" | "PATCH" | "DELETE" | "POST" | "PUT";
// Guild
type DefaultNotifications = Constants["DefaultMessageNotificationLevels"][keyof Constants["DefaultMessageNotificationLevels"]];
type ExplicitContentFilter = Constants["ExplicitContentFilterLevels"][keyof Constants["ExplicitContentFilterLevels"]];
type GuildFeatures = Constants["GuildFeatures"][number];
type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]];
type PossiblyUncachedGuild = Guild | Uncached;
type PremiumTier = Constants["PremiumTiers"][keyof Constants["PremiumTiers"]];
type VerificationLevel = Constants["VerificationLevels"][keyof Constants["VerificationLevels"]];
type SystemChannelFlags = Constants["SystemChannelFlags"][keyof Constants["SystemChannelFlags"]];
type GuildIntegrationTypes = Constants["GuildIntegrationTypes"][number];
type GuildIntegrationExpireBehavior = Constants["GuildIntegrationExpireBehavior"][keyof Constants["GuildIntegrationExpireBehavior"]];
// Message
type ActionRowComponents = Button | SelectMenu;
type Button = InteractionButton | URLButton;
type Component = ActionRow | ActionRowComponents;
type ImageFormat = Constants["ImageFormats"][number];
type MessageContent = string | AdvancedMessageContent;
type MFALevel = Constants["MFALevels"][keyof Constants["MFALevels"]];
type MessageContentEdit = string | AdvancedMessageContentEdit;
type PossiblyUncachedMessage = Message | { channel: TextableChannel | { id: string; guild?: Uncached }; guildID?: string; id: string };
type InteractionType = Constants["ApplicationCommandTypes"][keyof Constants["ApplicationCommandTypes"]];
// Interaction
type InteractionDataOptions = InteractionDataOptionsSubCommand | InteractionDataOptionsSubCommandGroup | InteractionDataOptionsWithValue;
type InteractionDataOptionsWithValue = InteractionDataOptionsString | InteractionDataOptionsInteger | InteractionDataOptionsBoolean | InteractionDataOptionsUser | InteractionDataOptionsChannel | InteractionDataOptionsRole | InteractionDataOptionsMentionable | InteractionDataOptionsNumber;
interface InteractionDataOptionsSubCommand {
name: string;
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND"];
options?: InteractionDataOptions[];
}
interface InteractionDataOptionsSubCommandGroup {
name: string;
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND_GROUP"];
options: InteractionDataOptions[];
}
interface InteractionDataOptionWithValue<T extends (Constants["ApplicationCommandOptionTypes"])[Exclude<keyof Constants["ApplicationCommandOptionTypes"], "SUB_COMMAND" | "SUB_COMMAND_GROUP">] = (Constants["ApplicationCommandOptionTypes"])[Exclude<keyof Constants["ApplicationCommandOptionTypes"], "SUB_COMMAND" | "SUB_COMMAND_GROUP">], V = unknown> {
name: string;
type: T;
value: V;
focused?: boolean;
}
type InteractionDataOptionsString = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["STRING"], string>;
type InteractionDataOptionsInteger = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["INTEGER"], number>;
type InteractionDataOptionsBoolean = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["BOOLEAN"], boolean>;
type InteractionDataOptionsUser = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["USER"], string>;
type InteractionDataOptionsChannel = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["CHANNEL"], string>;
type InteractionDataOptionsRole = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["ROLE"], string>;
type InteractionDataOptionsMentionable = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["MENTIONABLE"], string>;
type InteractionDataOptionsNumber = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["NUMBER"], number>;
interface InteractionOptions {
type: Constants["InteractionResponseTypes"][keyof Constants["InteractionResponseTypes"]];
data?: unknown;
}
type InteractionContent = Pick<WebhookPayload, "content" | "embeds" | "allowedMentions" | "tts" | "flags" | "components">;
type InteractionEditContent = Pick<WebhookPayload, "content" | "embeds" | "allowedMentions" | "components">;
// Application Commands
type ApplicationCommandOptions = ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsSubCommandGroup | ApplicationCommandOptionsWithValue;
type ApplicationCommandOptionsWithValue = ApplicationCommandOptionsString | ApplicationCommandOptionsInteger | ApplicationCommandOptionsBoolean | ApplicationCommandOptionsUser | ApplicationCommandOptionsChannel | ApplicationCommandOptionsRole | ApplicationCommandOptionsMentionable | ApplicationCommandOptionsNumber;
interface ApplicationCommandOptionsSubCommand {
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND"];
name: string;
description: string;
options?: ApplicationCommandOptionsWithValue[];
}
interface ApplicationCommandOptionsSubCommandGroup {
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND_GROUP"];
name: string;
description: string;
options?: (ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsWithValue)[];
}
interface ApplicationCommandOptionChoice<T extends (Constants["ApplicationCommandOptionTypes"])[keyof Pick<Constants["ApplicationCommandOptionTypes"], "STRING" | "INTEGER" | "NUMBER">] | unknown
= unknown> {
name: string;
value: T extends Constants["ApplicationCommandOptionTypes"]["STRING"] ? string :
T extends Constants["ApplicationCommandOptionTypes"]["NUMBER"] ? number :
T extends Constants["ApplicationCommandOptionTypes"]["INTEGER"] ? number :
number | string;
}
interface ApplicationCommandOptionWithChoices<T extends (Constants["ApplicationCommandOptionTypes"])[keyof Pick<Constants["ApplicationCommandOptionTypes"], "STRING" | "INTEGER" | "NUMBER">]
= (Constants["ApplicationCommandOptionTypes"])[keyof Pick<Constants["ApplicationCommandOptionTypes"], "STRING" | "INTEGER" | "NUMBER">]> {
type: T;
name: string;
description: string;
required?: boolean;
choices?: ApplicationCommandOptionChoice<T>[];
autocomplete?: boolean;
}
interface ApplicationCommandOptionWithMinMax<T extends (Constants["ApplicationCommandOptionTypes"])[keyof Pick<Constants["ApplicationCommandOptionTypes"], "INTEGER" | "NUMBER">]
= (Constants["ApplicationCommandOptionTypes"])[keyof Pick<Constants["ApplicationCommandOptionTypes"], "INTEGER" | "NUMBER">]> {
type: T;
name: string;
description: string;
required?: boolean;
choices?: ApplicationCommandOptionChoice<T>[];
autocomplete?: boolean;
min_value?: number;
max_value?: number;
}
interface ApplicationCommandOption<T extends (Constants["ApplicationCommandOptionTypes"])[Exclude<keyof Constants["ApplicationCommandOptionTypes"], "SUB_COMMAND" | "SUB_COMMAND_GROUP">]> {
type: T;
name: string;
description: string;
required?: boolean;
}
// String
type ApplicationCommandOptionsString = ApplicationCommandOptionsStringWithAutocomplete | ApplicationCommandOptionsStringWithoutAutocomplete;
type ApplicationCommandOptionsStringWithAutocomplete = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["STRING"]>, "choices">
& { autocomplete: true };
type ApplicationCommandOptionsStringWithoutAutocomplete = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["STRING"]>, "autocomplete">
& { autocomplete?: false };
// Integer
type ApplicationCommandOptionsInteger = ApplicationCommandOptionsIntegerWithAutocomplete | ApplicationCommandOptionsIntegerWithoutAutocomplete | ApplicationCommandOptionsIntegerWithMinMax;
type ApplicationCommandOptionsIntegerWithAutocomplete = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["INTEGER"]>, "choices" | "min_value" | "max_value">
& { autocomplete: true };
type ApplicationCommandOptionsIntegerWithoutAutocomplete = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["INTEGER"]>, "autocomplete" | "min_value" | "max_value">
& {
autocomplete?: false;
min_value?: null;
max_value?: null;
};
type ApplicationCommandOptionsIntegerWithMinMax = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["INTEGER"]>, "choices" | "autocomplete">
& {
autocomplete?: false;
choices?: null;
};
// Boolean
type ApplicationCommandOptionsBoolean = ApplicationCommandOption<Constants["ApplicationCommandOptionTypes"]["BOOLEAN"]>;
// User
type ApplicationCommandOptionsUser = ApplicationCommandOption<Constants["ApplicationCommandOptionTypes"]["USER"]>;
// Channel
type ApplicationCommandOptionsChannel = ApplicationCommandOption<Constants["ApplicationCommandOptionTypes"]["CHANNEL"]> & { channel_types?: ChannelTypes };
// Role
type ApplicationCommandOptionsRole = ApplicationCommandOption<Constants["ApplicationCommandOptionTypes"]["ROLE"]>;
// Mentionable
type ApplicationCommandOptionsMentionable = ApplicationCommandOption<Constants["ApplicationCommandOptionTypes"]["MENTIONABLE"]>;
// Number
type ApplicationCommandOptionsNumber = ApplicationCommandOptionsNumberWithAutocomplete | ApplicationCommandOptionsNumberWithoutAutocomplete | ApplicationCommandOptionsNumberWithMinMax;
type ApplicationCommandOptionsNumberWithAutocomplete = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["NUMBER"]>, "choices" | "min_value" | "max_value">
& { autocomplete: true };
type ApplicationCommandOptionsNumberWithoutAutocomplete = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["NUMBER"]>, "autocomplete" | "min_value" | "max_value">
& {
autocomplete?: false;
min_value?: null;
max_value?: null;
};
type ApplicationCommandOptionsNumberWithMinMax = Omit<ApplicationCommandOptionWithChoices<Constants["ApplicationCommandOptionTypes"]["NUMBER"]>, "choices" | "autocomplete">
& {
autocomplete?: false;
choices?: null;
};
interface ApplicationCommand<T extends (Constants["ApplicationCommandTypes"])[keyof Constants["ApplicationCommandTypes"]]
= (Constants["ApplicationCommandTypes"])[keyof Constants["ApplicationCommandTypes"]]> {
id: string;
application_id: string;
guild_id?: string;
name: string;
// I think never is the best we can do
description: T extends Constants["ApplicationCommandTypes"]["CHAT_INPUT"] ? string : never;
options?: ApplicationCommandOptions[];
type: T;
defaultPermission?: boolean;
}
type AnyApplicationCommand = ChatInputApplicationCommand | MessageApplicationCommand | UserApplicationCommand;
type ChatInputApplicationCommand = ApplicationCommand<Constants["ApplicationCommandTypes"]["CHAT_INPUT"]>;
type UserApplicationCommand = Omit<ApplicationCommand<Constants["ApplicationCommandTypes"]["USER"]>, "description" | "options">;
type MessageApplicationCommand = Omit<ApplicationCommand<Constants["ApplicationCommandTypes"]["MESSAGE"]>, "description" | "options">;
type ApplicationCommandStructure = ChatInputApplicationCommandStructure | MessageApplicationCommandStructure | UserApplicationCommandStructure;
type ChatInputApplicationCommandStructure = Omit<ChatInputApplicationCommand, "id" | "application_id" | "guild_id">;
type MessageApplicationCommandStructure = Omit<MessageApplicationCommand, "id" | "application_id" | "guild_id">;
type UserApplicationCommandStructure = Omit<UserApplicationCommand, "id" | "application_id" | "guild_id">;
interface ApplicationCommandPermissions {
id: string;
type: Constants["ApplicationCommandPermissionTypes"][keyof Constants["ApplicationCommandPermissionTypes"]];
permission: boolean;
}
interface GuildApplicationCommandPermissions {
id: string;
application_id: string;
guild_id: string;
permissions?: ApplicationCommandPermissions[];
}
// Permission
type PermissionType = Constants["PermissionOverwriteTypes"][keyof Constants["PermissionOverwriteTypes"]];
// Presence/Relationship
type ActivityType = BotActivityType | Constants["ActivityTypes"]["CUSTOM"];
type BotActivityType = Constants["ActivityTypes"][Exclude<keyof Constants["ActivityTypes"], "CUSTOM">];
type FriendSuggestionReasons = { name: string; platform_type: string; type: number }[];
type Status = "online" | "idle" | "dnd" | "offline";
// Thread
type AutoArchiveDuration = 60 | 1440 | 4320 | 10080;
// Voice
type ConverterCommand = "./ffmpeg" | "./avconv" | "ffmpeg" | "avconv";
type StageInstancePrivacyLevel = Constants["StageInstancePrivacyLevel"][keyof Constants["StageInstancePrivacyLevel"]];
// Webhook
type MessageWebhookContent = Pick<WebhookPayload, "content" | "embeds" | "file" | "allowedMentions" | "components">;
// INTERFACES
// Internals
interface JSONCache {
[s: string]: unknown;
}
interface NestedJSON {
toJSON(arg?: unknown, cache?: (string | unknown)[]): JSONCache;
}
interface SimpleJSON {
toJSON(props?: string[]): JSONCache;
}
// Channel
interface ChannelFollow {
channel_id: string;
webhook_id: string;
}
interface CreateChannelOptions {
bitrate?: number;
nsfw?: boolean;
parentID?: string;
permissionOverwrites?: Overwrite[];
rateLimitPerUser?: number;
reason?: string;
topic?: string;
userLimit?: number;
}
interface EditChannelOptions extends Omit<CreateChannelOptions, "permissionOverwrites" | "reason"> {
archived?: boolean;
autoArchiveDuration?: AutoArchiveDuration;
defaultAutoArchiveDuration?: AutoArchiveDuration;
icon?: string;
invitable?: boolean;
locked?: boolean;
name?: string;
ownerID?: string;
rtcRegion?: string | null;
videoQualityMode?: VideoQualityMode;
}
interface EditChannelPositionOptions {
lockPermissions?: string;
parentID?: string;
}
interface GetMessagesOptions {
after?: string;
around?: string;
before?: string;
limit?: number;
}
interface GuildTextable extends Textable {
lastPinTimestamp: number | null;
rateLimitPerUser: number;
topic: string | null;
createWebhook(options: { name: string; avatar?: string | null }, reason?: string): Promise<Webhook>;
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
getWebhooks(): Promise<Webhook[]>;
purge(options: PurgeChannelOptions): Promise<number>;
removeMessageReactionEmoji(messageID: string, reaction: string): Promise<void>;
removeMessageReactions(messageID: string): Promise<void>;
}
interface PartialChannel {
bitrate?: number;
id: string;
name?: string;
nsfw?: boolean;
parent_id?: number;
permission_overwrites?: Overwrite[];
rate_limit_per_user?: number;
topic?: string;
type: number;
user_limit?: number;
}
interface PurgeChannelOptions {
after?: string;
before?: string;
filter?: (m: Message<GuildTextableChannel>) => boolean;
limit: number;
reason?: string;
}
interface Textable {
lastMessageID: string;
messages: Collection<Message<this>>;
addMessageReaction(messageID: string, reaction: string): Promise<void>;
/** @deprecated */
addMessageReaction(messageID: string, reaction: string, userID: string): Promise<void>;
createMessage(content: MessageContent, file?: FileContent | FileContent[]): Promise<Message<this>>;
deleteMessage(messageID: string, reason?: string): Promise<void>;
editMessage(messageID: string, content: MessageContentEdit): Promise<Message<this>>;
getMessage(messageID: string): Promise<Message<this>>;
getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
/** @deprecated */
getMessageReaction(messageID: string, reaction: string, limit?: number, before?: string, after?: string): Promise<User[]>;
getMessages(options?: GetMessagesOptions): Promise<Message<this>[]>;
/** @deprecated */
getMessages(limit?: number, before?: string, after?: string, around?: string): Promise<Message<this>[]>;
getPins(): Promise<Message<this>[]>;
pinMessage(messageID: string): Promise<void>;
removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise<void>;
sendTyping(): Promise<void>;
unpinMessage(messageID: string): Promise<void>;
unsendMessage(messageID: string): Promise<void>;
}
interface ThreadTextable extends Textable {
lastPinTimestamp?: number;
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
getMembers(): Promise<ThreadMember[]>;
join(userID: string): Promise<void>;
leave(userID: string): Promise<void>;
purge(options: PurgeChannelOptions): Promise<number>;
removeMessageReactionEmoji(messageID: string, reaction: string): Promise<void>;
removeMessageReactions(messageID: string): Promise<void>;
}
interface WebhookData {
channelID: string;
guildID: string;
}
// Client
interface ClientOptions {
/** @deprecated */
agent?: HTTPSAgent;
allowedMentions?: AllowedMentions;
autoreconnect?: boolean;
compress?: boolean;
connectionTimeout?: number;
defaultImageFormat?: string;
defaultImageSize?: number;
disableEvents?: { [s: string]: boolean };
firstShardID?: number;
getAllUsers?: boolean;
guildCreateTimeout?: number;
intents: number | IntentStrings[];
largeThreshold?: number;
lastShardID?: number;
/** @deprecated */
latencyThreshold?: number;
maxReconnectAttempts?: number;
maxResumeAttempts?: number;
maxShards?: number | "auto";
messageLimit?: number;
opusOnly?: boolean;
/** @deprecated */
ratelimiterOffset?: number;
reconnectDelay?: ReconnectDelayFunction;
requestTimeout?: number;
rest?: RequestHandlerOptions;
restMode?: boolean;
seedVoiceConnections?: boolean;
ws?: unknown;
}
interface CommandClientOptions {
argsSplitter?: (str: string) => string[];
defaultCommandOptions?: CommandOptions;
defaultHelpCommand?: boolean;
description?: string;
ignoreBots?: boolean;
ignoreSelf?: boolean;
name?: string;
owner?: string;
prefix?: string | string[];
}
interface RequestHandlerOptions {
agent?: HTTPSAgent;
baseURL?: string;
decodeReasons?: boolean;
disableLatencyCompensation?: boolean;
domain?: string;
latencyThreshold?: number;
ratelimiterOffset?: number;
requestTimeout?: number;
}
// Command
interface CommandCooldownExclusions {
channelIDs?: string[];
guildIDs?: string[];
userIDs?: string[];
}
interface CommandOptions {
aliases?: string[];
argsRequired?: boolean;
caseInsensitive?: boolean;
cooldown?: number;
cooldownExclusions?: CommandCooldownExclusions;
cooldownMessage?: MessageContent | GenericCheckFunction<MessageContent> | false;
cooldownReturns?: number;
defaultSubcommandOptions?: CommandOptions;
deleteCommand?: boolean;
description?: string;
dmOnly?: boolean;
errorMessage?: MessageContent | GenericCheckFunction<MessageContent>;
fullDescription?: string;
guildOnly?: boolean;
hidden?: boolean;
hooks?: Hooks;
invalidUsageMessage?: MessageContent | GenericCheckFunction<MessageContent> | false;
permissionMessage?: MessageContent | GenericCheckFunction<MessageContent> | false;
reactionButtons?: CommandReactionButtonsOptions[] | null;
reactionButtonTimeout?: number;
requirements?: CommandRequirements;
restartCooldown?: boolean;
usage?: string;
}
interface CommandReactionButtons extends CommandReactionButtonsOptions {
execute: (msg: Message, args: string[], userID: string) => string | GeneratorFunctionReturn;
responses: ((() => string) | ReactionButtonsGeneratorFunction)[];
}
interface CommandReactionButtonsOptions {
emoji: string;
filter: ReactionButtonsFilterFunction;
response: string | ReactionButtonsGeneratorFunction;
type: "edit" | "cancel";
}
interface CommandRequirements {
custom?: GenericCheckFunction<boolean>;
permissions?: { [s: string]: boolean } | GenericCheckFunction<{ [s: string]: boolean }>;
roleIDs?: string[] | GenericCheckFunction<string[]>;
roleNames?: string[] | GenericCheckFunction<string[]>;
userIDs?: string[] | GenericCheckFunction<string[]>;
}
interface Hooks {
postCheck?: (msg: Message, args: string[], checksPassed: boolean) => void;
postCommand?: (msg: Message, args: string[], sent?: Message) => void;
postExecution?: (msg: Message, args: string[], executionSuccess: boolean) => void;
preCommand?: (msg: Message, args: string[]) => void;
}
// Embed
// Omit<T, K> used to override
interface Embed extends Omit<EmbedOptions, "footer" | "image" | "thumbnail" | "author"> {
author?: EmbedAuthor;
footer?: EmbedFooter;
image?: EmbedImage;
provider?: EmbedProvider;
thumbnail?: EmbedImage;
type: string;
video?: EmbedVideo;
}
interface EmbedAuthor extends EmbedAuthorOptions {
proxy_icon_url?: string;
}
interface EmbedAuthorOptions {
icon_url?: string;
name: string;
url?: string;
}
interface EmbedField {
inline?: boolean;
name: string;
value: string;
}
interface EmbedFooter extends EmbedFooterOptions {
proxy_icon_url?: string;
}
interface EmbedFooterOptions {
icon_url?: string;
text: string;
}
interface EmbedImage extends EmbedImageOptions {
height?: number;
proxy_url?: string;
width?: number;
}
interface EmbedImageOptions {
url?: string;
}
interface EmbedOptions {
author?: EmbedAuthorOptions;
color?: number;
description?: string;
fields?: EmbedField[];
footer?: EmbedFooterOptions;
image?: EmbedImageOptions;
thumbnail?: EmbedImageOptions;
timestamp?: Date | string;
title?: string;
url?: string;
}
interface EmbedProvider {
name?: string;
url?: string;
}
interface EmbedVideo {
height?: number;
url?: string;
width?: number;
}
// Emoji
interface Emoji extends EmojiBase {
animated: boolean;
available: boolean;
id: string;
managed: boolean;
require_colons: boolean;
roles: string[];
user?: PartialUser;
}
interface EmojiBase {
icon?: string;
name: string;
}
interface EmojiOptions extends Exclude<EmojiBase, "icon"> {
image: string;
roles?: string[];
}
interface PartialEmoji {
id: string | null;
name: string;
animated?: boolean;
}
// Events
interface OldCall {
endedTimestamp?: number;
participants: string[];
region: string;
ringing: string[];
unavailable: boolean;
}
interface OldGroupChannel {
name: string;
ownerID: string;
icon: string;
type: Constants["ChannelTypes"]["GROUP_DM"];
}
interface OldGuild {
afkChannelID: string | null;
afkTimeout: number;
banner: string | null;
defaultNotifications: DefaultNotifications;
description: string | null;
discoverySplash: string | null;
emojis: Omit<Emoji, "user" | "icon">[];
explicitContentFilter: ExplicitContentFilter;
features: GuildFeatures[];
icon: string | null;
large: boolean;
maxMembers?: number;
maxVideoChannelUsers?: number;
mfaLevel: MFALevel;
name: string;
/** @deprecated */
nsfw: boolean;
nsfwLevel: NSFWLevel;
ownerID: string;
preferredLocale?: string;
premiumSubscriptionCount?: number;
premiumTier: PremiumTier;
publicUpdatesChannelID: string | null;
rulesChannelID: string | null;
splash: string | null;
stickers?: Sticker[];
systemChannelFlags: SystemChannelFlags;
systemChannelID: string | null;
vanityURL: string | null;
verificationLevel: VerificationLevel;
}
interface OldGuildChannel {
bitrate?: number;
name: string;
nsfw?: boolean;
parentID: string | null;
permissionOverwrites: Collection<PermissionOverwrite>;
position: number;
rateLimitPerUser?: number;
rtcRegion?: string | null;
topic?: string | null;
type: GuildChannelTypes;
}
interface OldGuildTextChannel extends OldGuildChannel {
nsfw: boolean;
rateLimitPerUser: number;
topic: string | null;
type: GuildTextChannelTypes;
}
interface OldGuildVoiceChannel extends OldGuildChannel {
bitrate: number;
rtcRegion: string | null;
type: GuildVoiceChannelTypes;
userLimit: number;
videoQualityMode: VideoQualityMode;
}
interface OldMember {
avatar: string | null;
nick: string | null;
pending?: boolean;
premiumSince: number;
roles: string[];
}
interface OldMessage {
attachments: Attachment[];
channelMentions: string[];
content: string;
editedTimestamp?: number;
embeds: Embed[];
flags: number;
mentionedBy?: unknown;
mentions: string[];
pinned: boolean;
roleMentions: string[];
tts: boolean;
}
interface OldRole {
color: number;
hoist: boolean;
icon: string | null;
managed: boolean;
mentionable: boolean;
name: string;
permissions: Permission;
position: number;
unicodeEmoji: string | null;
}
interface OldStageInstance {
discoverableDisabled: boolean;
privacyLevel: StageInstancePrivacyLevel;
topic: string;
}
interface OldThread {
name: string;
rateLimitPerUser: number;
threadMetadata: ThreadMetadata;
}
interface OldThreadMember {
flags: number;
}
interface OldVoiceState {
deaf: boolean;
mute: boolean;
selfDeaf: boolean;
selfMute: boolean;
selfStream: boolean;
selfVideo: boolean;
}
interface EventListeners {
callCreate: [call: Call];
callDelete: [call: Call];
callRing: [call: Call];
callUpdate: [call: Call, oldCall: OldCall];
channelCreate: [channel: AnyChannel];
channelDelete: [channel: AnyChannel];
channelPinUpdate: [channel: TextableChannel, timestamp: number, oldTimestamp: number];
channelRecipientAdd: [channel: GroupChannel, user: User];
channelRecipientRemove: [channel: GroupChannel, user: User];
channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldGuildVoiceChannel]
| [channel: GroupChannel, oldChannel: OldGroupChannel];
connect: [id: number];
debug: [message: string, id?: number];
disconnect: [];
error: [err: Error, id?: number];
friendSuggestionCreate: [user: User, reasons: FriendSuggestionReasons];
friendSuggestionDelete: [user: User];
guildAvailable: [guild: Guild];
guildBanAdd: [guild: Guild, user: User];
guildBanRemove: [guild: Guild, user: User];
guildCreate: [guild: Guild];
guildDelete: [guild: PossiblyUncachedGuild];
guildEmojisUpdate: [guild: PossiblyUncachedGuild, emojis: Emoji[], oldEmojis: Emoji[] | null];
guildMemberAdd: [guild: Guild, member: Member];
guildMemberChunk: [guild: Guild, member: Member[]];
guildMemberRemove: [guild: Guild, member: Member | MemberPartial];
guildMemberUpdate: [guild: Guild, member: Member, oldMember: OldMember | null];
guildRoleCreate: [guild: Guild, role: Role];
guildRoleDelete: [guild: Guild, role: Role];
guildRoleUpdate: [guild: Guild, role: Role, oldRole: OldRole];
guildStickersUpdate: [guild: PossiblyUncachedGuild, stickers: Sticker[], oldStickers: Sticker[] | null];
guildUnavailable: [guild: UnavailableGuild];
guildUpdate: [guild: Guild, oldGuild: OldGuild];
hello: [trace: string[], id: number];
interactionCreate: [interaction: PingInteraction | CommandInteraction | ComponentInteraction | AutocompleteInteraction | UnknownInteraction];
inviteCreate: [guild: Guild, invite: Invite];
inviteDelete: [guild: Guild, invite: Invite];
messageCreate: [message: Message<PossiblyUncachedTextableChannel>];
messageDelete: [message: PossiblyUncachedMessage];
messageDeleteBulk: [messages: PossiblyUncachedMessage[]];
messageReactionAdd: [message: PossiblyUncachedMessage, emoji: PartialEmoji, reactor: Member | Uncached];
messageReactionRemove: [message: PossiblyUncachedMessage, emoji: PartialEmoji, userID: string];
messageReactionRemoveAll: [message: PossiblyUncachedMessage];
messageReactionRemoveEmoji: [message: PossiblyUncachedMessage, emoji: PartialEmoji];
messageUpdate: [message: Message<PossiblyUncachedTextableChannel>, oldMessage: OldMessage | null];
presenceUpdate: [other: Member | Relationship, oldPresence: Presence | null];
rawREST: [request: RawRESTRequest];
rawWS: [packet: RawPacket, id: number];
ready: [];
relationshipAdd: [relationship: Relationship];
relationshipRemove: [relationship: Relationship];
relationshipUpdate: [relationship: Relationship, oldRelationship: { type: number }];
shardPreReady: [id: number];
stageInstanceCreate: [stageInstance: StageInstance];
stageInstanceDelete: [stageInstance: StageInstance];
stageInstanceUpdate: [stageInstance: StageInstance, oldStageInstance: OldStageInstance | null];
threadCreate: [channel: AnyThreadChannel];
threadDelete: [channel: AnyThreadChannel];
threadListSync: [guild: Guild, deletedThreads: (AnyThreadChannel | Uncached)[], activeThreads: AnyThreadChannel[], joinedThreadsMember: ThreadMember[]];
threadMembersUpdate: [channel: AnyThreadChannel, addedMembers: ThreadMember[], removedMembers: (ThreadMember | Uncached)[]];
threadMemberUpdate: [channel: AnyThreadChannel, member: ThreadMember, oldMember: OldThreadMember];
threadUpdate: [channel: AnyThreadChannel, oldChannel: OldThread | null];
typingStart: [channel: GuildTextableChannel | Uncached, user: User | Uncached, member: Member]
| [channel: PrivateChannel | Uncached, user: User | Uncached, member: null];
unavailableGuildCreate: [guild: UnavailableGuild];
unknown: [packet: RawPacket, id?: number];
userUpdate: [user: User, oldUser: PartialUser | null];
voiceChannelJoin: [member: Member, channel: AnyVoiceChannel];
voiceChannelLeave: [member: Member, channel: AnyVoiceChannel];
voiceChannelSwitch: [member: Member, newChannel: AnyVoiceChannel, oldChannel: AnyVoiceChannel];
voiceStateUpdate: [member: Member, oldState: OldVoiceState];
warn: [message: string, id?: number];
webhooksUpdate: [data: WebhookData];
}
interface ClientEvents extends EventListeners {
shardDisconnect: [err: Error | undefined, id: number];
shardReady: [id: number];
shardResume: [id: number];
}
interface ShardEvents extends EventListeners {
resume: [];
}
interface StreamEvents {
end: [];
error: [err: Error];
start: [];
}
interface VoiceEvents {
connect: [];
debug: [message: string];
disconnect: [err?: Error];
end: [];
error: [err: Error];
pong: [latency: number];
ready: [];
speakingStart: [userID: string];
speakingStop: [userID: string];
start: [];
unknown: [packet: RawPacket];
userDisconnect: [userID: string];
warn: [message: string];
}
// Gateway/REST
interface HTTPResponse {
code: number;
message: string;
}
interface LatencyRef {
lastTimeOffsetCheck: number;
latency: number;
raw: number[];
timeOffset: number;
timeOffsets: number[];
}
interface RawPacket {
d?: unknown;
op: number;
s?: number;
t?: string;
}
interface RawRESTRequest {
auth: boolean;
body?: unknown;
file?: FileContent;
method: string;
resp: IncomingMessage;
route: string;
short: boolean;
url: string;
}
interface RequestMembersPromise {
members: Member;
received: number;
res: (value: Member[]) => void;
timeout: NodeJS.Timeout;
}
// Guild
interface CreateGuildOptions {
afkChannelID?: string;
afkTimeout?: number;
channels?: PartialChannel[];
defaultNotifications?: DefaultNotifications;
explicitContentFilter?: ExplicitContentFilter;
icon?: string;
roles?: PartialRole[];
systemChannelID: string;
verificationLevel?: VerificationLevel;
}
interface DiscoveryCategory {
id: number;
is_primary: boolean;
name: {
default: string;
localizations?: { [lang: string]: string };
};
}
interface DiscoveryMetadata {
category_ids: number[];
emoji_discoverability_enabled: boolean;
guild_id: string;
keywords: string[] | null;
primary_category_id: number;
}
interface DiscoveryOptions {
emojiDiscoverabilityEnabled?: boolean;
keywords?: string[];
primaryCategoryID?: string;
reason?: string;
}
interface DiscoverySubcategoryResponse {
category_id: number;
guild_id: string;
}
interface GetGuildAuditLogOptions {
actionType?: number;
before?: string;
limit?: number;
userID?: string;
}
interface GetPruneOptions {
days?: number;
includeRoles?: string[];
}
interface GetRESTGuildMembersOptions {
after?: string;
limit?: number;
}
interface GetRESTGuildsOptions {
after?: string;
before?: string;
limit?: number;
}
interface GuildAuditLog {
entries: GuildAuditLogEntry[];
integrations: GuildIntegration[];
threads: AnyThreadChannel[];
users: User[];
webhooks: Webhook[];
}
interface GuildOptions {
afkChannelID?: string;
afkTimeout?: number;
banner?: string;
defaultNotifications?: DefaultNotifications;
description?: string;
discoverySplash?: string;
explicitContentFilter?: ExplicitContentFilter;
features?: GuildFeatures[]; // Though only some are editable?
icon?: string;
name?: string;
ownerID?: string;
preferredLocale?: string;
publicUpdatesChannelID?: string;
rulesChannelID?: string;
splash?: string;
systemChannelFlags?: number;
systemChannelID?: string;
verificationLevel?: VerificationLevel;
}
interface GuildTemplateOptions {
name?: string;
description?: string | null;
}
interface GuildVanity {
code: string | null;
uses: number;
}
interface IntegrationApplication {
bot?: User;
description: string;
icon: string | null;
id: string;
name: string;
summary: string;
}
interface IntegrationOptions {
enableEmoticons?: string;
expireBehavior?: string;
expireGracePeriod?: string;
}
interface PruneMemberOptions extends GetPruneOptions {
computePruneCount?: boolean;
reason?: string;
}
interface VoiceRegion {
custom: boolean;
deprecated: boolean;
id: string;
name: string;
optimal: boolean;
vip: boolean;
}
interface WelcomeChannel {
channelID: string;
description: string;
emojiID: string | null;
emojiName: string | null;
}
interface WelcomeScreen {
description: string;
welcomeChannels: WelcomeChannel[];
}
interface WelcomeScreenOptions extends WelcomeScreen {
enabled: boolean;
}
interface Widget {
channel_id?: string;
enabled: boolean;
}
interface WidgetChannel {
id: string;
name: string;
position: number;
}
interface WidgetData {
channels: WidgetChannel[];
id: string;
instant_invite: string;
members: WidgetMember[];
name: string;
presence_count: number;
}
interface WidgetMember {
avatar: string | null;
avatar_url: string;
discriminator: string;
id: string;
status: string;
username: string;
}
// Invite
interface CreateChannelInviteOptions extends CreateInviteOptions {
targetApplicationID?: string;
targetType?: Constants["InviteTargetTypes"][keyof Constants["InviteTargetTypes"]];
targetUserID?: string;