forked from projectdysnomia/dysnomia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
3923 lines (3793 loc) · 152 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, IncomingHttpHeaders } from "http";
import OpusScript = require("opusscript"); // Thanks TypeScript
import { URL } from "url";
import { Socket as DgramSocket } from "dgram";
import * as WebSocket from "ws";
declare namespace Dysnomia {
export const Constants: Constants;
export const VERSION: string;
// TYPES
// Application Command
type AnyApplicationCommand<W extends boolean = false> = ChatInputApplicationCommand<W> | MessageApplicationCommand<W> | UserApplicationCommand<W>;
type ApplicationCommandOptions = ApplicationCommandOptionsWithOptions | ApplicationCommandOptionsWithValue;
type ApplicationCommandOptionsTypes = Constants["ApplicationCommandOptionTypes"][keyof Constants["ApplicationCommandOptionTypes"]];
type ApplicationCommandOptionsTypesWithAutocomplete = Constants["ApplicationCommandOptionTypes"][keyof Pick<Constants["ApplicationCommandOptionTypes"], "STRING" | "INTEGER" | "NUMBER">];
type ApplicationCommandOptionsTypesWithChoices = Constants["ApplicationCommandOptionTypes"][keyof Pick<Constants["ApplicationCommandOptionTypes"], "STRING" | "INTEGER" | "NUMBER">];
type ApplicationCommandOption<T extends keyof Constants["ApplicationCommandOptionTypes"]> = ApplicationCommandOptionBase<Constants["ApplicationCommandOptionTypes"][T]>;
type ApplicationCommandOptionAutocomplete<T extends "INTEGER" | "NUMBER" | "STRING"> = (ApplicationCommandOption<T> & ApplicationCommandOptionsAutocomplete);
type ApplicationCommandOptionChannelTypes<T extends "CHANNEL"> = (ApplicationCommandOption<T> & ApplicationCommandOptionsChannelTypes);
type ApplicationCommandOptionChoices<T extends "INTEGER" | "NUMBER" | "STRING"> = (ApplicationCommandOption<T> & ApplicationCommandOptionsChoices<Constants["ApplicationCommandOptionTypes"][T]>);
type ApplicationCommandOptionMinMaxValue<T extends "INTEGER" | "NUMBER"> = (ApplicationCommandOption<T> & ApplicationCommandOptionsMinMaxValue);
type ApplicationCommandOptionMinMaxLength<T extends "STRING"> = (ApplicationCommandOption<T> & ApplicationCommandOptionsMinMaxLength);
type ApplicationCommandOptionsAttachment = ApplicationCommandOption<"ATTACHMENT">;
type ApplicationCommandOptionsBoolean = ApplicationCommandOption<"BOOLEAN">;
type ApplicationCommandOptionsChannel = ApplicationCommandOptionChannelTypes<"CHANNEL">;
type ApplicationCommandOptionsInteger = ApplicationCommandOptionAutocomplete<"INTEGER"> | ApplicationCommandOptionChoices<"INTEGER"> | ApplicationCommandOptionMinMaxValue<"INTEGER">;
type ApplicationCommandOptionsMentionable = ApplicationCommandOption<"MENTIONABLE">;
type ApplicationCommandOptionsNumber = ApplicationCommandOptionAutocomplete<"NUMBER"> | ApplicationCommandOptionChoices<"NUMBER"> | ApplicationCommandOptionMinMaxValue<"NUMBER">;
type ApplicationCommandOptionsRole = ApplicationCommandOption<"ROLE">;
type ApplicationCommandOptionsString = ApplicationCommandOptionAutocomplete<"STRING"> | ApplicationCommandOptionChoices<"STRING"> | ApplicationCommandOptionMinMaxLength<"STRING">;
type ApplicationCommandOptionsUser = ApplicationCommandOption<"USER">;
type ApplicationCommandOptionsWithOptions = ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsSubCommandGroup;
type ApplicationCommandOptionsWithValue = ApplicationCommandOptionsString | ApplicationCommandOptionsInteger | ApplicationCommandOptionsBoolean | ApplicationCommandOptionsUser | ApplicationCommandOptionsChannel | ApplicationCommandOptionsRole | ApplicationCommandOptionsMentionable | ApplicationCommandOptionsNumber | ApplicationCommandOptionsAttachment;
type ApplicationCommandStructure = ChatInputApplicationCommandStructure | MessageApplicationCommandStructure | UserApplicationCommandStructure;
type ApplicationCommandStructureConversion<T extends ApplicationCommandStructure, W extends boolean = false> = T extends ChatInputApplicationCommandStructure ?
ChatInputApplicationCommand<W> : T extends MessageApplicationCommandStructure ?
MessageApplicationCommand<W> : T extends UserApplicationCommandStructure ?
UserApplicationCommand<W> : never;
type ApplicationCommandTypes = Constants["ApplicationCommandTypes"][keyof Constants["ApplicationCommandTypes"]];
type ApplicationRoleConnectionMetadataTypes = Constants["RoleConnectionMetadataTypes"][keyof Constants["RoleConnectionMetadataTypes"]];
type ChatInputApplicationCommand<W extends boolean = false> = ApplicationCommand<"CHAT_INPUT", W>;
type MessageApplicationCommand<W extends boolean = false> = ApplicationCommand<"MESSAGE", W>;
type MessageApplicationCommandStructure = ApplicationCommandStructureBase<"MESSAGE">;
type ModalSubmitInteractionDataComponent = ModalSubmitInteractionDataTextInputComponent;
type UserApplicationCommand<W extends boolean = false> = ApplicationCommand<"USER", W>;
type UserApplicationCommandStructure = ApplicationCommandStructureBase<"USER">;
// Auto Moderation
type AutoModerationActionType = Constants["AutoModerationActionTypes"][keyof Constants["AutoModerationActionTypes"]];
type AutoModerationEventType = Constants["AutoModerationEventTypes"][keyof Constants["AutoModerationEventTypes"]];
type AutoModerationKeywordPresetType = Constants["AutoModerationKeywordPresetTypes"][keyof Constants["AutoModerationKeywordPresetTypes"]];
type AutoModerationTriggerType = Constants["AutoModerationTriggerTypes"][keyof Constants["AutoModerationTriggerTypes"]];
type EditAutoModerationRuleOptions = Partial<Omit<CreateAutoModerationRuleOptions, "triggerType">>;
// Cache
interface Uncached { id: string }
// Channel
type AnyChannel = AnyGuildChannel | PrivateChannel;
type AnyGuildChannel = GuildTextableChannel | AnyVoiceChannel | CategoryChannel;
type AnyThreadChannel = NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | ThreadChannel;
type AnyVoiceChannel = TextVoiceChannel | StageChannel;
type GuildTextableChannel = TextChannel | TextVoiceChannel | NewsChannel | StageChannel;
type GuildTextableWithThreads = GuildTextableChannel | AnyThreadChannel;
type InviteChannel = InvitePartialChannel | Exclude<AnyGuildChannel, CategoryChannel | AnyThreadChannel>;
type PossiblyUncachedInteractionChannel = TextableChannel | PartialChannel;
type PossiblyUncachedSpeakableChannel = VoiceChannel | StageChannel | Uncached;
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_ANNOUNCEMENT">];
type GuildThreadChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "ANNOUNCEMENT_THREAD" | "PRIVATE_THREAD" | "PUBLIC_THREAD">];
type GuildThreadOnlyChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "GUILD_FORUM" | "GUILD_MEDIA">];
type GuildPublicThreadChannelTypes = Exclude<GuildThreadChannelTypes, Constants["ChannelTypes"]["PRIVATE_THREAD"]>;
type GuildVoiceChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "GUILD_VOICE" | "GUILD_STAGE_VOICE">];
type PrivateChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "DM" | "GROUP_DM">];
type TextVoiceChannelTypes = Constants["ChannelTypes"][keyof Pick<Constants["ChannelTypes"], "GUILD_VOICE" | "GUILD_STAGE_VOICE">];
type ThreadSortingOrders = Constants["ThreadSortingOrders"][keyof Constants["ThreadSortingOrders"]];
type ForumLayoutTypes = Constants["ForumLayoutTypes"][keyof Constants["ForumLayoutTypes"]];
// Client
type MembershipStates = Constants["MembershipState"][keyof Constants["MembershipState"]];
// 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 GuildScheduledEventEditOptions<T extends GuildScheduledEventEntityTypes> = GuildScheduledEventEditOptionsExternal | GuildScheduledEventEditOptionsDiscord | GuildScheduledEventEditOptionsBase<T>;
type GuildScheduledEventOptions<T extends GuildScheduledEventEntityTypes> = GuildScheduledEventOptionsExternal | GuildScheduledEventOptionsDiscord | GuildScheduledEventOptionsBase<T>;
type GuildScheduledEventEntityTypes = Constants["GuildScheduledEventEntityTypes"][keyof Constants["GuildScheduledEventEntityTypes"]];
type GuildScheduledEventPrivacyLevel = Constants["GuildScheduledEventPrivacyLevel"][keyof Constants["GuildScheduledEventPrivacyLevel"]];
type GuildScheduledEventStatus = Constants["GuildScheduledEventStatus"][keyof Constants["GuildScheduledEventStatus"]];
type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]];
type OnboardingModes = Constants["OnboardingModes"][keyof Constants["OnboardingModes"]];
type OnboardingPromptTypes = Constants["OnboardingPromptTypes"][keyof Constants["OnboardingPromptTypes"]];
type PossiblyUncachedGuild = Guild | Uncached;
type PossiblyUncachedGuildScheduledEvent = GuildScheduledEvent | 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"]];
// Interaction
type AnyInteraction = AnyInteractionGateway | PingInteraction;
type AnyInteractionGateway = AutocompleteInteraction | CommandInteraction | ComponentInteraction | ModalSubmitInteraction;
type InteractionContent = Pick<WebhookPayload, "content" | "embeds" | "allowedMentions" | "tts" | "flags" | "components" | "attachments">;
type InteractionContentEdit = Omit<InteractionContent, "tts" | "flags">;
type InteractionDataOption<T extends Exclude<keyof Constants["ApplicationCommandOptionTypes"], "SUB_COMMAND" | "SUB_COMMAND_GROUP">, V = boolean | number | string> = InteractionDataOptionsBase<Constants["ApplicationCommandOptionTypes"][T], V>;
type InteractionDataOptions = InteractionDataOptionsWithOptions | InteractionDataOptionsWithValue;
type InteractionDataOptionsBoolean = InteractionDataOption<"BOOLEAN", boolean>;
type InteractionDataOptionsChannel = InteractionDataOption<"CHANNEL", string>;
type InteractionDataOptionsInteger = InteractionDataOption<"INTEGER", number>;
type InteractionDataOptionsMentionable = InteractionDataOption<"MENTIONABLE", string>;
type InteractionDataOptionsNumber = InteractionDataOption<"NUMBER", number>;
type InteractionDataOptionsRole = InteractionDataOption<"ROLE", string>;
type InteractionDataOptionsString = InteractionDataOption<"STRING", string>;
type InteractionDataOptionsUser = InteractionDataOption<"USER", string>;
type InteractionDataOptionsWithOptions = InteractionDataOptionsSubCommand | InteractionDataOptionsSubCommandGroup;
type InteractionDataOptionsWithValue = InteractionDataOptionsString | InteractionDataOptionsInteger | InteractionDataOptionsBoolean | InteractionDataOptionsUser | InteractionDataOptionsChannel | InteractionDataOptionsRole | InteractionDataOptionsMentionable | InteractionDataOptionsNumber;
type InteractionResponse = InteractionResponseAutocomplete | InteractionResponseDeferred | InteractionResponseMessage;
type InteractionTypes = Constants["InteractionTypes"][keyof Constants["InteractionTypes"]];
// Invite
type InviteTargetTypes = Constants["InviteTargetTypes"][keyof Constants["InviteTargetTypes"]];
// Message
type ActionRowComponents = Button | SelectMenu;
type BaseSelectMenuTypes = Exclude<SelectMenuTypes, SelectMenuExtendedTypes>;
type Button = InteractionButton | URLButton;
type ButtonStyles = Constants["ButtonStyles"][keyof Constants["ButtonStyles"]];
type ButtonStyleNormal = Exclude<ButtonStyles, ButtonStyleLink>;
type ButtonStyleLink = Constants["ButtonStyles"]["LINK"];
type Component = ActionRow | ActionRowComponents;
type ComponentTypes = Constants["ComponentTypes"][keyof Constants["ComponentTypes"]];
type ImageFormat = Constants["ImageFormats"][number];
type MessageActivityTypes = Constants["MessageActivityTypes"][keyof Constants["MessageActivityTypes"]];
type MessageContent = string | AdvancedMessageContent;
type MFALevel = Constants["MFALevels"][keyof Constants["MFALevels"]];
type PossiblyUncachedMessage = Message | { author?: User | Uncached; channel: TextableChannel | { id: string; guild?: Uncached }; guildID?: string; id: string };
type SelectMenu = BaseSelectMenu | ChannelSelectMenu | StringSelectMenu | UserSelectMenu | RoleSelectMenu | MentionableSelectMenu;
type SelectMenuTypes = Constants["ComponentTypes"][keyof Pick<Constants["ComponentTypes"], "STRING_SELECT" | "USER_SELECT" | "ROLE_SELECT" | "MENTIONABLE_SELECT" | "CHANNEL_SELECT">];
type SelectMenuExtendedTypes = Constants["ComponentTypes"][keyof Pick<Constants["ComponentTypes"], "STRING_SELECT" | "CHANNEL_SELECT" | "ROLE_SELECT" | "USER_SELECT" | "MENTIONABLE_SELECT">];
// Permission
type PermissionType = Constants["PermissionOverwriteTypes"][keyof Constants["PermissionOverwriteTypes"]];
// Presence/Relationship
type ActivityFlags = Constants["ActivityFlags"][keyof Constants["ActivityFlags"]];
type ActivityType = Constants["ActivityTypes"][keyof Constants["ActivityTypes"]];
/** @deprecated This is equivalent to ActivityType, use that type instead */
type BotActivityType = ActivityType;
type FriendSuggestionReasons = { name: string; platform_type: string; type: number }[];
type Status = "online" | "idle" | "dnd";
type SelfStatus = Status | "invisible";
type UserStatus = Status | "offline";
// Selfbot
type ConnectionVisibilityTypes = Constants["ConnectionVisibilityTypes"][keyof Constants["ConnectionVisibilityTypes"]];
// Sticker
type StickerTypes = Constants["StickerTypes"][keyof Constants["StickerTypes"]];
type StickerFormats = Constants["StickerFormats"][keyof Constants["StickerFormats"]];
// Thread
type AutoArchiveDuration = 60 | 1440 | 4320 | 10080;
// User
type PremiumTypes = Constants["PremiumTypes"][keyof Constants["PremiumTypes"]];
// Voice
type ConverterCommand = "./ffmpeg" | "./avconv" | "ffmpeg" | "avconv";
type StageInstancePrivacyLevel = Constants["StageInstancePrivacyLevel"][keyof Constants["StageInstancePrivacyLevel"]];
// Webhook
type MessageWebhookContent = Pick<WebhookPayload, "content" | "embeds" | "allowedMentions" | "components" | "attachments" | "threadID">;
type WebhookTypes = Constants["WebhookTypes"][keyof Constants["WebhookTypes"]];
// INTERFACES
// Internals
interface JSONCache {
[s: string]: unknown;
}
interface NestedJSON {
toJSON(arg?: unknown, cache?: (string | unknown)[]): JSONCache;
}
interface SimpleJSON {
toJSON(props?: string[]): JSONCache;
}
// Application Command
interface ApplicationCommandStructureBase<T extends keyof Constants["ApplicationCommandTypes"] = keyof Constants["ApplicationCommandTypes"]> {
defaultMemberPermissions?: bigint | number | string | Permission;
dmPermission?: boolean;
name: string;
nameLocalizations?: Record<string, string>;
nsfw?: boolean;
type: Constants["ApplicationCommandTypes"][T];
}
interface ApplicationCommandOptionBase<T extends ApplicationCommandOptionsTypes> {
description: string;
description_localizations?: Record<string, string>;
name: string;
name_localizations?: Record<string, string>;
required?: T extends Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND" | "SUB_COMMAND_GROUP"] ? never : boolean;
type: T;
}
interface ApplicationCommandOptionsAutocomplete {
autocomplete?: boolean;
}
interface ApplicationCommandOptionsChoice<T extends ApplicationCommandOptionsTypesWithChoices = ApplicationCommandOptionsTypesWithChoices> {
name: string;
value:
T extends Constants["ApplicationCommandOptionTypes"]["STRING"] ? string :
T extends Constants["ApplicationCommandOptionTypes"]["INTEGER" | "NUMBER"] ? number :
unknown;
}
interface ApplicationCommandOptionsChannelTypes {
channel_types?: GuildChannelTypes[];
}
interface ApplicationCommandOptionsChoices<T extends ApplicationCommandOptionsTypesWithChoices = ApplicationCommandOptionsTypesWithChoices> { choices?: ApplicationCommandOptionsChoice<T>[] }
interface ApplicationCommandOptionsMinMaxValue {
max_value?: number;
min_value?: number;
}
interface ApplicationCommandOptionsMinMaxLength {
max_length?: number;
min_length?: number;
}
interface ApplicationCommandOptionsSubCommand extends ApplicationCommandOptionBase<Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND"]> {
options?: ApplicationCommandOptionsWithValue[];
}
interface ApplicationCommandOptionsSubCommandGroup extends ApplicationCommandOptionBase<Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND_GROUP"]> {
options?: (ApplicationCommandOptionsSubCommand | ApplicationCommandOptionsWithValue)[];
}
interface ApplicationCommandPermissions {
id: string;
permission: boolean;
type: Constants["ApplicationCommandPermissionTypes"][keyof Constants["ApplicationCommandPermissionTypes"]];
}
interface ApplicationRoleConnectionMetadata {
description: string;
descriptionLocalizations?: Record<string, string>;
key: string;
name: string;
nameLocalizations?: Record<string, string>;
type: ApplicationRoleConnectionMetadataTypes;
}
interface ChatInputApplicationCommandStructure extends ApplicationCommandStructureBase<"CHAT_INPUT"> {
description: string;
descriptionLocalizations?: Record<string, string>;
options?: ApplicationCommandOptions[];
}
interface GuildApplicationCommandPermissions {
application_id: string;
guild_id: string;
id: string;
permissions: ApplicationCommandPermissions[];
}
// Auto Moderation
interface AutoModerationAction {
metadata?: AutoModerationActionMetadata;
type: AutoModerationActionType;
}
interface AutoModerationActionExecution {
action: AutoModerationAction;
alertSystemMessageID?: string;
channelID?: string;
content?: string;
guildID: string;
matchedContent?: string | null;
matchedKeyword: string | null;
messageID?: string;
ruleID: string;
ruleTriggerType: AutoModerationTriggerType;
userID: string;
}
interface AutoModerationActionMetadata {
/** valid for SEND_ALERT_MESSAGE */
channel_id?: string;
/** valid for BLOCK_MESSAGE */
custom_message?: string;
/** valid for TIMEOUT */
duration_seconds?: number;
}
interface CreateAutoModerationRuleOptions {
actions: AutoModerationAction[];
enabled?: boolean;
eventType: AutoModerationEventType;
exemptChannels?: string[];
exemptRoles?: string[];
name: string;
reason?: string;
triggerMetadata?: Partial<AutoModerationTriggerMetadata>;
triggerType: AutoModerationTriggerType;
}
interface AutoModerationTriggerMetadata {
/** valid for KEYWORD */
allow_list: string[];
/** valid for KEYWORD */
keyword_filter: string[];
/** valid for MENTION_SPAM */
mention_total_limit: number;
/** valid for MENTION_SPAM */
mention_raid_protection_enabled: boolean;
/** valid for KEYWORD_PRESET */
presets: AutoModerationKeywordPresetType[];
/** valid for KEYWORD */
regex_patterns: string[];
}
// Channel
interface ChannelFollow {
channel_id: string;
webhook_id: string;
}
interface ChannelPosition {
id: string;
position?: number;
lockPermissions?: boolean;
parentID?: string;
}
interface CreateChannelOptions {
availableTags?: (Required<Pick<ForumTag, "name">> & Partial<ForumTag>)[];
bitrate?: number;
defaultAutoArchiveDuration?: AutoArchiveDuration;
defaultForumLayout?: ForumLayoutTypes;
defaultReactionEmoji?: ForumDefaultReactionEmoji | null;
defaultSortOrder?: ThreadSortingOrders | null;
defaultThreadRateLimitPerUser?: number | null;
nsfw?: boolean;
parentID?: string;
permissionOverwrites?: Overwrite[];
position?: number;
rateLimitPerUser?: number;
reason?: string;
rtcRegion?: string | null;
topic?: string;
userLimit?: number;
videoQualityMode?: VideoQualityMode;
}
interface EditChannelOptions extends Omit<CreateChannelOptions, "reason"> {
archived?: boolean;
appliedTags?: string[];
autoArchiveDuration?: AutoArchiveDuration;
flags?: number;
invitable?: boolean;
locked?: boolean;
name?: string;
}
interface EditChannelPositionOptions {
lockPermissions?: string;
parentID?: string;
}
interface ForumTag {
id: string;
name: string;
moderated: boolean;
emojiID?: string | null;
emojiName?: string | null;
}
interface ForumDefaultReactionEmoji {
emojiID?: string | null;
emojiName?: string | null;
}
interface GetMessagesOptions {
after?: string;
around?: string;
before?: string;
limit?: number;
}
interface GetThreadMemberOptions {
withMember?: boolean;
}
interface GetThreadMembersOptions {
after?: string;
limit?: number;
withMember?: boolean;
}
interface GuildPinnable extends Pinnable {
lastPinTimestamp: number | null;
topic?: string | null;
}
interface GuildTextable extends Textable {
rateLimitPerUser: number;
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 | null;
type: number;
user_limit?: number;
}
interface Pinnable {
getPins(): Promise<Message[]>;
pinMessage(messageID: string): Promise<void>;
unpinMessage(messageID: string): Promise<void>;
}
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>;
createMessage(content: MessageContent): Promise<Message<this>>;
deleteMessage(messageID: string, reason?: string): Promise<void>;
editMessage(messageID: string, content: MessageContent): Promise<Message<this>>;
getMessage(messageID: string): Promise<Message<this>>;
getMessageReaction(messageID: string, reaction: string, options?: GetMessageReactionOptions): Promise<User[]>;
getMessages(options?: GetMessagesOptions): Promise<Message<this>[]>;
removeMessageReaction(messageID: string, reaction: string, userID?: string): Promise<void>;
sendTyping(): Promise<void>;
unsendMessage(messageID: string): Promise<void>;
}
interface ThreadTextable extends Textable, Pinnable {
lastPinTimestamp?: number;
deleteMessages(messageIDs: string[], reason?: string): Promise<void>;
getMember(options: GetThreadMemberOptions): Promise<ThreadMember>;
getMembers(options: GetThreadMembersOptions): 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 {
allowedMentions?: AllowedMentions;
defaultImageFormat?: string;
defaultImageSize?: number;
gateway?: GatewayOptions;
messageLimit?: number;
opusOnly?: boolean;
requestTimeout?: number;
rest?: RequestHandlerOptions;
restMode?: boolean;
ws?: unknown;
}
interface RequestHandlerOptions {
agent?: HTTPSAgent;
baseURL?: string;
disableLatencyCompensation?: boolean;
domain?: string;
headers?: Record<string, number | string | string[]>;
https?: boolean;
latencyThreshold?: number;
port?: number;
ratelimiterOffset?: number;
requestTimeout?: number;
}
interface EditSelfOptions {
avatar?: string | null;
username?: string;
}
// 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;
proxy_url?: string;
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;
name: string;
animated?: boolean;
}
// Events
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;
maxStageVideoChannelUsers?: number;
maxVideoChannelUsers?: number;
mfaLevel: MFALevel;
name: string;
nsfwLevel: NSFWLevel;
ownerID: string;
preferredLocale?: string;
premiumProgressBarEnabled: boolean;
premiumSubscriptionCount?: number;
premiumTier: PremiumTier;
publicUpdatesChannelID: string | null;
rulesChannelID: string | null;
safetyAlertsChannelID: string | null;
splash: string | null;
stickers?: Sticker[];
systemChannelFlags: SystemChannelFlags;
systemChannelID: string | null;
vanityURL: string | null;
verificationLevel: VerificationLevel;
welcomeScreen?: WelcomeScreen;
}
interface OldGuildChannel {
availableTags?: ForumTag[];
bitrate?: number;
defaultAutoArchiveDuration?: AutoArchiveDuration;
defaultForumLayout?: ForumLayoutTypes;
defaultReactionEmoji?: ForumDefaultReactionEmoji;
defaultSortOrder?: ThreadSortingOrders;
defaultThreadRateLimitPerUser?: number;
flags?: number;
name: string;
nsfw?: boolean;
parentID: string | null;
permissionOverwrites: Collection<PermissionOverwrite>;
position: number;
rateLimitPerUser?: number;
rtcRegion?: string | null;
topic?: string | null;
type: GuildChannelTypes;
}
interface OldGuildScheduledEvent {
channel: PossiblyUncachedSpeakableChannel | null;
description?: string | null;
entityID: string | null;
enitityMetadata: GuildScheduledEventMetadata | null;
entityType: GuildScheduledEventEntityTypes;
image?: string;
name: string;
privacyLevel: GuildScheduledEventPrivacyLevel;
scheduledEndTime: number | null;
scheduledStartTime: number;
status: GuildScheduledEventStatus;
}
interface OldGuildTextChannel extends OldGuildChannel {
nsfw: boolean;
rateLimitPerUser: number;
topic?: string | null;
type: GuildTextChannelTypes;
}
interface OldMember {
avatar: string | null;
communicationDisabledUntil: number | null;
nick: string | null;
pending?: boolean;
premiumSince?: number | null;
roles: string[];
}
interface OldMessage {
attachments: Attachment[];
channelMentions: string[];
components?: ActionRow[];
content: string;
editedTimestamp?: number;
embeds: Embed[];
flags: number;
mentions: User[];
pinned: boolean;
roleMentions: string[];
tts: boolean;
}
interface OldRole {
color: number;
flags: 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 OldVoiceChannel extends OldGuildChannel {
bitrate: number;
rtcRegion: string | null;
type: GuildVoiceChannelTypes;
userLimit: number;
videoQualityMode: VideoQualityMode;
}
interface OldThread {
appliedTags?: string[];
flags?: number;
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 {
applicationCommandPermissionsUpdate: [applicationCommandPermissions: GuildApplicationCommandPermissions];
autoModerationActionExecution: [guild: Guild, action: AutoModerationActionExecution];
autoModerationRuleCreate: [guild: Guild, rule: AutoModerationRule];
autoModerationRuleDelete: [guild: Guild, rule: AutoModerationRule];
autoModerationRuleUpdate: [guild: Guild, rule: AutoModerationRule | null, newRule: AutoModerationRule];
channelCreate: [channel: AnyGuildChannel];
channelDelete: [channel: AnyChannel];
channelPinUpdate: [channel: TextableChannel, timestamp: number, oldTimestamp: number];
channelUpdate: [channel: AnyGuildChannel, oldChannel: OldGuildChannel | OldGuildTextChannel | OldVoiceChannel];
connect: [id: number];
debug: [message: string, id?: number];
disconnect: [];
error: [err: Error, id?: number];
guildAuditLogEntryCreate: [entry: GuildAuditLogEntry];
guildAvailable: [guild: Guild];
guildBanAdd: [guild: PossiblyUncachedGuild, user: User];
guildBanRemove: [guild: PossiblyUncachedGuild, user: User];
guildCreate: [guild: Guild];
guildDelete: [guild: PossiblyUncachedGuild];
guildEmojisUpdate: [guild: PossiblyUncachedGuild, emojis: Emoji[], oldEmojis: Emoji[] | null];
guildIntegrationsUpdate: [guild: PossiblyUncachedGuild];
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];
guildScheduledEventCreate: [event: GuildScheduledEvent];
guildScheduledEventDelete: [event: GuildScheduledEvent];
guildScheduledEventUpdate: [event: GuildScheduledEvent, oldEvent: OldGuildScheduledEvent | null];
guildScheduledEventUserAdd: [event: PossiblyUncachedGuildScheduledEvent, user: User | Uncached];
guildScheduledEventUserRemove: [event: PossiblyUncachedGuildScheduledEvent, user: User | Uncached];
guildStickersUpdate: [guild: PossiblyUncachedGuild, stickers: Sticker[], oldStickers: Sticker[] | null];
guildUnavailable: [guild: UnavailableGuild];
guildUpdate: [guild: Guild, oldGuild: OldGuild];
hello: [trace: string[], id: number];
interactionCreate: [interaction: AnyInteractionGateway];
inviteCreate: [guild: Guild, invite: Invite];
inviteDelete: [guild: Guild, invite: Invite];
integrationCreate: [guild: Guild, integration: GuildIntegration];
integrationUpdate: [guild: Guild, integration: GuildIntegration];
integrationDelete: [guild: PossiblyUncachedGuild, integration: DeletedGuildIntegration];
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, oldPresence: Presence | null];
rawREST: [request: RawRESTRequest];
rawWS: [packet: RawPacket, id: number];
ready: [];
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: OldUser | 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 GatewayOptions {
autoreconnect?: boolean;
compress?: boolean;
connectionTimeout?: number;
disableEvents?: Record<string, boolean>;
firstShardID?: number;
getAllUsers?: boolean;
guildCreateTimeout?: number;
intents?: number | (IntentStrings | number)[];
largeThreshold?: number;
lastShardID?: number;
maxReconnectAttempts?: number;
maxResumeAttempts?: number;
maxConcurrency?: number | "auto";
maxShards?: number | "auto";
reconnectDelay?: ReconnectDelayFunction;
seedVoiceConnections?: boolean;
}
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 AddGuildMemberOptions {
nick?: string;
roles?: string[];
deaf?: boolean;
mute?: boolean;
}
export interface BanMemberOptions {
deleteMessageSeconds?: number;
reason?: string;
}
interface CreateGuildOptions {
afkChannelID?: string;
afkTimeout?: number;
channels?: PartialChannel[];
defaultNotifications?: DefaultNotifications;
explicitContentFilter?: ExplicitContentFilter;
icon?: string;
roles?: PartialRole[];
systemChannelFlags?: number;
systemChannelID?: string;
verificationLevel?: VerificationLevel;
}
interface DeletedGuildIntegration {
applicationID?: string;
id: string;
}
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 EditGuildMFALevelOptions {
level: MFALevel;
reason?: string;
}
interface EditGuildOnboardingOptions extends Partial<Omit<GuildOnboarding, "guild_id" | "prompts">> {
prompts?: EditGuildOnboardingPrompt[];
reason?: string;
}
interface GetGuildAuditLogOptions {
actionType?: number;
after?: string;
before?: string;
limit?: number;
userID?: string;
}
interface GetGuildBansOptions {
after?: string;
before?: string;
limit?: number;
}
interface GetGuildScheduledEventOptions {
withUserCount?: boolean;
}
interface GetGuildScheduledEventUsersOptions {
after?: string;
before?: string;
limit?: number;
withMember?: boolean;
}
interface GetPruneOptions {
days?: number;
includeRoles?: string[];
}
interface GetRESTGuildMembersOptions {
after?: string;
limit?: number;
}
interface GetRESTGuildsOptions {
after?: string;
before?: string;
limit?: number;
withCounts?: boolean;
}
interface GuildAuditLog {
autoModerationRules: AutoModerationRule[];
commands: ApplicationCommand[];
entries: GuildAuditLogEntry[];
events: GuildScheduledEvent[];
integrations: GuildIntegration[];
threads: AnyThreadChannel[];
users: User[];
webhooks: Webhook[];
}
interface GuildBan {
reason?: string;
user: User;
}
interface GuildOnboarding {
enabled: boolean;
default_channel_ids: string[];
guild_id: string;
mode: OnboardingModes;
prompts: GuildOnboardingPrompt[];
}
interface GuildOnboardingPrompt {
id: string;
in_onboarding: boolean;
options: GuildOnboardingPromptOption[];
required: boolean;