/
discord.ts
2315 lines (2165 loc) · 83.8 KB
/
discord.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 {
ActivityTypes,
AllowedMentionsTypes,
ApplicationCommandOptionTypes,
ApplicationCommandPermissionTypes,
ApplicationCommandTypes,
ApplicationFlags,
AuditLogEvents,
ButtonStyles,
ChannelFlags,
ChannelTypes,
DefaultMessageNotificationLevels,
EmbedTypes,
ExplicitContentFilterLevels,
GatewayEventNames,
GuildFeatures,
GuildNsfwLevel,
IntegrationExpireBehaviors,
InteractionTypes,
Locales,
Localization,
MessageActivityTypes,
MessageComponentTypes,
MessageTypes,
MfaLevels,
OverwriteTypes,
PickPartial,
PremiumTiers,
PremiumTypes,
ScheduledEventEntityType,
ScheduledEventPrivacyLevel,
ScheduledEventStatus,
StickerFormatTypes,
StickerTypes,
SystemChannelFlags,
TargetTypes,
TeamMembershipStates,
TextStyles,
UserFlags,
VerificationLevels,
VideoQualityModes,
VisibilityTypes,
WebhookTypes,
} from "./shared.ts";
/** https://discord.com/developers/docs/resources/user#user-object */
export interface DiscordUser {
/** The user's username, not unique across the platform */
username: string;
/** The user's chosen language option */
locale?: string;
/** The flags on a user's account */
flags?: UserFlags;
/** The type of Nitro subscription on a user's account */
premium_type?: PremiumTypes;
/** The public flags on a user's account */
public_flags?: UserFlags;
/** the user's banner color encoded as an integer representation of hexadecimal color code */
accent_color?: number;
/** The user's id */
id: string;
/** The user's 4-digit discord-tag */
discriminator: string;
/** The user's avatar hash */
avatar: string | null;
/** Whether the user belongs to an OAuth2 application */
bot?: boolean;
/** Whether the user is an Official Discord System user (part of the urgent message system) */
system?: boolean;
/** Whether the user has two factor enabled on their account */
mfa_enabled?: boolean;
/** Whether the email on this account has been verified */
verified?: boolean;
/** The user's email */
email?: string | null;
/** the user's banner, or null if unset */
banner?: string;
}
/** https://discord.com/developers/docs/resources/user#connection-object */
export interface DiscordConnection {
/** id of the connection account */
id: string;
/** The username of the connection account */
name: string;
/** The service of the connection (twitch, youtube) */
type: string;
/** Whether the connection is revoked */
revoked?: boolean;
/** Whether the connection is verified */
verified: boolean;
/** Whether friend sync is enabled for this connection */
friendSync: boolean;
/** Whether activities related to this connection will be shown in presence updates */
showActivity: boolean;
/** Visibility of this connection */
visibility: VisibilityTypes;
/** An array of partial server integrations */
integrations?: DiscordIntegration[];
}
/** https://discord.com/developers/docs/resources/guild#integration-object-integration-structure */
export interface DiscordIntegration {
/** Integration Id */
id: string;
/** Integration name */
name: string;
/** Integration type (twitch, youtube or discord) */
type: "twitch" | "youtube" | "discord";
/** Is this integration enabled */
enabled?: boolean;
/** Is this integration syncing */
syncing?: boolean;
/** Role Id that this integration uses for "subscribers" */
role_id?: string;
/** Whether emoticons should be synced for this integration (twitch only currently) */
enable_emoticons?: boolean;
/** The behavior of expiring subscribers */
expire_behavior?: IntegrationExpireBehaviors;
/** The grace period (in days) before expiring subscribers */
expire_grace_period?: number;
/** When this integration was last synced */
synced_at?: string;
/** How many subscribers this integration has */
subscriber_count?: number;
/** Has this integration been revoked */
revoked?: boolean;
/** User for this integration */
user?: DiscordUser;
/** Integration account information */
account: DiscordIntegrationAccount;
/** The bot/OAuth2 application for discord integrations */
application?: DiscordIntegrationApplication;
}
/** https://discord.com/developers/docs/resources/guild#integration-account-object-integration-account-structure */
export interface DiscordIntegrationAccount {
/** Id of the account */
id: string;
/** Name of the account */
name: string;
}
/** https://discord.com/developers/docs/resources/guild#integration-application-object-integration-application-structure */
export interface DiscordIntegrationApplication {
/** The id of the app */
id: string;
/** The name of the app */
name: string;
/** the icon hash of the app */
icon: string | null;
/** The description of the app */
description: string;
/** The bot associated with this application */
bot?: DiscordUser;
}
/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-create-event-additional-fields */
export interface DiscordIntegrationCreateUpdate extends DiscordIntegration {
/** Id of the guild */
guild_id: string;
}
/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-delete-event-fields */
export interface DiscordIntegrationDelete {
/** Integration id */
id: string;
/** Id of the guild */
guild_id: string;
/** Id of the bot/OAuth2 application for this discord integration */
application_id?: string;
}
/** https://discord.com/developers/docs/topics/gateway#guild-integrations-update */
export interface DiscordGuildIntegrationsUpdate {
/** id of the guild whose integrations were updated */
guild_id: string;
}
/** https://discord.com/developers/docs/topics/gateway#typing-start */
export interface DiscordTypingStart {
/** Unix time (in seconds) of when the user started typing */
timestamp: number;
/** id of the channel */
channel_id: string;
/** id of the guild */
guild_id?: string;
/** id of the user */
user_id: string;
/** The member who started typing if this happened in a guild */
member?: DiscordMember;
}
/** https://discord.com/developers/docs/resources/guild#guild-member-object */
export interface DiscordMember {
/** Whether the user is deafened in voice channels */
deaf?: boolean;
/** Whether the user is muted in voice channels */
mute?: boolean;
/** Whether the user has not yet passed the guild's Membership Screening requirements */
pending?: boolean;
/** The user this guild member represents */
user?: DiscordUser;
/** This users guild nickname */
nick?: string | null;
/** The members custom avatar for this server. */
avatar?: string;
/** Array of role object ids */
roles: string[];
/** When the user joined the guild */
joined_at: string;
/** When the user started boosting the guild */
premium_since?: string | null;
/** The permissions this member has in the guild. Only present on interaction events. */
permissions?: string;
/** when the user's timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out */
communication_disabled_until?: string | null;
}
/** https://discord.com/developers/docs/topics/oauth2#application-object */
export interface DiscordApplication {
/** The name of the app */
name: string;
/** The description of the app */
description: string;
/** An array of rpc origin urls, if rpc is enabled */
rpc_origins?: string[];
/** The url of the app's terms of service */
terms_of_service_url?: string;
/** The url of the app's privacy policy */
privacy_policy_url?: string;
/** The hex encoded key for verification in interactions and the GameSDK's GetTicket */
verify_key: string;
/** If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists */
primary_sku_id?: string;
/** If this application is a game sold on Discord, this field will be the URL slug that links to the store page */
slug?: string;
/** The application's public flags */
flags?: ApplicationFlags;
/** The id of the app */
id: string;
/** The icon hash of the app */
icon: string | null;
/** When false only app owner can join the app's bot to guilds */
bot_public: boolean;
/** When true the app's bot will only join upon completion of the full oauth2 code grant flow */
bot_require_code_grant: boolean;
/** Partial user object containing info on the owner of the application */
owner?: Partial<DiscordUser>;
/** If the application belongs to a team, this will be a list of the members of that team */
team: DiscordTeam | null;
/** If this application is a game sold on Discord, this field will be the guild to which it has been linked */
guild_id?: string;
/** If this application is a game sold on Discord, this field will be the hash of the image on store embeds */
cover_image?: string;
/** up to 5 tags describing the content and functionality of the application */
tags?: string[];
/** settings for the application's default in-app authorization link, if enabled */
install_params?: DiscordInstallParams;
/** the application's default custom authorization link, if enabled */
custom_install_url?: string;
}
/** https://discord.com/developers/docs/topics/teams#data-models-team-object */
export interface DiscordTeam {
/** A hash of the image of the team's icon */
icon: string | null;
/** The unique id of the team */
id: string;
/** The members of the team */
members: DiscordTeamMember[];
/** The user id of the current team owner */
owner_user_id: string;
/** The name of the team */
name: string;
}
/** https://discord.com/developers/docs/topics/teams#data-models-team-members-object */
export interface DiscordTeamMember {
/** The user's membership state on the team */
membership_state: TeamMembershipStates;
/** Will always be `["*"]` */
permissions: "*"[];
/** The id of the parent team of which they are a member */
team_id: string;
/** The avatar, discriminator, id, and username of the user */
user: Partial<DiscordUser> & Pick<DiscordUser, "avatar" | "discriminator" | "id" | "username">;
}
/** https://discord.com/developers/docs/topics/gateway#webhooks-update-webhook-update-event-fields */
export interface DiscordWebhookUpdate {
/** id of the guild */
guild_id: string;
/** id of the channel */
channel_id: string;
}
/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object */
export interface DiscordAllowedMentions {
/** An array of allowed mention types to parse from the content. */
parse?: AllowedMentionsTypes[];
/** For replies, whether to mention the author of the message being replied to (default false) */
repliedUser?: boolean;
/** Array of role_ids to mention (Max size of 100) */
roles?: string[];
/** Array of user_ids to mention (Max size of 100) */
users?: string[];
}
/** https://discord.com/developers/docs/resources/channel#embed-object */
export interface DiscordEmbed {
/** Title of embed */
title?: string;
/** Type of embed (always "rich" for webhook embeds) */
type?: EmbedTypes;
/** Description of embed */
description?: string;
/** Url of embed */
url?: string;
/** Color code of the embed */
color?: number;
/** Timestamp of embed content */
timestamp?: string;
/** Footer information */
footer?: DiscordEmbedFooter;
/** Image information */
image?: DiscordEmbedImage;
/** Thumbnail information */
thumbnail?: DiscordEmbedThumbnail;
/** Video information */
video?: DiscordEmbedVideo;
/** Provider information */
provider?: DiscordEmbedProvider;
/** Author information */
author?: DiscordEmbedAuthor;
/** Fields information */
fields?: DiscordEmbedField[];
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */
export interface DiscordEmbedAuthor {
/** Name of author */
name: string;
/** Url of author */
url?: string;
/** Url of author icon (only supports http(s) and attachments) */
icon_url?: string;
/** A proxied url of author icon */
proxy_icon_url?: string;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure */
export interface DiscordEmbedField {
/** Name of the field */
name: string;
/** Value of the field */
value: string;
/** Whether or not this field should display inline */
inline?: boolean;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure */
export interface DiscordEmbedFooter {
/** Footer text */
text: string;
/** Url of footer icon (only supports http(s) and attachments) */
icon_url?: string;
/** A proxied url of footer icon */
proxy_icon_url?: string;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */
export interface DiscordEmbedImage {
/** Source url of image (only supports http(s) and attachments) */
url: string;
/** A proxied url of the image */
proxy_url?: string;
/** Height of image */
height?: number;
/** Width of image */
width?: number;
}
export interface DiscordEmbedProvider {
/** Name of provider */
name?: string;
/** Url of provider */
url?: string;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */
export interface DiscordEmbedThumbnail {
/** Source url of thumbnail (only supports http(s) and attachments) */
url: string;
/** A proxied url of the thumbnail */
proxy_url?: string;
/** Height of thumbnail */
height?: number;
/** Width of thumbnail */
width?: number;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */
export interface DiscordEmbedVideo {
/** Source url of video */
url?: string;
/** A proxied url of the video */
proxy_url?: string;
/** Height of video */
height?: number;
/** Width of video */
width?: number;
}
/** https://discord.com/developers/docs/resources/channel#attachment-object */
export interface DiscordAttachment {
/** Name of file attached */
filename: string;
/** The attachment's [media type](https://en.wikipedia.org/wiki/Media_type) */
content_type?: string;
/** Size of file in bytes */
size: number;
/** Source url of file */
url: string;
/** A proxied url of file */
proxy_url: string;
/** Attachment id */
id: string;
/** Height of file (if image) */
height?: number | null;
/** Width of file (if image) */
width?: number | null;
/** whether this attachment is ephemeral. Ephemeral attachments will automatically be removed after a set period of time. Ephemeral attachments on messages are guaranteed to be available as long as the message itself exists. */
ephemeral?: boolean;
}
/** https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure */
export type DiscordWebhook = DiscordIncomingWebhook | DiscordApplicationWebhook;
export interface DiscordIncomingWebhook {
/** The type of the webhook */
type: WebhookTypes;
/** The secure token of the webhook (returned for Incoming Webhooks) */
token?: string;
/** The url used for executing the webhook (returned by the webhooks OAuth2 flow) */
url?: string;
/** The id of the webhook */
id: string;
/** The guild id this webhook is for */
guild_id?: string;
/** The channel id this webhook is for */
channel_id: string;
/** The user this webhook was created by (not returned when getting a webhook with its token) */
user?: DiscordUser;
/** The default name of the webhook */
name: string | null;
/** The default user avatar hash of the webhook */
avatar: string | null;
/** The bot/OAuth2 application that created this webhook */
application_id: string | null;
/** The guild of the channel that this webhook is following (returned for Channel Follower Webhooks) */
source_guild?: Partial<DiscordGuild>;
/** The channel that this webhook is following (returned for Channel Follower Webhooks) */
source_channel?: Partial<DiscordChannel>;
}
export interface DiscordApplicationWebhook {
/** The type of the webhook */
type: WebhookTypes.Application;
/** The secure token of the webhook (returned for Incoming Webhooks) */
token?: string;
/** The url used for executing the webhook (returned by the webhooks OAuth2 flow) */
url?: string;
/** The id of the webhook */
id: string;
/** The guild id this webhook is for */
guild_id?: string | null;
/** The channel id this webhook is for */
channel_id?: string | null;
/** The user this webhook was created by (not returned when getting a webhook with its token) */
user?: DiscordUser;
/** The default name of the webhook */
name: string | null;
/** The default user avatar hash of the webhook */
avatar: string | null;
/** The bot/OAuth2 application that created this webhook */
application_id: string | null;
/** The guild of the channel that this webhook is following (returned for Channel Follower Webhooks) */
source_guild?: Partial<DiscordGuild>;
/** The channel that this webhook is following (returned for Channel Follower Webhooks) */
source_channel?: Partial<DiscordChannel>;
}
/** https://discord.com/developers/docs/resources/guild#guild-object */
export interface DiscordGuild {
/** Guild name (2-100 characters, excluding trailing and leading whitespace) */
name: string;
/** True if the user is the owner of the guild */
owner?: boolean;
/** Afk timeout in seconds */
afk_timeout: number;
/** True if the server widget is enabled */
widget_enabled?: boolean;
/** Verification level required for the guild */
verification_level: VerificationLevels;
/** Default message notifications level */
default_message_notifications: DefaultMessageNotificationLevels;
/** Explicit content filter level */
explicit_content_filter: ExplicitContentFilterLevels;
/** Enabled guild features */
features: GuildFeatures[];
/** Required MFA level for the guild */
mfa_level: MfaLevels;
/** System channel flags */
system_channel_flags: SystemChannelFlags;
/** True if this is considered a large guild */
large?: boolean;
/** True if this guild is unavailable due to an outage */
unavailable?: boolean;
/** Total number of members in this guild */
member_count?: number;
/** The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned) */
max_presences?: number | null;
/** The maximum number of members for the guild */
max_members?: number;
/** The vanity url code for the guild */
vanity_url_code: string | null;
/** The description of a guild */
description: string | null;
/** Premium tier (Server Boost level) */
premium_tier: PremiumTiers;
/** The number of boosts this guild currently has */
premium_subscription_count?: number;
/** The maximum amount of users in a video channel */
max_video_channel_users?: number;
/** Approximate number of members in this guild, returned from the GET /guilds/<id> endpoint when with_counts is true */
approximate_member_count?: number;
/** Approximate number of non-offline members in this guild, returned from the GET /guilds/<id> endpoint when with_counts is true */
approximate_presence_count?: number;
/** Guild NSFW level */
nsfw_level: GuildNsfwLevel;
/** Whether the guild has the boost progress bar enabled */
premium_progress_bar_enabled: boolean;
/** Guild id */
id: string;
/** Icon hash */
icon: string | null;
/** Icon hash, returned when in the template object */
icon_hash?: string | null;
/** Splash hash */
splash: string | null;
/** Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature */
discovery_splash: string | null;
/** Id of the owner */
owner_id: string;
/** Total permissions for the user in the guild (excludes overwrites) */
permissions?: string;
/** Id of afk channel */
afk_channel_id: string | null;
/** The channel id that the widget will generate an invite to, or null if set to no invite */
widget_channel_id?: string | null;
/** Roles in the guild */
roles: DiscordRole[];
/** Custom guild emojis */
emojis: DiscordEmoji[];
/** Application id of the guild creator if it is bot-created */
application_id: string | null;
/** The id of the channel where guild notices such as welcome messages and boost events are posted */
system_channel_id: string | null;
/** The id of the channel where community guilds can display rules and/or guidelines */
rules_channel_id: string | null;
/** When this guild was joined at */
joined_at?: string;
/** States of members currently in voice channels; lacks the guild_id key */
voice_states?: Omit<DiscordVoiceState, "guildId">[];
/** Users in the guild */
members?: DiscordMember[];
/** Channels in the guild */
channels?: DiscordChannel[];
// TODO: check if need to omit
/** All active threads in the guild that the current user has permission to view */
threads?: DiscordChannel[];
/** Presences of the members in the guild, will only include non-offline members if the size is greater than large threshold */
presences?: Partial<DiscordPresenceUpdate>[];
/** Banner hash */
banner: string | null;
// TODO: Can be optimized to a number but is it worth it?
/** The preferred locale of a Community guild; used in server discovery and notices from Discord; defaults to "en-US" */
preferred_locale: string;
/** The id of the channel where admins and moderators of Community guilds receive notices from Discord */
public_updates_channel_id: string | null;
/** The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object */
welcome_screen?: DiscordWelcomeScreen;
/** Stage instances in the guild */
stage_instances?: DiscordStageInstance[];
}
/** https://discord.com/developers/docs/topics/permissions#role-object-role-structure */
export interface DiscordRole {
/** Role id */
id: string;
/** If this role is showed separately in the user listing */
hoist: boolean;
/** Permission bit set */
permissions: string;
/** Whether this role is managed by an integration */
managed: boolean;
/** Whether this role is mentionable */
mentionable: boolean;
/** The tags this role has */
tags?: DiscordRoleTags;
/** the role emoji hash */
icon?: string;
/** Role name */
name: string;
/** Integer representation of hexadecimal color code */
color: number;
/** Position of this role */
position: number;
/** role unicode emoji */
unicode_emoji?: string;
}
/** https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure */
export interface DiscordRoleTags {
/** The id of the bot this role belongs to */
bot_id?: string;
/** The id of the integration this role belongs to */
integration_id?: string;
/** Whether this is the guild's premium subscriber role */
premium_subscriber?: null;
}
/** https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure */
export interface DiscordEmoji {
/** Emoji name (can only be null in reaction emoji objects) */
name?: string;
/** Emoji id */
id?: string;
/** Roles allowed to use this emoji */
roles?: string[];
/** User that created this emoji */
user?: DiscordUser;
/** Whether this emoji must be wrapped in colons */
require_colons?: boolean;
/** Whether this emoji is managed */
managed?: boolean;
/** Whether this emoji is animated */
animated?: boolean;
/** Whether this emoji can be used, may be false due to loss of Server Boosts */
available?: boolean;
}
/** https://discord.com/developers/docs/resources/voice#voice-state-object-voice-state-structure */
export interface DiscordVoiceState {
/** The session id for this voice state */
session_id: string;
/** The guild id this voice state is for */
guild_id?: string;
/** The channel id this user is connected to */
channel_id: string | null;
/** The user id this voice state is for */
user_id: string;
/** The guild member this voice state is for */
member?: DiscordMemberWithUser;
/** Whether this user is deafened by the server */
deaf: boolean;
/** Whether this user is muted by the server */
mute: boolean;
/** Whether this user is locally deafened */
self_deaf: boolean;
/** Whether this user is locally muted */
self_mute: boolean;
/** Whether this user is streaming using "Go Live" */
self_stream?: boolean;
/** Whether this user's camera is enabled */
self_video: boolean;
/** Whether this user is muted by the current user */
suppress: boolean;
/** The time at which the user requested to speak */
request_to_speak_timestamp: string | null;
}
/** https://discord.com/developers/docs/resources/channel#channel-object */
export interface DiscordChannel {
/** The type of channel */
type: ChannelTypes;
/** The flags of the channel */
flags?: ChannelFlags;
/** Sorting position of the channel */
position?: number;
/** The name of the channel (1-100 characters) */
name?: string;
/** The channel topic (0-1024 characters) */
topic?: string | null;
/** The bitrate (in bits) of the voice channel */
bitrate?: number;
/** The user limit of the voice channel */
user_limit?: number;
/** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission `manage_messages` or `manage_channel`, are unaffected */
rate_limit_per_user?: number;
/** Voice region id for the voice channel, automatic when set to null */
rtc_region?: string | null;
/** The camera video quality mode of the voice channel, 1 when not present */
video_quality_mode?: VideoQualityModes;
/** An approximate count of messages in a thread, stops counting at 50 */
message_count?: number;
/** An approximate count of users in a thread, stops counting at 50 */
member_count?: number;
/** Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */
default_auto_archive_duration?: number;
/** The id of the channel */
id: string;
/** The id of the guild */
guild_id?: string;
/** Explicit permission overwrites for members and roles */
permission_overwrites?: DiscordOverwrite[];
/** Whether the channel is nsfw */
nsfw?: boolean;
/** The id of the last message sent in this channel (may not point to an existing or valid message) */
last_message_id?: string | null;
/** Id of the creator of the thread */
owner_id?: string;
/** Application id of the group DM creator if it is bot-created */
application_id?: string;
/** For guild channels: Id of the parent category for a channel (each parent category can contain up to 50 channels), for threads: id of the text channel this thread was created */
parent_id?: string | null;
/** When the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned. */
last_pin_timestamp?: string | null;
/** Thread-specific fields not needed by other channels */
thread_metadata?: DiscordThreadMetadata;
/** Thread member object for the current user, if they have joined the thread, only included on certain API endpoints */
member?: DiscordThreadMember;
/** computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a application command interaction */
permissions?: string;
/** When a thread is created this will be true on that channel payload for the thread. */
newly_created?: boolean;
}
/** https://discord.com/developers/docs/topics/gateway#presence-update */
export interface DiscordPresenceUpdate {
/** Either "idle", "dnd", "online", or "offline" */
status: "idle" | "dnd" | "online" | "offline";
/** The user presence is being updated for */
user: DiscordUser;
/** id of the guild */
guild_id: string;
/** User's current activities */
activities: DiscordActivity[];
/** User's platform-dependent status */
client_status: DiscordClientStatus;
}
/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-structure */
export interface DiscordWelcomeScreen {
/** The server description shown in the welcome screen */
description: string | null;
/** The channels shown in the welcome screen, up to 5 */
welcome_channels: DiscordWelcomeScreenChannel[];
}
/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-channel-structure */
export interface DiscordWelcomeScreenChannel {
/** The description shown for the channel */
description: string;
/** The channel's id */
channel_id: string;
/** The emoji id, if the emoji is custom */
emoji_id: string | null;
/** The emoji name if custom, the unicode character if standard, or `null` if no emoji is set */
emoji_name: string | null;
}
/** https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure */
export interface DiscordStageInstance {
/** The topic of the Stage instance (1-120 characters) */
topic: string;
/** The id of this Stage instance */
id: string;
/** The guild id of the associated Stage channel */
guild_id: string;
/** The id of the associated Stage channel */
channel_id: string;
/** The id of the scheduled event for this Stage instance */
guild_scheduled_event_id?: string;
}
export interface DiscordThreadMetadata {
/** Whether the thread is archived */
archived: boolean;
/** Duration in minutes to automatically archive the thread after recent activity */
auto_archive_duration: 60 | 1440 | 4320 | 10080;
/** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */
locked: boolean;
/** whether non-moderators can add other non-moderators to a thread; only available on private threads */
invitable?: boolean;
/** Timestamp when the thread's archive status was last changed, used for calculating recent activity */
archive_timestamp: string;
/** Timestamp when the thread was created; only populated for threads created after 2022-01-09 */
create_timestamp?: string | null;
}
export interface DiscordThreadMemberBase {
/** Any user-thread settings, currently only used for notifications */
flags: number;
}
export interface DiscordThreadMember {
/** Any user-thread settings, currently only used for notifications */
flags: number;
/** The id of the thread */
id: string;
/** The id of the user */
user_id: string;
/** The time the current user last joined the thread */
join_timestamp: string;
}
export interface DiscordThreadMemberGuildCreate {
/** Any user-thread settings, currently only used for notifications */
flags: number;
/** The time the current user last joined the thread */
join_timestamp: string;
}
/** https://discord.com/developers/docs/topics/gateway#activity-object */
export interface DiscordActivity {
/** The activity's name */
name: string;
/** Activity type */
type: ActivityTypes;
/** Stream url, is validated when type is 1 */
url?: string | null;
/** Unix timestamp of when the activity was added to the user's session */
created_at: number;
/** What the player is currently doing */
details?: string | null;
/** The user's current party status */
state?: string | null;
/** Whether or not the activity is an instanced game session */
instance?: boolean;
/** Activity flags `OR`d together, describes what the payload includes */
flags?: number;
/** Unix timestamps for start and/or end of the game */
timestamps?: DiscordActivityTimestamps;
/** Application id for the game */
application_id?: string;
/** The emoji used for a custom status */
emoji?: DiscordActivityEmoji | null;
/** Information for the current party of the player */
party?: DiscordActivityParty;
/** Images for the presence and their hover texts */
assets?: DiscordActivityAssets;
/** Secrets for Rich Presence joining and spectating */
secrets?: DiscordActivitySecrets;
/** The custom buttons shown in the Rich Presence (max 2) */
buttons?: DiscordActivityButton[];
}
/** https://discord.com/developers/docs/topics/gateway#client-status-object */
export interface DiscordClientStatus {
/** The user's status set for an active desktop (Windows, Linux, Mac) application session */
desktop?: string;
/** The user's status set for an active mobile (iOS, Android) application session */
mobile?: string;
/** The user's status set for an active web (browser, bot account) application session */
web?: string;
}
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps */
export interface DiscordActivityTimestamps {
/** Unix time (in milliseconds) of when the activity started */
start?: number;
/** Unix time (in milliseconds) of when the activity ends */
end?: number;
}
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji */
export interface DiscordActivityEmoji {
/** The name of the emoji */
name: string;
/** Whether this emoji is animated */
animated?: boolean;
/** The id of the emoji */
id?: string;
}
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-party */
export interface DiscordActivityParty {
/** Used to show the party's current and maximum size */
size?: [currentSize: number, maxSize: number];
/** The id of the party */
id?: string;
}
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets */
export interface DiscordActivityAssets {
/** Text displayed when hovering over the large image of the activity */
large_text?: string;
/** Text displayed when hovering over the small image of the activity */
small_text?: string;
/** The id for a large asset of the activity, usually a snowflake */
large_image?: string;
/** The id for a small asset of the activity, usually a snowflake */
small_image?: string;
}
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets */
export interface DiscordActivitySecrets {
/** The secret for joining a party */
join?: string;
/** The secret for spectating a game */
spectate?: string;
/** The secret for a specific instanced match */
match?: string;
}
/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-buttons */
export interface DiscordActivityButton {
/** The text shown on the button (1-32 characters) */
label: string;
/** The url opened when clicking the button (1-512 characters) */
url: string;
}
export interface DiscordOverwrite {
/** Either 0 (role) or 1 (member) */
type: OverwriteTypes;
/** Role or user id */
id: string;
/** Permission bit set */
allow?: string;
/** Permission bit set */
deny?: string;
}
export interface DiscordMemberWithUser extends DiscordMember {
/** The user object for this member */
user: DiscordUser;
}
/** https://discord.com/developers/docs/resources/channel#message-object */
export interface DiscordMessage {
/** id of the message */
id: string;
/** id of the channel the message was sent in */
channel_id: string;
/**
* id of the guild the message was sent in
* Note: For MESSAGE_CREATE and MESSAGE_UPDATE events, the message object may not contain a guild_id or member field since the events are sent directly to the receiving user and the bot who sent the message, rather than being sent through the guild like non-ephemeral messages.
*/
guild_id?: string;
/**
* The author of this message (not guaranteed to be a valid user)
* Note: The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.
*/
author: DiscordUser;
/**
* Member properties for this message's author
* Note: The member object exists in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events from text-based guild channels. This allows bots to obtain real-time member data without requiring bots to store member state in memory.
*/
member?: DiscordMember;
/** Contents of the message */
content?: string;
/** When this message was sent */
timestamp: string;
/** When this message was edited (or null if never) */
edited_timestamp: string | null;
/** Whether this was a TTS message */
tts: boolean;
/** Whether this message mentions everyone */
mention_everyone: boolean;
/**
* Users specifically mentioned in the message
* Note: The user objects in the mentions array will only have the partial member field present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events from text-based guild channels.
*/
mentions?: (DiscordUser & { member?: Partial<DiscordMember> })[];
/** Roles specifically mentioned in this message */
mention_roles?: string[];
/**
* Channels specifically mentioned in this message
* Note: Not all channel mentions in a message will appear in `mention_channels`. Only textual channels that are visible to everyone in a lurkable guild will ever be included. Only crossposted messages (via Channel Following) currently include `mention_channels` at all. If no mentions in the message meet these requirements, this field will not be sent.