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