-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
channel.ts
714 lines (660 loc) · 19.9 KB
/
channel.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
import type { Permissions, Snowflake } from '../../globals.ts';
import type {
APIActionRowComponent,
APIAllowedMentions,
APIAttachment,
APIChannel,
APIEmbed,
APIExtendedInvite,
APIFollowedChannel,
APIMessage,
APIMessageActionRowComponent,
APIMessageReference,
APIThreadList,
APIThreadMember,
APIUser,
ChannelType,
InviteTargetType,
MessageFlags,
OverwriteType,
ThreadAutoArchiveDuration,
VideoQualityMode,
APIGuildForumTag,
APIGuildForumDefaultReactionEmoji,
} from '../../payloads/v9/mod.ts';
import type { AddUndefinedToPossiblyUndefinedPropertiesOfInterface, StrictPartial } from '../../utils/internals.ts';
export interface APIChannelPatchOverwrite extends RESTPutAPIChannelPermissionJSONBody {
id: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/channel#get-channel
*/
export type RESTGetAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export type RESTPatchAPIChannelJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character channel name
*
* Channel types: all
*/
name?: string;
/**
* The type of channel; only conversion between `text` and `news`
* is supported and only in guilds with the "NEWS" feature
*
* Channel types: text, news
*/
type?: ChannelType.GuildAnnouncement | ChannelType.GuildText;
/**
* The position of the channel in the left-hand listing
*
* Channel types: all excluding newsThread, publicThread, privateThread
*/
position?: number | null;
/**
* 0-1024 character channel topic (0-4096 characters for forum channels)
*
* Channel types: text, news, forum
*/
topic?: string | null;
/**
* Whether the channel is nsfw
*
* Channel types: text, voice, news, forum
*/
nsfw?: boolean | null;
/**
* 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_CHANNELS`,
* are unaffected
*
* Channel types: text, newsThread, publicThread, privateThread, forum
*/
rate_limit_per_user?: number | null;
/**
* The bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers)
*
* Channel types: voice
*/
bitrate?: number | null;
/**
* The user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit
*
* Channel types: voice
*/
user_limit?: number | null;
/**
* Channel or category-specific permissions
*
* Channel types: all excluding newsThread, publicThread, privateThread
*/
permission_overwrites?: APIChannelPatchOverwrite[] | null;
/**
* ID of the new parent category for a channel
*
* Channel types: text, voice, news
*/
parent_id?: Snowflake | null;
/**
* Voice region id for the voice or stage channel, automatic when set to `null`
*
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
/**
* The camera video quality mode of the voice channel
*
* See https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes
*/
video_quality_mode?: VideoQualityMode | null;
/**
* Whether the thread should be archived
*
* Channel types: newsThread, publicThread, privateThread
*/
archived?: boolean;
/**
* The amount of time in minutes to wait before automatically archiving the thread
*
* Channel types: newsThread, publicThread, privateThread
*/
auto_archive_duration?: ThreadAutoArchiveDuration;
/**
* Whether the thread should be locked
*
* Channel types: newsThread, publicThread, privateThread
*/
locked?: boolean;
/**
* Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity
*
* Channel types: text, news
*/
default_auto_archive_duration?: ThreadAutoArchiveDuration;
/**
* Whether non-moderators can add other non-moderators to the thread
*
* Channel types: privateThread
*/
invitable?: boolean;
/**
* The set of tags that can be used in a forum channel
*
* Channel types: forum
*/
available_tags?: APIGuildForumTag[];
/**
* The emoji to show in the add reaction button on a thread in a forum channel
*
* Channel types: forum
*/
default_reaction_emoji?: APIGuildForumDefaultReactionEmoji;
/**
* The initial `rate_limit_per_user` to set on newly created threads in a channel.
* This field is copied to the thread at creation time and does not live update
*
* Channel types: text, forum
*/
default_thread_rate_limit_per_user?: number | null;
}>;
/**
* https://discord.com/developers/docs/resources/channel#modify-channel
*/
export type RESTPatchAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#deleteclose-channel
*/
export type RESTDeleteAPIChannelResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#get-channel-messages
*/
export interface RESTGetAPIChannelMessagesQuery {
/**
* Get messages around this message ID
*/
around?: Snowflake;
/**
* Get messages before this message ID
*/
before?: Snowflake;
/**
* Get messages after this message ID
*/
after?: Snowflake;
/**
* Max number of messages to return (1-100)
*
* @default 50
*/
limit?: number;
}
/**
* https://discord.com/developers/docs/resources/channel#get-channel-messages
*/
export type RESTGetAPIChannelMessagesResult = APIMessage[];
/**
* https://discord.com/developers/docs/resources/channel#get-channel-message
*/
export type RESTGetAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure
*/
export type APIMessageReferenceSend = StrictPartial<APIMessageReference> &
Required<Pick<APIMessageReference, 'message_id'>> &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
*
* @default true
*/
fail_if_not_exists?: boolean;
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export type RESTPostAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The message contents (up to 2000 characters)
*/
content?: string;
/**
* A nonce that can be used for optimistic message sending
*/
nonce?: number | string;
/**
* `true` if this is a TTS message
*/
tts?: boolean;
/**
* Embedded `rich` content (up to 6000 characters)
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[];
/**
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
* @deprecated Use `embeds` instead
*/
embed?: APIEmbed;
/**
* Allowed mentions for a message
*
* See https://discord.com/developers/docs/resources/channel#allowed-mentions-object
*/
allowed_mentions?: APIAllowedMentions;
/**
* Include to make your message a reply
*
* See https://discord.com/developers/docs/resources/channel#message-reference-object-message-reference-structure
*/
message_reference?: APIMessageReferenceSend;
/**
* The components to include with the message
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageActionRowComponent>[];
/**
* IDs of up to 3 stickers in the server to send in the message
*
* See https://discord.com/developers/docs/resources/sticker#sticker-object
*/
sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake];
/**
* Attachment objects with filename and description
*/
attachments?: (Pick<APIAttachment, 'id' | 'description'> & Partial<Pick<APIAttachment, 'filename'>>)[];
/**
* Message flags combined as a bitfield
*/
flags?: MessageFlags;
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export type RESTPostAPIChannelMessageFormDataBody =
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
} & Record<`files[${bigint}]`, unknown>)
| (RESTPostAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);
/**
* https://discord.com/developers/docs/resources/channel#create-message
*/
export type RESTPostAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#crosspost-message
*/
export type RESTPostAPIChannelMessageCrosspostResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#create-reaction
*/
export type RESTPutAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#delete-own-reaction
*/
export type RESTDeleteAPIChannelMessageOwnReaction = never;
/**
* https://discord.com/developers/docs/resources/channel#delete-user-reaction
*/
export type RESTDeleteAPIChannelMessageUserReactionResult = never;
/*
* https://discord.com/developers/docs/resources/channel#get-reactions
*/
export interface RESTGetAPIChannelMessageReactionUsersQuery {
/**
* Get users after this user ID
*/
after?: Snowflake;
/**
* Max number of users to return (1-100)
*
* @default 25
*/
limit?: number;
}
/**
* https://discord.com/developers/docs/resources/channel#get-reactions
*/
export type RESTGetAPIChannelMessageReactionUsersResult = APIUser[];
/**
* https://discord.com/developers/docs/resources/channel#delete-all-reactions
*/
export type RESTDeleteAPIChannelAllMessageReactionsResult = never;
/**
* https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji
*/
export type RESTDeleteAPIChannelMessageReactionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The new message contents (up to 2000 characters)
*/
content?: string | null;
/**
* Embedded `rich` content (up to 6000 characters)
*
* See https://discord.com/developers/docs/resources/channel#embed-object
*/
embeds?: APIEmbed[] | null;
/**
* Embedded `rich` content
*
* See https://discord.com/developers/docs/resources/channel#embed-object
* @deprecated Use `embeds` instead
*/
embed?: APIEmbed | null;
/**
* Edit the flags of a message (only `SUPPRESS_EMBEDS` can currently be set/unset)
*
* When specifying flags, ensure to include all previously set flags/bits
* in addition to ones that you are modifying
*
* See https://discord.com/developers/docs/resources/channel#message-object-message-flags
*/
flags?: MessageFlags | null;
/**
* Allowed mentions for the message
*
* See https://discord.com/developers/docs/resources/channel#allowed-mentions-object
*/
allowed_mentions?: APIAllowedMentions | null;
/**
* Attached files to keep
*
* Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body.
*
* See https://discord.com/developers/docs/resources/channel#attachment-object
*/
attachments?: (Pick<APIAttachment, 'id'> & Partial<Pick<APIAttachment, 'filename' | 'description'>>)[];
/**
* The components to include with the message
*
* See https://discord.com/developers/docs/interactions/message-components#component-object
*/
components?: APIActionRowComponent<APIMessageActionRowComponent>[] | null;
}>;
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageFormDataBody =
| ({
/**
* JSON stringified message body
*/
payload_json?: string;
} & Record<`files[${bigint}]`, unknown>)
| (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>);
/**
* https://discord.com/developers/docs/resources/channel#edit-message
*/
export type RESTPatchAPIChannelMessageResult = APIMessage;
/**
* https://discord.com/developers/docs/resources/channel#delete-message
*/
export type RESTDeleteAPIChannelMessageResult = never;
/**
* https://discord.com/developers/docs/resources/channel#bulk-delete-messages
*/
export interface RESTPostAPIChannelMessagesBulkDeleteJSONBody {
/**
* An array of message ids to delete (2-100)
*/
messages: Snowflake[];
}
/**
* https://discord.com/developers/docs/resources/channel#bulk-delete-messages
*/
export type RESTPostAPIChannelMessagesBulkDeleteResult = never;
/**
* https://discord.com/developers/docs/resources/channel#edit-channel-permissions
*/
export interface RESTPutAPIChannelPermissionJSONBody {
/**
* The bitwise value of all allowed permissions
*
* See https://en.wikipedia.org/wiki/Bit_field
*
* @default "0"
*/
allow?: Permissions | null;
/**
* The bitwise value of all disallowed permissions
*
* See https://en.wikipedia.org/wiki/Bit_field
*
* @default "0"
*/
deny?: Permissions | null;
/**
* `0` for a role or `1` for a member
*/
type: OverwriteType;
}
/**
* https://discord.com/developers/docs/resources/channel#edit-channel-permissions
*/
export type RESTPutAPIChannelPermissionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#get-channel-invites
*/
export type RESTGetAPIChannelInvitesResult = APIExtendedInvite[];
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export type RESTPostAPIChannelInviteJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Duration of invite in seconds before expiry, or 0 for never
*
* @default 86400 (24 hours)
*/
max_age?: number;
/**
* Max number of uses or 0 for unlimited
*
* @default 0
*/
max_uses?: number;
/**
* Whether this invite only grants temporary membership
*
* @default false
*/
temporary?: boolean;
/**
* If true, don't try to reuse a similar invite
* (useful for creating many unique one time use invites)
*
* @default false
*/
unique?: boolean;
/**
* The type of target for this voice channel invite
*
* See https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
*/
target_type?: InviteTargetType;
/**
* The id of the user whose stream to display for this invite
* - Required if `target_type` is 1
* - The user must be streaming in the channel
*/
target_user_id?: Snowflake;
/**
* The id of the embedded application to open for this invite
* - Required if `target_type` is 2
* - The application must have the `EMBEDDED` flag
*/
target_application_id?: Snowflake;
}>;
/**
* https://discord.com/developers/docs/resources/channel#create-channel-invite
*/
export type RESTPostAPIChannelInviteResult = APIExtendedInvite;
/**
* https://discord.com/developers/docs/resources/channel#delete-channel-permission
*/
export type RESTDeleteAPIChannelPermissionResult = never;
/**
* https://discord.com/developers/docs/resources/channel#follow-news-channel
*/
export interface RESTPostAPIChannelFollowersJSONBody {
/**
* ID of target channel
*/
webhook_channel_id: Snowflake;
}
/**
* https://discord.com/developers/docs/resources/channel#follow-news-channel
*/
export type RESTPostAPIChannelFollowersResult = APIFollowedChannel;
/**
* https://discord.com/developers/docs/resources/channel#trigger-typing-indicator
*/
export type RESTPostAPIChannelTypingResult = never;
/**
* https://discord.com/developers/docs/resources/channel#get-pinned-messages
*/
export type RESTGetAPIChannelPinsResult = APIMessage[];
/**
* https://discord.com/developers/docs/resources/channel#pin-message
*/
export type RESTPutAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#unpin-message
*/
export type RESTDeleteAPIChannelPinResult = never;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export type RESTPutAPIChannelRecipientJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* Access token of a user that has granted your app the `gdm.join` scope
*/
access_token: string;
/**
* Nickname of the user being added
*/
nick?: string;
}>;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
*/
export type RESTPutAPIChannelRecipientResult = unknown;
/**
* https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient
*/
export type RESTDeleteAPIChannelRecipientResult = unknown;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-from-message
*/
export type RESTPostAPIChannelMessagesThreadsJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* 1-100 character thread name
*/
name: string;
/**
* The amount of time in minutes to wait before automatically archiving the thread
*
* The 3 day and 7 day archive durations require the server to be boosted. The [guild features](https://discord.com/developers/docs/resources/guild#guild-object-guild-features) will indicate if a server is able to use those settings.
*/
auto_archive_duration: ThreadAutoArchiveDuration;
/**
* Amount of seconds a user has to wait before sending another message (0-21600)
*/
rate_limit_per_user?: number;
}>;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: RESTPostAPIChannelMessageJSONBody;
/**
* The IDs of the set of tags that have been applied to a thread in a forum channel
*/
applied_tags?: Snowflake[];
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel
*/
export type RESTPostAPIGuildForumThreadsFormDataBody = RESTPostAPIChannelMessagesThreadsJSONBody & {
/**
* First message in the forum thread
*/
message: string;
};
/**
* https://discord.com/developers/docs/resources/channel#start-thread-from-message
*/
export type RESTPostAPIChannelMessagesThreadsResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message
*/
export type RESTPostAPIChannelThreadsJSONBody = RESTPostAPIChannelMessagesThreadsJSONBody &
AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{
/**
* The type of thread to create
*
* In API v9, `type` defaults to `PRIVATE_THREAD`.
* In a future API version this will be changed to be a required field, with no default.
*
* See https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*
* @default ChannelType.PrivateThread
*/
type?: ChannelType.AnnouncementThread | ChannelType.PublicThread | ChannelType.PrivateThread;
/**
* Whether non-moderators can add other non-moderators to the thread; only available when creating a private thread
*/
invitable?: boolean;
}>;
/**
* https://discord.com/developers/docs/resources/channel#start-thread-without-message
*/
export type RESTPostAPIChannelThreadsResult = APIChannel;
/**
* https://discord.com/developers/docs/resources/channel#join-thread
*/
export type RESTPutAPIChannelThreadMembersResult = never;
/**
* https://discord.com/developers/docs/resources/channel#leave-thread
*/
export type RESTDeleteAPIChannelThreadMembersResult = never;
/**
* https://discord.com/developers/docs/resources/channel#list-thread-members
*/
export type RESTGetAPIChannelThreadMembersResult = APIThreadMember[];
/*
* https://discord.com/developers/docs/resources/channel#list-public-archived-threads
*/
export interface RESTGetAPIChannelThreadsArchivedQuery {
/**
* Get threads before this id or ISO8601 timestamp
*/
before?: Snowflake | string;
/**
* Max number of thread to return
*/
limit?: number;
}
/**
* https://discord.com/developers/docs/resources/channel#list-active-threads
*
* @deprecated Removed in API v10, use [List Active Guild Threads](https://discord.com/developers/docs/resources/guild#list-active-threads) instead.
*/
export type RESTGetAPIChannelThreadsResult = APIThreadList;
/**
* https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads
*/
export type RESTGetAPIChannelUsersThreadsArchivedResult = APIThreadList;