@discordjs/core 0.1.1-dev.1669637061-8376e2d.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,849 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/api/applicationCommands.ts
5
+ import { makeURLSearchParams } from "@discordjs/rest";
6
+ import {
7
+ Routes
8
+ } from "discord-api-types/v10";
9
+ var ApplicationCommandsAPI = class {
10
+ constructor(rest) {
11
+ this.rest = rest;
12
+ }
13
+ async getGlobalCommands(applicationId, options = {}) {
14
+ return this.rest.get(Routes.applicationCommands(applicationId), {
15
+ query: makeURLSearchParams(options)
16
+ });
17
+ }
18
+ async createGlobalCommand(applicationId, data) {
19
+ return this.rest.post(Routes.applicationCommands(applicationId), {
20
+ body: data
21
+ });
22
+ }
23
+ async getGlobalCommand(applicationId, commandId) {
24
+ return this.rest.get(
25
+ Routes.applicationCommand(applicationId, commandId)
26
+ );
27
+ }
28
+ async editGlobalCommand(applicationId, commandId, data) {
29
+ return this.rest.patch(Routes.applicationCommand(applicationId, commandId), {
30
+ body: data
31
+ });
32
+ }
33
+ async deleteGlobalCommand(applicationId, commandId) {
34
+ await this.rest.delete(Routes.applicationCommand(applicationId, commandId));
35
+ }
36
+ async bulkOverwriteGlobalCommands(applicationId, data) {
37
+ return this.rest.put(Routes.applicationCommands(applicationId), {
38
+ body: data
39
+ });
40
+ }
41
+ async getGuildCommands(applicationId, guildId, data = {}) {
42
+ return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
43
+ query: makeURLSearchParams(data)
44
+ });
45
+ }
46
+ async createGuildCommand(applicationId, guildId, data) {
47
+ return this.rest.post(Routes.applicationGuildCommands(applicationId, guildId), {
48
+ body: data
49
+ });
50
+ }
51
+ async getGuildCommand(applicationId, guildId, commandId) {
52
+ return this.rest.get(
53
+ Routes.applicationGuildCommand(applicationId, guildId, commandId)
54
+ );
55
+ }
56
+ async editGuildCommand(applicationId, guildId, commandId, data) {
57
+ return this.rest.patch(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
58
+ body: data
59
+ });
60
+ }
61
+ async deleteGuildCommand(applicationId, guildId, commandId) {
62
+ await this.rest.delete(Routes.applicationGuildCommand(applicationId, guildId, commandId));
63
+ }
64
+ async bulkOverwriteGuildCommands(applicationId, guildId, data) {
65
+ return this.rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
66
+ body: data
67
+ });
68
+ }
69
+ async getGuildCommandPermissions(applicationId, guildId, commandId) {
70
+ return this.rest.get(
71
+ Routes.applicationCommandPermissions(applicationId, guildId, commandId)
72
+ );
73
+ }
74
+ async getGuildCommandsPermissions(applicationId, guildId) {
75
+ return this.rest.get(
76
+ Routes.guildApplicationCommandsPermissions(applicationId, guildId)
77
+ );
78
+ }
79
+ async editGuildCommandPermissions(userToken, applicationId, guildId, commandId, data) {
80
+ return this.rest.put(Routes.applicationCommandPermissions(applicationId, guildId, commandId), {
81
+ headers: { Authorization: `Bearer ${userToken.replace("Bearer ", "")}` },
82
+ auth: false,
83
+ body: data
84
+ });
85
+ }
86
+ };
87
+ __name(ApplicationCommandsAPI, "ApplicationCommandsAPI");
88
+
89
+ // src/api/channel.ts
90
+ import { makeURLSearchParams as makeURLSearchParams2 } from "@discordjs/rest";
91
+ import {
92
+ Routes as Routes2
93
+ } from "discord-api-types/v10";
94
+ var ChannelsAPI = class {
95
+ constructor(rest) {
96
+ this.rest = rest;
97
+ }
98
+ async createMessage(channelId, { files, ...body }) {
99
+ return this.rest.post(Routes2.channelMessages(channelId), {
100
+ files,
101
+ body
102
+ });
103
+ }
104
+ async editMessage(channelId, messageId, { files, ...body }) {
105
+ return this.rest.patch(Routes2.channelMessage(channelId, messageId), {
106
+ files,
107
+ body
108
+ });
109
+ }
110
+ async getMessageReactions(channelId, messageId, emoji, options = {}) {
111
+ return this.rest.get(Routes2.channelMessageReaction(channelId, messageId, encodeURIComponent(emoji)), {
112
+ query: makeURLSearchParams2(options)
113
+ });
114
+ }
115
+ async deleteOwnMessageReaction(channelId, messageId, emoji) {
116
+ await this.rest.delete(Routes2.channelMessageOwnReaction(channelId, messageId, encodeURIComponent(emoji)));
117
+ }
118
+ async deleteUserMessageReaction(channelId, messageId, emoji, userId) {
119
+ await this.rest.delete(Routes2.channelMessageUserReaction(channelId, messageId, encodeURIComponent(emoji), userId));
120
+ }
121
+ async deleteAllMessageReactions(channelId, messageId) {
122
+ await this.rest.delete(Routes2.channelMessageAllReactions(channelId, messageId));
123
+ }
124
+ async deleteAllMessageReactionsForEmoji(channelId, messageId, emoji) {
125
+ await this.rest.delete(Routes2.channelMessageReaction(channelId, messageId, encodeURIComponent(emoji)));
126
+ }
127
+ async addMessageReaction(channelId, messageId, emoji) {
128
+ await this.rest.put(Routes2.channelMessageOwnReaction(channelId, messageId, encodeURIComponent(emoji)));
129
+ }
130
+ async get(channelId) {
131
+ return this.rest.get(Routes2.channel(channelId));
132
+ }
133
+ async edit(channelId, data) {
134
+ return this.rest.patch(Routes2.channel(channelId), { body: data });
135
+ }
136
+ async delete(channelId) {
137
+ return this.rest.delete(Routes2.channel(channelId));
138
+ }
139
+ async getMessages(channelId, options = {}) {
140
+ return this.rest.get(Routes2.channelMessages(channelId), {
141
+ query: makeURLSearchParams2(options)
142
+ });
143
+ }
144
+ async showTyping(channelId) {
145
+ await this.rest.post(Routes2.channelTyping(channelId));
146
+ }
147
+ async getPins(channelId) {
148
+ return this.rest.get(Routes2.channelPins(channelId));
149
+ }
150
+ async pinMessage(channelId, messageId, reason) {
151
+ await this.rest.put(Routes2.channelPin(channelId, messageId), { reason });
152
+ }
153
+ async deleteMessage(channelId, messageId, reason) {
154
+ await this.rest.delete(Routes2.channelMessage(channelId, messageId), { reason });
155
+ }
156
+ async bulkDeleteMessages(channelId, messageIds, reason) {
157
+ await this.rest.post(Routes2.channelBulkDelete(channelId), { reason, body: { messages: messageIds } });
158
+ }
159
+ async getMessage(channelId, messageId) {
160
+ return this.rest.get(Routes2.channelMessage(channelId, messageId));
161
+ }
162
+ async crosspostMessage(channelId, messageId) {
163
+ return this.rest.post(
164
+ Routes2.channelMessageCrosspost(channelId, messageId)
165
+ );
166
+ }
167
+ async unpinMessage(channelId, messageId, reason) {
168
+ await this.rest.delete(Routes2.channelPin(channelId, messageId), { reason });
169
+ }
170
+ async followAnnouncements(channelId, webhookChannelId) {
171
+ return this.rest.post(Routes2.channelFollowers(channelId), {
172
+ body: { webhook_channel_id: webhookChannelId }
173
+ });
174
+ }
175
+ async createInvite(channelId, data, reason) {
176
+ return this.rest.post(Routes2.channelInvites(channelId), {
177
+ reason,
178
+ body: data
179
+ });
180
+ }
181
+ async getInvites(channelId) {
182
+ return this.rest.get(Routes2.channelInvites(channelId));
183
+ }
184
+ async getArchivedThreads(channelId, archivedStatus, options = {}) {
185
+ return this.rest.get(Routes2.channelThreads(channelId, archivedStatus), {
186
+ query: makeURLSearchParams2(options)
187
+ });
188
+ }
189
+ async getJoinedPrivateArchivedThreads(channelId, options = {}) {
190
+ return this.rest.get(Routes2.channelJoinedArchivedThreads(channelId), {
191
+ query: makeURLSearchParams2(options)
192
+ });
193
+ }
194
+ };
195
+ __name(ChannelsAPI, "ChannelsAPI");
196
+
197
+ // src/api/guild.ts
198
+ import { makeURLSearchParams as makeURLSearchParams3 } from "@discordjs/rest";
199
+ import {
200
+ Routes as Routes3
201
+ } from "discord-api-types/v10";
202
+ var GuildsAPI = class {
203
+ constructor(rest) {
204
+ this.rest = rest;
205
+ }
206
+ async get(guildId) {
207
+ return this.rest.get(Routes3.guild(guildId));
208
+ }
209
+ async getPreview(guildId) {
210
+ return this.rest.get(Routes3.guildPreview(guildId));
211
+ }
212
+ async create(data) {
213
+ return this.rest.post(Routes3.guilds(), { body: data });
214
+ }
215
+ async edit(guildId, data, reason) {
216
+ return this.rest.patch(Routes3.guild(guildId), { reason, body: data });
217
+ }
218
+ async delete(guildId, reason) {
219
+ await this.rest.delete(Routes3.guild(guildId), { reason });
220
+ }
221
+ async getMembers(guildId, options = {}) {
222
+ return this.rest.get(Routes3.guildMembers(guildId), {
223
+ query: makeURLSearchParams3(options)
224
+ });
225
+ }
226
+ async getChannels(guildId) {
227
+ return this.rest.get(Routes3.guildChannels(guildId));
228
+ }
229
+ async createChannel(guildId, data, reason) {
230
+ return this.rest.post(Routes3.guildChannels(guildId), {
231
+ reason,
232
+ body: data
233
+ });
234
+ }
235
+ async setChannelPositions(guildId, data, reason) {
236
+ await this.rest.patch(Routes3.guildChannels(guildId), { reason, body: data });
237
+ }
238
+ async getActiveThreads(guildId) {
239
+ return this.rest.get(Routes3.guildActiveThreads(guildId));
240
+ }
241
+ async getMemberBans(guildId) {
242
+ return this.rest.get(Routes3.guildBans(guildId));
243
+ }
244
+ async banUser(guildId, userId, options = {}, reason) {
245
+ await this.rest.put(Routes3.guildBan(guildId, userId), { reason, body: options });
246
+ }
247
+ async unbanUser(guildId, userId, reason) {
248
+ await this.rest.delete(Routes3.guildBan(guildId, userId), { reason });
249
+ }
250
+ async getRoles(guildId) {
251
+ return this.rest.get(Routes3.guildRoles(guildId));
252
+ }
253
+ async createRole(guildId, data, reason) {
254
+ return this.rest.post(Routes3.guildRoles(guildId), { reason, body: data });
255
+ }
256
+ async setRolePositions(guildId, data, reason) {
257
+ return this.rest.patch(Routes3.guildRoles(guildId), {
258
+ reason,
259
+ body: data
260
+ });
261
+ }
262
+ async editRole(guildId, roleId, data, reason) {
263
+ return this.rest.patch(Routes3.guildRole(guildId, roleId), {
264
+ reason,
265
+ body: data
266
+ });
267
+ }
268
+ async deleteRole(guildId, roleId, reason) {
269
+ await this.rest.delete(Routes3.guildRole(guildId, roleId), { reason });
270
+ }
271
+ async editMFALevel(guildId, level, reason) {
272
+ return this.rest.post(Routes3.guildMFA(guildId), {
273
+ reason,
274
+ body: { mfa_level: level }
275
+ });
276
+ }
277
+ async getPruneCount(guildId, options = {}) {
278
+ return this.rest.get(Routes3.guildPrune(guildId), {
279
+ query: makeURLSearchParams3(options)
280
+ });
281
+ }
282
+ async beginPrune(guildId, options = {}, reason) {
283
+ return this.rest.post(Routes3.guildPrune(guildId), {
284
+ body: options,
285
+ reason
286
+ });
287
+ }
288
+ async getVoiceRegions(guildId) {
289
+ return this.rest.get(Routes3.guildVoiceRegions(guildId));
290
+ }
291
+ async getInvites(guildId) {
292
+ return this.rest.get(Routes3.guildInvites(guildId));
293
+ }
294
+ async getIntegrations(guildId) {
295
+ return this.rest.get(Routes3.guildIntegrations(guildId));
296
+ }
297
+ async deleteIntegration(guildId, integrationId, reason) {
298
+ await this.rest.delete(Routes3.guildIntegration(guildId, integrationId), { reason });
299
+ }
300
+ async getWidgetSettings(guildId) {
301
+ return this.rest.get(Routes3.guildWidgetSettings(guildId));
302
+ }
303
+ async editWidgetSettings(guildId, data, reason) {
304
+ return this.rest.patch(Routes3.guildWidgetSettings(guildId), {
305
+ reason,
306
+ body: data
307
+ });
308
+ }
309
+ async getWidget(guildId) {
310
+ return this.rest.get(Routes3.guildWidgetJSON(guildId));
311
+ }
312
+ async getVanityURL(guildId) {
313
+ return this.rest.get(Routes3.guildVanityUrl(guildId));
314
+ }
315
+ async getWidgetImage(guildId, style) {
316
+ return this.rest.get(Routes3.guildWidgetImage(guildId), {
317
+ query: makeURLSearchParams3({ style })
318
+ });
319
+ }
320
+ async getWelcomeScreen(guildId) {
321
+ return this.rest.get(Routes3.guildWelcomeScreen(guildId));
322
+ }
323
+ async editWelcomeScreen(guildId, data, reason) {
324
+ return this.rest.patch(Routes3.guildWelcomeScreen(guildId), {
325
+ reason,
326
+ body: data
327
+ });
328
+ }
329
+ async editUserVoiceState(guildId, userId, data, reason) {
330
+ await this.rest.patch(Routes3.guildVoiceState(guildId, userId), { reason, body: data });
331
+ }
332
+ async getEmojis(guildId) {
333
+ return this.rest.get(Routes3.guildEmojis(guildId));
334
+ }
335
+ async getEmoji(guildId, emojiId) {
336
+ return this.rest.get(Routes3.guildEmoji(guildId, emojiId));
337
+ }
338
+ async createEmoji(guildId, data, reason) {
339
+ return this.rest.post(Routes3.guildEmojis(guildId), {
340
+ reason,
341
+ body: data
342
+ });
343
+ }
344
+ async editEmoji(guildId, emojiId, data, reason) {
345
+ return this.rest.patch(Routes3.guildEmoji(guildId, emojiId), {
346
+ reason,
347
+ body: data
348
+ });
349
+ }
350
+ async deleteEmoji(guildId, emojiId, reason) {
351
+ await this.rest.delete(Routes3.guildEmoji(guildId, emojiId), { reason });
352
+ }
353
+ async getScheduledEvents(guildId, options = {}) {
354
+ return this.rest.get(Routes3.guildScheduledEvents(guildId), {
355
+ query: makeURLSearchParams3(options)
356
+ });
357
+ }
358
+ async createScheduledEvent(guildId, data, reason) {
359
+ return this.rest.post(Routes3.guildScheduledEvents(guildId), {
360
+ reason,
361
+ body: data
362
+ });
363
+ }
364
+ async getScheduledEvent(guildId, eventId, options = {}) {
365
+ return this.rest.get(Routes3.guildScheduledEvent(guildId, eventId), {
366
+ query: makeURLSearchParams3(options)
367
+ });
368
+ }
369
+ async editScheduledEvent(guildId, eventId, data, reason) {
370
+ return this.rest.patch(Routes3.guildScheduledEvent(guildId, eventId), {
371
+ reason,
372
+ body: data
373
+ });
374
+ }
375
+ async deleteScheduledEvent(guildId, eventId, reason) {
376
+ await this.rest.delete(Routes3.guildScheduledEvent(guildId, eventId), { reason });
377
+ }
378
+ async getScheduledEventUsers(guildId, eventId, options = {}) {
379
+ return this.rest.get(Routes3.guildScheduledEventUsers(guildId, eventId), {
380
+ query: makeURLSearchParams3(options)
381
+ });
382
+ }
383
+ async getTemplates(guildId) {
384
+ return this.rest.get(Routes3.guildTemplates(guildId));
385
+ }
386
+ async syncTemplate(guildId, templateCode) {
387
+ return this.rest.put(Routes3.guildTemplate(guildId, templateCode));
388
+ }
389
+ async editTemplate(guildId, templateCode, data) {
390
+ return this.rest.patch(Routes3.guildTemplate(guildId, templateCode), {
391
+ body: data
392
+ });
393
+ }
394
+ async deleteTemplate(guildId, templateCode) {
395
+ await this.rest.delete(Routes3.guildTemplate(guildId, templateCode));
396
+ }
397
+ async getStickers(guildId) {
398
+ return this.rest.get(Routes3.guildStickers(guildId));
399
+ }
400
+ async getSticker(guildId, stickerId) {
401
+ return this.rest.get(Routes3.guildSticker(guildId, stickerId));
402
+ }
403
+ async createSticker(guildId, { file, ...body }, reason) {
404
+ const fileData = { ...file, key: "file" };
405
+ return this.rest.post(Routes3.guildStickers(guildId), {
406
+ appendToFormData: true,
407
+ body,
408
+ files: [fileData],
409
+ reason
410
+ });
411
+ }
412
+ async editSticker(guildId, stickerId, data, reason) {
413
+ return this.rest.patch(Routes3.guildSticker(guildId, stickerId), {
414
+ reason,
415
+ body: data
416
+ });
417
+ }
418
+ async deleteSticker(guildId, stickerId, reason) {
419
+ await this.rest.delete(Routes3.guildSticker(guildId, stickerId), { reason });
420
+ }
421
+ async getAuditLogs(guildId, options = {}) {
422
+ return this.rest.get(Routes3.guildAuditLog(guildId), {
423
+ query: makeURLSearchParams3(options)
424
+ });
425
+ }
426
+ async getAutoModerationRules(guildId) {
427
+ return this.rest.get(Routes3.guildAutoModerationRules(guildId));
428
+ }
429
+ async getAutoModerationRule(guildId, ruleId) {
430
+ return this.rest.get(
431
+ Routes3.guildAutoModerationRule(guildId, ruleId)
432
+ );
433
+ }
434
+ async createAutoModerationRule(guildId, data, reason) {
435
+ return this.rest.post(Routes3.guildAutoModerationRules(guildId), {
436
+ reason,
437
+ body: data
438
+ });
439
+ }
440
+ async editAutoModerationRule(guildId, ruleId, data, reason) {
441
+ return this.rest.patch(Routes3.guildAutoModerationRule(guildId, ruleId), {
442
+ reason,
443
+ body: data
444
+ });
445
+ }
446
+ async deleteAutoModerationRule(guildId, ruleId, reason) {
447
+ await this.rest.delete(Routes3.guildAutoModerationRule(guildId, ruleId), { reason });
448
+ }
449
+ async getMember(guildId, userId) {
450
+ return this.rest.get(Routes3.guildMember(guildId, userId));
451
+ }
452
+ async searchForMembers(guildId, options) {
453
+ return this.rest.get(Routes3.guildMembersSearch(guildId), {
454
+ query: makeURLSearchParams3(options)
455
+ });
456
+ }
457
+ async editMember(guildId, userId, data = {}, reason) {
458
+ return this.rest.patch(Routes3.guildMember(guildId, userId), {
459
+ reason,
460
+ body: data
461
+ });
462
+ }
463
+ async addRoleToMember(guildId, userId, roleId, reason) {
464
+ await this.rest.put(Routes3.guildMemberRole(guildId, userId, roleId), { reason });
465
+ }
466
+ async removeRoleFromMember(guildId, userId, roleId, reason) {
467
+ await this.rest.delete(Routes3.guildMemberRole(guildId, userId, roleId), { reason });
468
+ }
469
+ async getTemplate(templateCode) {
470
+ return this.rest.get(Routes3.template(templateCode));
471
+ }
472
+ async createTemplate(templateCode, data) {
473
+ return this.rest.post(Routes3.template(templateCode), { body: data });
474
+ }
475
+ };
476
+ __name(GuildsAPI, "GuildsAPI");
477
+
478
+ // src/api/interactions.ts
479
+ import {
480
+ InteractionResponseType,
481
+ Routes as Routes4
482
+ } from "discord-api-types/v10";
483
+ var InteractionsAPI = class {
484
+ constructor(rest, webhooks) {
485
+ this.rest = rest;
486
+ this.webhooks = webhooks;
487
+ }
488
+ async reply(interactionId, interactionToken, { files, ...data }) {
489
+ await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
490
+ files,
491
+ body: {
492
+ type: InteractionResponseType.ChannelMessageWithSource,
493
+ data
494
+ }
495
+ });
496
+ }
497
+ async defer(interactionId, interactionToken) {
498
+ await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
499
+ body: {
500
+ type: InteractionResponseType.DeferredChannelMessageWithSource
501
+ }
502
+ });
503
+ }
504
+ async deferMessageUpdate(interactionId, interactionToken) {
505
+ await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
506
+ body: {
507
+ type: InteractionResponseType.DeferredMessageUpdate
508
+ }
509
+ });
510
+ }
511
+ async followUp(applicationId, interactionToken, data) {
512
+ await this.webhooks.execute(applicationId, interactionToken, data);
513
+ }
514
+ async editReply(applicationId, interactionToken, data, messageId) {
515
+ return this.webhooks.editMessage(applicationId, interactionToken, messageId ?? "@original", data);
516
+ }
517
+ async getOriginalReply(applicationId, interactionToken) {
518
+ return this.webhooks.getMessage(
519
+ applicationId,
520
+ interactionToken,
521
+ "@original"
522
+ );
523
+ }
524
+ async deleteReply(applicationId, interactionToken) {
525
+ await this.webhooks.deleteMessage(applicationId, interactionToken, "@original");
526
+ }
527
+ async updateMessage(interactionId, interactionToken, { files, ...data }) {
528
+ await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
529
+ files,
530
+ body: {
531
+ type: InteractionResponseType.UpdateMessage,
532
+ data
533
+ }
534
+ });
535
+ }
536
+ async createAutocompleteResponse(interactionId, interactionToken, data) {
537
+ await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
538
+ body: {
539
+ type: InteractionResponseType.ApplicationCommandAutocompleteResult,
540
+ data
541
+ }
542
+ });
543
+ }
544
+ async createModal(interactionId, interactionToken, data) {
545
+ await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
546
+ body: {
547
+ type: InteractionResponseType.Modal,
548
+ data
549
+ }
550
+ });
551
+ }
552
+ };
553
+ __name(InteractionsAPI, "InteractionsAPI");
554
+
555
+ // src/api/invite.ts
556
+ import { makeURLSearchParams as makeURLSearchParams4 } from "@discordjs/rest";
557
+ import { Routes as Routes5 } from "discord-api-types/v10";
558
+ var InvitesAPI = class {
559
+ constructor(rest) {
560
+ this.rest = rest;
561
+ }
562
+ async get(code, options = {}) {
563
+ return this.rest.get(Routes5.invite(code), {
564
+ query: makeURLSearchParams4(options)
565
+ });
566
+ }
567
+ async delete(code, reason) {
568
+ await this.rest.delete(Routes5.invite(code), { reason });
569
+ }
570
+ };
571
+ __name(InvitesAPI, "InvitesAPI");
572
+
573
+ // src/api/sticker.ts
574
+ import {
575
+ Routes as Routes6
576
+ } from "discord-api-types/v10";
577
+ var StickersAPI = class {
578
+ constructor(rest) {
579
+ this.rest = rest;
580
+ }
581
+ async getNitroStickers() {
582
+ return this.rest.get(Routes6.nitroStickerPacks());
583
+ }
584
+ async get(stickerId) {
585
+ return this.rest.get(Routes6.sticker(stickerId));
586
+ }
587
+ };
588
+ __name(StickersAPI, "StickersAPI");
589
+
590
+ // src/api/thread.ts
591
+ import {
592
+ Routes as Routes7
593
+ } from "discord-api-types/v10";
594
+ var ThreadsAPI = class {
595
+ constructor(rest) {
596
+ this.rest = rest;
597
+ }
598
+ async get(channelId, threadId) {
599
+ return this.rest.get(Routes7.threads(channelId, threadId));
600
+ }
601
+ async create(channelId, { message_id, ...body }) {
602
+ return this.rest.post(Routes7.threads(channelId, message_id), { body });
603
+ }
604
+ async createForumThread(channelId, { message, ...optionsBody }) {
605
+ const { files, ...messageBody } = message;
606
+ const body = {
607
+ ...optionsBody,
608
+ message: messageBody
609
+ };
610
+ return this.rest.post(Routes7.threads(channelId), { files, body });
611
+ }
612
+ async join(threadId) {
613
+ await this.rest.put(Routes7.threadMembers(threadId, "@me"));
614
+ }
615
+ async addMember(threadId, userId) {
616
+ await this.rest.put(Routes7.threadMembers(threadId, userId));
617
+ }
618
+ async leave(threadId) {
619
+ await this.rest.delete(Routes7.threadMembers(threadId, "@me"));
620
+ }
621
+ async removeMember(threadId, userId) {
622
+ await this.rest.delete(Routes7.threadMembers(threadId, userId));
623
+ }
624
+ async getMember(threadId, userId) {
625
+ return this.rest.get(Routes7.threadMembers(threadId, userId));
626
+ }
627
+ async getAllMembers(threadId) {
628
+ return this.rest.get(Routes7.threadMembers(threadId));
629
+ }
630
+ };
631
+ __name(ThreadsAPI, "ThreadsAPI");
632
+
633
+ // src/api/user.ts
634
+ import { makeURLSearchParams as makeURLSearchParams5 } from "@discordjs/rest";
635
+ import {
636
+ Routes as Routes8
637
+ } from "discord-api-types/v10";
638
+ var UsersAPI = class {
639
+ constructor(rest) {
640
+ this.rest = rest;
641
+ }
642
+ async get(userId) {
643
+ return this.rest.get(Routes8.user(userId));
644
+ }
645
+ async getCurrent() {
646
+ return this.rest.get(Routes8.user("@me"));
647
+ }
648
+ async getGuilds(options = {}) {
649
+ return this.rest.get(Routes8.userGuilds(), {
650
+ query: makeURLSearchParams5(options)
651
+ });
652
+ }
653
+ async leaveGuild(guildId) {
654
+ await this.rest.delete(Routes8.userGuild(guildId));
655
+ }
656
+ async edit(user) {
657
+ return this.rest.patch(Routes8.user("@me"), { body: user });
658
+ }
659
+ async getGuildMember(guildId) {
660
+ return this.rest.get(Routes8.userGuildMember(guildId));
661
+ }
662
+ async editGuildMember(guildId, member = {}, reason) {
663
+ return this.rest.patch(Routes8.guildMember(guildId, "@me"), {
664
+ reason,
665
+ body: member
666
+ });
667
+ }
668
+ async setVoiceState(guildId, options = {}) {
669
+ return this.rest.patch(Routes8.guildVoiceState(guildId, "@me"), {
670
+ body: options
671
+ });
672
+ }
673
+ async createDM(userId) {
674
+ return this.rest.post(Routes8.userChannels(), {
675
+ body: { recipient_id: userId }
676
+ });
677
+ }
678
+ };
679
+ __name(UsersAPI, "UsersAPI");
680
+
681
+ // src/api/voice.ts
682
+ import { Routes as Routes9 } from "discord-api-types/v10";
683
+ var VoiceAPI = class {
684
+ constructor(rest) {
685
+ this.rest = rest;
686
+ }
687
+ async getVoiceRegions() {
688
+ return this.rest.get(Routes9.voiceRegions());
689
+ }
690
+ };
691
+ __name(VoiceAPI, "VoiceAPI");
692
+
693
+ // src/api/webhook.ts
694
+ import { makeURLSearchParams as makeURLSearchParams6 } from "@discordjs/rest";
695
+ import {
696
+ Routes as Routes10
697
+ } from "discord-api-types/v10";
698
+ var WebhooksAPI = class {
699
+ constructor(rest) {
700
+ this.rest = rest;
701
+ }
702
+ async get(id, token) {
703
+ return this.rest.get(Routes10.webhook(id, token));
704
+ }
705
+ async create(channelId, data, reason) {
706
+ return this.rest.post(Routes10.channelWebhooks(channelId), {
707
+ reason,
708
+ body: data
709
+ });
710
+ }
711
+ async edit(id, webhook, { token, reason } = {}) {
712
+ return this.rest.patch(Routes10.webhook(id, token), { reason, body: webhook });
713
+ }
714
+ async delete(id, { token, reason } = {}) {
715
+ await this.rest.delete(Routes10.webhook(id, token), { reason });
716
+ }
717
+ async execute(id, token, {
718
+ wait,
719
+ thread_id,
720
+ files,
721
+ ...body
722
+ }) {
723
+ return this.rest.post(Routes10.webhook(id, token), {
724
+ query: makeURLSearchParams6({ wait, thread_id }),
725
+ files,
726
+ body,
727
+ auth: false
728
+ });
729
+ }
730
+ async executeSlack(id, token, body, options = {}) {
731
+ await this.rest.post(Routes10.webhookPlatform(id, token, "slack"), {
732
+ query: makeURLSearchParams6(options),
733
+ body,
734
+ auth: false
735
+ });
736
+ }
737
+ async executeGitHub(id, token, body, options = {}) {
738
+ await this.rest.post(Routes10.webhookPlatform(id, token, "github"), {
739
+ query: makeURLSearchParams6(options),
740
+ body,
741
+ auth: false
742
+ });
743
+ }
744
+ async getMessage(id, token, messageId, options = {}) {
745
+ return this.rest.get(Routes10.webhookMessage(id, token, messageId), {
746
+ query: makeURLSearchParams6(options),
747
+ auth: false
748
+ });
749
+ }
750
+ async editMessage(id, token, messageId, { thread_id, ...body }) {
751
+ return this.rest.patch(Routes10.webhookMessage(id, token, messageId), {
752
+ query: makeURLSearchParams6({ thread_id }),
753
+ auth: false,
754
+ body
755
+ });
756
+ }
757
+ async deleteMessage(id, token, messageId, options = {}) {
758
+ await this.rest.delete(Routes10.webhookMessage(id, token, messageId), {
759
+ query: makeURLSearchParams6(options),
760
+ auth: false
761
+ });
762
+ }
763
+ };
764
+ __name(WebhooksAPI, "WebhooksAPI");
765
+
766
+ // src/api/index.ts
767
+ var API = class {
768
+ constructor(rest) {
769
+ this.rest = rest;
770
+ this.applicationCommands = new ApplicationCommandsAPI(rest);
771
+ this.channels = new ChannelsAPI(rest);
772
+ this.guilds = new GuildsAPI(rest);
773
+ this.invites = new InvitesAPI(rest);
774
+ this.stickers = new StickersAPI(rest);
775
+ this.threads = new ThreadsAPI(rest);
776
+ this.users = new UsersAPI(rest);
777
+ this.voice = new VoiceAPI(rest);
778
+ this.webhooks = new WebhooksAPI(rest);
779
+ this.interactions = new InteractionsAPI(rest, this.webhooks);
780
+ }
781
+ applicationCommands;
782
+ channels;
783
+ guilds;
784
+ interactions;
785
+ invites;
786
+ stickers;
787
+ threads;
788
+ users;
789
+ voice;
790
+ webhooks;
791
+ };
792
+ __name(API, "API");
793
+
794
+ // src/client.ts
795
+ import { WebSocketShardEvents } from "@discordjs/ws";
796
+ import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
797
+ function createClient({ rest, ws }) {
798
+ const api = new API(rest);
799
+ const emitter = new AsyncEventEmitter();
800
+ function wrapIntrinsicProps(obj, shardId) {
801
+ return {
802
+ api,
803
+ shardId,
804
+ data: obj
805
+ };
806
+ }
807
+ __name(wrapIntrinsicProps, "wrapIntrinsicProps");
808
+ ws.on(WebSocketShardEvents.Dispatch, ({ data: dispatch, shardId }) => {
809
+ emitter.emit(dispatch.t, wrapIntrinsicProps(dispatch.d, shardId));
810
+ });
811
+ return emitter;
812
+ }
813
+ __name(createClient, "createClient");
814
+
815
+ // src/util/files.ts
816
+ function withFiles(files, options) {
817
+ const body = {
818
+ ...options,
819
+ attachments: files.map((file, index) => ({
820
+ id: index.toString(),
821
+ description: file.description
822
+ }))
823
+ };
824
+ const outputFiles = files.map((file, index) => ({
825
+ name: file.name ?? index.toString(),
826
+ data: file.data
827
+ }));
828
+ return { body, files: outputFiles };
829
+ }
830
+ __name(withFiles, "withFiles");
831
+
832
+ // src/index.ts
833
+ export * from "discord-api-types/v10";
834
+ export {
835
+ API,
836
+ ApplicationCommandsAPI,
837
+ ChannelsAPI,
838
+ GuildsAPI,
839
+ InteractionsAPI,
840
+ InvitesAPI,
841
+ StickersAPI,
842
+ ThreadsAPI,
843
+ UsersAPI,
844
+ VoiceAPI,
845
+ WebhooksAPI,
846
+ createClient,
847
+ withFiles
848
+ };
849
+ //# sourceMappingURL=index.mjs.map