disgroove 2.2.0-dev.15819eb → 2.2.0-dev.301452e
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/lib/Client.d.ts +500 -73
- package/dist/lib/Client.js +917 -716
- package/dist/lib/gateway/Shard.js +277 -62
- package/dist/lib/index.d.ts +25 -0
- package/dist/lib/index.js +25 -0
- package/dist/lib/types/application-command.d.ts +0 -73
- package/dist/lib/types/application.d.ts +0 -12
- package/dist/lib/types/auto-moderation.d.ts +0 -20
- package/dist/lib/types/channel.d.ts +2 -105
- package/dist/lib/types/emoji.d.ts +0 -9
- package/dist/lib/types/entitlements.d.ts +0 -5
- package/dist/lib/types/guild-scheduled-event.d.ts +0 -23
- package/dist/lib/types/guild-template.d.ts +0 -12
- package/dist/lib/types/guild.d.ts +2 -160
- package/dist/lib/types/interaction.d.ts +0 -3
- package/dist/lib/types/stage-instance.d.ts +0 -11
- package/dist/lib/types/sticker.d.ts +0 -12
- package/dist/lib/types/user.d.ts +2 -26
- package/dist/lib/types/webhook.d.ts +2 -38
- package/dist/lib/utils/Util.d.ts +88 -2
- package/dist/lib/utils/Util.js +2137 -29
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/lib/Client.js
CHANGED
@@ -47,9 +47,8 @@ class Client extends node_events_1.default {
|
|
47
47
|
});
|
48
48
|
}
|
49
49
|
/** https://discord.com/developers/docs/resources/guild#add-guild-member */
|
50
|
-
addGuildMember(guildId, userId, options) {
|
51
|
-
|
52
|
-
.request(rest_1.RESTMethods.Put, rest_1.Endpoints.guildMember(guildId, userId), {
|
50
|
+
async addGuildMember(guildId, userId, options) {
|
51
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.guildMember(guildId, userId), {
|
53
52
|
json: {
|
54
53
|
access_token: options.accessToken,
|
55
54
|
nick: options.nick,
|
@@ -57,8 +56,8 @@ class Client extends node_events_1.default {
|
|
57
56
|
mute: options.mute,
|
58
57
|
deaf: options.deaf,
|
59
58
|
},
|
60
|
-
})
|
61
|
-
|
59
|
+
});
|
60
|
+
return response !== null ? this.util.guildMemberFromRaw(response) : null;
|
62
61
|
}
|
63
62
|
/** https://discord.com/developers/docs/resources/guild#add-guild-member-role */
|
64
63
|
addGuildMemberRole(guildId, userId, roleId, reason) {
|
@@ -72,8 +71,7 @@ class Client extends node_events_1.default {
|
|
72
71
|
}
|
73
72
|
/** https://discord.com/developers/docs/resources/guild#begin-guild-prune */
|
74
73
|
beginGuildPrune(guildId, options, reason) {
|
75
|
-
return this.rest
|
76
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildPrune(guildId), {
|
74
|
+
return this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildPrune(guildId), {
|
77
75
|
json: {
|
78
76
|
days: options.days,
|
79
77
|
compute_prune_count: options.computePruneCount,
|
@@ -81,20 +79,21 @@ class Client extends node_events_1.default {
|
|
81
79
|
reason: options.reason,
|
82
80
|
},
|
83
81
|
reason,
|
84
|
-
})
|
85
|
-
.then((response) => this.util.toCamelCase(response));
|
82
|
+
});
|
86
83
|
}
|
87
84
|
/** https://discord.com/developers/docs/resources/guild#bulk-guild-ban */
|
88
|
-
bulkGuildBan(guildId, options, reason) {
|
89
|
-
|
90
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.bulkGuildBan(guildId), {
|
85
|
+
async bulkGuildBan(guildId, options, reason) {
|
86
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.bulkGuildBan(guildId), {
|
91
87
|
json: {
|
92
88
|
user_ids: options.userIds,
|
93
89
|
delete_message_seconds: options.deleteMessageSeconds,
|
94
90
|
},
|
95
91
|
reason,
|
96
|
-
})
|
97
|
-
|
92
|
+
});
|
93
|
+
return {
|
94
|
+
bannedUsers: response.banned_users,
|
95
|
+
failedUsers: response.failed_users,
|
96
|
+
};
|
98
97
|
}
|
99
98
|
/** https://discord.com/developers/docs/resources/channel#bulk-delete-messages */
|
100
99
|
bulkDeleteMessages(channelId, options, reason) {
|
@@ -106,20 +105,18 @@ class Client extends node_events_1.default {
|
|
106
105
|
});
|
107
106
|
}
|
108
107
|
/** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */
|
109
|
-
bulkEditGlobalApplicationCommands(applicationId, commands) {
|
110
|
-
|
111
|
-
.
|
112
|
-
|
113
|
-
|
114
|
-
.then((response) => response.map((applicationCommand) => this.util.toCamelCase(applicationCommand)));
|
108
|
+
async bulkEditGlobalApplicationCommands(applicationId, commands) {
|
109
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommands(applicationId), {
|
110
|
+
json: commands.map((command) => this.util.partialApplicationCommandToRaw(command)),
|
111
|
+
});
|
112
|
+
return response.map((c) => this.util.applicationCommandFromRaw(c));
|
115
113
|
}
|
116
114
|
/** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */
|
117
|
-
bulkEditGuildApplicationCommands(applicationId, guildId, commands) {
|
118
|
-
|
119
|
-
.
|
120
|
-
|
121
|
-
|
122
|
-
.then((response) => response.map((applicationCommand) => this.util.toCamelCase(applicationCommand)));
|
115
|
+
async bulkEditGuildApplicationCommands(applicationId, guildId, commands) {
|
116
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationGuildCommands(applicationId, guildId), {
|
117
|
+
json: commands.map((command) => this.util.partialApplicationCommandToRaw(command)),
|
118
|
+
});
|
119
|
+
return response.map((c) => this.util.applicationCommandFromRaw(c));
|
123
120
|
}
|
124
121
|
/** https://discord.com/developers/docs/topics/gateway#connections */
|
125
122
|
async connect() {
|
@@ -136,27 +133,32 @@ class Client extends node_events_1.default {
|
|
136
133
|
this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationEntitlementConsume(applicationId, entitlementId));
|
137
134
|
}
|
138
135
|
/** https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule */
|
139
|
-
createAutoModerationRule(guildId, options, reason) {
|
140
|
-
|
141
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildAutoModerationRules(guildId), {
|
136
|
+
async createAutoModerationRule(guildId, options, reason) {
|
137
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildAutoModerationRules(guildId), {
|
142
138
|
json: {
|
143
139
|
name: options.name,
|
144
140
|
event_type: options.eventType,
|
145
141
|
trigger_type: options.triggerType,
|
146
142
|
trigger_metadata: options.triggerMetadata,
|
147
|
-
actions: options.actions.map((action) =>
|
143
|
+
actions: options.actions.map((action) => ({
|
144
|
+
type: action.type,
|
145
|
+
metadata: {
|
146
|
+
channel_id: action.metadata.channelId,
|
147
|
+
duration_seconds: action.metadata.durationSeconds,
|
148
|
+
custom_message: action.metadata.customMessage,
|
149
|
+
},
|
150
|
+
})),
|
148
151
|
enabled: options.enabled,
|
149
152
|
exempt_roles: options.exemptRoles,
|
150
153
|
exempt_channels: options.exemptChannels,
|
151
154
|
},
|
152
155
|
reason,
|
153
|
-
})
|
154
|
-
|
156
|
+
});
|
157
|
+
return this.util.autoModerationRuleFromRaw(response);
|
155
158
|
}
|
156
159
|
/** https://discord.com/developers/docs/resources/guild#create-guild-channel */
|
157
|
-
createChannel(guildId, options, reason) {
|
158
|
-
|
159
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildChannels(guildId), {
|
160
|
+
async createChannel(guildId, options, reason) {
|
161
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildChannels(guildId), {
|
160
162
|
json: {
|
161
163
|
name: options.name,
|
162
164
|
type: options.type,
|
@@ -173,7 +175,10 @@ class Client extends node_events_1.default {
|
|
173
175
|
default_auto_archive_duration: options.defaultAutoArchiveDuration,
|
174
176
|
default_reaction_emoji: options.defaultReactionEmoji !== undefined
|
175
177
|
? options.defaultReactionEmoji !== null
|
176
|
-
?
|
178
|
+
? {
|
179
|
+
emoji_id: options.defaultReactionEmoji.emojiId,
|
180
|
+
emoji_name: options.defaultReactionEmoji.emojiName,
|
181
|
+
}
|
177
182
|
: null
|
178
183
|
: undefined,
|
179
184
|
available_tags: options.availableTags,
|
@@ -182,13 +187,12 @@ class Client extends node_events_1.default {
|
|
182
187
|
default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,
|
183
188
|
},
|
184
189
|
reason,
|
185
|
-
})
|
186
|
-
|
190
|
+
});
|
191
|
+
return this.util.channelFromRaw(response);
|
187
192
|
}
|
188
193
|
/** https://discord.com/developers/docs/resources/channel#create-channel-invite */
|
189
|
-
createChannelInvite(channelId, options, reason) {
|
190
|
-
|
191
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelInvites(channelId), {
|
194
|
+
async createChannelInvite(channelId, options, reason) {
|
195
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelInvites(channelId), {
|
192
196
|
json: {
|
193
197
|
max_age: options.maxAge,
|
194
198
|
max_uses: options.maxUses,
|
@@ -199,65 +203,49 @@ class Client extends node_events_1.default {
|
|
199
203
|
target_application_id: options.targetApplicationId,
|
200
204
|
},
|
201
205
|
reason,
|
202
|
-
})
|
203
|
-
|
206
|
+
});
|
207
|
+
return this.util.inviteFromRaw(response);
|
204
208
|
}
|
205
209
|
/** https://discord.com/developers/docs/resources/webhook#create-webhook */
|
206
|
-
createChannelWebhook(channelId, options, reason) {
|
207
|
-
|
208
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelWebhooks(channelId), {
|
210
|
+
async createChannelWebhook(channelId, options, reason) {
|
211
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelWebhooks(channelId), {
|
209
212
|
json: {
|
210
213
|
name: options.name,
|
211
214
|
avatar: options.avatar,
|
212
215
|
},
|
213
216
|
reason,
|
214
|
-
})
|
215
|
-
|
217
|
+
});
|
218
|
+
return this.util.webhookFromRaw(response);
|
216
219
|
}
|
217
220
|
/** https://discord.com/developers/docs/resources/user#create-dm */
|
218
|
-
createDM(options) {
|
219
|
-
|
220
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.userChannels(), {
|
221
|
+
async createDM(options) {
|
222
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.userChannels(), {
|
221
223
|
json: {
|
222
224
|
recipient_id: options.recipientId,
|
223
225
|
},
|
224
|
-
})
|
225
|
-
|
226
|
+
});
|
227
|
+
return this.util.channelFromRaw(response);
|
226
228
|
}
|
227
229
|
/** https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */
|
228
|
-
createGlobalApplicationCommand(applicationId, options) {
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
name: options.name,
|
234
|
-
name_localizations: options.nameLocalizations,
|
235
|
-
description: options.description,
|
236
|
-
description_localizations: options.descriptionLocalizations,
|
237
|
-
options: options.options?.map((option) => this.util.toSnakeCase(option)),
|
238
|
-
default_member_permissions: options.defaultMemberPermissions,
|
239
|
-
dm_permission: options.dmPermission,
|
240
|
-
default_permission: options.defaultPermission,
|
241
|
-
nsfw: options.nsfw,
|
242
|
-
},
|
243
|
-
})
|
244
|
-
.then((response) => this.util.toCamelCase(response));
|
230
|
+
async createGlobalApplicationCommand(applicationId, options) {
|
231
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationCommands(applicationId), {
|
232
|
+
json: this.util.partialApplicationCommandToRaw(options),
|
233
|
+
});
|
234
|
+
return this.util.applicationCommandFromRaw(response);
|
245
235
|
}
|
246
236
|
/** https://discord.com/developers/docs/resources/user#create-group-dm */
|
247
|
-
createGroupDM(options) {
|
248
|
-
|
249
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.userChannels(), {
|
237
|
+
async createGroupDM(options) {
|
238
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.userChannels(), {
|
250
239
|
json: {
|
251
240
|
access_tokens: options.accessTokens,
|
252
241
|
nicks: options.nicks,
|
253
242
|
},
|
254
|
-
})
|
255
|
-
|
243
|
+
});
|
244
|
+
return this.util.channelFromRaw(response);
|
256
245
|
}
|
257
246
|
/** https://discord.com/developers/docs/resources/guild#create-guild */
|
258
|
-
createGuild(options) {
|
259
|
-
|
260
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guilds(), {
|
247
|
+
async createGuild(options) {
|
248
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guilds(), {
|
261
249
|
json: {
|
262
250
|
name: options.name,
|
263
251
|
region: options.region,
|
@@ -265,33 +253,29 @@ class Client extends node_events_1.default {
|
|
265
253
|
verification_level: options.verificationLevel,
|
266
254
|
default_message_notifications: options.defaultMessageNotifications,
|
267
255
|
explicit_content_filter: options.explicitContentFilter,
|
268
|
-
roles: options.roles?.map((role) =>
|
269
|
-
|
256
|
+
roles: options.roles?.map((role) => ({
|
257
|
+
name: role.name,
|
258
|
+
color: role.color,
|
259
|
+
hoist: role.hoist,
|
260
|
+
icon: role.icon,
|
261
|
+
unicode_emoji: role.unicodeEmoji,
|
262
|
+
permissions: role.permissions,
|
263
|
+
mentionable: role.mentionable,
|
264
|
+
})),
|
270
265
|
afk_channel_id: options.afkChannelId,
|
271
266
|
afk_timeout: options.afkTimeout,
|
272
267
|
system_channel_id: options.systemChannelId,
|
273
268
|
system_channel_flags: options.systemChannelFlags,
|
274
269
|
},
|
275
|
-
})
|
276
|
-
|
270
|
+
});
|
271
|
+
return this.util.guildFromRaw(response);
|
277
272
|
}
|
278
273
|
/** https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */
|
279
|
-
createGuildApplicationCommand(applicationId, guildId, options) {
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
name: options.name,
|
285
|
-
name_localizations: options.nameLocalizations,
|
286
|
-
description: options.description,
|
287
|
-
description_localizations: options.descriptionLocalizations,
|
288
|
-
options: options.options?.map((option) => this.util.toSnakeCase(option)),
|
289
|
-
default_member_permissions: options.defaultMemberPermissions,
|
290
|
-
default_permission: options.defaultPermission,
|
291
|
-
nsfw: options.nsfw,
|
292
|
-
},
|
293
|
-
})
|
294
|
-
.then((response) => this.util.toCamelCase(response));
|
274
|
+
async createGuildApplicationCommand(applicationId, guildId, options) {
|
275
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationGuildCommands(applicationId, guildId), {
|
276
|
+
json: this.util.partialApplicationCommandToRaw(options),
|
277
|
+
});
|
278
|
+
return this.util.applicationCommandFromRaw(response);
|
295
279
|
}
|
296
280
|
/** https://discord.com/developers/docs/resources/guild#create-guild-ban */
|
297
281
|
createGuildBan(guildId, userId, options, reason) {
|
@@ -304,33 +288,30 @@ class Client extends node_events_1.default {
|
|
304
288
|
});
|
305
289
|
}
|
306
290
|
/** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */
|
307
|
-
createGuildEmoji(guildId, options, reason) {
|
308
|
-
|
309
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildEmojis(guildId), {
|
291
|
+
async createGuildEmoji(guildId, options, reason) {
|
292
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildEmojis(guildId), {
|
310
293
|
json: {
|
311
294
|
name: options.name,
|
312
295
|
image: options.image,
|
313
296
|
roles: options.roles,
|
314
297
|
},
|
315
298
|
reason,
|
316
|
-
})
|
317
|
-
|
299
|
+
});
|
300
|
+
return this.util.emojiFromRaw(response);
|
318
301
|
}
|
319
302
|
/** https://discord.com/developers/docs/resources/guild-template#create-guild-from-guild-template */
|
320
|
-
createGuildFromTemplate(code, options) {
|
321
|
-
|
322
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.template(code), {
|
303
|
+
async createGuildFromTemplate(code, options) {
|
304
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.template(code), {
|
323
305
|
json: {
|
324
306
|
name: options.name,
|
325
307
|
icon: options.icon,
|
326
308
|
},
|
327
|
-
})
|
328
|
-
|
309
|
+
});
|
310
|
+
return this.util.guildFromRaw(response);
|
329
311
|
}
|
330
312
|
/** https://discord.com/developers/docs/resources/guild#create-guild-role */
|
331
|
-
createGuildRole(guildId, options, reason) {
|
332
|
-
|
333
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildRoles(guildId), {
|
313
|
+
async createGuildRole(guildId, options, reason) {
|
314
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildRoles(guildId), {
|
334
315
|
json: {
|
335
316
|
name: options.name,
|
336
317
|
permissions: options.permissions,
|
@@ -341,13 +322,12 @@ class Client extends node_events_1.default {
|
|
341
322
|
mentionable: options.mentionable,
|
342
323
|
},
|
343
324
|
reason,
|
344
|
-
})
|
345
|
-
|
325
|
+
});
|
326
|
+
return this.util.roleFromRaw(response);
|
346
327
|
}
|
347
328
|
/** https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event */
|
348
|
-
createGuildScheduledEvent(guildId, options, reason) {
|
349
|
-
|
350
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildScheduledEvents(guildId), {
|
329
|
+
async createGuildScheduledEvent(guildId, options, reason) {
|
330
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildScheduledEvents(guildId), {
|
351
331
|
json: {
|
352
332
|
channel_id: options.channelId,
|
353
333
|
entity_metadata: options.entityMetadata,
|
@@ -360,63 +340,63 @@ class Client extends node_events_1.default {
|
|
360
340
|
image: options.image,
|
361
341
|
},
|
362
342
|
reason,
|
363
|
-
})
|
364
|
-
|
343
|
+
});
|
344
|
+
return this.util.guildScheduledEventFromRaw(response);
|
365
345
|
}
|
366
346
|
/** https://discord.com/developers/docs/resources/sticker#create-guild-sticker */
|
367
|
-
createGuildSticker(guildId, options, reason) {
|
347
|
+
async createGuildSticker(guildId, options, reason) {
|
368
348
|
const formData = new FormData();
|
369
349
|
formData.set("name", options.name);
|
370
350
|
formData.set("description", options.description);
|
371
351
|
formData.set("tags", options.tags);
|
372
352
|
formData.set("file", new Blob([options.file.contents]), options.file.name);
|
373
|
-
|
374
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildStickers(guildId), {
|
353
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildStickers(guildId), {
|
375
354
|
form: formData,
|
376
355
|
reason,
|
377
|
-
})
|
378
|
-
|
356
|
+
});
|
357
|
+
return this.util.stickerFromRaw(response);
|
379
358
|
}
|
380
359
|
/** https://discord.com/developers/docs/resources/guild-template#create-guild-template */
|
381
|
-
createGuildTemplate(guildId, options) {
|
382
|
-
|
383
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildTemplates(guildId), {
|
360
|
+
async createGuildTemplate(guildId, options) {
|
361
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.guildTemplates(guildId), {
|
384
362
|
json: {
|
385
363
|
name: options.name,
|
386
364
|
description: options.description,
|
387
365
|
},
|
388
|
-
})
|
389
|
-
|
366
|
+
});
|
367
|
+
return this.util.guildTemplateFromRaw(response);
|
390
368
|
}
|
391
369
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */
|
392
|
-
createInteractionFollowupMessage(applicationId, interactionToken, options) {
|
393
|
-
|
394
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhook(applicationId, interactionToken), {
|
370
|
+
async createInteractionFollowupMessage(applicationId, interactionToken, options) {
|
371
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhook(applicationId, interactionToken), {
|
395
372
|
json: {
|
396
373
|
content: options.content,
|
397
374
|
tts: options.tts,
|
398
|
-
embeds: options.embeds !==
|
399
|
-
? options.embeds
|
400
|
-
|
401
|
-
: null
|
402
|
-
: undefined,
|
375
|
+
embeds: options.embeds !== null
|
376
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
377
|
+
: null,
|
403
378
|
allowed_mentions: options.allowedMentions !== undefined
|
404
379
|
? options.allowedMentions !== null
|
405
|
-
?
|
380
|
+
? {
|
381
|
+
parse: options.allowedMentions.parse,
|
382
|
+
roles: options.allowedMentions.roles,
|
383
|
+
users: options.allowedMentions.users,
|
384
|
+
replied_user: options.allowedMentions.repliedUser,
|
385
|
+
}
|
406
386
|
: null
|
407
387
|
: undefined,
|
408
388
|
components: options.components !== undefined
|
409
389
|
? options.components !== null
|
410
|
-
?
|
390
|
+
? this.util.messageComponentsToRaw(options.components)
|
411
391
|
: null
|
412
392
|
: undefined,
|
413
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
393
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
414
394
|
flags: options.flags,
|
415
395
|
thread_name: options.threadName,
|
416
396
|
},
|
417
397
|
files: options.files,
|
418
|
-
})
|
419
|
-
|
398
|
+
});
|
399
|
+
return this.util.messageFromRaw(response);
|
420
400
|
}
|
421
401
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */
|
422
402
|
createInteractionResponse(interactionId, interactionToken, options) {
|
@@ -430,18 +410,32 @@ class Client extends node_events_1.default {
|
|
430
410
|
data: {
|
431
411
|
content: options.data?.content,
|
432
412
|
embeds: options.data?.embeds !== undefined
|
433
|
-
?
|
413
|
+
? options.data.embeds.map((embed) => this.util.embedToRaw(embed))
|
434
414
|
: undefined,
|
435
415
|
allowed_mentions: options.data?.allowedMentions !== undefined
|
436
|
-
?
|
416
|
+
? {
|
417
|
+
parse: options.data.allowedMentions.parse,
|
418
|
+
roles: options.data.allowedMentions.roles,
|
419
|
+
users: options.data.allowedMentions.users,
|
420
|
+
replied_user: options.data.allowedMentions.repliedUser,
|
421
|
+
}
|
437
422
|
: undefined,
|
438
423
|
flags: options.data?.flags,
|
439
424
|
components: options.data?.components !== undefined
|
440
|
-
? this.util.
|
425
|
+
? this.util.messageComponentsToRaw(options.data.components)
|
441
426
|
: undefined,
|
442
|
-
attachments: options.data?.attachments?.map((attachment) => this.util.
|
427
|
+
attachments: options.data?.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
443
428
|
poll: options.data?.poll !== undefined
|
444
|
-
?
|
429
|
+
? {
|
430
|
+
question: options.data.poll.question,
|
431
|
+
answers: options.data.poll.answers.map((answer) => ({
|
432
|
+
answer_id: answer.answerId,
|
433
|
+
poll_media: answer.pollMedia,
|
434
|
+
})),
|
435
|
+
duration: options.data.poll.duration,
|
436
|
+
allow_multiselect: options.data.poll.allowMultiselect,
|
437
|
+
layout_type: options.data.poll.layoutType,
|
438
|
+
}
|
445
439
|
: undefined,
|
446
440
|
},
|
447
441
|
},
|
@@ -468,7 +462,11 @@ class Client extends node_events_1.default {
|
|
468
462
|
json: {
|
469
463
|
type: options.type,
|
470
464
|
data: {
|
471
|
-
choices: options.data?.choices?.map((choice) =>
|
465
|
+
choices: options.data?.choices?.map((choice) => ({
|
466
|
+
name: choice.name,
|
467
|
+
name_localizations: choice.nameLocalizations,
|
468
|
+
value: choice.value,
|
469
|
+
})),
|
472
470
|
},
|
473
471
|
},
|
474
472
|
});
|
@@ -482,7 +480,7 @@ class Client extends node_events_1.default {
|
|
482
480
|
data: {
|
483
481
|
custom_id: options.data?.customId,
|
484
482
|
components: options.data?.components !== undefined
|
485
|
-
? this.util.
|
483
|
+
? this.util.messageComponentsToRaw(options.data.components)
|
486
484
|
: undefined,
|
487
485
|
title: options.data?.title,
|
488
486
|
},
|
@@ -503,43 +501,53 @@ class Client extends node_events_1.default {
|
|
503
501
|
}
|
504
502
|
}
|
505
503
|
/** https://discord.com/developers/docs/resources/channel#create-message */
|
506
|
-
createMessage(channelId, options) {
|
507
|
-
|
508
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelMessages(channelId), {
|
504
|
+
async createMessage(channelId, options) {
|
505
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelMessages(channelId), {
|
509
506
|
json: {
|
510
507
|
content: options.content,
|
511
508
|
nonce: options.nonce,
|
512
509
|
tts: options.tts,
|
513
|
-
embeds: options.embeds
|
514
|
-
? options.embeds.map((e) => this.util.toSnakeCase(e))
|
515
|
-
: undefined,
|
510
|
+
embeds: options.embeds?.map((embed) => this.util.embedToRaw(embed)),
|
516
511
|
allowed_mentions: options.allowedMentions !== undefined
|
517
|
-
?
|
512
|
+
? {
|
513
|
+
parse: options.allowedMentions.parse,
|
514
|
+
roles: options.allowedMentions.roles,
|
515
|
+
users: options.allowedMentions.users,
|
516
|
+
replied_user: options.allowedMentions.repliedUser,
|
517
|
+
}
|
518
518
|
: undefined,
|
519
519
|
message_reference: options.messageReference,
|
520
520
|
components: options.components !== undefined
|
521
|
-
?
|
521
|
+
? this.util.messageComponentsToRaw(options.components)
|
522
522
|
: undefined,
|
523
523
|
stickers_ids: options.stickersIds,
|
524
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
524
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
525
525
|
flags: options.flags,
|
526
526
|
enforce_nonce: options.enforceNonce,
|
527
527
|
poll: options.poll !== undefined
|
528
|
-
?
|
528
|
+
? {
|
529
|
+
question: options.poll.question,
|
530
|
+
answers: options.poll.answers.map((answer) => ({
|
531
|
+
answer_id: answer.answerId,
|
532
|
+
poll_media: answer.pollMedia,
|
533
|
+
})),
|
534
|
+
duration: options.poll.duration,
|
535
|
+
allow_multiselect: options.poll.allowMultiselect,
|
536
|
+
layout_type: options.poll.layoutType,
|
537
|
+
}
|
529
538
|
: undefined,
|
530
539
|
},
|
531
540
|
files: options.files,
|
532
|
-
})
|
533
|
-
|
541
|
+
});
|
542
|
+
return this.util.messageFromRaw(response);
|
534
543
|
}
|
535
544
|
/** https://discord.com/developers/docs/resources/channel#create-reaction */
|
536
545
|
createMessageReaction(channelId, messageId, emoji) {
|
537
546
|
this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.channelMessageReaction(channelId, messageId, emoji));
|
538
547
|
}
|
539
548
|
/** https://discord.com/developers/docs/resources/stage-instance#create-stage-instance */
|
540
|
-
createStageInstance(options, reason) {
|
541
|
-
|
542
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.stageInstances(), {
|
549
|
+
async createStageInstance(options, reason) {
|
550
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.stageInstances(), {
|
543
551
|
json: {
|
544
552
|
channel_id: options.channelId,
|
545
553
|
topic: options.topic,
|
@@ -548,54 +556,63 @@ class Client extends node_events_1.default {
|
|
548
556
|
guild_scheduled_event_id: options.guildScheduledEventId,
|
549
557
|
},
|
550
558
|
reason,
|
551
|
-
})
|
552
|
-
|
559
|
+
});
|
560
|
+
return this.util.stageInstanceFromRaw(response);
|
553
561
|
}
|
554
562
|
/** https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement */
|
555
|
-
createTestEntitlement(applicationId, options) {
|
556
|
-
|
557
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationEntitlements(applicationId), {
|
563
|
+
async createTestEntitlement(applicationId, options) {
|
564
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationEntitlements(applicationId), {
|
558
565
|
json: {
|
559
566
|
sku_id: options.skuId,
|
560
567
|
owner_id: options.ownerId,
|
561
568
|
owner_type: options.ownerType,
|
562
569
|
},
|
563
|
-
})
|
564
|
-
|
570
|
+
});
|
571
|
+
return this.util.testEntitlementFromRaw(response);
|
565
572
|
}
|
566
573
|
/** https://discord.com/developers/docs/resources/channel#start-thread-in-forum-or-media-channel */
|
567
|
-
createThread(channelId, options, reason) {
|
568
|
-
|
569
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId), {
|
574
|
+
async createThread(channelId, options, reason) {
|
575
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId), {
|
570
576
|
json: {
|
571
577
|
name: options.name,
|
572
578
|
auto_archive_duration: options.autoArchiveDuration,
|
573
579
|
rate_limit_per_user: options.rateLimitPerUser,
|
574
|
-
message:
|
580
|
+
message: {
|
581
|
+
content: options.message.content,
|
582
|
+
embeds: options.message.embeds?.map((embed) => this.util.embedToRaw(embed)),
|
583
|
+
allowed_mentions: options.message.allowedMentions !== undefined
|
584
|
+
? options.message.allowedMentions !== null
|
585
|
+
? {
|
586
|
+
parse: options.message.allowedMentions.parse,
|
587
|
+
roles: options.message.allowedMentions.roles,
|
588
|
+
users: options.message.allowedMentions.users,
|
589
|
+
replied_user: options.message.allowedMentions.repliedUser,
|
590
|
+
}
|
591
|
+
: null
|
592
|
+
: undefined,
|
593
|
+
},
|
575
594
|
applied_tags: options.appliedTags,
|
576
595
|
},
|
577
596
|
files: options.files,
|
578
597
|
reason,
|
579
|
-
})
|
580
|
-
|
598
|
+
});
|
599
|
+
return this.util.channelFromRaw(response);
|
581
600
|
}
|
582
601
|
/** https://discord.com/developers/docs/resources/channel#start-thread-from-message */
|
583
|
-
createThreadFromMessage(channelId, messageId, options, reason) {
|
584
|
-
|
585
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId, messageId), {
|
602
|
+
async createThreadFromMessage(channelId, messageId, options, reason) {
|
603
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId, messageId), {
|
586
604
|
json: {
|
587
605
|
name: options.name,
|
588
606
|
auto_archive_duration: options.autoArchiveDuration,
|
589
607
|
rate_limit_per_user: options.rateLimitPerUser,
|
590
608
|
},
|
591
609
|
reason,
|
592
|
-
})
|
593
|
-
|
610
|
+
});
|
611
|
+
return this.util.channelFromRaw(response);
|
594
612
|
}
|
595
613
|
/** https://discord.com/developers/docs/resources/channel#start-thread-without-message */
|
596
|
-
createThreadWithoutMessage(channelId, options, reason) {
|
597
|
-
|
598
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId), {
|
614
|
+
async createThreadWithoutMessage(channelId, options, reason) {
|
615
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId), {
|
599
616
|
json: {
|
600
617
|
name: options.name,
|
601
618
|
auto_archive_duration: options.autoArchiveDuration,
|
@@ -604,14 +621,13 @@ class Client extends node_events_1.default {
|
|
604
621
|
rate_limit_per_user: options.rateLimitPerUser,
|
605
622
|
},
|
606
623
|
reason,
|
607
|
-
})
|
608
|
-
|
624
|
+
});
|
625
|
+
return this.util.channelFromRaw(response);
|
609
626
|
}
|
610
627
|
/** https://discord.com/developers/docs/resources/channel#crosspost-message */
|
611
|
-
crosspostMessage(channelId, messageId) {
|
612
|
-
|
613
|
-
|
614
|
-
.then((response) => this.util.toCamelCase(response));
|
628
|
+
async crosspostMessage(channelId, messageId) {
|
629
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelMessage(channelId, messageId));
|
630
|
+
return this.util.messageFromRaw(response);
|
615
631
|
}
|
616
632
|
/** https://discord.com/developers/docs/resources/channel#delete-all-reactions */
|
617
633
|
deleteAllMessageReactions(channelId, messageId, emoji) {
|
@@ -624,12 +640,11 @@ class Client extends node_events_1.default {
|
|
624
640
|
});
|
625
641
|
}
|
626
642
|
/** https://discord.com/developers/docs/resources/channel#deleteclose-channel */
|
627
|
-
deleteChannel(channelId, reason) {
|
628
|
-
|
629
|
-
.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.channel(channelId), {
|
643
|
+
async deleteChannel(channelId, reason) {
|
644
|
+
const response = await this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.channel(channelId), {
|
630
645
|
reason,
|
631
|
-
})
|
632
|
-
|
646
|
+
});
|
647
|
+
return this.util.channelFromRaw(response);
|
633
648
|
}
|
634
649
|
/** https://discord.com/developers/docs/resources/channel#delete-channel-permission */
|
635
650
|
deleteChannelPermission(channelId, overwriteId, reason) {
|
@@ -678,18 +693,16 @@ class Client extends node_events_1.default {
|
|
678
693
|
});
|
679
694
|
}
|
680
695
|
/** https://discord.com/developers/docs/resources/guild-template#delete-guild-template */
|
681
|
-
deleteGuildTemplate(guildId, code) {
|
682
|
-
|
683
|
-
|
684
|
-
.then((response) => this.util.toCamelCase(response));
|
696
|
+
async deleteGuildTemplate(guildId, code) {
|
697
|
+
const response = await this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.guildTemplate(guildId, code));
|
698
|
+
return this.util.guildTemplateFromRaw(response);
|
685
699
|
}
|
686
700
|
/** https://discord.com/developers/docs/resources/invite#delete-invite */
|
687
|
-
deleteInvite(code, reason) {
|
688
|
-
|
689
|
-
.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.invite(code), {
|
701
|
+
async deleteInvite(code, reason) {
|
702
|
+
const response = await this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.invite(code), {
|
690
703
|
reason,
|
691
|
-
})
|
692
|
-
|
704
|
+
});
|
705
|
+
return this.util.inviteFromRaw(response);
|
693
706
|
}
|
694
707
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */
|
695
708
|
deleteInteractionFollowupMessage(applicationId, interactionToken, messageId) {
|
@@ -744,37 +757,59 @@ class Client extends node_events_1.default {
|
|
744
757
|
this.shards.disconnect();
|
745
758
|
}
|
746
759
|
/** https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule */
|
747
|
-
editAutoModerationRule(guildId, autoModerationRuleId, options, reason) {
|
748
|
-
|
749
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildAutoModerationRule(guildId, autoModerationRuleId), {
|
760
|
+
async editAutoModerationRule(guildId, autoModerationRuleId, options, reason) {
|
761
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildAutoModerationRule(guildId, autoModerationRuleId), {
|
750
762
|
json: {
|
751
763
|
name: options.name,
|
752
764
|
event_type: options.eventType,
|
753
765
|
trigger_type: options.triggerType,
|
754
766
|
trigger_metadata: options.triggerMetadata,
|
755
|
-
actions: options.actions?.map((action) =>
|
767
|
+
actions: options.actions?.map((action) => ({
|
768
|
+
type: action.type,
|
769
|
+
metadata: {
|
770
|
+
channel_id: action.metadata.channelId,
|
771
|
+
duration_seconds: action.metadata.durationSeconds,
|
772
|
+
custom_message: action.metadata.customMessage,
|
773
|
+
},
|
774
|
+
})),
|
756
775
|
enabled: options.enabled,
|
757
776
|
exempt_roles: options.exemptRoles,
|
758
777
|
exempt_channels: options.exemptChannels,
|
759
778
|
},
|
760
779
|
reason,
|
761
|
-
})
|
762
|
-
|
780
|
+
});
|
781
|
+
return this.util.autoModerationRuleFromRaw(response);
|
763
782
|
}
|
764
783
|
/** https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */
|
765
|
-
editApplicationCommandPermissions(applicationId, guildId, commandId, options) {
|
766
|
-
|
767
|
-
.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommandPermissions(applicationId, guildId, commandId), {
|
784
|
+
async editApplicationCommandPermissions(applicationId, guildId, commandId, options) {
|
785
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommandPermissions(applicationId, guildId, commandId), {
|
768
786
|
json: {
|
769
|
-
permissions: options.permissions.map((permission) =>
|
787
|
+
permissions: options.permissions.map((permission) => ({
|
788
|
+
id: permission.id,
|
789
|
+
application_id: permission.applicationId,
|
790
|
+
guild_id: permission.guildId,
|
791
|
+
permissions: permission.permissions.map((perm) => ({
|
792
|
+
id: perm.id,
|
793
|
+
type: perm.type,
|
794
|
+
permission: perm.permission,
|
795
|
+
})),
|
796
|
+
})),
|
770
797
|
},
|
771
|
-
})
|
772
|
-
|
798
|
+
});
|
799
|
+
return {
|
800
|
+
id: response.id,
|
801
|
+
applicationId: response.application_id,
|
802
|
+
guildId: response.guild_id,
|
803
|
+
permissions: response.permissions.map((permission) => ({
|
804
|
+
id: permission.id,
|
805
|
+
type: permission.type,
|
806
|
+
permission: permission.permission,
|
807
|
+
})),
|
808
|
+
};
|
773
809
|
}
|
774
810
|
/** https://discord.com/developers/docs/resources/channel#modify-channel */
|
775
|
-
editChannel(channelId, options, reason) {
|
776
|
-
|
777
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channel(channelId), {
|
811
|
+
async editChannel(channelId, options, reason) {
|
812
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channel(channelId), {
|
778
813
|
json: {
|
779
814
|
name: options.name,
|
780
815
|
type: options.type,
|
@@ -801,8 +836,8 @@ class Client extends node_events_1.default {
|
|
801
836
|
applied_tags: options.appliedTags,
|
802
837
|
},
|
803
838
|
reason,
|
804
|
-
})
|
805
|
-
|
839
|
+
});
|
840
|
+
return this.util.channelFromRaw(response);
|
806
841
|
}
|
807
842
|
/** https://discord.com/developers/docs/resources/channel#edit-channel-permissions */
|
808
843
|
editChannelPermissions(channelId, overwriteId, options, reason) {
|
@@ -823,27 +858,25 @@ class Client extends node_events_1.default {
|
|
823
858
|
});
|
824
859
|
}
|
825
860
|
/** https://discord.com/developers/docs/resources/user#modify-current-user */
|
826
|
-
editCurrentUser(options) {
|
827
|
-
|
828
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.user(), {
|
861
|
+
async editCurrentUser(options) {
|
862
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.user(), {
|
829
863
|
json: {
|
830
864
|
username: options.username,
|
831
865
|
avatar: options.avatar,
|
832
866
|
banner: options.banner,
|
833
867
|
},
|
834
|
-
})
|
835
|
-
|
868
|
+
});
|
869
|
+
return this.util.userFromRaw(response);
|
836
870
|
}
|
837
871
|
/** https://discord.com/developers/docs/resources/guild#modify-current-member */
|
838
|
-
editCurrentGuildMember(guildId, options, reason) {
|
839
|
-
|
840
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildMember(guildId), {
|
872
|
+
async editCurrentGuildMember(guildId, options, reason) {
|
873
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildMember(guildId), {
|
841
874
|
json: {
|
842
875
|
nick: options.nick,
|
843
876
|
},
|
844
877
|
reason,
|
845
|
-
})
|
846
|
-
|
878
|
+
});
|
879
|
+
return this.util.guildMemberFromRaw(response);
|
847
880
|
}
|
848
881
|
/** https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state */
|
849
882
|
editCurrentUserVoiceState(guildId, options) {
|
@@ -856,9 +889,8 @@ class Client extends node_events_1.default {
|
|
856
889
|
});
|
857
890
|
}
|
858
891
|
/** https://discord.com/developers/docs/resources/application#edit-current-application */
|
859
|
-
editCurrentApplication(options) {
|
860
|
-
|
861
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCurrentUser(), {
|
892
|
+
async editCurrentApplication(options) {
|
893
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCurrentUser(), {
|
862
894
|
json: {
|
863
895
|
custom_install_url: options.customInstallUrl,
|
864
896
|
description: options.description,
|
@@ -870,31 +902,19 @@ class Client extends node_events_1.default {
|
|
870
902
|
interactions_endpoint_url: options.interactionsEndpointUrl,
|
871
903
|
tags: options.tags,
|
872
904
|
},
|
873
|
-
})
|
874
|
-
|
905
|
+
});
|
906
|
+
return this.util.applicationFromRaw(response);
|
875
907
|
}
|
876
908
|
/** https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */
|
877
|
-
editGlobalApplicationCommand(applicationId, commandId, options) {
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
name_localizations: options.nameLocalizations,
|
883
|
-
description: options.description,
|
884
|
-
description_localizations: options.descriptionLocalizations,
|
885
|
-
options: options.options?.map((option) => this.util.toSnakeCase(option)),
|
886
|
-
default_member_permissions: options.defaultMemberPermissions,
|
887
|
-
dm_permission: options.dmPermission,
|
888
|
-
default_permission: options.defaultPermission,
|
889
|
-
nsfw: options.nsfw,
|
890
|
-
},
|
891
|
-
})
|
892
|
-
.then((response) => this.util.toCamelCase(response));
|
909
|
+
async editGlobalApplicationCommand(applicationId, commandId, options) {
|
910
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCommand(applicationId, commandId), {
|
911
|
+
json: this.util.partialApplicationCommandToRaw(options),
|
912
|
+
});
|
913
|
+
return this.util.applicationCommandFromRaw(response);
|
893
914
|
}
|
894
915
|
/** https://discord.com/developers/docs/resources/guild#modify-guild */
|
895
|
-
editGuild(guildId, options, reason) {
|
896
|
-
|
897
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guild(guildId), {
|
916
|
+
async editGuild(guildId, options, reason) {
|
917
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guild(guildId), {
|
898
918
|
json: {
|
899
919
|
name: options.name,
|
900
920
|
region: options.region,
|
@@ -919,42 +939,30 @@ class Client extends node_events_1.default {
|
|
919
939
|
safety_alerts_channel_id: options.safetyAlertsChannelId,
|
920
940
|
},
|
921
941
|
reason,
|
922
|
-
})
|
923
|
-
|
942
|
+
});
|
943
|
+
return this.util.guildFromRaw(response);
|
924
944
|
}
|
925
945
|
/** https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */
|
926
|
-
editGuildApplicationCommand(applicationId, guildId, commandId, options) {
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
name_localizations: options.nameLocalizations,
|
932
|
-
description: options.description,
|
933
|
-
description_localizations: options.descriptionLocalizations,
|
934
|
-
options: options.options?.map((option) => this.util.toSnakeCase(option)),
|
935
|
-
default_member_permissions: options.defaultMemberPermissions,
|
936
|
-
default_permission: options.defaultPermission,
|
937
|
-
nsfw: options.nsfw,
|
938
|
-
},
|
939
|
-
})
|
940
|
-
.then((response) => this.util.toCamelCase(response));
|
946
|
+
async editGuildApplicationCommand(applicationId, guildId, commandId, options) {
|
947
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationGuildCommand(applicationId, guildId, commandId), {
|
948
|
+
json: this.util.partialApplicationCommandToRaw(options),
|
949
|
+
});
|
950
|
+
return this.util.applicationCommandFromRaw(response);
|
941
951
|
}
|
942
952
|
/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
|
943
|
-
editGuildEmoji(guildId, emojiId, options, reason) {
|
944
|
-
|
945
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildEmoji(guildId, emojiId), {
|
953
|
+
async editGuildEmoji(guildId, emojiId, options, reason) {
|
954
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildEmoji(guildId, emojiId), {
|
946
955
|
json: {
|
947
956
|
name: options.name,
|
948
957
|
roles: options.roles,
|
949
958
|
},
|
950
959
|
reason,
|
951
|
-
})
|
952
|
-
|
960
|
+
});
|
961
|
+
return this.util.emojiFromRaw(response);
|
953
962
|
}
|
954
963
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-member */
|
955
|
-
editGuildMember(guildId, userId, options, reason) {
|
956
|
-
|
957
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildMember(guildId, userId), {
|
964
|
+
async editGuildMember(guildId, userId, options, reason) {
|
965
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildMember(guildId, userId), {
|
958
966
|
json: {
|
959
967
|
nick: options.nick,
|
960
968
|
roles: options.roles,
|
@@ -965,8 +973,8 @@ class Client extends node_events_1.default {
|
|
965
973
|
flags: options.flags,
|
966
974
|
},
|
967
975
|
reason,
|
968
|
-
})
|
969
|
-
|
976
|
+
});
|
977
|
+
return this.util.guildMemberFromRaw(response);
|
970
978
|
}
|
971
979
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-mfa-level */
|
972
980
|
editGuildMFALevel(guildId, options, reason) {
|
@@ -981,15 +989,34 @@ class Client extends node_events_1.default {
|
|
981
989
|
editGuildOnboarding(guildId, options, reason) {
|
982
990
|
this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildOnboarding(guildId), {
|
983
991
|
json: {
|
984
|
-
prompts: options.prompts.map((prompt) =>
|
992
|
+
prompts: options.prompts.map((prompt) => ({
|
993
|
+
id: prompt.id,
|
994
|
+
type: prompt.type,
|
995
|
+
options: prompt.options.map((promptOption) => ({
|
996
|
+
id: promptOption.id,
|
997
|
+
channel_ids: promptOption.channelIds,
|
998
|
+
role_ids: promptOption.roleIds,
|
999
|
+
emoji: promptOption.emoji !== undefined
|
1000
|
+
? this.util.emojiToRaw(promptOption.emoji)
|
1001
|
+
: undefined,
|
1002
|
+
emoji_id: promptOption.emojiId,
|
1003
|
+
emoji_name: promptOption.emojiName,
|
1004
|
+
emoji_animated: promptOption.emojiAnimated,
|
1005
|
+
title: promptOption.title,
|
1006
|
+
description: promptOption.description,
|
1007
|
+
})),
|
1008
|
+
title: prompt.id,
|
1009
|
+
single_select: prompt.id,
|
1010
|
+
required: prompt.id,
|
1011
|
+
in_onboarding: prompt.id,
|
1012
|
+
})),
|
985
1013
|
},
|
986
1014
|
reason,
|
987
1015
|
});
|
988
1016
|
}
|
989
1017
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-role */
|
990
|
-
editGuildRole(guildId, roleId, options, reason) {
|
991
|
-
|
992
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildRole(guildId, roleId), {
|
1018
|
+
async editGuildRole(guildId, roleId, options, reason) {
|
1019
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildRole(guildId, roleId), {
|
993
1020
|
json: {
|
994
1021
|
name: options?.name,
|
995
1022
|
permissions: options?.permissions,
|
@@ -1000,21 +1027,19 @@ class Client extends node_events_1.default {
|
|
1000
1027
|
mentionable: options?.mentionable,
|
1001
1028
|
},
|
1002
1029
|
reason,
|
1003
|
-
})
|
1004
|
-
|
1030
|
+
});
|
1031
|
+
return this.util.roleFromRaw(response);
|
1005
1032
|
}
|
1006
1033
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-role-positions */
|
1007
|
-
editGuildRolePositions(guildId, options) {
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
.then((response) => response.map((role) => this.util.toCamelCase(role)));
|
1034
|
+
async editGuildRolePositions(guildId, options) {
|
1035
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildRoles(guildId), {
|
1036
|
+
json: options,
|
1037
|
+
});
|
1038
|
+
return response.map((role) => this.util.roleFromRaw(role));
|
1013
1039
|
}
|
1014
1040
|
/** https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event */
|
1015
|
-
editGuildScheduledEvent(guildId, guildScheduledEventId, options, reason) {
|
1016
|
-
|
1017
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildScheduledEvent(guildId, guildScheduledEventId), {
|
1041
|
+
async editGuildScheduledEvent(guildId, guildScheduledEventId, options, reason) {
|
1042
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildScheduledEvent(guildId, guildScheduledEventId), {
|
1018
1043
|
json: {
|
1019
1044
|
channel_id: options.channelId,
|
1020
1045
|
entity_metadata: options.entityMetadata,
|
@@ -1028,159 +1053,171 @@ class Client extends node_events_1.default {
|
|
1028
1053
|
image: options.image,
|
1029
1054
|
},
|
1030
1055
|
reason,
|
1031
|
-
})
|
1032
|
-
|
1056
|
+
});
|
1057
|
+
return this.util.guildScheduledEventFromRaw(response);
|
1033
1058
|
}
|
1034
1059
|
/** https://discord.com/developers/docs/resources/sticker#modify-guild-sticker */
|
1035
|
-
editGuildSticker(guildId, stickerId, options, reason) {
|
1036
|
-
|
1037
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildSticker(guildId, stickerId), {
|
1060
|
+
async editGuildSticker(guildId, stickerId, options, reason) {
|
1061
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildSticker(guildId, stickerId), {
|
1038
1062
|
json: {
|
1039
1063
|
name: options.name,
|
1040
1064
|
description: options.description,
|
1041
1065
|
tags: options.tags,
|
1042
1066
|
},
|
1043
1067
|
reason,
|
1044
|
-
})
|
1045
|
-
|
1068
|
+
});
|
1069
|
+
return this.util.stickerFromRaw(response);
|
1046
1070
|
}
|
1047
1071
|
/** https://discord.com/developers/docs/resources/guild-template#modify-guild-template */
|
1048
|
-
editGuildTemplate(guildId, code, options) {
|
1049
|
-
|
1050
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildTemplate(guildId, code), {
|
1072
|
+
async editGuildTemplate(guildId, code, options) {
|
1073
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildTemplate(guildId, code), {
|
1051
1074
|
json: {
|
1052
1075
|
name: options.name,
|
1053
1076
|
description: options.description,
|
1054
1077
|
},
|
1055
|
-
})
|
1056
|
-
|
1078
|
+
});
|
1079
|
+
return this.util.guildTemplateFromRaw(response);
|
1057
1080
|
}
|
1058
1081
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen */
|
1059
|
-
editGuildWelcomeScreen(guildId, options, reason) {
|
1060
|
-
|
1061
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWelcomeScreen(guildId), {
|
1082
|
+
async editGuildWelcomeScreen(guildId, options, reason) {
|
1083
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWelcomeScreen(guildId), {
|
1062
1084
|
json: {
|
1063
1085
|
enabled: options.enabled,
|
1064
1086
|
welcome_channels: options.welcomeChannels,
|
1065
1087
|
description: options.description,
|
1066
1088
|
},
|
1067
1089
|
reason,
|
1068
|
-
})
|
1069
|
-
|
1090
|
+
});
|
1091
|
+
return {
|
1092
|
+
description: response.description,
|
1093
|
+
welcomeChannels: response.welcome_channels.map((welcomeScreenChannel) => ({
|
1094
|
+
channelId: welcomeScreenChannel.channel_id,
|
1095
|
+
description: welcomeScreenChannel.description,
|
1096
|
+
emojiId: welcomeScreenChannel.emoji_id,
|
1097
|
+
emojiName: welcomeScreenChannel.emoji_name,
|
1098
|
+
})),
|
1099
|
+
};
|
1070
1100
|
}
|
1071
1101
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-widget */
|
1072
|
-
editGuildWidget(guildId, options, reason) {
|
1073
|
-
|
1074
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWidgetSettings(guildId), {
|
1102
|
+
async editGuildWidget(guildId, options, reason) {
|
1103
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWidgetSettings(guildId), {
|
1075
1104
|
json: {
|
1076
1105
|
enabled: options.enabled,
|
1077
1106
|
channel_id: options.channelId,
|
1078
1107
|
},
|
1079
1108
|
reason,
|
1080
|
-
})
|
1081
|
-
|
1109
|
+
});
|
1110
|
+
return {
|
1111
|
+
enabled: response.enabled,
|
1112
|
+
channelId: response.channel_id,
|
1113
|
+
};
|
1082
1114
|
}
|
1083
1115
|
/** https://discord.com/developers/docs/resources/channel#edit-message */
|
1084
|
-
editMessage(channelId, messageId, options) {
|
1085
|
-
|
1086
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channelMessage(channelId, messageId), {
|
1116
|
+
async editMessage(channelId, messageId, options) {
|
1117
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channelMessage(channelId, messageId), {
|
1087
1118
|
json: {
|
1088
1119
|
content: options.content,
|
1089
|
-
embeds: options.embeds !==
|
1090
|
-
? options.embeds
|
1091
|
-
|
1092
|
-
: null
|
1093
|
-
: undefined,
|
1120
|
+
embeds: options.embeds !== null
|
1121
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1122
|
+
: null,
|
1094
1123
|
allowed_mentions: options.allowedMentions !== undefined
|
1095
1124
|
? options.allowedMentions !== null
|
1096
|
-
?
|
1125
|
+
? {
|
1126
|
+
parse: options.allowedMentions.parse,
|
1127
|
+
roles: options.allowedMentions.roles,
|
1128
|
+
users: options.allowedMentions.users,
|
1129
|
+
replied_user: options.allowedMentions.repliedUser,
|
1130
|
+
}
|
1097
1131
|
: null
|
1098
1132
|
: undefined,
|
1099
1133
|
components: options.components !== undefined
|
1100
1134
|
? options.components !== null
|
1101
|
-
?
|
1135
|
+
? this.util.messageComponentsToRaw(options.components)
|
1102
1136
|
: null
|
1103
1137
|
: undefined,
|
1104
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1138
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1105
1139
|
flags: options.flags,
|
1106
1140
|
},
|
1107
1141
|
files: options.files,
|
1108
|
-
})
|
1109
|
-
|
1142
|
+
});
|
1143
|
+
return this.util.messageFromRaw(response);
|
1110
1144
|
}
|
1111
1145
|
/** https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance */
|
1112
|
-
editStageInstance(channelId, options, reason) {
|
1113
|
-
|
1114
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.stageInstance(channelId), {
|
1146
|
+
async editStageInstance(channelId, options, reason) {
|
1147
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.stageInstance(channelId), {
|
1115
1148
|
json: {
|
1116
1149
|
topic: options.topic,
|
1117
1150
|
privacy_level: options.privacyLevel,
|
1118
1151
|
},
|
1119
1152
|
reason,
|
1120
|
-
})
|
1121
|
-
|
1153
|
+
});
|
1154
|
+
return this.util.stageInstanceFromRaw(response);
|
1122
1155
|
}
|
1123
1156
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */
|
1124
|
-
editInteractionFollowupMessage(applicationId, interactionToken, messageId, options) {
|
1125
|
-
|
1126
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhookMessage(applicationId, interactionToken, messageId), {
|
1157
|
+
async editInteractionFollowupMessage(applicationId, interactionToken, messageId, options) {
|
1158
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhookMessage(applicationId, interactionToken, messageId), {
|
1127
1159
|
json: {
|
1128
1160
|
content: options.content,
|
1129
|
-
embeds: options.embeds !==
|
1130
|
-
? options.embeds
|
1131
|
-
|
1132
|
-
: null
|
1133
|
-
: undefined,
|
1161
|
+
embeds: options.embeds !== null
|
1162
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1163
|
+
: null,
|
1134
1164
|
allowed_mentions: options.allowedMentions !== undefined
|
1135
1165
|
? options.allowedMentions !== null
|
1136
|
-
?
|
1166
|
+
? {
|
1167
|
+
parse: options.allowedMentions.parse,
|
1168
|
+
roles: options.allowedMentions.roles,
|
1169
|
+
users: options.allowedMentions.users,
|
1170
|
+
replied_user: options.allowedMentions.repliedUser,
|
1171
|
+
}
|
1137
1172
|
: null
|
1138
1173
|
: undefined,
|
1139
1174
|
components: options.components !== undefined
|
1140
1175
|
? options.components !== null
|
1141
|
-
?
|
1176
|
+
? this.util.messageComponentsToRaw(options.components)
|
1142
1177
|
: null
|
1143
1178
|
: undefined,
|
1144
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1179
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1145
1180
|
flags: options.flags,
|
1146
1181
|
},
|
1147
1182
|
files: options.files,
|
1148
1183
|
query: {
|
1149
1184
|
thread_id: options.threadId,
|
1150
1185
|
},
|
1151
|
-
})
|
1152
|
-
|
1186
|
+
});
|
1187
|
+
return this.util.messageFromRaw(response);
|
1153
1188
|
}
|
1154
1189
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */
|
1155
|
-
editInteractionResponse(applicationId, interactionToken, options) {
|
1156
|
-
|
1157
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhookMessage(applicationId, interactionToken), {
|
1190
|
+
async editInteractionResponse(applicationId, interactionToken, options) {
|
1191
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhookMessage(applicationId, interactionToken), {
|
1158
1192
|
json: {
|
1159
1193
|
content: options.content,
|
1160
|
-
embeds: options.embeds !==
|
1161
|
-
? options.embeds
|
1162
|
-
|
1163
|
-
: null
|
1164
|
-
: undefined,
|
1194
|
+
embeds: options.embeds !== null
|
1195
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1196
|
+
: null,
|
1165
1197
|
allowed_mentions: options.allowedMentions !== undefined
|
1166
1198
|
? options.allowedMentions !== null
|
1167
|
-
?
|
1199
|
+
? {
|
1200
|
+
parse: options.allowedMentions.parse,
|
1201
|
+
roles: options.allowedMentions.roles,
|
1202
|
+
users: options.allowedMentions.users,
|
1203
|
+
replied_user: options.allowedMentions.repliedUser,
|
1204
|
+
}
|
1168
1205
|
: null
|
1169
1206
|
: undefined,
|
1170
1207
|
components: options.components !== undefined
|
1171
1208
|
? options.components !== null
|
1172
|
-
?
|
1209
|
+
? this.util.messageComponentsToRaw(options.components)
|
1173
1210
|
: null
|
1174
1211
|
: undefined,
|
1175
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1212
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1176
1213
|
flags: options.flags,
|
1177
1214
|
},
|
1178
1215
|
files: options.files,
|
1179
1216
|
query: {
|
1180
1217
|
thread_id: options.threadId,
|
1181
1218
|
},
|
1182
|
-
})
|
1183
|
-
|
1219
|
+
});
|
1220
|
+
return this.util.messageFromRaw(response);
|
1184
1221
|
}
|
1185
1222
|
/** https://discord.com/developers/docs/resources/guild#modify-user-voice-state */
|
1186
1223
|
editUserVoiceState(guildId, userId, options) {
|
@@ -1193,98 +1230,108 @@ class Client extends node_events_1.default {
|
|
1193
1230
|
});
|
1194
1231
|
}
|
1195
1232
|
/** https://discord.com/developers/docs/resources/webhook#modify-webhook */
|
1196
|
-
editWebhook(webhookId, options, reason) {
|
1197
|
-
|
1198
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhook(webhookId), {
|
1233
|
+
async editWebhook(webhookId, options, reason) {
|
1234
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhook(webhookId), {
|
1199
1235
|
json: {
|
1200
1236
|
name: options.name,
|
1201
1237
|
avatar: options.avatar,
|
1202
1238
|
channel_id: options.channelId,
|
1203
1239
|
},
|
1204
1240
|
reason,
|
1205
|
-
})
|
1206
|
-
|
1241
|
+
});
|
1242
|
+
return this.util.webhookFromRaw(response);
|
1207
1243
|
}
|
1208
1244
|
/** https://discord.com/developers/docs/resources/webhook#edit-webhook-message */
|
1209
|
-
editWebhookMessage(webhookId, webhookToken, messageId, options) {
|
1210
|
-
|
1211
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhookMessage(webhookId, webhookToken, messageId), {
|
1245
|
+
async editWebhookMessage(webhookId, webhookToken, messageId, options) {
|
1246
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhookMessage(webhookId, webhookToken, messageId), {
|
1212
1247
|
json: {
|
1213
1248
|
content: options.content,
|
1214
|
-
embeds: options.embeds !==
|
1215
|
-
? options.embeds
|
1216
|
-
|
1217
|
-
: null
|
1218
|
-
: undefined,
|
1249
|
+
embeds: options.embeds !== null
|
1250
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1251
|
+
: null,
|
1219
1252
|
allowed_mentions: options.allowedMentions !== undefined
|
1220
1253
|
? options.allowedMentions !== null
|
1221
|
-
?
|
1254
|
+
? {
|
1255
|
+
parse: options.allowedMentions.parse,
|
1256
|
+
roles: options.allowedMentions.roles,
|
1257
|
+
users: options.allowedMentions.users,
|
1258
|
+
replied_user: options.allowedMentions.repliedUser,
|
1259
|
+
}
|
1222
1260
|
: null
|
1223
1261
|
: undefined,
|
1224
1262
|
components: options.components !== undefined
|
1225
1263
|
? options.components !== null
|
1226
|
-
?
|
1264
|
+
? this.util.messageComponentsToRaw(options.components)
|
1227
1265
|
: null
|
1228
1266
|
: undefined,
|
1229
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1267
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1230
1268
|
flags: options.flags,
|
1231
1269
|
},
|
1232
1270
|
files: options.files,
|
1233
1271
|
query: {
|
1234
1272
|
thread_id: options.threadId,
|
1235
1273
|
},
|
1236
|
-
})
|
1237
|
-
|
1274
|
+
});
|
1275
|
+
return this.util.messageFromRaw(response);
|
1238
1276
|
}
|
1239
1277
|
/** https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token */
|
1240
|
-
editWebhookWithToken(webhookId, webhookToken, options, reason) {
|
1241
|
-
|
1242
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhook(webhookId, webhookToken), {
|
1278
|
+
async editWebhookWithToken(webhookId, webhookToken, options, reason) {
|
1279
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhook(webhookId, webhookToken), {
|
1243
1280
|
json: {
|
1244
1281
|
name: options.name,
|
1245
1282
|
avatar: options.avatar,
|
1246
1283
|
},
|
1247
1284
|
reason,
|
1248
1285
|
authorization: false,
|
1249
|
-
})
|
1250
|
-
|
1286
|
+
});
|
1287
|
+
return this.util.webhookFromRaw(response);
|
1251
1288
|
}
|
1252
1289
|
/** https://discord.com/developers/docs/resources/poll#end-poll */
|
1253
|
-
endPoll(channelId, messageId) {
|
1254
|
-
|
1255
|
-
|
1256
|
-
.then((response) => this.util.toCamelCase(response));
|
1290
|
+
async endPoll(channelId, messageId) {
|
1291
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.pollExpire(channelId, messageId));
|
1292
|
+
return this.util.messageFromRaw(response);
|
1257
1293
|
}
|
1258
1294
|
/** https://discord.com/developers/docs/resources/webhook#execute-webhook */
|
1259
|
-
executeWebhook(webhookId, webhookToken, options) {
|
1260
|
-
|
1261
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhook(webhookId, webhookToken), {
|
1295
|
+
async executeWebhook(webhookId, webhookToken, options) {
|
1296
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhook(webhookId, webhookToken), {
|
1262
1297
|
json: {
|
1263
1298
|
content: options.content,
|
1264
1299
|
username: options.username,
|
1265
1300
|
avatarUrl: options.avatarUrl,
|
1266
1301
|
tts: options.tts,
|
1267
|
-
embeds: options.embeds !==
|
1268
|
-
? options.embeds
|
1269
|
-
|
1270
|
-
: null
|
1271
|
-
: undefined,
|
1302
|
+
embeds: options.embeds !== null
|
1303
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1304
|
+
: null,
|
1272
1305
|
allowed_mentions: options.allowedMentions !== undefined
|
1273
1306
|
? options.allowedMentions !== null
|
1274
|
-
?
|
1307
|
+
? {
|
1308
|
+
parse: options.allowedMentions.parse,
|
1309
|
+
roles: options.allowedMentions.roles,
|
1310
|
+
users: options.allowedMentions.users,
|
1311
|
+
replied_user: options.allowedMentions.repliedUser,
|
1312
|
+
}
|
1275
1313
|
: null
|
1276
1314
|
: undefined,
|
1277
1315
|
components: options.components !== undefined
|
1278
1316
|
? options.components !== null
|
1279
|
-
?
|
1317
|
+
? this.util.messageComponentsToRaw(options.components)
|
1280
1318
|
: null
|
1281
1319
|
: undefined,
|
1282
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1320
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1283
1321
|
flags: options.flags,
|
1284
1322
|
thread_name: options.threadName,
|
1285
1323
|
applied_tags: options.appliedTags,
|
1286
1324
|
poll: options.poll !== undefined
|
1287
|
-
?
|
1325
|
+
? {
|
1326
|
+
question: options.poll.question,
|
1327
|
+
answers: options.poll.answers.map((answer) => ({
|
1328
|
+
answer_id: answer.answerId,
|
1329
|
+
poll_media: answer.pollMedia,
|
1330
|
+
})),
|
1331
|
+
duration: options.poll.duration,
|
1332
|
+
allow_multiselect: options.poll.allowMultiselect,
|
1333
|
+
layout_type: options.poll.layoutType,
|
1334
|
+
}
|
1288
1335
|
: undefined,
|
1289
1336
|
},
|
1290
1337
|
files: options.files,
|
@@ -1292,57 +1339,78 @@ class Client extends node_events_1.default {
|
|
1292
1339
|
wait: options.wait,
|
1293
1340
|
thread_id: options.threadId,
|
1294
1341
|
},
|
1295
|
-
})
|
1296
|
-
|
1342
|
+
});
|
1343
|
+
return response !== null ? this.util.messageFromRaw(response) : response;
|
1297
1344
|
}
|
1298
1345
|
/**
|
1299
1346
|
* https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook
|
1300
1347
|
*
|
1301
1348
|
* https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook
|
1302
1349
|
*/
|
1303
|
-
executeWebhookPlatform(webhookId, webhookToken, platform, options) {
|
1304
|
-
|
1305
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhookPlatform(webhookId, webhookToken, platform), {
|
1350
|
+
async executeWebhookPlatform(webhookId, webhookToken, platform, options) {
|
1351
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhookPlatform(webhookId, webhookToken, platform), {
|
1306
1352
|
query: {
|
1307
1353
|
thread_id: options.threadId,
|
1308
1354
|
wait: options.wait,
|
1309
1355
|
},
|
1310
1356
|
json: options,
|
1311
|
-
})
|
1312
|
-
|
1357
|
+
});
|
1358
|
+
return response !== null ? this.util.messageFromRaw(response) : null;
|
1313
1359
|
}
|
1314
1360
|
/** https://discord.com/developers/docs/resources/channel#follow-announcement-channel */
|
1315
|
-
followChannel(channelId, options, reason) {
|
1316
|
-
|
1317
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelFollowers(channelId), {
|
1361
|
+
async followChannel(channelId, options, reason) {
|
1362
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelFollowers(channelId), {
|
1318
1363
|
json: {
|
1319
1364
|
webhook_channel_id: options.webhookChannelId,
|
1320
1365
|
},
|
1321
1366
|
reason,
|
1322
|
-
})
|
1323
|
-
|
1367
|
+
});
|
1368
|
+
return {
|
1369
|
+
channelId: response.channel_id,
|
1370
|
+
webhookId: response.webhook_id,
|
1371
|
+
};
|
1324
1372
|
}
|
1325
1373
|
/** https://discord.com/developers/docs/resources/guild#list-active-guild-threads */
|
1326
|
-
getActiveGuildThreads(guildId) {
|
1327
|
-
|
1328
|
-
|
1329
|
-
.
|
1374
|
+
async getActiveGuildThreads(guildId) {
|
1375
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildActiveThreads(guildId));
|
1376
|
+
return {
|
1377
|
+
threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
|
1378
|
+
members: response.members.map((threadMember) => ({
|
1379
|
+
id: threadMember.id,
|
1380
|
+
userId: threadMember.user_id,
|
1381
|
+
joinTimestamp: threadMember.join_timestamp,
|
1382
|
+
flags: threadMember.flags,
|
1383
|
+
member: threadMember.member !== undefined
|
1384
|
+
? this.util.guildMemberFromRaw(threadMember.member)
|
1385
|
+
: undefined,
|
1386
|
+
})),
|
1387
|
+
};
|
1330
1388
|
}
|
1331
1389
|
/** https://discord.com/developers/docs/resources/channel#list-public-archived-threads */
|
1332
|
-
getArchivedThreads(channelId, archivedStatus, options) {
|
1333
|
-
|
1334
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelThreads(channelId, archivedStatus, false), {
|
1390
|
+
async getArchivedThreads(channelId, archivedStatus, options) {
|
1391
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelThreads(channelId, archivedStatus, false), {
|
1335
1392
|
query: {
|
1336
1393
|
before: options?.before,
|
1337
1394
|
limit: options?.limit,
|
1338
1395
|
},
|
1339
|
-
})
|
1340
|
-
|
1396
|
+
});
|
1397
|
+
return {
|
1398
|
+
threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
|
1399
|
+
members: response.members.map((threadMember) => ({
|
1400
|
+
id: threadMember.id,
|
1401
|
+
userId: threadMember.user_id,
|
1402
|
+
joinTimestamp: threadMember.join_timestamp,
|
1403
|
+
flags: threadMember.flags,
|
1404
|
+
member: threadMember.member !== undefined
|
1405
|
+
? this.util.guildMemberFromRaw(threadMember.member)
|
1406
|
+
: undefined,
|
1407
|
+
})),
|
1408
|
+
hasMore: response.has_more,
|
1409
|
+
};
|
1341
1410
|
}
|
1342
1411
|
/** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log */
|
1343
|
-
getAuditLog(guildId, options) {
|
1344
|
-
|
1345
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildAuditLog(guildId), {
|
1412
|
+
async getAuditLog(guildId, options) {
|
1413
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildAuditLog(guildId), {
|
1346
1414
|
query: {
|
1347
1415
|
user_id: options?.userId,
|
1348
1416
|
action_type: options?.actionType,
|
@@ -1350,85 +1418,110 @@ class Client extends node_events_1.default {
|
|
1350
1418
|
after: options?.after,
|
1351
1419
|
limit: options?.limit,
|
1352
1420
|
},
|
1353
|
-
})
|
1354
|
-
|
1421
|
+
});
|
1422
|
+
return this.util.auditLogFromRaw(response);
|
1355
1423
|
}
|
1356
1424
|
/** https://discord.com/developers/docs/resources/auto-moderation#get-auto-moderation-rule */
|
1357
|
-
getAutoModerationRule(guildId, ruleId) {
|
1358
|
-
|
1359
|
-
|
1360
|
-
.then((response) => this.util.toCamelCase(response));
|
1425
|
+
async getAutoModerationRule(guildId, ruleId) {
|
1426
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildAutoModerationRule(guildId, ruleId));
|
1427
|
+
return this.util.autoModerationRuleFromRaw(response);
|
1361
1428
|
}
|
1362
1429
|
/** https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild */
|
1363
|
-
getAutoModerationRules(guildId) {
|
1364
|
-
|
1365
|
-
|
1366
|
-
.then((response) => response.map((autoModerationRule) => this.util.toCamelCase(autoModerationRule)));
|
1430
|
+
async getAutoModerationRules(guildId) {
|
1431
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildAutoModerationRules(guildId));
|
1432
|
+
return response.map((autoModerationRule) => this.util.autoModerationRuleFromRaw(autoModerationRule));
|
1367
1433
|
}
|
1368
1434
|
/** https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */
|
1369
|
-
getApplicationCommandPermissions(applicationId, guildId, commandId) {
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1435
|
+
async getApplicationCommandPermissions(applicationId, guildId, commandId) {
|
1436
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommandPermissions(applicationId, guildId, commandId));
|
1437
|
+
return {
|
1438
|
+
id: response.id,
|
1439
|
+
applicationId: response.application_id,
|
1440
|
+
guildId: response.guild_id,
|
1441
|
+
permissions: response.permissions.map((permission) => ({
|
1442
|
+
id: permission.id,
|
1443
|
+
type: permission.type,
|
1444
|
+
permission: permission.permission,
|
1445
|
+
})),
|
1446
|
+
};
|
1373
1447
|
}
|
1374
1448
|
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records */
|
1375
|
-
getApplicationRoleConnectionMetadataRecords(applicationId) {
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1449
|
+
async getApplicationRoleConnectionMetadataRecords(applicationId) {
|
1450
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationRoleConnectionMetadata(applicationId));
|
1451
|
+
return response.map((applicationRoleConnectionMetadata) => ({
|
1452
|
+
type: applicationRoleConnectionMetadata.type,
|
1453
|
+
key: applicationRoleConnectionMetadata.key,
|
1454
|
+
name: applicationRoleConnectionMetadata.name,
|
1455
|
+
nameLocalizations: applicationRoleConnectionMetadata.name_localizations,
|
1456
|
+
description: applicationRoleConnectionMetadata.description,
|
1457
|
+
descriptionLocalizations: applicationRoleConnectionMetadata.description_localizations,
|
1458
|
+
}));
|
1379
1459
|
}
|
1380
1460
|
/** https://discord.com/developers/docs/resources/channel#get-channel */
|
1381
|
-
getChannel(channelId) {
|
1382
|
-
|
1383
|
-
|
1384
|
-
.then((response) => this.util.toCamelCase(response));
|
1461
|
+
async getChannel(channelId) {
|
1462
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channel(channelId));
|
1463
|
+
return this.util.channelFromRaw(response);
|
1385
1464
|
}
|
1386
1465
|
/** https://discord.com/developers/docs/resources/guild#get-guild-channels */
|
1387
|
-
getChannels(guildId) {
|
1388
|
-
|
1389
|
-
|
1390
|
-
.then((response) => response.map((channel) => this.util.toCamelCase(channel)));
|
1466
|
+
async getChannels(guildId) {
|
1467
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildChannels(guildId));
|
1468
|
+
return response.map((channel) => this.util.channelFromRaw(channel));
|
1391
1469
|
}
|
1392
1470
|
/** https://discord.com/developers/docs/resources/channel#get-channel-invites */
|
1393
|
-
getChannelInvites(channelId) {
|
1394
|
-
|
1395
|
-
|
1396
|
-
.then((response) => response.map((invite) => this.util.toCamelCase(invite)));
|
1471
|
+
async getChannelInvites(channelId) {
|
1472
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelInvites(channelId));
|
1473
|
+
return response.map((invite) => this.util.inviteFromRaw(invite));
|
1397
1474
|
}
|
1398
1475
|
/** https://discord.com/developers/docs/resources/webhook#get-channel-webhooks */
|
1399
|
-
getChannelWebhooks(channelId) {
|
1400
|
-
|
1401
|
-
|
1402
|
-
.then((response) => response.map((webhook) => this.util.toCamelCase(webhook)));
|
1476
|
+
async getChannelWebhooks(channelId) {
|
1477
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelWebhooks(channelId));
|
1478
|
+
return response.map((webhook) => this.util.webhookFromRaw(webhook));
|
1403
1479
|
}
|
1404
1480
|
/** https://discord.com/developers/docs/resources/application#get-current-application */
|
1405
|
-
getCurrentApplication() {
|
1406
|
-
|
1407
|
-
|
1408
|
-
.then((response) => this.util.toCamelCase(response));
|
1481
|
+
async getCurrentApplication() {
|
1482
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCurrentUser());
|
1483
|
+
return this.util.applicationFromRaw(response);
|
1409
1484
|
}
|
1410
1485
|
/** https://discord.com/developers/docs/resources/user#get-current-user-application-role-connection */
|
1411
|
-
getCurrentApplicationRoleConnection(applicationId) {
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1486
|
+
async getCurrentApplicationRoleConnection(applicationId) {
|
1487
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.userApplicationRoleConnection(applicationId));
|
1488
|
+
return {
|
1489
|
+
platformName: response.platform_name,
|
1490
|
+
platformUsername: response.platform_username,
|
1491
|
+
metadata: {
|
1492
|
+
type: response.metadata.type,
|
1493
|
+
key: response.metadata.key,
|
1494
|
+
name: response.metadata.name,
|
1495
|
+
nameLocalizations: response.metadata.name_localizations,
|
1496
|
+
description: response.metadata.description,
|
1497
|
+
descriptionLocalizations: response.metadata.description_localizations,
|
1498
|
+
},
|
1499
|
+
};
|
1415
1500
|
}
|
1416
1501
|
/** https://discord.com/developers/docs/resources/user#get-current-user-guild-member */
|
1417
|
-
getCurrentGuildMember(guildId) {
|
1418
|
-
|
1419
|
-
|
1420
|
-
.then((response) => this.util.toCamelCase(response));
|
1502
|
+
async getCurrentGuildMember(guildId) {
|
1503
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMember(guildId));
|
1504
|
+
return this.util.guildMemberFromRaw(response);
|
1421
1505
|
}
|
1422
1506
|
/** https://discord.com/developers/docs/resources/user#get-current-user-connections */
|
1423
|
-
getCurrentUserConnections() {
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1507
|
+
async getCurrentUserConnections() {
|
1508
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.userConnections());
|
1509
|
+
return response.map((connection) => ({
|
1510
|
+
id: connection.id,
|
1511
|
+
name: connection.name,
|
1512
|
+
type: connection.type,
|
1513
|
+
revoked: connection.revoked,
|
1514
|
+
integrations: connection.integrations?.map((integration) => this.util.integrationFromRaw(integration)),
|
1515
|
+
verified: connection.verified,
|
1516
|
+
friendSync: connection.friend_sync,
|
1517
|
+
showActivity: connection.show_activity,
|
1518
|
+
twoWayLink: connection.two_way_link,
|
1519
|
+
visibility: connection.visibility,
|
1520
|
+
}));
|
1427
1521
|
}
|
1428
1522
|
/** https://discord.com/developers/docs/monetization/entitlements#list-entitlements */
|
1429
|
-
getEntitlements(applicationId, options) {
|
1430
|
-
|
1431
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationEntitlements(applicationId), {
|
1523
|
+
async getEntitlements(applicationId, options) {
|
1524
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationEntitlements(applicationId), {
|
1432
1525
|
query: {
|
1433
1526
|
user_id: options?.userId,
|
1434
1527
|
sku_ids: options?.skuIds,
|
@@ -1438,231 +1531,290 @@ class Client extends node_events_1.default {
|
|
1438
1531
|
guild_id: options?.guildId,
|
1439
1532
|
exclude_ended: options?.excludeEnded,
|
1440
1533
|
},
|
1441
|
-
})
|
1442
|
-
|
1534
|
+
});
|
1535
|
+
return response.map((entitlement) => this.util.entitlementFromRaw(entitlement));
|
1443
1536
|
}
|
1444
1537
|
/** https://discord.com/developers/docs/topics/gateway#get-gateway */
|
1445
1538
|
getGateway() {
|
1446
1539
|
return this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.gateway());
|
1447
1540
|
}
|
1448
1541
|
/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */
|
1449
|
-
getGatewayBot() {
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1542
|
+
async getGatewayBot() {
|
1543
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.gatewayBot());
|
1544
|
+
return {
|
1545
|
+
url: response.url,
|
1546
|
+
shards: response.shards,
|
1547
|
+
sessionStartLimit: {
|
1548
|
+
total: response.session_start_limit.total,
|
1549
|
+
remaining: response.session_start_limit.remaining,
|
1550
|
+
resetAfter: response.session_start_limit.reset_after,
|
1551
|
+
maxConcurrency: response.session_start_limit.max_concurrency,
|
1552
|
+
},
|
1553
|
+
};
|
1453
1554
|
}
|
1454
1555
|
/** https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */
|
1455
|
-
getGlobalApplicationCommand(applicationId, commandId) {
|
1456
|
-
|
1457
|
-
|
1458
|
-
.then((response) => this.util.toCamelCase(response));
|
1556
|
+
async getGlobalApplicationCommand(applicationId, commandId) {
|
1557
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommand(applicationId, commandId));
|
1558
|
+
return this.util.applicationCommandFromRaw(response);
|
1459
1559
|
}
|
1460
1560
|
/** https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */
|
1461
|
-
getGlobalApplicationCommands(applicationId, options) {
|
1462
|
-
|
1463
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommands(applicationId), {
|
1561
|
+
async getGlobalApplicationCommands(applicationId, options) {
|
1562
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommands(applicationId), {
|
1464
1563
|
query: {
|
1465
1564
|
with_localizations: options.withLocalizations,
|
1466
1565
|
},
|
1467
|
-
})
|
1468
|
-
|
1566
|
+
});
|
1567
|
+
return response.map((applicationCommand) => this.util.applicationCommandFromRaw(applicationCommand));
|
1469
1568
|
}
|
1470
1569
|
/** https://discord.com/developers/docs/resources/guild#get-guild */
|
1471
|
-
getGuild(guildId, options) {
|
1472
|
-
|
1473
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guild(guildId), {
|
1570
|
+
async getGuild(guildId, options) {
|
1571
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guild(guildId), {
|
1474
1572
|
query: {
|
1475
1573
|
with_counts: options?.withCounts,
|
1476
1574
|
},
|
1477
|
-
})
|
1478
|
-
|
1575
|
+
});
|
1576
|
+
return this.util.guildFromRaw(response);
|
1479
1577
|
}
|
1480
1578
|
/** https://discord.com/developers/docs/resources/user#get-current-user-guilds */
|
1481
|
-
getGuilds(options) {
|
1482
|
-
|
1483
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.userGuilds(), {
|
1579
|
+
async getGuilds(options) {
|
1580
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.userGuilds(), {
|
1484
1581
|
query: {
|
1485
1582
|
before: options?.before,
|
1486
1583
|
after: options?.after,
|
1487
1584
|
limit: options?.limit,
|
1488
1585
|
with_counts: options?.withCounts,
|
1489
1586
|
},
|
1490
|
-
})
|
1491
|
-
|
1587
|
+
});
|
1588
|
+
return response.map((guild) => this.util.guildFromRaw(guild));
|
1492
1589
|
}
|
1493
1590
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
|
1494
|
-
getGuildApplicationCommand(applicationId, guildId, commandId) {
|
1495
|
-
|
1496
|
-
|
1497
|
-
.then((response) => this.util.toCamelCase(response));
|
1591
|
+
async getGuildApplicationCommand(applicationId, guildId, commandId) {
|
1592
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationGuildCommand(applicationId, guildId, commandId));
|
1593
|
+
return this.util.applicationCommandFromRaw(response);
|
1498
1594
|
}
|
1499
1595
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
|
1500
|
-
getGuildApplicationCommands(applicationId, guildId, options) {
|
1501
|
-
|
1502
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationGuildCommands(applicationId, guildId), {
|
1596
|
+
async getGuildApplicationCommands(applicationId, guildId, options) {
|
1597
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationGuildCommands(applicationId, guildId), {
|
1503
1598
|
query: {
|
1504
1599
|
with_localizations: options?.withLocalizations,
|
1505
1600
|
},
|
1506
|
-
})
|
1507
|
-
|
1601
|
+
});
|
1602
|
+
return response.map((applicationCommand) => this.util.applicationCommandFromRaw(applicationCommand));
|
1508
1603
|
}
|
1509
1604
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
|
1510
|
-
getGuildApplicationCommandPermissions(applicationId, guildId) {
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1605
|
+
async getGuildApplicationCommandPermissions(applicationId, guildId) {
|
1606
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildApplicationCommandsPermissions(applicationId, guildId));
|
1607
|
+
return {
|
1608
|
+
id: response.id,
|
1609
|
+
applicationId: response.application_id,
|
1610
|
+
guildId: response.guild_id,
|
1611
|
+
permissions: response.permissions.map((permission) => ({
|
1612
|
+
id: permission.id,
|
1613
|
+
type: permission.type,
|
1614
|
+
permission: permission.permission,
|
1615
|
+
})),
|
1616
|
+
};
|
1514
1617
|
}
|
1515
1618
|
/** https://discord.com/developers/docs/resources/guild#get-guild-ban */
|
1516
|
-
getGuildBan(guildId, userId) {
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1619
|
+
async getGuildBan(guildId, userId) {
|
1620
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildBan(guildId, userId));
|
1621
|
+
return {
|
1622
|
+
reason: response.reason,
|
1623
|
+
user: this.util.userFromRaw(response.user),
|
1624
|
+
};
|
1520
1625
|
}
|
1521
1626
|
/** https://discord.com/developers/docs/resources/guild#get-guild-bans */
|
1522
|
-
getGuildBans(guildId, options) {
|
1523
|
-
|
1524
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildBans(guildId), {
|
1627
|
+
async getGuildBans(guildId, options) {
|
1628
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildBans(guildId), {
|
1525
1629
|
query: {
|
1526
1630
|
limit: options?.limit,
|
1527
1631
|
before: options?.before,
|
1528
1632
|
after: options?.after,
|
1529
1633
|
},
|
1530
|
-
})
|
1531
|
-
|
1634
|
+
});
|
1635
|
+
return response.map((ban) => ({
|
1636
|
+
reason: ban.reason,
|
1637
|
+
user: this.util.userFromRaw(ban.user),
|
1638
|
+
}));
|
1532
1639
|
}
|
1533
1640
|
/** https://discord.com/developers/docs/resources/emoji#get-guild-emoji */
|
1534
|
-
getGuildEmoji(guildId, emojiId) {
|
1535
|
-
|
1536
|
-
|
1537
|
-
.then((response) => this.util.toCamelCase(response));
|
1641
|
+
async getGuildEmoji(guildId, emojiId) {
|
1642
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildEmoji(guildId, emojiId));
|
1643
|
+
return this.util.emojiFromRaw(response);
|
1538
1644
|
}
|
1539
1645
|
/** https://discord.com/developers/docs/resources/emoji#list-guild-emojis */
|
1540
|
-
getGuildEmojis(guildId) {
|
1541
|
-
|
1542
|
-
|
1543
|
-
.then((response) => response.map((emoji) => this.util.toCamelCase(emoji)));
|
1646
|
+
async getGuildEmojis(guildId) {
|
1647
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildEmojis(guildId));
|
1648
|
+
return response.map((emoji) => this.util.emojiFromRaw(emoji));
|
1544
1649
|
}
|
1545
1650
|
/** https://discord.com/developers/docs/resources/guild#get-guild-integrations */
|
1546
|
-
getGuildIntegrations(guildId) {
|
1547
|
-
|
1548
|
-
|
1549
|
-
.then((response) => response.map((integration) => this.util.toCamelCase(integration)));
|
1651
|
+
async getGuildIntegrations(guildId) {
|
1652
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildIntegrations(guildId));
|
1653
|
+
return response.map((integration) => this.util.integrationFromRaw(integration));
|
1550
1654
|
}
|
1551
1655
|
/** https://discord.com/developers/docs/resources/guild#get-guild-invites */
|
1552
|
-
getGuildInvites(guildId) {
|
1553
|
-
|
1554
|
-
|
1555
|
-
.then((response) => response.map((invite) => this.util.toCamelCase(invite)));
|
1656
|
+
async getGuildInvites(guildId) {
|
1657
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildInvites(guildId));
|
1658
|
+
return response.map((invite) => this.util.inviteFromRaw(invite));
|
1556
1659
|
}
|
1557
1660
|
/** https://discord.com/developers/docs/resources/guild#get-guild-member */
|
1558
|
-
getGuildMember(guildId, userId) {
|
1559
|
-
|
1560
|
-
|
1561
|
-
.then((response) => this.util.toCamelCase(response));
|
1661
|
+
async getGuildMember(guildId, userId) {
|
1662
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMember(guildId, userId));
|
1663
|
+
return this.util.guildMemberFromRaw(response);
|
1562
1664
|
}
|
1563
1665
|
/** https://discord.com/developers/docs/resources/guild#list-guild-members */
|
1564
|
-
getGuildMembers(guildId) {
|
1565
|
-
|
1566
|
-
|
1567
|
-
.then((response) => response.map((guildMember) => this.util.toCamelCase(guildMember)));
|
1666
|
+
async getGuildMembers(guildId) {
|
1667
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMembers(guildId));
|
1668
|
+
return response.map((guildMember) => this.util.guildMemberFromRaw(guildMember));
|
1568
1669
|
}
|
1569
1670
|
/** https://discord.com/developers/docs/resources/guild#get-guild-onboarding */
|
1570
|
-
getGuildOnboarding(guildId) {
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1671
|
+
async getGuildOnboarding(guildId) {
|
1672
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildOnboarding(guildId));
|
1673
|
+
return {
|
1674
|
+
guildId: response.guild_id,
|
1675
|
+
prompts: response.prompts.map((prompt) => ({
|
1676
|
+
id: prompt.id,
|
1677
|
+
type: prompt.type,
|
1678
|
+
options: prompt.options.map((promptOption) => ({
|
1679
|
+
id: promptOption.id,
|
1680
|
+
channelIds: promptOption.channel_ids,
|
1681
|
+
roleIds: promptOption.role_ids,
|
1682
|
+
emoji: promptOption.emoji !== undefined
|
1683
|
+
? this.util.emojiFromRaw(promptOption.emoji)
|
1684
|
+
: undefined,
|
1685
|
+
emojiId: promptOption.emoji_id,
|
1686
|
+
emojiName: promptOption.emoji_name,
|
1687
|
+
emojiAnimated: promptOption.emoji_animated,
|
1688
|
+
title: promptOption.title,
|
1689
|
+
description: promptOption.description,
|
1690
|
+
})),
|
1691
|
+
title: prompt.title,
|
1692
|
+
singleSelect: prompt.single_select,
|
1693
|
+
required: prompt.required,
|
1694
|
+
inOnboarding: prompt.in_onboarding,
|
1695
|
+
})),
|
1696
|
+
defaultChannelIds: response.default_channel_ids,
|
1697
|
+
enabled: response.enabled,
|
1698
|
+
mode: response.mode,
|
1699
|
+
};
|
1574
1700
|
}
|
1575
1701
|
/** https://discord.com/developers/docs/resources/guild#get-guild-preview */
|
1576
|
-
getGuildPreview(guildId) {
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1702
|
+
async getGuildPreview(guildId) {
|
1703
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildPreview(guildId));
|
1704
|
+
return {
|
1705
|
+
id: response.id,
|
1706
|
+
name: response.name,
|
1707
|
+
icon: response.icon,
|
1708
|
+
splash: response.splash,
|
1709
|
+
discoverySplash: response.discovery_splash,
|
1710
|
+
emojis: response.emojis.map((emoji) => this.util.emojiFromRaw(emoji)),
|
1711
|
+
features: response.features,
|
1712
|
+
approximateMemberCount: response.approximate_member_count,
|
1713
|
+
approximatePresenceCount: response.approximate_presence_count,
|
1714
|
+
description: response.description,
|
1715
|
+
stickers: response.stickers?.map((sticker) => this.util.stickerFromRaw(sticker)),
|
1716
|
+
};
|
1580
1717
|
}
|
1581
1718
|
/** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */
|
1582
1719
|
getGuildPruneCount(guildId, options) {
|
1583
|
-
return this.rest
|
1584
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildPrune(guildId), {
|
1720
|
+
return this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildPrune(guildId), {
|
1585
1721
|
query: {
|
1586
1722
|
days: options.days,
|
1587
1723
|
include_roles: options.includeRoles,
|
1588
1724
|
},
|
1589
|
-
})
|
1590
|
-
.then((response) => this.util.toCamelCase(response));
|
1725
|
+
});
|
1591
1726
|
}
|
1592
1727
|
/** https://discord.com/developers/docs/resources/guild#get-guild-roles */
|
1593
|
-
getGuildRoles(guildId) {
|
1594
|
-
|
1595
|
-
|
1596
|
-
.then((response) => response.map((role) => this.util.toCamelCase(role)));
|
1728
|
+
async getGuildRoles(guildId) {
|
1729
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildRoles(guildId));
|
1730
|
+
return response.map((role) => this.util.roleFromRaw(role));
|
1597
1731
|
}
|
1598
1732
|
/** https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild */
|
1599
|
-
getGuildScheduledEvents(guildId, options) {
|
1600
|
-
|
1601
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildScheduledEvents(guildId), {
|
1733
|
+
async getGuildScheduledEvents(guildId, options) {
|
1734
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildScheduledEvents(guildId), {
|
1602
1735
|
query: {
|
1603
1736
|
with_user_count: options?.withUserCount,
|
1604
1737
|
},
|
1605
|
-
})
|
1606
|
-
|
1738
|
+
});
|
1739
|
+
return response.map((guildScheduledEvent) => this.util.guildScheduledEventFromRaw(guildScheduledEvent));
|
1607
1740
|
}
|
1608
1741
|
/** https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users */
|
1609
|
-
getGuildScheduledEventUsers(guildId, guildScheduledEventId, options) {
|
1610
|
-
|
1611
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildScheduledEvent(guildId, guildScheduledEventId), {
|
1742
|
+
async getGuildScheduledEventUsers(guildId, guildScheduledEventId, options) {
|
1743
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildScheduledEvent(guildId, guildScheduledEventId), {
|
1612
1744
|
query: {
|
1613
1745
|
limit: options?.limit,
|
1614
1746
|
with_member: options?.withMember,
|
1615
1747
|
before: options?.before,
|
1616
1748
|
after: options?.after,
|
1617
1749
|
},
|
1618
|
-
})
|
1619
|
-
|
1750
|
+
});
|
1751
|
+
return response.map((guildScheduledEventUser) => ({
|
1752
|
+
guildScheduledEventId: guildScheduledEventUser.guild_scheduled_event_id,
|
1753
|
+
user: this.util.userFromRaw(guildScheduledEventUser.user),
|
1754
|
+
member: guildScheduledEventUser.member !== undefined
|
1755
|
+
? this.util.guildMemberFromRaw(guildScheduledEventUser.member)
|
1756
|
+
: undefined,
|
1757
|
+
}));
|
1620
1758
|
}
|
1621
1759
|
/** https://discord.com/developers/docs/resources/sticker#get-guild-sticker */
|
1622
|
-
getGuildSticker(guildId, stickerId) {
|
1623
|
-
|
1624
|
-
|
1625
|
-
.then((response) => this.util.toCamelCase(response));
|
1760
|
+
async getGuildSticker(guildId, stickerId) {
|
1761
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildSticker(guildId, stickerId));
|
1762
|
+
return this.util.stickerFromRaw(response);
|
1626
1763
|
}
|
1627
1764
|
/** https://discord.com/developers/docs/resources/sticker#list-guild-stickers */
|
1628
|
-
getGuildStickers(guildId) {
|
1629
|
-
|
1630
|
-
|
1631
|
-
.then((response) => response.map((sticker) => this.util.toCamelCase(sticker)));
|
1765
|
+
async getGuildStickers(guildId) {
|
1766
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildStickers(guildId));
|
1767
|
+
return response.map((sticker) => this.util.stickerFromRaw(sticker));
|
1632
1768
|
}
|
1633
1769
|
/** https://discord.com/developers/docs/resources/guild-template#get-guild-template */
|
1634
|
-
getGuildTemplate(guildId, code) {
|
1635
|
-
|
1636
|
-
|
1637
|
-
.then((response) => this.util.toCamelCase(response));
|
1770
|
+
async getGuildTemplate(guildId, code) {
|
1771
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildTemplate(guildId, code));
|
1772
|
+
return this.util.guildTemplateFromRaw(response);
|
1638
1773
|
}
|
1639
1774
|
/** https://discord.com/developers/docs/resources/guild-template#get-guild-templates */
|
1640
|
-
getGuildTemplates(guildId) {
|
1641
|
-
|
1642
|
-
|
1643
|
-
.then((response) => response.map((guildTemplate) => this.util.toCamelCase(guildTemplate)));
|
1775
|
+
async getGuildTemplates(guildId) {
|
1776
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildTemplates(guildId));
|
1777
|
+
return response.map((guildTemplate) => this.util.guildTemplateFromRaw(guildTemplate));
|
1644
1778
|
}
|
1645
1779
|
/** https://discord.com/developers/docs/resources/guild#get-guild-vanity-url */
|
1646
1780
|
getGuildVanityUrl(guildId) {
|
1647
1781
|
return this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildVanityUrl(guildId));
|
1648
1782
|
}
|
1649
1783
|
/** https://discord.com/developers/docs/resources/guild#get-guild-voice-regions */
|
1650
|
-
getGuildVoiceRegions(guildId) {
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1784
|
+
async getGuildVoiceRegions(guildId) {
|
1785
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildVoiceRegions(guildId));
|
1786
|
+
return response.map((voiceRegion) => ({
|
1787
|
+
id: voiceRegion.id,
|
1788
|
+
name: voiceRegion.name,
|
1789
|
+
optimal: voiceRegion.optimal,
|
1790
|
+
deprecated: voiceRegion.deprecated,
|
1791
|
+
custom: voiceRegion.custom,
|
1792
|
+
}));
|
1654
1793
|
}
|
1655
1794
|
/** https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen */
|
1656
|
-
getGuildWelcomeScreen(guildId) {
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1795
|
+
async getGuildWelcomeScreen(guildId) {
|
1796
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWelcomeScreen(guildId));
|
1797
|
+
return {
|
1798
|
+
description: response.description,
|
1799
|
+
welcomeChannels: response.welcome_channels.map((welcomeScreenChannel) => ({
|
1800
|
+
channelId: welcomeScreenChannel.channel_id,
|
1801
|
+
description: welcomeScreenChannel.description,
|
1802
|
+
emojiId: welcomeScreenChannel.emoji_id,
|
1803
|
+
emojiName: welcomeScreenChannel.emoji_name,
|
1804
|
+
})),
|
1805
|
+
};
|
1660
1806
|
}
|
1661
1807
|
/** https://discord.com/developers/docs/resources/guild#get-guild-widget */
|
1662
|
-
getGuildWidget(guildId) {
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1808
|
+
async getGuildWidget(guildId) {
|
1809
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWidgetJSON(guildId));
|
1810
|
+
return {
|
1811
|
+
id: response.id,
|
1812
|
+
name: response.name,
|
1813
|
+
instantInvite: response.instant_invite,
|
1814
|
+
channels: response.channels.map((channel) => this.util.channelFromRaw(channel)),
|
1815
|
+
members: response.members.map((member) => this.util.userFromRaw(member)),
|
1816
|
+
presenceCount: response.presence_count,
|
1817
|
+
};
|
1666
1818
|
}
|
1667
1819
|
/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image */
|
1668
1820
|
getGuildWidgetImage(guildId, options) {
|
@@ -1673,181 +1825,216 @@ class Client extends node_events_1.default {
|
|
1673
1825
|
});
|
1674
1826
|
}
|
1675
1827
|
/** https://discord.com/developers/docs/resources/guild#get-guild-widget-settings */
|
1676
|
-
getGuildWidgetSettings(guildId) {
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1828
|
+
async getGuildWidgetSettings(guildId) {
|
1829
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWidgetSettings(guildId));
|
1830
|
+
return {
|
1831
|
+
enabled: response.enabled,
|
1832
|
+
channelId: response.channel_id,
|
1833
|
+
};
|
1680
1834
|
}
|
1681
1835
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message */
|
1682
|
-
getInteractionFollowupMessage(applicationId, interactionToken, messageId, options) {
|
1683
|
-
|
1684
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(applicationId, interactionToken, messageId), {
|
1836
|
+
async getInteractionFollowupMessage(applicationId, interactionToken, messageId, options) {
|
1837
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(applicationId, interactionToken, messageId), {
|
1685
1838
|
query: {
|
1686
1839
|
thread_id: options?.threadId,
|
1687
1840
|
},
|
1688
|
-
})
|
1689
|
-
|
1841
|
+
});
|
1842
|
+
return this.util.messageFromRaw(response);
|
1690
1843
|
}
|
1691
1844
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response */
|
1692
|
-
getInteractionResponse(applicationId, interactionToken, options) {
|
1693
|
-
|
1694
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(applicationId, interactionToken), {
|
1845
|
+
async getInteractionResponse(applicationId, interactionToken, options) {
|
1846
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(applicationId, interactionToken), {
|
1695
1847
|
query: {
|
1696
1848
|
thread_id: options?.threadId,
|
1697
1849
|
},
|
1698
|
-
})
|
1699
|
-
|
1850
|
+
});
|
1851
|
+
return this.util.messageFromRaw(response);
|
1700
1852
|
}
|
1701
1853
|
/** https://discord.com/developers/docs/resources/invite#get-invite */
|
1702
|
-
getInvite(code, options) {
|
1703
|
-
|
1704
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.invite(code), {
|
1854
|
+
async getInvite(code, options) {
|
1855
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.invite(code), {
|
1705
1856
|
query: {
|
1706
1857
|
with_counts: options?.withCounts,
|
1707
1858
|
with_expiration: options?.withExpiration,
|
1708
1859
|
guild_scheduled_event_id: options?.guildScheduledEventId,
|
1709
1860
|
},
|
1710
|
-
})
|
1711
|
-
|
1861
|
+
});
|
1862
|
+
return this.util.inviteFromRaw(response);
|
1712
1863
|
}
|
1713
1864
|
/** https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads */
|
1714
|
-
getJoinedPrivateArchivedThreads(channelId, options) {
|
1715
|
-
|
1716
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelThreads(channelId, "private", true), {
|
1865
|
+
async getJoinedPrivateArchivedThreads(channelId, options) {
|
1866
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelThreads(channelId, "private", true), {
|
1717
1867
|
query: {
|
1718
1868
|
before: options?.before,
|
1719
1869
|
limit: options?.limit,
|
1720
1870
|
},
|
1721
|
-
})
|
1722
|
-
|
1871
|
+
});
|
1872
|
+
return {
|
1873
|
+
threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
|
1874
|
+
members: response.members.map((threadMember) => ({
|
1875
|
+
id: threadMember.id,
|
1876
|
+
userId: threadMember.user_id,
|
1877
|
+
joinTimestamp: threadMember.join_timestamp,
|
1878
|
+
flags: threadMember.flags,
|
1879
|
+
member: threadMember.member !== undefined
|
1880
|
+
? this.util.guildMemberFromRaw(threadMember.member)
|
1881
|
+
: undefined,
|
1882
|
+
})),
|
1883
|
+
hasMore: response.has_more,
|
1884
|
+
};
|
1723
1885
|
}
|
1724
1886
|
/** https://discord.com/developers/docs/resources/channel#get-channel-message */
|
1725
|
-
getMessage(channelId, messageId) {
|
1726
|
-
|
1727
|
-
|
1728
|
-
.then((response) => this.util.toCamelCase(response));
|
1887
|
+
async getMessage(channelId, messageId) {
|
1888
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessage(channelId, messageId));
|
1889
|
+
return this.util.messageFromRaw(response);
|
1729
1890
|
}
|
1730
1891
|
/** https://discord.com/developers/docs/resources/channel#get-reactions */
|
1731
|
-
getMessageReactions(channelId, messageId, emoji, options) {
|
1732
|
-
|
1733
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessageAllReactions(channelId, messageId, emoji), {
|
1892
|
+
async getMessageReactions(channelId, messageId, emoji, options) {
|
1893
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessageAllReactions(channelId, messageId, emoji), {
|
1734
1894
|
query: {
|
1735
1895
|
type: options?.type,
|
1736
1896
|
after: options?.after,
|
1737
1897
|
limit: options?.limit,
|
1738
1898
|
},
|
1739
|
-
})
|
1740
|
-
|
1899
|
+
});
|
1900
|
+
return response.map((user) => this.util.userFromRaw(user));
|
1741
1901
|
}
|
1742
1902
|
/** https://discord.com/developers/docs/resources/channel#get-channel-messages */
|
1743
|
-
getMessages(channelId, options) {
|
1744
|
-
|
1745
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessages(channelId), {
|
1903
|
+
async getMessages(channelId, options) {
|
1904
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessages(channelId), {
|
1746
1905
|
query: {
|
1747
1906
|
around: options.around,
|
1748
1907
|
before: options.before,
|
1749
1908
|
after: options.after,
|
1750
1909
|
limit: options.limit,
|
1751
1910
|
},
|
1752
|
-
})
|
1753
|
-
|
1911
|
+
});
|
1912
|
+
return response.map((message) => this.util.messageFromRaw(message));
|
1754
1913
|
}
|
1755
1914
|
/** https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information */
|
1756
|
-
getOAuth2Application() {
|
1757
|
-
|
1758
|
-
|
1759
|
-
.then((response) => this.util.toCamelCase(response));
|
1915
|
+
async getOAuth2Application() {
|
1916
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.oauth2CurrentApplication());
|
1917
|
+
return this.util.applicationFromRaw(response);
|
1760
1918
|
}
|
1761
1919
|
/** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information */
|
1762
|
-
getOAuth2Authorization() {
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1920
|
+
async getOAuth2Authorization() {
|
1921
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.oauth2Authorization());
|
1922
|
+
return {
|
1923
|
+
application: this.util.applicationFromRaw(response.application),
|
1924
|
+
scopes: response.scopes,
|
1925
|
+
expires: response.expires,
|
1926
|
+
user: response.user !== undefined
|
1927
|
+
? this.util.userFromRaw(response.user)
|
1928
|
+
: undefined,
|
1929
|
+
};
|
1766
1930
|
}
|
1767
1931
|
/** https://discord.com/developers/docs/resources/channel#get-pinned-messages */
|
1768
|
-
getPinnedMessages(channelId) {
|
1769
|
-
|
1770
|
-
|
1771
|
-
.then((response) => response.map((message) => this.util.toCamelCase(message)));
|
1932
|
+
async getPinnedMessages(channelId) {
|
1933
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelPins(channelId));
|
1934
|
+
return response.map((message) => this.util.messageFromRaw(message));
|
1772
1935
|
}
|
1773
1936
|
/** https://discord.com/developers/docs/resources/poll#get-answer-voters */
|
1774
|
-
getPollAnswerVoters(channelId, messageId, answerId, options) {
|
1775
|
-
|
1776
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.pollAnswerVoters(channelId, messageId, answerId), {
|
1937
|
+
async getPollAnswerVoters(channelId, messageId, answerId, options) {
|
1938
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.pollAnswerVoters(channelId, messageId, answerId), {
|
1777
1939
|
query: {
|
1778
1940
|
after: options?.after,
|
1779
1941
|
limit: options?.limit,
|
1780
1942
|
},
|
1781
|
-
})
|
1782
|
-
|
1943
|
+
});
|
1944
|
+
return {
|
1945
|
+
users: response.users.map((user) => this.util.userFromRaw(user)),
|
1946
|
+
};
|
1783
1947
|
}
|
1784
1948
|
/** https://discord.com/developers/docs/monetization/skus#list-skus */
|
1785
|
-
getSkus(applicationId) {
|
1786
|
-
|
1787
|
-
|
1788
|
-
.then((response) => response.map((sku) => this.util.toCamelCase(sku)));
|
1949
|
+
async getSkus(applicationId) {
|
1950
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationSkus(applicationId));
|
1951
|
+
return response.map((sku) => this.util.skuFromRaw(sku));
|
1789
1952
|
}
|
1790
1953
|
/** https://discord.com/developers/docs/resources/stage-instance#get-stage-instance */
|
1791
|
-
getStageInstance(channelId) {
|
1792
|
-
|
1793
|
-
|
1794
|
-
.then((response) => this.util.toCamelCase(response));
|
1954
|
+
async getStageInstance(channelId) {
|
1955
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.stageInstance(channelId));
|
1956
|
+
return this.util.stageInstanceFromRaw(response);
|
1795
1957
|
}
|
1796
1958
|
/** https://discord.com/developers/docs/resources/sticker#list-sticker-packs */
|
1797
|
-
getStickerPacks() {
|
1798
|
-
|
1799
|
-
|
1800
|
-
.
|
1959
|
+
async getStickerPacks() {
|
1960
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.stickerPacks());
|
1961
|
+
return {
|
1962
|
+
stickerPacks: response.sticker_packs.map((stickerPack) => ({
|
1963
|
+
id: stickerPack.id,
|
1964
|
+
stickers: stickerPack.stickers.map((sticker) => this.util.stickerFromRaw(sticker)),
|
1965
|
+
name: stickerPack.name,
|
1966
|
+
skuId: stickerPack.sku_id,
|
1967
|
+
coverStickerId: stickerPack.cover_sticker_id,
|
1968
|
+
description: stickerPack.description,
|
1969
|
+
bannerAssetId: stickerPack.banner_asset_id,
|
1970
|
+
})),
|
1971
|
+
};
|
1801
1972
|
}
|
1802
1973
|
/** https://discord.com/developers/docs/resources/channel#get-thread-member */
|
1803
|
-
getThreadMember(channelId, userId, options) {
|
1804
|
-
|
1805
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.threadMembers(channelId, userId), {
|
1974
|
+
async getThreadMember(channelId, userId, options) {
|
1975
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.threadMembers(channelId, userId), {
|
1806
1976
|
query: {
|
1807
1977
|
with_member: options?.withMember,
|
1808
1978
|
},
|
1809
|
-
})
|
1810
|
-
|
1979
|
+
});
|
1980
|
+
return {
|
1981
|
+
id: response.id,
|
1982
|
+
userId: response.user_id,
|
1983
|
+
joinTimestamp: response.join_timestamp,
|
1984
|
+
flags: response.flags,
|
1985
|
+
member: response.member !== undefined
|
1986
|
+
? this.util.guildMemberFromRaw(response.member)
|
1987
|
+
: undefined,
|
1988
|
+
};
|
1811
1989
|
}
|
1812
1990
|
/** https://discord.com/developers/docs/resources/channel#list-thread-members */
|
1813
|
-
getThreadMembers(channelId, options) {
|
1814
|
-
|
1815
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.threadMembers(channelId), {
|
1991
|
+
async getThreadMembers(channelId, options) {
|
1992
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.threadMembers(channelId), {
|
1816
1993
|
query: {
|
1817
1994
|
with_member: options?.withMember,
|
1818
1995
|
after: options?.after,
|
1819
1996
|
limit: options?.limit,
|
1820
1997
|
},
|
1821
|
-
})
|
1822
|
-
|
1998
|
+
});
|
1999
|
+
return response.map((threadMember) => ({
|
2000
|
+
id: threadMember.id,
|
2001
|
+
userId: threadMember.user_id,
|
2002
|
+
joinTimestamp: threadMember.join_timestamp,
|
2003
|
+
flags: threadMember.flags,
|
2004
|
+
member: threadMember.member !== undefined
|
2005
|
+
? this.util.guildMemberFromRaw(threadMember.member)
|
2006
|
+
: undefined,
|
2007
|
+
}));
|
1823
2008
|
}
|
1824
2009
|
/** https://discord.com/developers/docs/resources/user#get-user */
|
1825
|
-
getUser(userId) {
|
1826
|
-
|
1827
|
-
|
1828
|
-
.then((response) => this.util.toCamelCase(response));
|
2010
|
+
async getUser(userId) {
|
2011
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.user(userId));
|
2012
|
+
return this.util.userFromRaw(response);
|
1829
2013
|
}
|
1830
2014
|
/** https://discord.com/developers/docs/resources/voice#list-voice-regions */
|
1831
|
-
getVoiceRegions() {
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
2015
|
+
async getVoiceRegions() {
|
2016
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.voiceRegions());
|
2017
|
+
return response.map((voiceRegion) => ({
|
2018
|
+
id: voiceRegion.id,
|
2019
|
+
name: voiceRegion.name,
|
2020
|
+
optimal: voiceRegion.optimal,
|
2021
|
+
deprecated: voiceRegion.deprecated,
|
2022
|
+
custom: voiceRegion.custom,
|
2023
|
+
}));
|
1835
2024
|
}
|
1836
2025
|
/** https://discord.com/developers/docs/resources/webhook#get-webhook-message */
|
1837
|
-
getWebhookMessage(webhookId, webhookToken, messageId, options) {
|
1838
|
-
|
1839
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(webhookId, webhookToken, messageId), {
|
2026
|
+
async getWebhookMessage(webhookId, webhookToken, messageId, options) {
|
2027
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(webhookId, webhookToken, messageId), {
|
1840
2028
|
query: {
|
1841
2029
|
thread_id: options?.threadId,
|
1842
2030
|
},
|
1843
|
-
})
|
1844
|
-
|
2031
|
+
});
|
2032
|
+
return this.util.messageFromRaw(response);
|
1845
2033
|
}
|
1846
2034
|
/** https://discord.com/developers/docs/resources/webhook#get-guild-webhooks */
|
1847
|
-
getWebhooks(guildId) {
|
1848
|
-
|
1849
|
-
|
1850
|
-
.then((response) => response.map((webhook) => this.util.toCamelCase(webhook)));
|
2035
|
+
async getWebhooks(guildId) {
|
2036
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWebhooks(guildId));
|
2037
|
+
return response.map((webhook) => this.util.webhookFromRaw(webhook));
|
1851
2038
|
}
|
1852
2039
|
/** https://discord.com/developers/docs/resources/channel#join-thread */
|
1853
2040
|
joinThread(channelId) {
|
@@ -1918,15 +2105,14 @@ class Client extends node_events_1.default {
|
|
1918
2105
|
this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.threadMembers(channelId, userId));
|
1919
2106
|
}
|
1920
2107
|
/** https://discord.com/developers/docs/resources/guild#search-guild-members */
|
1921
|
-
searchGuildMembers(guildId, options) {
|
1922
|
-
|
1923
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMembersSearch(guildId), {
|
2108
|
+
async searchGuildMembers(guildId, options) {
|
2109
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMembersSearch(guildId), {
|
1924
2110
|
query: {
|
1925
2111
|
query: options.query,
|
1926
2112
|
limit: options.limit,
|
1927
2113
|
},
|
1928
|
-
})
|
1929
|
-
|
2114
|
+
});
|
2115
|
+
return response.map((guildMember) => this.util.guildMemberFromRaw(guildMember));
|
1930
2116
|
}
|
1931
2117
|
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
1932
2118
|
setPresence(options) {
|
@@ -1934,32 +2120,47 @@ class Client extends node_events_1.default {
|
|
1934
2120
|
shard.setPresence(options);
|
1935
2121
|
}
|
1936
2122
|
/** https://discord.com/developers/docs/resources/guild-template#sync-guild-template */
|
1937
|
-
syncGuildTemplate(guildId, code) {
|
1938
|
-
|
1939
|
-
|
1940
|
-
.then((response) => this.util.toCamelCase(response));
|
2123
|
+
async syncGuildTemplate(guildId, code) {
|
2124
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.guildTemplate(guildId, code));
|
2125
|
+
return this.util.guildTemplateFromRaw(response);
|
1941
2126
|
}
|
1942
2127
|
/** https://discord.com/developers/docs/resources/channel#trigger-typing-indicator */
|
1943
2128
|
triggerTypingIndicator(channelId) {
|
1944
2129
|
this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelTyping(channelId));
|
1945
2130
|
}
|
1946
2131
|
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
|
1947
|
-
updateApplicationRoleConnectionMetadataRecords(applicationId) {
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
2132
|
+
async updateApplicationRoleConnectionMetadataRecords(applicationId) {
|
2133
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationRoleConnectionMetadata(applicationId));
|
2134
|
+
return response.map((applicationRoleConnectionMetadata) => ({
|
2135
|
+
type: applicationRoleConnectionMetadata.type,
|
2136
|
+
key: applicationRoleConnectionMetadata.key,
|
2137
|
+
name: applicationRoleConnectionMetadata.name,
|
2138
|
+
nameLocalizations: applicationRoleConnectionMetadata.name_localizations,
|
2139
|
+
description: applicationRoleConnectionMetadata.description,
|
2140
|
+
descriptionLocalizations: applicationRoleConnectionMetadata.description_localizations,
|
2141
|
+
}));
|
1951
2142
|
}
|
1952
2143
|
/** https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection */
|
1953
|
-
updateCurrentApplicationRoleConnection(options) {
|
1954
|
-
|
1955
|
-
.request(rest_1.RESTMethods.Put, rest_1.Endpoints.userApplicationRoleConnection(this.application.id), {
|
2144
|
+
async updateCurrentApplicationRoleConnection(options) {
|
2145
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.userApplicationRoleConnection(this.application.id), {
|
1956
2146
|
json: {
|
1957
2147
|
platform_name: options.platformName,
|
1958
2148
|
platform_username: options.platformUsername,
|
1959
2149
|
metadata: options.metadata,
|
1960
2150
|
},
|
1961
|
-
})
|
1962
|
-
|
2151
|
+
});
|
2152
|
+
return {
|
2153
|
+
platformName: response.platform_name,
|
2154
|
+
platformUsername: response.platform_username,
|
2155
|
+
metadata: {
|
2156
|
+
type: response.metadata.type,
|
2157
|
+
key: response.metadata.key,
|
2158
|
+
name: response.metadata.name,
|
2159
|
+
nameLocalizations: response.metadata.name_localizations,
|
2160
|
+
description: response.metadata.description,
|
2161
|
+
descriptionLocalizations: response.metadata.description_localizations,
|
2162
|
+
},
|
2163
|
+
};
|
1963
2164
|
}
|
1964
2165
|
/** https://discord.com/developers/docs/resources/channel#unpin-message */
|
1965
2166
|
unpinMessage(channelId, messageId, reason) {
|