disgroove 2.2.0-dev.15819eb → 2.2.0-dev.4623b99
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 +861 -716
- package/dist/lib/gateway/Shard.js +252 -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 +12 -5
- 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 +92 -2
- package/dist/lib/utils/Util.js +2207 -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,75 @@ 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,
|
396
|
+
poll: options.poll !== undefined
|
397
|
+
? {
|
398
|
+
question: options.poll.question,
|
399
|
+
answers: options.poll.answers.map((answer) => ({
|
400
|
+
answer_id: answer.answerId,
|
401
|
+
poll_media: answer.pollMedia,
|
402
|
+
})),
|
403
|
+
duration: options.poll.duration,
|
404
|
+
allow_multiselect: options.poll.allowMultiselect,
|
405
|
+
layout_type: options.poll.layoutType,
|
406
|
+
}
|
407
|
+
: undefined,
|
416
408
|
},
|
417
409
|
files: options.files,
|
418
|
-
})
|
419
|
-
|
410
|
+
});
|
411
|
+
return this.util.messageFromRaw(response);
|
420
412
|
}
|
421
413
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */
|
422
414
|
createInteractionResponse(interactionId, interactionToken, options) {
|
@@ -430,18 +422,32 @@ class Client extends node_events_1.default {
|
|
430
422
|
data: {
|
431
423
|
content: options.data?.content,
|
432
424
|
embeds: options.data?.embeds !== undefined
|
433
|
-
?
|
425
|
+
? options.data.embeds.map((embed) => this.util.embedToRaw(embed))
|
434
426
|
: undefined,
|
435
427
|
allowed_mentions: options.data?.allowedMentions !== undefined
|
436
|
-
?
|
428
|
+
? {
|
429
|
+
parse: options.data.allowedMentions.parse,
|
430
|
+
roles: options.data.allowedMentions.roles,
|
431
|
+
users: options.data.allowedMentions.users,
|
432
|
+
replied_user: options.data.allowedMentions.repliedUser,
|
433
|
+
}
|
437
434
|
: undefined,
|
438
435
|
flags: options.data?.flags,
|
439
436
|
components: options.data?.components !== undefined
|
440
|
-
? this.util.
|
437
|
+
? this.util.messageComponentsToRaw(options.data.components)
|
441
438
|
: undefined,
|
442
|
-
attachments: options.data?.attachments?.map((attachment) => this.util.
|
439
|
+
attachments: options.data?.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
443
440
|
poll: options.data?.poll !== undefined
|
444
|
-
?
|
441
|
+
? {
|
442
|
+
question: options.data.poll.question,
|
443
|
+
answers: options.data.poll.answers.map((answer) => ({
|
444
|
+
answer_id: answer.answerId,
|
445
|
+
poll_media: answer.pollMedia,
|
446
|
+
})),
|
447
|
+
duration: options.data.poll.duration,
|
448
|
+
allow_multiselect: options.data.poll.allowMultiselect,
|
449
|
+
layout_type: options.data.poll.layoutType,
|
450
|
+
}
|
445
451
|
: undefined,
|
446
452
|
},
|
447
453
|
},
|
@@ -468,7 +474,11 @@ class Client extends node_events_1.default {
|
|
468
474
|
json: {
|
469
475
|
type: options.type,
|
470
476
|
data: {
|
471
|
-
choices: options.data?.choices?.map((choice) =>
|
477
|
+
choices: options.data?.choices?.map((choice) => ({
|
478
|
+
name: choice.name,
|
479
|
+
name_localizations: choice.nameLocalizations,
|
480
|
+
value: choice.value,
|
481
|
+
})),
|
472
482
|
},
|
473
483
|
},
|
474
484
|
});
|
@@ -482,7 +492,7 @@ class Client extends node_events_1.default {
|
|
482
492
|
data: {
|
483
493
|
custom_id: options.data?.customId,
|
484
494
|
components: options.data?.components !== undefined
|
485
|
-
? this.util.
|
495
|
+
? this.util.messageComponentsToRaw(options.data.components)
|
486
496
|
: undefined,
|
487
497
|
title: options.data?.title,
|
488
498
|
},
|
@@ -503,43 +513,53 @@ class Client extends node_events_1.default {
|
|
503
513
|
}
|
504
514
|
}
|
505
515
|
/** 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), {
|
516
|
+
async createMessage(channelId, options) {
|
517
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelMessages(channelId), {
|
509
518
|
json: {
|
510
519
|
content: options.content,
|
511
520
|
nonce: options.nonce,
|
512
521
|
tts: options.tts,
|
513
|
-
embeds: options.embeds
|
514
|
-
? options.embeds.map((e) => this.util.toSnakeCase(e))
|
515
|
-
: undefined,
|
522
|
+
embeds: options.embeds?.map((embed) => this.util.embedToRaw(embed)),
|
516
523
|
allowed_mentions: options.allowedMentions !== undefined
|
517
|
-
?
|
524
|
+
? {
|
525
|
+
parse: options.allowedMentions.parse,
|
526
|
+
roles: options.allowedMentions.roles,
|
527
|
+
users: options.allowedMentions.users,
|
528
|
+
replied_user: options.allowedMentions.repliedUser,
|
529
|
+
}
|
518
530
|
: undefined,
|
519
531
|
message_reference: options.messageReference,
|
520
532
|
components: options.components !== undefined
|
521
|
-
?
|
533
|
+
? this.util.messageComponentsToRaw(options.components)
|
522
534
|
: undefined,
|
523
535
|
stickers_ids: options.stickersIds,
|
524
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
536
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
525
537
|
flags: options.flags,
|
526
538
|
enforce_nonce: options.enforceNonce,
|
527
539
|
poll: options.poll !== undefined
|
528
|
-
?
|
540
|
+
? {
|
541
|
+
question: options.poll.question,
|
542
|
+
answers: options.poll.answers.map((answer) => ({
|
543
|
+
answer_id: answer.answerId,
|
544
|
+
poll_media: answer.pollMedia,
|
545
|
+
})),
|
546
|
+
duration: options.poll.duration,
|
547
|
+
allow_multiselect: options.poll.allowMultiselect,
|
548
|
+
layout_type: options.poll.layoutType,
|
549
|
+
}
|
529
550
|
: undefined,
|
530
551
|
},
|
531
552
|
files: options.files,
|
532
|
-
})
|
533
|
-
|
553
|
+
});
|
554
|
+
return this.util.messageFromRaw(response);
|
534
555
|
}
|
535
556
|
/** https://discord.com/developers/docs/resources/channel#create-reaction */
|
536
557
|
createMessageReaction(channelId, messageId, emoji) {
|
537
558
|
this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.channelMessageReaction(channelId, messageId, emoji));
|
538
559
|
}
|
539
560
|
/** 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(), {
|
561
|
+
async createStageInstance(options, reason) {
|
562
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.stageInstances(), {
|
543
563
|
json: {
|
544
564
|
channel_id: options.channelId,
|
545
565
|
topic: options.topic,
|
@@ -548,54 +568,63 @@ class Client extends node_events_1.default {
|
|
548
568
|
guild_scheduled_event_id: options.guildScheduledEventId,
|
549
569
|
},
|
550
570
|
reason,
|
551
|
-
})
|
552
|
-
|
571
|
+
});
|
572
|
+
return this.util.stageInstanceFromRaw(response);
|
553
573
|
}
|
554
574
|
/** 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), {
|
575
|
+
async createTestEntitlement(applicationId, options) {
|
576
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationEntitlements(applicationId), {
|
558
577
|
json: {
|
559
578
|
sku_id: options.skuId,
|
560
579
|
owner_id: options.ownerId,
|
561
580
|
owner_type: options.ownerType,
|
562
581
|
},
|
563
|
-
})
|
564
|
-
|
582
|
+
});
|
583
|
+
return this.util.testEntitlementFromRaw(response);
|
565
584
|
}
|
566
585
|
/** 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), {
|
586
|
+
async createThread(channelId, options, reason) {
|
587
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId), {
|
570
588
|
json: {
|
571
589
|
name: options.name,
|
572
590
|
auto_archive_duration: options.autoArchiveDuration,
|
573
591
|
rate_limit_per_user: options.rateLimitPerUser,
|
574
|
-
message:
|
592
|
+
message: {
|
593
|
+
content: options.message.content,
|
594
|
+
embeds: options.message.embeds?.map((embed) => this.util.embedToRaw(embed)),
|
595
|
+
allowed_mentions: options.message.allowedMentions !== undefined
|
596
|
+
? options.message.allowedMentions !== null
|
597
|
+
? {
|
598
|
+
parse: options.message.allowedMentions.parse,
|
599
|
+
roles: options.message.allowedMentions.roles,
|
600
|
+
users: options.message.allowedMentions.users,
|
601
|
+
replied_user: options.message.allowedMentions.repliedUser,
|
602
|
+
}
|
603
|
+
: null
|
604
|
+
: undefined,
|
605
|
+
},
|
575
606
|
applied_tags: options.appliedTags,
|
576
607
|
},
|
577
608
|
files: options.files,
|
578
609
|
reason,
|
579
|
-
})
|
580
|
-
|
610
|
+
});
|
611
|
+
return this.util.channelFromRaw(response);
|
581
612
|
}
|
582
613
|
/** 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), {
|
614
|
+
async createThreadFromMessage(channelId, messageId, options, reason) {
|
615
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId, messageId), {
|
586
616
|
json: {
|
587
617
|
name: options.name,
|
588
618
|
auto_archive_duration: options.autoArchiveDuration,
|
589
619
|
rate_limit_per_user: options.rateLimitPerUser,
|
590
620
|
},
|
591
621
|
reason,
|
592
|
-
})
|
593
|
-
|
622
|
+
});
|
623
|
+
return this.util.channelFromRaw(response);
|
594
624
|
}
|
595
625
|
/** 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), {
|
626
|
+
async createThreadWithoutMessage(channelId, options, reason) {
|
627
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.threads(channelId), {
|
599
628
|
json: {
|
600
629
|
name: options.name,
|
601
630
|
auto_archive_duration: options.autoArchiveDuration,
|
@@ -604,14 +633,13 @@ class Client extends node_events_1.default {
|
|
604
633
|
rate_limit_per_user: options.rateLimitPerUser,
|
605
634
|
},
|
606
635
|
reason,
|
607
|
-
})
|
608
|
-
|
636
|
+
});
|
637
|
+
return this.util.channelFromRaw(response);
|
609
638
|
}
|
610
639
|
/** https://discord.com/developers/docs/resources/channel#crosspost-message */
|
611
|
-
crosspostMessage(channelId, messageId) {
|
612
|
-
|
613
|
-
|
614
|
-
.then((response) => this.util.toCamelCase(response));
|
640
|
+
async crosspostMessage(channelId, messageId) {
|
641
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelMessage(channelId, messageId));
|
642
|
+
return this.util.messageFromRaw(response);
|
615
643
|
}
|
616
644
|
/** https://discord.com/developers/docs/resources/channel#delete-all-reactions */
|
617
645
|
deleteAllMessageReactions(channelId, messageId, emoji) {
|
@@ -624,12 +652,11 @@ class Client extends node_events_1.default {
|
|
624
652
|
});
|
625
653
|
}
|
626
654
|
/** 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), {
|
655
|
+
async deleteChannel(channelId, reason) {
|
656
|
+
const response = await this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.channel(channelId), {
|
630
657
|
reason,
|
631
|
-
})
|
632
|
-
|
658
|
+
});
|
659
|
+
return this.util.channelFromRaw(response);
|
633
660
|
}
|
634
661
|
/** https://discord.com/developers/docs/resources/channel#delete-channel-permission */
|
635
662
|
deleteChannelPermission(channelId, overwriteId, reason) {
|
@@ -678,18 +705,16 @@ class Client extends node_events_1.default {
|
|
678
705
|
});
|
679
706
|
}
|
680
707
|
/** https://discord.com/developers/docs/resources/guild-template#delete-guild-template */
|
681
|
-
deleteGuildTemplate(guildId, code) {
|
682
|
-
|
683
|
-
|
684
|
-
.then((response) => this.util.toCamelCase(response));
|
708
|
+
async deleteGuildTemplate(guildId, code) {
|
709
|
+
const response = await this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.guildTemplate(guildId, code));
|
710
|
+
return this.util.guildTemplateFromRaw(response);
|
685
711
|
}
|
686
712
|
/** 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), {
|
713
|
+
async deleteInvite(code, reason) {
|
714
|
+
const response = await this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.invite(code), {
|
690
715
|
reason,
|
691
|
-
})
|
692
|
-
|
716
|
+
});
|
717
|
+
return this.util.inviteFromRaw(response);
|
693
718
|
}
|
694
719
|
/** https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */
|
695
720
|
deleteInteractionFollowupMessage(applicationId, interactionToken, messageId) {
|
@@ -744,37 +769,41 @@ class Client extends node_events_1.default {
|
|
744
769
|
this.shards.disconnect();
|
745
770
|
}
|
746
771
|
/** 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), {
|
772
|
+
async editAutoModerationRule(guildId, autoModerationRuleId, options, reason) {
|
773
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildAutoModerationRule(guildId, autoModerationRuleId), {
|
750
774
|
json: {
|
751
775
|
name: options.name,
|
752
776
|
event_type: options.eventType,
|
753
777
|
trigger_type: options.triggerType,
|
754
778
|
trigger_metadata: options.triggerMetadata,
|
755
|
-
actions: options.actions?.map((action) =>
|
779
|
+
actions: options.actions?.map((action) => ({
|
780
|
+
type: action.type,
|
781
|
+
metadata: {
|
782
|
+
channel_id: action.metadata.channelId,
|
783
|
+
duration_seconds: action.metadata.durationSeconds,
|
784
|
+
custom_message: action.metadata.customMessage,
|
785
|
+
},
|
786
|
+
})),
|
756
787
|
enabled: options.enabled,
|
757
788
|
exempt_roles: options.exemptRoles,
|
758
789
|
exempt_channels: options.exemptChannels,
|
759
790
|
},
|
760
791
|
reason,
|
761
|
-
})
|
762
|
-
|
792
|
+
});
|
793
|
+
return this.util.autoModerationRuleFromRaw(response);
|
763
794
|
}
|
764
795
|
/** 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), {
|
796
|
+
async editApplicationCommandPermissions(applicationId, guildId, commandId, options) {
|
797
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommandPermissions(applicationId, guildId, commandId), {
|
768
798
|
json: {
|
769
|
-
permissions: options.permissions.map((permission) => this.util.
|
799
|
+
permissions: options.permissions.map((permission) => this.util.guildApplicationCommandPermissionsToRaw(permission)),
|
770
800
|
},
|
771
|
-
})
|
772
|
-
|
801
|
+
});
|
802
|
+
return this.util.guildApplicationCommandPermissionsFromRaw(response);
|
773
803
|
}
|
774
804
|
/** 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), {
|
805
|
+
async editChannel(channelId, options, reason) {
|
806
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channel(channelId), {
|
778
807
|
json: {
|
779
808
|
name: options.name,
|
780
809
|
type: options.type,
|
@@ -801,8 +830,8 @@ class Client extends node_events_1.default {
|
|
801
830
|
applied_tags: options.appliedTags,
|
802
831
|
},
|
803
832
|
reason,
|
804
|
-
})
|
805
|
-
|
833
|
+
});
|
834
|
+
return this.util.channelFromRaw(response);
|
806
835
|
}
|
807
836
|
/** https://discord.com/developers/docs/resources/channel#edit-channel-permissions */
|
808
837
|
editChannelPermissions(channelId, overwriteId, options, reason) {
|
@@ -823,27 +852,25 @@ class Client extends node_events_1.default {
|
|
823
852
|
});
|
824
853
|
}
|
825
854
|
/** https://discord.com/developers/docs/resources/user#modify-current-user */
|
826
|
-
editCurrentUser(options) {
|
827
|
-
|
828
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.user(), {
|
855
|
+
async editCurrentUser(options) {
|
856
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.user(), {
|
829
857
|
json: {
|
830
858
|
username: options.username,
|
831
859
|
avatar: options.avatar,
|
832
860
|
banner: options.banner,
|
833
861
|
},
|
834
|
-
})
|
835
|
-
|
862
|
+
});
|
863
|
+
return this.util.userFromRaw(response);
|
836
864
|
}
|
837
865
|
/** 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), {
|
866
|
+
async editCurrentGuildMember(guildId, options, reason) {
|
867
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildMember(guildId), {
|
841
868
|
json: {
|
842
869
|
nick: options.nick,
|
843
870
|
},
|
844
871
|
reason,
|
845
|
-
})
|
846
|
-
|
872
|
+
});
|
873
|
+
return this.util.guildMemberFromRaw(response);
|
847
874
|
}
|
848
875
|
/** https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state */
|
849
876
|
editCurrentUserVoiceState(guildId, options) {
|
@@ -856,9 +883,8 @@ class Client extends node_events_1.default {
|
|
856
883
|
});
|
857
884
|
}
|
858
885
|
/** https://discord.com/developers/docs/resources/application#edit-current-application */
|
859
|
-
editCurrentApplication(options) {
|
860
|
-
|
861
|
-
.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCurrentUser(), {
|
886
|
+
async editCurrentApplication(options) {
|
887
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCurrentUser(), {
|
862
888
|
json: {
|
863
889
|
custom_install_url: options.customInstallUrl,
|
864
890
|
description: options.description,
|
@@ -870,31 +896,19 @@ class Client extends node_events_1.default {
|
|
870
896
|
interactions_endpoint_url: options.interactionsEndpointUrl,
|
871
897
|
tags: options.tags,
|
872
898
|
},
|
873
|
-
})
|
874
|
-
|
899
|
+
});
|
900
|
+
return this.util.applicationFromRaw(response);
|
875
901
|
}
|
876
902
|
/** 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));
|
903
|
+
async editGlobalApplicationCommand(applicationId, commandId, options) {
|
904
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCommand(applicationId, commandId), {
|
905
|
+
json: this.util.partialApplicationCommandToRaw(options),
|
906
|
+
});
|
907
|
+
return this.util.applicationCommandFromRaw(response);
|
893
908
|
}
|
894
909
|
/** 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), {
|
910
|
+
async editGuild(guildId, options, reason) {
|
911
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guild(guildId), {
|
898
912
|
json: {
|
899
913
|
name: options.name,
|
900
914
|
region: options.region,
|
@@ -919,42 +933,30 @@ class Client extends node_events_1.default {
|
|
919
933
|
safety_alerts_channel_id: options.safetyAlertsChannelId,
|
920
934
|
},
|
921
935
|
reason,
|
922
|
-
})
|
923
|
-
|
936
|
+
});
|
937
|
+
return this.util.guildFromRaw(response);
|
924
938
|
}
|
925
939
|
/** 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));
|
940
|
+
async editGuildApplicationCommand(applicationId, guildId, commandId, options) {
|
941
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationGuildCommand(applicationId, guildId, commandId), {
|
942
|
+
json: this.util.partialApplicationCommandToRaw(options),
|
943
|
+
});
|
944
|
+
return this.util.applicationCommandFromRaw(response);
|
941
945
|
}
|
942
946
|
/** 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), {
|
947
|
+
async editGuildEmoji(guildId, emojiId, options, reason) {
|
948
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildEmoji(guildId, emojiId), {
|
946
949
|
json: {
|
947
950
|
name: options.name,
|
948
951
|
roles: options.roles,
|
949
952
|
},
|
950
953
|
reason,
|
951
|
-
})
|
952
|
-
|
954
|
+
});
|
955
|
+
return this.util.emojiFromRaw(response);
|
953
956
|
}
|
954
957
|
/** 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), {
|
958
|
+
async editGuildMember(guildId, userId, options, reason) {
|
959
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildMember(guildId, userId), {
|
958
960
|
json: {
|
959
961
|
nick: options.nick,
|
960
962
|
roles: options.roles,
|
@@ -965,8 +967,8 @@ class Client extends node_events_1.default {
|
|
965
967
|
flags: options.flags,
|
966
968
|
},
|
967
969
|
reason,
|
968
|
-
})
|
969
|
-
|
970
|
+
});
|
971
|
+
return this.util.guildMemberFromRaw(response);
|
970
972
|
}
|
971
973
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-mfa-level */
|
972
974
|
editGuildMFALevel(guildId, options, reason) {
|
@@ -981,15 +983,34 @@ class Client extends node_events_1.default {
|
|
981
983
|
editGuildOnboarding(guildId, options, reason) {
|
982
984
|
this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildOnboarding(guildId), {
|
983
985
|
json: {
|
984
|
-
prompts: options.prompts.map((prompt) =>
|
986
|
+
prompts: options.prompts.map((prompt) => ({
|
987
|
+
id: prompt.id,
|
988
|
+
type: prompt.type,
|
989
|
+
options: prompt.options.map((promptOption) => ({
|
990
|
+
id: promptOption.id,
|
991
|
+
channel_ids: promptOption.channelIds,
|
992
|
+
role_ids: promptOption.roleIds,
|
993
|
+
emoji: promptOption.emoji !== undefined
|
994
|
+
? this.util.emojiToRaw(promptOption.emoji)
|
995
|
+
: undefined,
|
996
|
+
emoji_id: promptOption.emojiId,
|
997
|
+
emoji_name: promptOption.emojiName,
|
998
|
+
emoji_animated: promptOption.emojiAnimated,
|
999
|
+
title: promptOption.title,
|
1000
|
+
description: promptOption.description,
|
1001
|
+
})),
|
1002
|
+
title: prompt.id,
|
1003
|
+
single_select: prompt.id,
|
1004
|
+
required: prompt.id,
|
1005
|
+
in_onboarding: prompt.id,
|
1006
|
+
})),
|
985
1007
|
},
|
986
1008
|
reason,
|
987
1009
|
});
|
988
1010
|
}
|
989
1011
|
/** 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), {
|
1012
|
+
async editGuildRole(guildId, roleId, options, reason) {
|
1013
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildRole(guildId, roleId), {
|
993
1014
|
json: {
|
994
1015
|
name: options?.name,
|
995
1016
|
permissions: options?.permissions,
|
@@ -1000,21 +1021,19 @@ class Client extends node_events_1.default {
|
|
1000
1021
|
mentionable: options?.mentionable,
|
1001
1022
|
},
|
1002
1023
|
reason,
|
1003
|
-
})
|
1004
|
-
|
1024
|
+
});
|
1025
|
+
return this.util.roleFromRaw(response);
|
1005
1026
|
}
|
1006
1027
|
/** 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)));
|
1028
|
+
async editGuildRolePositions(guildId, options) {
|
1029
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildRoles(guildId), {
|
1030
|
+
json: options,
|
1031
|
+
});
|
1032
|
+
return response.map((role) => this.util.roleFromRaw(role));
|
1013
1033
|
}
|
1014
1034
|
/** 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), {
|
1035
|
+
async editGuildScheduledEvent(guildId, guildScheduledEventId, options, reason) {
|
1036
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildScheduledEvent(guildId, guildScheduledEventId), {
|
1018
1037
|
json: {
|
1019
1038
|
channel_id: options.channelId,
|
1020
1039
|
entity_metadata: options.entityMetadata,
|
@@ -1028,159 +1047,171 @@ class Client extends node_events_1.default {
|
|
1028
1047
|
image: options.image,
|
1029
1048
|
},
|
1030
1049
|
reason,
|
1031
|
-
})
|
1032
|
-
|
1050
|
+
});
|
1051
|
+
return this.util.guildScheduledEventFromRaw(response);
|
1033
1052
|
}
|
1034
1053
|
/** 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), {
|
1054
|
+
async editGuildSticker(guildId, stickerId, options, reason) {
|
1055
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildSticker(guildId, stickerId), {
|
1038
1056
|
json: {
|
1039
1057
|
name: options.name,
|
1040
1058
|
description: options.description,
|
1041
1059
|
tags: options.tags,
|
1042
1060
|
},
|
1043
1061
|
reason,
|
1044
|
-
})
|
1045
|
-
|
1062
|
+
});
|
1063
|
+
return this.util.stickerFromRaw(response);
|
1046
1064
|
}
|
1047
1065
|
/** 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), {
|
1066
|
+
async editGuildTemplate(guildId, code, options) {
|
1067
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildTemplate(guildId, code), {
|
1051
1068
|
json: {
|
1052
1069
|
name: options.name,
|
1053
1070
|
description: options.description,
|
1054
1071
|
},
|
1055
|
-
})
|
1056
|
-
|
1072
|
+
});
|
1073
|
+
return this.util.guildTemplateFromRaw(response);
|
1057
1074
|
}
|
1058
1075
|
/** 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), {
|
1076
|
+
async editGuildWelcomeScreen(guildId, options, reason) {
|
1077
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWelcomeScreen(guildId), {
|
1062
1078
|
json: {
|
1063
1079
|
enabled: options.enabled,
|
1064
1080
|
welcome_channels: options.welcomeChannels,
|
1065
1081
|
description: options.description,
|
1066
1082
|
},
|
1067
1083
|
reason,
|
1068
|
-
})
|
1069
|
-
|
1084
|
+
});
|
1085
|
+
return {
|
1086
|
+
description: response.description,
|
1087
|
+
welcomeChannels: response.welcome_channels.map((welcomeScreenChannel) => ({
|
1088
|
+
channelId: welcomeScreenChannel.channel_id,
|
1089
|
+
description: welcomeScreenChannel.description,
|
1090
|
+
emojiId: welcomeScreenChannel.emoji_id,
|
1091
|
+
emojiName: welcomeScreenChannel.emoji_name,
|
1092
|
+
})),
|
1093
|
+
};
|
1070
1094
|
}
|
1071
1095
|
/** 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), {
|
1096
|
+
async editGuildWidget(guildId, options, reason) {
|
1097
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWidgetSettings(guildId), {
|
1075
1098
|
json: {
|
1076
1099
|
enabled: options.enabled,
|
1077
1100
|
channel_id: options.channelId,
|
1078
1101
|
},
|
1079
1102
|
reason,
|
1080
|
-
})
|
1081
|
-
|
1103
|
+
});
|
1104
|
+
return {
|
1105
|
+
enabled: response.enabled,
|
1106
|
+
channelId: response.channel_id,
|
1107
|
+
};
|
1082
1108
|
}
|
1083
1109
|
/** 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), {
|
1110
|
+
async editMessage(channelId, messageId, options) {
|
1111
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channelMessage(channelId, messageId), {
|
1087
1112
|
json: {
|
1088
1113
|
content: options.content,
|
1089
|
-
embeds: options.embeds !==
|
1090
|
-
? options.embeds
|
1091
|
-
|
1092
|
-
: null
|
1093
|
-
: undefined,
|
1114
|
+
embeds: options.embeds !== null
|
1115
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1116
|
+
: null,
|
1094
1117
|
allowed_mentions: options.allowedMentions !== undefined
|
1095
1118
|
? options.allowedMentions !== null
|
1096
|
-
?
|
1119
|
+
? {
|
1120
|
+
parse: options.allowedMentions.parse,
|
1121
|
+
roles: options.allowedMentions.roles,
|
1122
|
+
users: options.allowedMentions.users,
|
1123
|
+
replied_user: options.allowedMentions.repliedUser,
|
1124
|
+
}
|
1097
1125
|
: null
|
1098
1126
|
: undefined,
|
1099
1127
|
components: options.components !== undefined
|
1100
1128
|
? options.components !== null
|
1101
|
-
?
|
1129
|
+
? this.util.messageComponentsToRaw(options.components)
|
1102
1130
|
: null
|
1103
1131
|
: undefined,
|
1104
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1132
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1105
1133
|
flags: options.flags,
|
1106
1134
|
},
|
1107
1135
|
files: options.files,
|
1108
|
-
})
|
1109
|
-
|
1136
|
+
});
|
1137
|
+
return this.util.messageFromRaw(response);
|
1110
1138
|
}
|
1111
1139
|
/** 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), {
|
1140
|
+
async editStageInstance(channelId, options, reason) {
|
1141
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.stageInstance(channelId), {
|
1115
1142
|
json: {
|
1116
1143
|
topic: options.topic,
|
1117
1144
|
privacy_level: options.privacyLevel,
|
1118
1145
|
},
|
1119
1146
|
reason,
|
1120
|
-
})
|
1121
|
-
|
1147
|
+
});
|
1148
|
+
return this.util.stageInstanceFromRaw(response);
|
1122
1149
|
}
|
1123
1150
|
/** 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), {
|
1151
|
+
async editInteractionFollowupMessage(applicationId, interactionToken, messageId, options) {
|
1152
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhookMessage(applicationId, interactionToken, messageId), {
|
1127
1153
|
json: {
|
1128
1154
|
content: options.content,
|
1129
|
-
embeds: options.embeds !==
|
1130
|
-
? options.embeds
|
1131
|
-
|
1132
|
-
: null
|
1133
|
-
: undefined,
|
1155
|
+
embeds: options.embeds !== null
|
1156
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1157
|
+
: null,
|
1134
1158
|
allowed_mentions: options.allowedMentions !== undefined
|
1135
1159
|
? options.allowedMentions !== null
|
1136
|
-
?
|
1160
|
+
? {
|
1161
|
+
parse: options.allowedMentions.parse,
|
1162
|
+
roles: options.allowedMentions.roles,
|
1163
|
+
users: options.allowedMentions.users,
|
1164
|
+
replied_user: options.allowedMentions.repliedUser,
|
1165
|
+
}
|
1137
1166
|
: null
|
1138
1167
|
: undefined,
|
1139
1168
|
components: options.components !== undefined
|
1140
1169
|
? options.components !== null
|
1141
|
-
?
|
1170
|
+
? this.util.messageComponentsToRaw(options.components)
|
1142
1171
|
: null
|
1143
1172
|
: undefined,
|
1144
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1173
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1145
1174
|
flags: options.flags,
|
1146
1175
|
},
|
1147
1176
|
files: options.files,
|
1148
1177
|
query: {
|
1149
1178
|
thread_id: options.threadId,
|
1150
1179
|
},
|
1151
|
-
})
|
1152
|
-
|
1180
|
+
});
|
1181
|
+
return this.util.messageFromRaw(response);
|
1153
1182
|
}
|
1154
1183
|
/** 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), {
|
1184
|
+
async editInteractionResponse(applicationId, interactionToken, options) {
|
1185
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhookMessage(applicationId, interactionToken), {
|
1158
1186
|
json: {
|
1159
1187
|
content: options.content,
|
1160
|
-
embeds: options.embeds !==
|
1161
|
-
? options.embeds
|
1162
|
-
|
1163
|
-
: null
|
1164
|
-
: undefined,
|
1188
|
+
embeds: options.embeds !== null
|
1189
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1190
|
+
: null,
|
1165
1191
|
allowed_mentions: options.allowedMentions !== undefined
|
1166
1192
|
? options.allowedMentions !== null
|
1167
|
-
?
|
1193
|
+
? {
|
1194
|
+
parse: options.allowedMentions.parse,
|
1195
|
+
roles: options.allowedMentions.roles,
|
1196
|
+
users: options.allowedMentions.users,
|
1197
|
+
replied_user: options.allowedMentions.repliedUser,
|
1198
|
+
}
|
1168
1199
|
: null
|
1169
1200
|
: undefined,
|
1170
1201
|
components: options.components !== undefined
|
1171
1202
|
? options.components !== null
|
1172
|
-
?
|
1203
|
+
? this.util.messageComponentsToRaw(options.components)
|
1173
1204
|
: null
|
1174
1205
|
: undefined,
|
1175
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1206
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1176
1207
|
flags: options.flags,
|
1177
1208
|
},
|
1178
1209
|
files: options.files,
|
1179
1210
|
query: {
|
1180
1211
|
thread_id: options.threadId,
|
1181
1212
|
},
|
1182
|
-
})
|
1183
|
-
|
1213
|
+
});
|
1214
|
+
return this.util.messageFromRaw(response);
|
1184
1215
|
}
|
1185
1216
|
/** https://discord.com/developers/docs/resources/guild#modify-user-voice-state */
|
1186
1217
|
editUserVoiceState(guildId, userId, options) {
|
@@ -1193,98 +1224,108 @@ class Client extends node_events_1.default {
|
|
1193
1224
|
});
|
1194
1225
|
}
|
1195
1226
|
/** 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), {
|
1227
|
+
async editWebhook(webhookId, options, reason) {
|
1228
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhook(webhookId), {
|
1199
1229
|
json: {
|
1200
1230
|
name: options.name,
|
1201
1231
|
avatar: options.avatar,
|
1202
1232
|
channel_id: options.channelId,
|
1203
1233
|
},
|
1204
1234
|
reason,
|
1205
|
-
})
|
1206
|
-
|
1235
|
+
});
|
1236
|
+
return this.util.webhookFromRaw(response);
|
1207
1237
|
}
|
1208
1238
|
/** 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), {
|
1239
|
+
async editWebhookMessage(webhookId, webhookToken, messageId, options) {
|
1240
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhookMessage(webhookId, webhookToken, messageId), {
|
1212
1241
|
json: {
|
1213
1242
|
content: options.content,
|
1214
|
-
embeds: options.embeds !==
|
1215
|
-
? options.embeds
|
1216
|
-
|
1217
|
-
: null
|
1218
|
-
: undefined,
|
1243
|
+
embeds: options.embeds !== null
|
1244
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1245
|
+
: null,
|
1219
1246
|
allowed_mentions: options.allowedMentions !== undefined
|
1220
1247
|
? options.allowedMentions !== null
|
1221
|
-
?
|
1248
|
+
? {
|
1249
|
+
parse: options.allowedMentions.parse,
|
1250
|
+
roles: options.allowedMentions.roles,
|
1251
|
+
users: options.allowedMentions.users,
|
1252
|
+
replied_user: options.allowedMentions.repliedUser,
|
1253
|
+
}
|
1222
1254
|
: null
|
1223
1255
|
: undefined,
|
1224
1256
|
components: options.components !== undefined
|
1225
1257
|
? options.components !== null
|
1226
|
-
?
|
1258
|
+
? this.util.messageComponentsToRaw(options.components)
|
1227
1259
|
: null
|
1228
1260
|
: undefined,
|
1229
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1261
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1230
1262
|
flags: options.flags,
|
1231
1263
|
},
|
1232
1264
|
files: options.files,
|
1233
1265
|
query: {
|
1234
1266
|
thread_id: options.threadId,
|
1235
1267
|
},
|
1236
|
-
})
|
1237
|
-
|
1268
|
+
});
|
1269
|
+
return this.util.messageFromRaw(response);
|
1238
1270
|
}
|
1239
1271
|
/** 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), {
|
1272
|
+
async editWebhookWithToken(webhookId, webhookToken, options, reason) {
|
1273
|
+
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.webhook(webhookId, webhookToken), {
|
1243
1274
|
json: {
|
1244
1275
|
name: options.name,
|
1245
1276
|
avatar: options.avatar,
|
1246
1277
|
},
|
1247
1278
|
reason,
|
1248
1279
|
authorization: false,
|
1249
|
-
})
|
1250
|
-
|
1280
|
+
});
|
1281
|
+
return this.util.webhookFromRaw(response);
|
1251
1282
|
}
|
1252
1283
|
/** https://discord.com/developers/docs/resources/poll#end-poll */
|
1253
|
-
endPoll(channelId, messageId) {
|
1254
|
-
|
1255
|
-
|
1256
|
-
.then((response) => this.util.toCamelCase(response));
|
1284
|
+
async endPoll(channelId, messageId) {
|
1285
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.pollExpire(channelId, messageId));
|
1286
|
+
return this.util.messageFromRaw(response);
|
1257
1287
|
}
|
1258
1288
|
/** 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), {
|
1289
|
+
async executeWebhook(webhookId, webhookToken, options) {
|
1290
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhook(webhookId, webhookToken), {
|
1262
1291
|
json: {
|
1263
1292
|
content: options.content,
|
1264
1293
|
username: options.username,
|
1265
1294
|
avatarUrl: options.avatarUrl,
|
1266
1295
|
tts: options.tts,
|
1267
|
-
embeds: options.embeds !==
|
1268
|
-
? options.embeds
|
1269
|
-
|
1270
|
-
: null
|
1271
|
-
: undefined,
|
1296
|
+
embeds: options.embeds !== null
|
1297
|
+
? options.embeds?.map((embed) => this.util.embedToRaw(embed))
|
1298
|
+
: null,
|
1272
1299
|
allowed_mentions: options.allowedMentions !== undefined
|
1273
1300
|
? options.allowedMentions !== null
|
1274
|
-
?
|
1301
|
+
? {
|
1302
|
+
parse: options.allowedMentions.parse,
|
1303
|
+
roles: options.allowedMentions.roles,
|
1304
|
+
users: options.allowedMentions.users,
|
1305
|
+
replied_user: options.allowedMentions.repliedUser,
|
1306
|
+
}
|
1275
1307
|
: null
|
1276
1308
|
: undefined,
|
1277
1309
|
components: options.components !== undefined
|
1278
1310
|
? options.components !== null
|
1279
|
-
?
|
1311
|
+
? this.util.messageComponentsToRaw(options.components)
|
1280
1312
|
: null
|
1281
1313
|
: undefined,
|
1282
|
-
attachments: options.attachments?.map((attachment) => this.util.
|
1314
|
+
attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
|
1283
1315
|
flags: options.flags,
|
1284
1316
|
thread_name: options.threadName,
|
1285
1317
|
applied_tags: options.appliedTags,
|
1286
1318
|
poll: options.poll !== undefined
|
1287
|
-
?
|
1319
|
+
? {
|
1320
|
+
question: options.poll.question,
|
1321
|
+
answers: options.poll.answers.map((answer) => ({
|
1322
|
+
answer_id: answer.answerId,
|
1323
|
+
poll_media: answer.pollMedia,
|
1324
|
+
})),
|
1325
|
+
duration: options.poll.duration,
|
1326
|
+
allow_multiselect: options.poll.allowMultiselect,
|
1327
|
+
layout_type: options.poll.layoutType,
|
1328
|
+
}
|
1288
1329
|
: undefined,
|
1289
1330
|
},
|
1290
1331
|
files: options.files,
|
@@ -1292,57 +1333,62 @@ class Client extends node_events_1.default {
|
|
1292
1333
|
wait: options.wait,
|
1293
1334
|
thread_id: options.threadId,
|
1294
1335
|
},
|
1295
|
-
})
|
1296
|
-
|
1336
|
+
});
|
1337
|
+
return response !== null ? this.util.messageFromRaw(response) : response;
|
1297
1338
|
}
|
1298
1339
|
/**
|
1299
1340
|
* https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook
|
1300
1341
|
*
|
1301
1342
|
* https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook
|
1302
1343
|
*/
|
1303
|
-
executeWebhookPlatform(webhookId, webhookToken, platform, options) {
|
1304
|
-
|
1305
|
-
.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhookPlatform(webhookId, webhookToken, platform), {
|
1344
|
+
async executeWebhookPlatform(webhookId, webhookToken, platform, options) {
|
1345
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.webhookPlatform(webhookId, webhookToken, platform), {
|
1306
1346
|
query: {
|
1307
1347
|
thread_id: options.threadId,
|
1308
1348
|
wait: options.wait,
|
1309
1349
|
},
|
1310
1350
|
json: options,
|
1311
|
-
})
|
1312
|
-
|
1351
|
+
});
|
1352
|
+
return response !== null ? this.util.messageFromRaw(response) : null;
|
1313
1353
|
}
|
1314
1354
|
/** 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), {
|
1355
|
+
async followChannel(channelId, options, reason) {
|
1356
|
+
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelFollowers(channelId), {
|
1318
1357
|
json: {
|
1319
1358
|
webhook_channel_id: options.webhookChannelId,
|
1320
1359
|
},
|
1321
1360
|
reason,
|
1322
|
-
})
|
1323
|
-
|
1361
|
+
});
|
1362
|
+
return {
|
1363
|
+
channelId: response.channel_id,
|
1364
|
+
webhookId: response.webhook_id,
|
1365
|
+
};
|
1324
1366
|
}
|
1325
1367
|
/** https://discord.com/developers/docs/resources/guild#list-active-guild-threads */
|
1326
|
-
getActiveGuildThreads(guildId) {
|
1327
|
-
|
1328
|
-
|
1329
|
-
.
|
1368
|
+
async getActiveGuildThreads(guildId) {
|
1369
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildActiveThreads(guildId));
|
1370
|
+
return {
|
1371
|
+
threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
|
1372
|
+
members: response.members.map((threadMember) => this.util.threadMemberFromRaw(threadMember)),
|
1373
|
+
};
|
1330
1374
|
}
|
1331
1375
|
/** 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), {
|
1376
|
+
async getArchivedThreads(channelId, archivedStatus, options) {
|
1377
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelThreads(channelId, archivedStatus, false), {
|
1335
1378
|
query: {
|
1336
1379
|
before: options?.before,
|
1337
1380
|
limit: options?.limit,
|
1338
1381
|
},
|
1339
|
-
})
|
1340
|
-
|
1382
|
+
});
|
1383
|
+
return {
|
1384
|
+
threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
|
1385
|
+
members: response.members.map((threadMember) => this.util.threadMemberFromRaw(threadMember)),
|
1386
|
+
hasMore: response.has_more,
|
1387
|
+
};
|
1341
1388
|
}
|
1342
1389
|
/** 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), {
|
1390
|
+
async getAuditLog(guildId, options) {
|
1391
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildAuditLog(guildId), {
|
1346
1392
|
query: {
|
1347
1393
|
user_id: options?.userId,
|
1348
1394
|
action_type: options?.actionType,
|
@@ -1350,85 +1396,101 @@ class Client extends node_events_1.default {
|
|
1350
1396
|
after: options?.after,
|
1351
1397
|
limit: options?.limit,
|
1352
1398
|
},
|
1353
|
-
})
|
1354
|
-
|
1399
|
+
});
|
1400
|
+
return this.util.auditLogFromRaw(response);
|
1355
1401
|
}
|
1356
1402
|
/** 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));
|
1403
|
+
async getAutoModerationRule(guildId, ruleId) {
|
1404
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildAutoModerationRule(guildId, ruleId));
|
1405
|
+
return this.util.autoModerationRuleFromRaw(response);
|
1361
1406
|
}
|
1362
1407
|
/** 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)));
|
1408
|
+
async getAutoModerationRules(guildId) {
|
1409
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildAutoModerationRules(guildId));
|
1410
|
+
return response.map((autoModerationRule) => this.util.autoModerationRuleFromRaw(autoModerationRule));
|
1367
1411
|
}
|
1368
1412
|
/** https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */
|
1369
|
-
getApplicationCommandPermissions(applicationId, guildId, commandId) {
|
1370
|
-
|
1371
|
-
|
1372
|
-
.then((response) => this.util.toCamelCase(response));
|
1413
|
+
async getApplicationCommandPermissions(applicationId, guildId, commandId) {
|
1414
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommandPermissions(applicationId, guildId, commandId));
|
1415
|
+
return this.util.guildApplicationCommandPermissionsFromRaw(response);
|
1373
1416
|
}
|
1374
1417
|
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records */
|
1375
|
-
getApplicationRoleConnectionMetadataRecords(applicationId) {
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1418
|
+
async getApplicationRoleConnectionMetadataRecords(applicationId) {
|
1419
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationRoleConnectionMetadata(applicationId));
|
1420
|
+
return response.map((applicationRoleConnectionMetadata) => ({
|
1421
|
+
type: applicationRoleConnectionMetadata.type,
|
1422
|
+
key: applicationRoleConnectionMetadata.key,
|
1423
|
+
name: applicationRoleConnectionMetadata.name,
|
1424
|
+
nameLocalizations: applicationRoleConnectionMetadata.name_localizations,
|
1425
|
+
description: applicationRoleConnectionMetadata.description,
|
1426
|
+
descriptionLocalizations: applicationRoleConnectionMetadata.description_localizations,
|
1427
|
+
}));
|
1379
1428
|
}
|
1380
1429
|
/** https://discord.com/developers/docs/resources/channel#get-channel */
|
1381
|
-
getChannel(channelId) {
|
1382
|
-
|
1383
|
-
|
1384
|
-
.then((response) => this.util.toCamelCase(response));
|
1430
|
+
async getChannel(channelId) {
|
1431
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channel(channelId));
|
1432
|
+
return this.util.channelFromRaw(response);
|
1385
1433
|
}
|
1386
1434
|
/** 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)));
|
1435
|
+
async getChannels(guildId) {
|
1436
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildChannels(guildId));
|
1437
|
+
return response.map((channel) => this.util.channelFromRaw(channel));
|
1391
1438
|
}
|
1392
1439
|
/** 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)));
|
1440
|
+
async getChannelInvites(channelId) {
|
1441
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelInvites(channelId));
|
1442
|
+
return response.map((invite) => this.util.inviteFromRaw(invite));
|
1397
1443
|
}
|
1398
1444
|
/** 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)));
|
1445
|
+
async getChannelWebhooks(channelId) {
|
1446
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelWebhooks(channelId));
|
1447
|
+
return response.map((webhook) => this.util.webhookFromRaw(webhook));
|
1403
1448
|
}
|
1404
1449
|
/** https://discord.com/developers/docs/resources/application#get-current-application */
|
1405
|
-
getCurrentApplication() {
|
1406
|
-
|
1407
|
-
|
1408
|
-
.then((response) => this.util.toCamelCase(response));
|
1450
|
+
async getCurrentApplication() {
|
1451
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCurrentUser());
|
1452
|
+
return this.util.applicationFromRaw(response);
|
1409
1453
|
}
|
1410
1454
|
/** https://discord.com/developers/docs/resources/user#get-current-user-application-role-connection */
|
1411
|
-
getCurrentApplicationRoleConnection(applicationId) {
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1455
|
+
async getCurrentApplicationRoleConnection(applicationId) {
|
1456
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.userApplicationRoleConnection(applicationId));
|
1457
|
+
return {
|
1458
|
+
platformName: response.platform_name,
|
1459
|
+
platformUsername: response.platform_username,
|
1460
|
+
metadata: {
|
1461
|
+
type: response.metadata.type,
|
1462
|
+
key: response.metadata.key,
|
1463
|
+
name: response.metadata.name,
|
1464
|
+
nameLocalizations: response.metadata.name_localizations,
|
1465
|
+
description: response.metadata.description,
|
1466
|
+
descriptionLocalizations: response.metadata.description_localizations,
|
1467
|
+
},
|
1468
|
+
};
|
1415
1469
|
}
|
1416
1470
|
/** https://discord.com/developers/docs/resources/user#get-current-user-guild-member */
|
1417
|
-
getCurrentGuildMember(guildId) {
|
1418
|
-
|
1419
|
-
|
1420
|
-
.then((response) => this.util.toCamelCase(response));
|
1471
|
+
async getCurrentGuildMember(guildId) {
|
1472
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMember(guildId));
|
1473
|
+
return this.util.guildMemberFromRaw(response);
|
1421
1474
|
}
|
1422
1475
|
/** https://discord.com/developers/docs/resources/user#get-current-user-connections */
|
1423
|
-
getCurrentUserConnections() {
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1476
|
+
async getCurrentUserConnections() {
|
1477
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.userConnections());
|
1478
|
+
return response.map((connection) => ({
|
1479
|
+
id: connection.id,
|
1480
|
+
name: connection.name,
|
1481
|
+
type: connection.type,
|
1482
|
+
revoked: connection.revoked,
|
1483
|
+
integrations: connection.integrations?.map((integration) => this.util.integrationFromRaw(integration)),
|
1484
|
+
verified: connection.verified,
|
1485
|
+
friendSync: connection.friend_sync,
|
1486
|
+
showActivity: connection.show_activity,
|
1487
|
+
twoWayLink: connection.two_way_link,
|
1488
|
+
visibility: connection.visibility,
|
1489
|
+
}));
|
1427
1490
|
}
|
1428
1491
|
/** 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), {
|
1492
|
+
async getEntitlements(applicationId, options) {
|
1493
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationEntitlements(applicationId), {
|
1432
1494
|
query: {
|
1433
1495
|
user_id: options?.userId,
|
1434
1496
|
sku_ids: options?.skuIds,
|
@@ -1438,231 +1500,281 @@ class Client extends node_events_1.default {
|
|
1438
1500
|
guild_id: options?.guildId,
|
1439
1501
|
exclude_ended: options?.excludeEnded,
|
1440
1502
|
},
|
1441
|
-
})
|
1442
|
-
|
1503
|
+
});
|
1504
|
+
return response.map((entitlement) => this.util.entitlementFromRaw(entitlement));
|
1443
1505
|
}
|
1444
1506
|
/** https://discord.com/developers/docs/topics/gateway#get-gateway */
|
1445
1507
|
getGateway() {
|
1446
1508
|
return this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.gateway());
|
1447
1509
|
}
|
1448
1510
|
/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */
|
1449
|
-
getGatewayBot() {
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1511
|
+
async getGatewayBot() {
|
1512
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.gatewayBot());
|
1513
|
+
return {
|
1514
|
+
url: response.url,
|
1515
|
+
shards: response.shards,
|
1516
|
+
sessionStartLimit: {
|
1517
|
+
total: response.session_start_limit.total,
|
1518
|
+
remaining: response.session_start_limit.remaining,
|
1519
|
+
resetAfter: response.session_start_limit.reset_after,
|
1520
|
+
maxConcurrency: response.session_start_limit.max_concurrency,
|
1521
|
+
},
|
1522
|
+
};
|
1453
1523
|
}
|
1454
1524
|
/** 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));
|
1525
|
+
async getGlobalApplicationCommand(applicationId, commandId) {
|
1526
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommand(applicationId, commandId));
|
1527
|
+
return this.util.applicationCommandFromRaw(response);
|
1459
1528
|
}
|
1460
1529
|
/** 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), {
|
1530
|
+
async getGlobalApplicationCommands(applicationId, options) {
|
1531
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommands(applicationId), {
|
1464
1532
|
query: {
|
1465
1533
|
with_localizations: options.withLocalizations,
|
1466
1534
|
},
|
1467
|
-
})
|
1468
|
-
|
1535
|
+
});
|
1536
|
+
return response.map((applicationCommand) => this.util.applicationCommandFromRaw(applicationCommand));
|
1469
1537
|
}
|
1470
1538
|
/** 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), {
|
1539
|
+
async getGuild(guildId, options) {
|
1540
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guild(guildId), {
|
1474
1541
|
query: {
|
1475
1542
|
with_counts: options?.withCounts,
|
1476
1543
|
},
|
1477
|
-
})
|
1478
|
-
|
1544
|
+
});
|
1545
|
+
return this.util.guildFromRaw(response);
|
1479
1546
|
}
|
1480
1547
|
/** 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(), {
|
1548
|
+
async getGuilds(options) {
|
1549
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.userGuilds(), {
|
1484
1550
|
query: {
|
1485
1551
|
before: options?.before,
|
1486
1552
|
after: options?.after,
|
1487
1553
|
limit: options?.limit,
|
1488
1554
|
with_counts: options?.withCounts,
|
1489
1555
|
},
|
1490
|
-
})
|
1491
|
-
|
1556
|
+
});
|
1557
|
+
return response.map((guild) => this.util.guildFromRaw(guild));
|
1492
1558
|
}
|
1493
1559
|
/** 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));
|
1560
|
+
async getGuildApplicationCommand(applicationId, guildId, commandId) {
|
1561
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationGuildCommand(applicationId, guildId, commandId));
|
1562
|
+
return this.util.applicationCommandFromRaw(response);
|
1498
1563
|
}
|
1499
1564
|
/** 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), {
|
1565
|
+
async getGuildApplicationCommands(applicationId, guildId, options) {
|
1566
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationGuildCommands(applicationId, guildId), {
|
1503
1567
|
query: {
|
1504
1568
|
with_localizations: options?.withLocalizations,
|
1505
1569
|
},
|
1506
|
-
})
|
1507
|
-
|
1570
|
+
});
|
1571
|
+
return response.map((applicationCommand) => this.util.applicationCommandFromRaw(applicationCommand));
|
1508
1572
|
}
|
1509
1573
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
|
1510
|
-
getGuildApplicationCommandPermissions(applicationId, guildId) {
|
1511
|
-
|
1512
|
-
|
1513
|
-
.then((response) => this.util.toCamelCase(response));
|
1574
|
+
async getGuildApplicationCommandPermissions(applicationId, guildId) {
|
1575
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildApplicationCommandsPermissions(applicationId, guildId));
|
1576
|
+
return this.util.guildApplicationCommandPermissionsFromRaw(response);
|
1514
1577
|
}
|
1515
1578
|
/** https://discord.com/developers/docs/resources/guild#get-guild-ban */
|
1516
|
-
getGuildBan(guildId, userId) {
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1579
|
+
async getGuildBan(guildId, userId) {
|
1580
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildBan(guildId, userId));
|
1581
|
+
return {
|
1582
|
+
reason: response.reason,
|
1583
|
+
user: this.util.userFromRaw(response.user),
|
1584
|
+
};
|
1520
1585
|
}
|
1521
1586
|
/** 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), {
|
1587
|
+
async getGuildBans(guildId, options) {
|
1588
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildBans(guildId), {
|
1525
1589
|
query: {
|
1526
1590
|
limit: options?.limit,
|
1527
1591
|
before: options?.before,
|
1528
1592
|
after: options?.after,
|
1529
1593
|
},
|
1530
|
-
})
|
1531
|
-
|
1594
|
+
});
|
1595
|
+
return response.map((ban) => ({
|
1596
|
+
reason: ban.reason,
|
1597
|
+
user: this.util.userFromRaw(ban.user),
|
1598
|
+
}));
|
1532
1599
|
}
|
1533
1600
|
/** https://discord.com/developers/docs/resources/emoji#get-guild-emoji */
|
1534
|
-
getGuildEmoji(guildId, emojiId) {
|
1535
|
-
|
1536
|
-
|
1537
|
-
.then((response) => this.util.toCamelCase(response));
|
1601
|
+
async getGuildEmoji(guildId, emojiId) {
|
1602
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildEmoji(guildId, emojiId));
|
1603
|
+
return this.util.emojiFromRaw(response);
|
1538
1604
|
}
|
1539
1605
|
/** 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)));
|
1606
|
+
async getGuildEmojis(guildId) {
|
1607
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildEmojis(guildId));
|
1608
|
+
return response.map((emoji) => this.util.emojiFromRaw(emoji));
|
1544
1609
|
}
|
1545
1610
|
/** 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)));
|
1611
|
+
async getGuildIntegrations(guildId) {
|
1612
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildIntegrations(guildId));
|
1613
|
+
return response.map((integration) => this.util.integrationFromRaw(integration));
|
1550
1614
|
}
|
1551
1615
|
/** 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)));
|
1616
|
+
async getGuildInvites(guildId) {
|
1617
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildInvites(guildId));
|
1618
|
+
return response.map((invite) => this.util.inviteFromRaw(invite));
|
1556
1619
|
}
|
1557
1620
|
/** https://discord.com/developers/docs/resources/guild#get-guild-member */
|
1558
|
-
getGuildMember(guildId, userId) {
|
1559
|
-
|
1560
|
-
|
1561
|
-
.then((response) => this.util.toCamelCase(response));
|
1621
|
+
async getGuildMember(guildId, userId) {
|
1622
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMember(guildId, userId));
|
1623
|
+
return this.util.guildMemberFromRaw(response);
|
1562
1624
|
}
|
1563
1625
|
/** 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)));
|
1626
|
+
async getGuildMembers(guildId) {
|
1627
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMembers(guildId));
|
1628
|
+
return response.map((guildMember) => this.util.guildMemberFromRaw(guildMember));
|
1568
1629
|
}
|
1569
1630
|
/** https://discord.com/developers/docs/resources/guild#get-guild-onboarding */
|
1570
|
-
getGuildOnboarding(guildId) {
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1631
|
+
async getGuildOnboarding(guildId) {
|
1632
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildOnboarding(guildId));
|
1633
|
+
return {
|
1634
|
+
guildId: response.guild_id,
|
1635
|
+
prompts: response.prompts.map((prompt) => ({
|
1636
|
+
id: prompt.id,
|
1637
|
+
type: prompt.type,
|
1638
|
+
options: prompt.options.map((promptOption) => ({
|
1639
|
+
id: promptOption.id,
|
1640
|
+
channelIds: promptOption.channel_ids,
|
1641
|
+
roleIds: promptOption.role_ids,
|
1642
|
+
emoji: promptOption.emoji !== undefined
|
1643
|
+
? this.util.emojiFromRaw(promptOption.emoji)
|
1644
|
+
: undefined,
|
1645
|
+
emojiId: promptOption.emoji_id,
|
1646
|
+
emojiName: promptOption.emoji_name,
|
1647
|
+
emojiAnimated: promptOption.emoji_animated,
|
1648
|
+
title: promptOption.title,
|
1649
|
+
description: promptOption.description,
|
1650
|
+
})),
|
1651
|
+
title: prompt.title,
|
1652
|
+
singleSelect: prompt.single_select,
|
1653
|
+
required: prompt.required,
|
1654
|
+
inOnboarding: prompt.in_onboarding,
|
1655
|
+
})),
|
1656
|
+
defaultChannelIds: response.default_channel_ids,
|
1657
|
+
enabled: response.enabled,
|
1658
|
+
mode: response.mode,
|
1659
|
+
};
|
1574
1660
|
}
|
1575
1661
|
/** https://discord.com/developers/docs/resources/guild#get-guild-preview */
|
1576
|
-
getGuildPreview(guildId) {
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1662
|
+
async getGuildPreview(guildId) {
|
1663
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildPreview(guildId));
|
1664
|
+
return {
|
1665
|
+
id: response.id,
|
1666
|
+
name: response.name,
|
1667
|
+
icon: response.icon,
|
1668
|
+
splash: response.splash,
|
1669
|
+
discoverySplash: response.discovery_splash,
|
1670
|
+
emojis: response.emojis.map((emoji) => this.util.emojiFromRaw(emoji)),
|
1671
|
+
features: response.features,
|
1672
|
+
approximateMemberCount: response.approximate_member_count,
|
1673
|
+
approximatePresenceCount: response.approximate_presence_count,
|
1674
|
+
description: response.description,
|
1675
|
+
stickers: response.stickers?.map((sticker) => this.util.stickerFromRaw(sticker)),
|
1676
|
+
};
|
1580
1677
|
}
|
1581
1678
|
/** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */
|
1582
1679
|
getGuildPruneCount(guildId, options) {
|
1583
|
-
return this.rest
|
1584
|
-
.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildPrune(guildId), {
|
1680
|
+
return this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildPrune(guildId), {
|
1585
1681
|
query: {
|
1586
1682
|
days: options.days,
|
1587
1683
|
include_roles: options.includeRoles,
|
1588
1684
|
},
|
1589
|
-
})
|
1590
|
-
.then((response) => this.util.toCamelCase(response));
|
1685
|
+
});
|
1591
1686
|
}
|
1592
1687
|
/** 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)));
|
1688
|
+
async getGuildRoles(guildId) {
|
1689
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildRoles(guildId));
|
1690
|
+
return response.map((role) => this.util.roleFromRaw(role));
|
1597
1691
|
}
|
1598
1692
|
/** 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), {
|
1693
|
+
async getGuildScheduledEvents(guildId, options) {
|
1694
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildScheduledEvents(guildId), {
|
1602
1695
|
query: {
|
1603
1696
|
with_user_count: options?.withUserCount,
|
1604
1697
|
},
|
1605
|
-
})
|
1606
|
-
|
1698
|
+
});
|
1699
|
+
return response.map((guildScheduledEvent) => this.util.guildScheduledEventFromRaw(guildScheduledEvent));
|
1607
1700
|
}
|
1608
1701
|
/** 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), {
|
1702
|
+
async getGuildScheduledEventUsers(guildId, guildScheduledEventId, options) {
|
1703
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildScheduledEvent(guildId, guildScheduledEventId), {
|
1612
1704
|
query: {
|
1613
1705
|
limit: options?.limit,
|
1614
1706
|
with_member: options?.withMember,
|
1615
1707
|
before: options?.before,
|
1616
1708
|
after: options?.after,
|
1617
1709
|
},
|
1618
|
-
})
|
1619
|
-
|
1710
|
+
});
|
1711
|
+
return response.map((guildScheduledEventUser) => ({
|
1712
|
+
guildScheduledEventId: guildScheduledEventUser.guild_scheduled_event_id,
|
1713
|
+
user: this.util.userFromRaw(guildScheduledEventUser.user),
|
1714
|
+
member: guildScheduledEventUser.member !== undefined
|
1715
|
+
? this.util.guildMemberFromRaw(guildScheduledEventUser.member)
|
1716
|
+
: undefined,
|
1717
|
+
}));
|
1620
1718
|
}
|
1621
1719
|
/** https://discord.com/developers/docs/resources/sticker#get-guild-sticker */
|
1622
|
-
getGuildSticker(guildId, stickerId) {
|
1623
|
-
|
1624
|
-
|
1625
|
-
.then((response) => this.util.toCamelCase(response));
|
1720
|
+
async getGuildSticker(guildId, stickerId) {
|
1721
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildSticker(guildId, stickerId));
|
1722
|
+
return this.util.stickerFromRaw(response);
|
1626
1723
|
}
|
1627
1724
|
/** 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)));
|
1725
|
+
async getGuildStickers(guildId) {
|
1726
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildStickers(guildId));
|
1727
|
+
return response.map((sticker) => this.util.stickerFromRaw(sticker));
|
1632
1728
|
}
|
1633
1729
|
/** https://discord.com/developers/docs/resources/guild-template#get-guild-template */
|
1634
|
-
getGuildTemplate(guildId, code) {
|
1635
|
-
|
1636
|
-
|
1637
|
-
.then((response) => this.util.toCamelCase(response));
|
1730
|
+
async getGuildTemplate(guildId, code) {
|
1731
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildTemplate(guildId, code));
|
1732
|
+
return this.util.guildTemplateFromRaw(response);
|
1638
1733
|
}
|
1639
1734
|
/** 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)));
|
1735
|
+
async getGuildTemplates(guildId) {
|
1736
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildTemplates(guildId));
|
1737
|
+
return response.map((guildTemplate) => this.util.guildTemplateFromRaw(guildTemplate));
|
1644
1738
|
}
|
1645
1739
|
/** https://discord.com/developers/docs/resources/guild#get-guild-vanity-url */
|
1646
1740
|
getGuildVanityUrl(guildId) {
|
1647
1741
|
return this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildVanityUrl(guildId));
|
1648
1742
|
}
|
1649
1743
|
/** https://discord.com/developers/docs/resources/guild#get-guild-voice-regions */
|
1650
|
-
getGuildVoiceRegions(guildId) {
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1744
|
+
async getGuildVoiceRegions(guildId) {
|
1745
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildVoiceRegions(guildId));
|
1746
|
+
return response.map((voiceRegion) => ({
|
1747
|
+
id: voiceRegion.id,
|
1748
|
+
name: voiceRegion.name,
|
1749
|
+
optimal: voiceRegion.optimal,
|
1750
|
+
deprecated: voiceRegion.deprecated,
|
1751
|
+
custom: voiceRegion.custom,
|
1752
|
+
}));
|
1654
1753
|
}
|
1655
1754
|
/** https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen */
|
1656
|
-
getGuildWelcomeScreen(guildId) {
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1755
|
+
async getGuildWelcomeScreen(guildId) {
|
1756
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWelcomeScreen(guildId));
|
1757
|
+
return {
|
1758
|
+
description: response.description,
|
1759
|
+
welcomeChannels: response.welcome_channels.map((welcomeScreenChannel) => ({
|
1760
|
+
channelId: welcomeScreenChannel.channel_id,
|
1761
|
+
description: welcomeScreenChannel.description,
|
1762
|
+
emojiId: welcomeScreenChannel.emoji_id,
|
1763
|
+
emojiName: welcomeScreenChannel.emoji_name,
|
1764
|
+
})),
|
1765
|
+
};
|
1660
1766
|
}
|
1661
1767
|
/** https://discord.com/developers/docs/resources/guild#get-guild-widget */
|
1662
|
-
getGuildWidget(guildId) {
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1768
|
+
async getGuildWidget(guildId) {
|
1769
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWidgetJSON(guildId));
|
1770
|
+
return {
|
1771
|
+
id: response.id,
|
1772
|
+
name: response.name,
|
1773
|
+
instantInvite: response.instant_invite,
|
1774
|
+
channels: response.channels.map((channel) => this.util.channelFromRaw(channel)),
|
1775
|
+
members: response.members.map((member) => this.util.userFromRaw(member)),
|
1776
|
+
presenceCount: response.presence_count,
|
1777
|
+
};
|
1666
1778
|
}
|
1667
1779
|
/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image */
|
1668
1780
|
getGuildWidgetImage(guildId, options) {
|
@@ -1673,181 +1785,200 @@ class Client extends node_events_1.default {
|
|
1673
1785
|
});
|
1674
1786
|
}
|
1675
1787
|
/** https://discord.com/developers/docs/resources/guild#get-guild-widget-settings */
|
1676
|
-
getGuildWidgetSettings(guildId) {
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1788
|
+
async getGuildWidgetSettings(guildId) {
|
1789
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWidgetSettings(guildId));
|
1790
|
+
return {
|
1791
|
+
enabled: response.enabled,
|
1792
|
+
channelId: response.channel_id,
|
1793
|
+
};
|
1680
1794
|
}
|
1681
1795
|
/** 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), {
|
1796
|
+
async getInteractionFollowupMessage(applicationId, interactionToken, messageId, options) {
|
1797
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(applicationId, interactionToken, messageId), {
|
1685
1798
|
query: {
|
1686
1799
|
thread_id: options?.threadId,
|
1687
1800
|
},
|
1688
|
-
})
|
1689
|
-
|
1801
|
+
});
|
1802
|
+
return this.util.messageFromRaw(response);
|
1690
1803
|
}
|
1691
1804
|
/** 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), {
|
1805
|
+
async getInteractionResponse(applicationId, interactionToken, options) {
|
1806
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(applicationId, interactionToken), {
|
1695
1807
|
query: {
|
1696
1808
|
thread_id: options?.threadId,
|
1697
1809
|
},
|
1698
|
-
})
|
1699
|
-
|
1810
|
+
});
|
1811
|
+
return this.util.messageFromRaw(response);
|
1700
1812
|
}
|
1701
1813
|
/** 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), {
|
1814
|
+
async getInvite(code, options) {
|
1815
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.invite(code), {
|
1705
1816
|
query: {
|
1706
1817
|
with_counts: options?.withCounts,
|
1707
1818
|
with_expiration: options?.withExpiration,
|
1708
1819
|
guild_scheduled_event_id: options?.guildScheduledEventId,
|
1709
1820
|
},
|
1710
|
-
})
|
1711
|
-
|
1821
|
+
});
|
1822
|
+
return this.util.inviteFromRaw(response);
|
1712
1823
|
}
|
1713
1824
|
/** 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), {
|
1825
|
+
async getJoinedPrivateArchivedThreads(channelId, options) {
|
1826
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelThreads(channelId, "private", true), {
|
1717
1827
|
query: {
|
1718
1828
|
before: options?.before,
|
1719
1829
|
limit: options?.limit,
|
1720
1830
|
},
|
1721
|
-
})
|
1722
|
-
|
1831
|
+
});
|
1832
|
+
return {
|
1833
|
+
threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
|
1834
|
+
members: response.members.map((threadMember) => this.util.threadMemberFromRaw(threadMember)),
|
1835
|
+
hasMore: response.has_more,
|
1836
|
+
};
|
1723
1837
|
}
|
1724
1838
|
/** https://discord.com/developers/docs/resources/channel#get-channel-message */
|
1725
|
-
getMessage(channelId, messageId) {
|
1726
|
-
|
1727
|
-
|
1728
|
-
.then((response) => this.util.toCamelCase(response));
|
1839
|
+
async getMessage(channelId, messageId) {
|
1840
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessage(channelId, messageId));
|
1841
|
+
return this.util.messageFromRaw(response);
|
1729
1842
|
}
|
1730
1843
|
/** 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), {
|
1844
|
+
async getMessageReactions(channelId, messageId, emoji, options) {
|
1845
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessageAllReactions(channelId, messageId, emoji), {
|
1734
1846
|
query: {
|
1735
1847
|
type: options?.type,
|
1736
1848
|
after: options?.after,
|
1737
1849
|
limit: options?.limit,
|
1738
1850
|
},
|
1739
|
-
})
|
1740
|
-
|
1851
|
+
});
|
1852
|
+
return response.map((user) => this.util.userFromRaw(user));
|
1741
1853
|
}
|
1742
1854
|
/** 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), {
|
1855
|
+
async getMessages(channelId, options) {
|
1856
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelMessages(channelId), {
|
1746
1857
|
query: {
|
1747
1858
|
around: options.around,
|
1748
1859
|
before: options.before,
|
1749
1860
|
after: options.after,
|
1750
1861
|
limit: options.limit,
|
1751
1862
|
},
|
1752
|
-
})
|
1753
|
-
|
1863
|
+
});
|
1864
|
+
return response.map((message) => this.util.messageFromRaw(message));
|
1754
1865
|
}
|
1755
1866
|
/** https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information */
|
1756
|
-
getOAuth2Application() {
|
1757
|
-
|
1758
|
-
|
1759
|
-
.then((response) => this.util.toCamelCase(response));
|
1867
|
+
async getOAuth2Application() {
|
1868
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.oauth2CurrentApplication());
|
1869
|
+
return this.util.applicationFromRaw(response);
|
1760
1870
|
}
|
1761
1871
|
/** https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information */
|
1762
|
-
getOAuth2Authorization() {
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1872
|
+
async getOAuth2Authorization() {
|
1873
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.oauth2Authorization());
|
1874
|
+
return {
|
1875
|
+
application: this.util.applicationFromRaw(response.application),
|
1876
|
+
scopes: response.scopes,
|
1877
|
+
expires: response.expires,
|
1878
|
+
user: response.user !== undefined
|
1879
|
+
? this.util.userFromRaw(response.user)
|
1880
|
+
: undefined,
|
1881
|
+
};
|
1766
1882
|
}
|
1767
1883
|
/** 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)));
|
1884
|
+
async getPinnedMessages(channelId) {
|
1885
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.channelPins(channelId));
|
1886
|
+
return response.map((message) => this.util.messageFromRaw(message));
|
1772
1887
|
}
|
1773
1888
|
/** 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), {
|
1889
|
+
async getPollAnswerVoters(channelId, messageId, answerId, options) {
|
1890
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.pollAnswerVoters(channelId, messageId, answerId), {
|
1777
1891
|
query: {
|
1778
1892
|
after: options?.after,
|
1779
1893
|
limit: options?.limit,
|
1780
1894
|
},
|
1781
|
-
})
|
1782
|
-
|
1895
|
+
});
|
1896
|
+
return {
|
1897
|
+
users: response.users.map((user) => this.util.userFromRaw(user)),
|
1898
|
+
};
|
1783
1899
|
}
|
1784
1900
|
/** https://discord.com/developers/docs/monetization/skus#list-skus */
|
1785
|
-
getSkus(applicationId) {
|
1786
|
-
|
1787
|
-
|
1788
|
-
.then((response) => response.map((sku) => this.util.toCamelCase(sku)));
|
1901
|
+
async getSkus(applicationId) {
|
1902
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationSkus(applicationId));
|
1903
|
+
return response.map((sku) => this.util.skuFromRaw(sku));
|
1789
1904
|
}
|
1790
1905
|
/** https://discord.com/developers/docs/resources/stage-instance#get-stage-instance */
|
1791
|
-
getStageInstance(channelId) {
|
1792
|
-
|
1793
|
-
|
1794
|
-
.then((response) => this.util.toCamelCase(response));
|
1906
|
+
async getStageInstance(channelId) {
|
1907
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.stageInstance(channelId));
|
1908
|
+
return this.util.stageInstanceFromRaw(response);
|
1795
1909
|
}
|
1796
1910
|
/** https://discord.com/developers/docs/resources/sticker#list-sticker-packs */
|
1797
|
-
getStickerPacks() {
|
1798
|
-
|
1799
|
-
|
1800
|
-
.
|
1911
|
+
async getStickerPacks() {
|
1912
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.stickerPacks());
|
1913
|
+
return {
|
1914
|
+
stickerPacks: response.sticker_packs.map((stickerPack) => ({
|
1915
|
+
id: stickerPack.id,
|
1916
|
+
stickers: stickerPack.stickers.map((sticker) => this.util.stickerFromRaw(sticker)),
|
1917
|
+
name: stickerPack.name,
|
1918
|
+
skuId: stickerPack.sku_id,
|
1919
|
+
coverStickerId: stickerPack.cover_sticker_id,
|
1920
|
+
description: stickerPack.description,
|
1921
|
+
bannerAssetId: stickerPack.banner_asset_id,
|
1922
|
+
})),
|
1923
|
+
};
|
1801
1924
|
}
|
1802
1925
|
/** 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), {
|
1926
|
+
async getThreadMember(channelId, userId, options) {
|
1927
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.threadMembers(channelId, userId), {
|
1806
1928
|
query: {
|
1807
1929
|
with_member: options?.withMember,
|
1808
1930
|
},
|
1809
|
-
})
|
1810
|
-
|
1931
|
+
});
|
1932
|
+
return {
|
1933
|
+
id: response.id,
|
1934
|
+
userId: response.user_id,
|
1935
|
+
joinTimestamp: response.join_timestamp,
|
1936
|
+
flags: response.flags,
|
1937
|
+
member: response.member !== undefined
|
1938
|
+
? this.util.guildMemberFromRaw(response.member)
|
1939
|
+
: undefined,
|
1940
|
+
};
|
1811
1941
|
}
|
1812
1942
|
/** 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), {
|
1943
|
+
async getThreadMembers(channelId, options) {
|
1944
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.threadMembers(channelId), {
|
1816
1945
|
query: {
|
1817
1946
|
with_member: options?.withMember,
|
1818
1947
|
after: options?.after,
|
1819
1948
|
limit: options?.limit,
|
1820
1949
|
},
|
1821
|
-
})
|
1822
|
-
|
1950
|
+
});
|
1951
|
+
return response.map((threadMember) => this.util.threadMemberFromRaw(threadMember));
|
1823
1952
|
}
|
1824
1953
|
/** https://discord.com/developers/docs/resources/user#get-user */
|
1825
|
-
getUser(userId) {
|
1826
|
-
|
1827
|
-
|
1828
|
-
.then((response) => this.util.toCamelCase(response));
|
1954
|
+
async getUser(userId) {
|
1955
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.user(userId));
|
1956
|
+
return this.util.userFromRaw(response);
|
1829
1957
|
}
|
1830
1958
|
/** https://discord.com/developers/docs/resources/voice#list-voice-regions */
|
1831
|
-
getVoiceRegions() {
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1959
|
+
async getVoiceRegions() {
|
1960
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.voiceRegions());
|
1961
|
+
return response.map((voiceRegion) => ({
|
1962
|
+
id: voiceRegion.id,
|
1963
|
+
name: voiceRegion.name,
|
1964
|
+
optimal: voiceRegion.optimal,
|
1965
|
+
deprecated: voiceRegion.deprecated,
|
1966
|
+
custom: voiceRegion.custom,
|
1967
|
+
}));
|
1835
1968
|
}
|
1836
1969
|
/** 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), {
|
1970
|
+
async getWebhookMessage(webhookId, webhookToken, messageId, options) {
|
1971
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.webhookMessage(webhookId, webhookToken, messageId), {
|
1840
1972
|
query: {
|
1841
1973
|
thread_id: options?.threadId,
|
1842
1974
|
},
|
1843
|
-
})
|
1844
|
-
|
1975
|
+
});
|
1976
|
+
return this.util.messageFromRaw(response);
|
1845
1977
|
}
|
1846
1978
|
/** 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)));
|
1979
|
+
async getWebhooks(guildId) {
|
1980
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildWebhooks(guildId));
|
1981
|
+
return response.map((webhook) => this.util.webhookFromRaw(webhook));
|
1851
1982
|
}
|
1852
1983
|
/** https://discord.com/developers/docs/resources/channel#join-thread */
|
1853
1984
|
joinThread(channelId) {
|
@@ -1918,15 +2049,14 @@ class Client extends node_events_1.default {
|
|
1918
2049
|
this.rest.request(rest_1.RESTMethods.Delete, rest_1.Endpoints.threadMembers(channelId, userId));
|
1919
2050
|
}
|
1920
2051
|
/** 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), {
|
2052
|
+
async searchGuildMembers(guildId, options) {
|
2053
|
+
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildMembersSearch(guildId), {
|
1924
2054
|
query: {
|
1925
2055
|
query: options.query,
|
1926
2056
|
limit: options.limit,
|
1927
2057
|
},
|
1928
|
-
})
|
1929
|
-
|
2058
|
+
});
|
2059
|
+
return response.map((guildMember) => this.util.guildMemberFromRaw(guildMember));
|
1930
2060
|
}
|
1931
2061
|
/** https://discord.com/developers/docs/topics/gateway-events#update-presence */
|
1932
2062
|
setPresence(options) {
|
@@ -1934,32 +2064,47 @@ class Client extends node_events_1.default {
|
|
1934
2064
|
shard.setPresence(options);
|
1935
2065
|
}
|
1936
2066
|
/** https://discord.com/developers/docs/resources/guild-template#sync-guild-template */
|
1937
|
-
syncGuildTemplate(guildId, code) {
|
1938
|
-
|
1939
|
-
|
1940
|
-
.then((response) => this.util.toCamelCase(response));
|
2067
|
+
async syncGuildTemplate(guildId, code) {
|
2068
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.guildTemplate(guildId, code));
|
2069
|
+
return this.util.guildTemplateFromRaw(response);
|
1941
2070
|
}
|
1942
2071
|
/** https://discord.com/developers/docs/resources/channel#trigger-typing-indicator */
|
1943
2072
|
triggerTypingIndicator(channelId) {
|
1944
2073
|
this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.channelTyping(channelId));
|
1945
2074
|
}
|
1946
2075
|
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
|
1947
|
-
updateApplicationRoleConnectionMetadataRecords(applicationId) {
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
2076
|
+
async updateApplicationRoleConnectionMetadataRecords(applicationId) {
|
2077
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationRoleConnectionMetadata(applicationId));
|
2078
|
+
return response.map((applicationRoleConnectionMetadata) => ({
|
2079
|
+
type: applicationRoleConnectionMetadata.type,
|
2080
|
+
key: applicationRoleConnectionMetadata.key,
|
2081
|
+
name: applicationRoleConnectionMetadata.name,
|
2082
|
+
nameLocalizations: applicationRoleConnectionMetadata.name_localizations,
|
2083
|
+
description: applicationRoleConnectionMetadata.description,
|
2084
|
+
descriptionLocalizations: applicationRoleConnectionMetadata.description_localizations,
|
2085
|
+
}));
|
1951
2086
|
}
|
1952
2087
|
/** 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), {
|
2088
|
+
async updateCurrentApplicationRoleConnection(options) {
|
2089
|
+
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.userApplicationRoleConnection(this.application.id), {
|
1956
2090
|
json: {
|
1957
2091
|
platform_name: options.platformName,
|
1958
2092
|
platform_username: options.platformUsername,
|
1959
2093
|
metadata: options.metadata,
|
1960
2094
|
},
|
1961
|
-
})
|
1962
|
-
|
2095
|
+
});
|
2096
|
+
return {
|
2097
|
+
platformName: response.platform_name,
|
2098
|
+
platformUsername: response.platform_username,
|
2099
|
+
metadata: {
|
2100
|
+
type: response.metadata.type,
|
2101
|
+
key: response.metadata.key,
|
2102
|
+
name: response.metadata.name,
|
2103
|
+
nameLocalizations: response.metadata.name_localizations,
|
2104
|
+
description: response.metadata.description,
|
2105
|
+
descriptionLocalizations: response.metadata.description_localizations,
|
2106
|
+
},
|
2107
|
+
};
|
1963
2108
|
}
|
1964
2109
|
/** https://discord.com/developers/docs/resources/channel#unpin-message */
|
1965
2110
|
unpinMessage(channelId, messageId, reason) {
|