@discordjs/core 0.4.0-dev.1677456628-ffdb197.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +2 -2
- package/dist/index.d.ts +18 -17
- package/dist/index.js +1354 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1365 -139
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.mjs
CHANGED
|
@@ -3,82 +3,191 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/api/applicationCommands.ts
|
|
5
5
|
import { makeURLSearchParams } from "@discordjs/rest";
|
|
6
|
-
import {
|
|
7
|
-
Routes
|
|
8
|
-
} from "discord-api-types/v10";
|
|
6
|
+
import { Routes } from "discord-api-types/v10";
|
|
9
7
|
var ApplicationCommandsAPI = class {
|
|
10
8
|
constructor(rest) {
|
|
11
9
|
this.rest = rest;
|
|
12
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetches all global commands for a application
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands}
|
|
15
|
+
* @param applicationId - The application id to fetch commands for
|
|
16
|
+
* @param options - The options to use when fetching commands
|
|
17
|
+
*/
|
|
13
18
|
async getGlobalCommands(applicationId, options = {}) {
|
|
14
19
|
return this.rest.get(Routes.applicationCommands(applicationId), {
|
|
15
20
|
query: makeURLSearchParams(options)
|
|
16
21
|
});
|
|
17
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new global command
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#create-global-application-command}
|
|
27
|
+
* @param applicationId - The application id to create the command for
|
|
28
|
+
* @param data - The data to use when creating the command
|
|
29
|
+
*/
|
|
18
30
|
async createGlobalCommand(applicationId, data) {
|
|
19
31
|
return this.rest.post(Routes.applicationCommands(applicationId), {
|
|
20
32
|
body: data
|
|
21
33
|
});
|
|
22
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Fetches a global command
|
|
37
|
+
*
|
|
38
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-global-application-command}
|
|
39
|
+
* @param applicationId - The application id to fetch the command from
|
|
40
|
+
* @param commandId - The command id to fetch
|
|
41
|
+
*/
|
|
23
42
|
async getGlobalCommand(applicationId, commandId) {
|
|
24
|
-
return this.rest.get(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
return this.rest.get(Routes.applicationCommand(applicationId, commandId));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Edits a global command
|
|
47
|
+
*
|
|
48
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command}
|
|
49
|
+
* @param applicationId - The application id of the command
|
|
50
|
+
* @param commandId - The id of the command to edit
|
|
51
|
+
* @param data - The data to use when editing the command
|
|
52
|
+
*/
|
|
28
53
|
async editGlobalCommand(applicationId, commandId, data) {
|
|
29
54
|
return this.rest.patch(Routes.applicationCommand(applicationId, commandId), {
|
|
30
55
|
body: data
|
|
31
56
|
});
|
|
32
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Deletes a global command
|
|
60
|
+
*
|
|
61
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command}
|
|
62
|
+
* @param applicationId - The application id of the command
|
|
63
|
+
* @param commandId - The id of the command to delete
|
|
64
|
+
*/
|
|
33
65
|
async deleteGlobalCommand(applicationId, commandId) {
|
|
34
66
|
await this.rest.delete(Routes.applicationCommand(applicationId, commandId));
|
|
35
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Overwrites global commands
|
|
70
|
+
*
|
|
71
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands}
|
|
72
|
+
* @param applicationId - The application id to overwrite commands for
|
|
73
|
+
* @param data - The data to use when overwriting commands
|
|
74
|
+
*/
|
|
36
75
|
async bulkOverwriteGlobalCommands(applicationId, data) {
|
|
37
76
|
return this.rest.put(Routes.applicationCommands(applicationId), {
|
|
38
77
|
body: data
|
|
39
78
|
});
|
|
40
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Fetches all commands for a guild
|
|
82
|
+
*
|
|
83
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands}
|
|
84
|
+
* @param applicationId - The application id to fetch commands for
|
|
85
|
+
* @param guildId - The guild id to fetch commands for
|
|
86
|
+
* @param data - The data to use when fetching commands
|
|
87
|
+
*/
|
|
41
88
|
async getGuildCommands(applicationId, guildId, data = {}) {
|
|
42
89
|
return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
|
|
43
90
|
query: makeURLSearchParams(data)
|
|
44
91
|
});
|
|
45
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Creates a new command for a guild
|
|
95
|
+
*
|
|
96
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command}
|
|
97
|
+
* @param applicationId - The application id to create the command for
|
|
98
|
+
* @param guildId - The guild id to create the command for
|
|
99
|
+
* @param data - The data to use when creating the command
|
|
100
|
+
*/
|
|
46
101
|
async createGuildCommand(applicationId, guildId, data) {
|
|
47
102
|
return this.rest.post(Routes.applicationGuildCommands(applicationId, guildId), {
|
|
48
103
|
body: data
|
|
49
104
|
});
|
|
50
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Fetches a guild command
|
|
108
|
+
*
|
|
109
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command}
|
|
110
|
+
* @param applicationId - The application id to fetch the command from
|
|
111
|
+
* @param guildId - The guild id to fetch the command from
|
|
112
|
+
* @param commandId - The command id to fetch
|
|
113
|
+
*/
|
|
51
114
|
async getGuildCommand(applicationId, guildId, commandId) {
|
|
52
|
-
return this.rest.get(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
115
|
+
return this.rest.get(Routes.applicationGuildCommand(applicationId, guildId, commandId));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Edits a guild command
|
|
119
|
+
*
|
|
120
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command}
|
|
121
|
+
* @param applicationId - The application id of the command
|
|
122
|
+
* @param guildId - The guild id of the command
|
|
123
|
+
* @param commandId - The command id to edit
|
|
124
|
+
* @param data - The data to use when editing the command
|
|
125
|
+
*/
|
|
56
126
|
async editGuildCommand(applicationId, guildId, commandId, data) {
|
|
57
127
|
return this.rest.patch(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
|
58
128
|
body: data
|
|
59
129
|
});
|
|
60
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Deletes a guild command
|
|
133
|
+
*
|
|
134
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command}
|
|
135
|
+
* @param applicationId - The application id of the command
|
|
136
|
+
* @param guildId - The guild id of the command
|
|
137
|
+
* @param commandId - The id of the command to delete
|
|
138
|
+
*/
|
|
61
139
|
async deleteGuildCommand(applicationId, guildId, commandId) {
|
|
62
140
|
await this.rest.delete(Routes.applicationGuildCommand(applicationId, guildId, commandId));
|
|
63
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Bulk overwrites guild commands
|
|
144
|
+
*
|
|
145
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands}
|
|
146
|
+
* @param applicationId - The application id to overwrite commands for
|
|
147
|
+
* @param guildId - The guild id to overwrite commands for
|
|
148
|
+
* @param data - The data to use when overwriting commands
|
|
149
|
+
*/
|
|
64
150
|
async bulkOverwriteGuildCommands(applicationId, guildId, data) {
|
|
65
151
|
return this.rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
|
|
66
152
|
body: data
|
|
67
153
|
});
|
|
68
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Fetches the permissions for a guild command
|
|
157
|
+
*
|
|
158
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions}
|
|
159
|
+
* @param applicationId - The application id to get the permissions for
|
|
160
|
+
* @param guildId - The guild id of the command
|
|
161
|
+
* @param commandId - The command id to get the permissions for
|
|
162
|
+
*/
|
|
69
163
|
async getGuildCommandPermissions(applicationId, guildId, commandId) {
|
|
70
|
-
return this.rest.get(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
164
|
+
return this.rest.get(Routes.applicationCommandPermissions(applicationId, guildId, commandId));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Fetches all permissions for all commands in a guild
|
|
168
|
+
*
|
|
169
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions}
|
|
170
|
+
* @param applicationId - The application id to get the permissions for
|
|
171
|
+
* @param guildId - The guild id to get the permissions for
|
|
172
|
+
*/
|
|
74
173
|
async getGuildCommandsPermissions(applicationId, guildId) {
|
|
75
|
-
return this.rest.get(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
174
|
+
return this.rest.get(Routes.guildApplicationCommandsPermissions(applicationId, guildId));
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Edits the permissions for a guild command
|
|
178
|
+
*
|
|
179
|
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions}
|
|
180
|
+
* @param userToken - The token of the user to edit permissions on behalf of
|
|
181
|
+
* @param applicationId - The application id to edit the permissions for
|
|
182
|
+
* @param guildId - The guild id to edit the permissions for
|
|
183
|
+
* @param commandId - The id of the command to edit the permissions for
|
|
184
|
+
* @param data - The data to use when editing the permissions
|
|
185
|
+
*/
|
|
79
186
|
async editGuildCommandPermissions(userToken, applicationId, guildId, commandId, data) {
|
|
80
187
|
return this.rest.put(Routes.applicationCommandPermissions(applicationId, guildId, commandId), {
|
|
81
|
-
headers: {
|
|
188
|
+
headers: {
|
|
189
|
+
Authorization: `Bearer ${userToken.replace("Bearer ", "")}`
|
|
190
|
+
},
|
|
82
191
|
auth: false,
|
|
83
192
|
body: data
|
|
84
193
|
});
|
|
@@ -88,109 +197,309 @@ __name(ApplicationCommandsAPI, "ApplicationCommandsAPI");
|
|
|
88
197
|
|
|
89
198
|
// src/api/channel.ts
|
|
90
199
|
import { makeURLSearchParams as makeURLSearchParams2 } from "@discordjs/rest";
|
|
91
|
-
import {
|
|
92
|
-
Routes as Routes2
|
|
93
|
-
} from "discord-api-types/v10";
|
|
200
|
+
import { Routes as Routes2 } from "discord-api-types/v10";
|
|
94
201
|
var ChannelsAPI = class {
|
|
95
202
|
constructor(rest) {
|
|
96
203
|
this.rest = rest;
|
|
97
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Sends a message in a channel
|
|
207
|
+
*
|
|
208
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#create-message}
|
|
209
|
+
* @param channelId - The id of the channel to send the message in
|
|
210
|
+
* @param data - The data to use when sending the message
|
|
211
|
+
*/
|
|
98
212
|
async createMessage(channelId, { files, ...body }) {
|
|
99
213
|
return this.rest.post(Routes2.channelMessages(channelId), {
|
|
100
214
|
files,
|
|
101
215
|
body
|
|
102
216
|
});
|
|
103
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Edits a message
|
|
220
|
+
*
|
|
221
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#edit-message}
|
|
222
|
+
* @param channelId - The id of the channel the message is in
|
|
223
|
+
* @param messageId - The id of the message to edit
|
|
224
|
+
* @param data - The data to use when editing the message
|
|
225
|
+
*/
|
|
104
226
|
async editMessage(channelId, messageId, { files, ...body }) {
|
|
105
227
|
return this.rest.patch(Routes2.channelMessage(channelId, messageId), {
|
|
106
228
|
files,
|
|
107
229
|
body
|
|
108
230
|
});
|
|
109
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Fetches the reactions for a message
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-reactions}
|
|
236
|
+
* @param channelId - The id of the channel the message is in
|
|
237
|
+
* @param messageId - The id of the message to get the reactions for
|
|
238
|
+
* @param emoji - The emoji to get the reactions for
|
|
239
|
+
* @param options - The options to use when fetching the reactions
|
|
240
|
+
*/
|
|
110
241
|
async getMessageReactions(channelId, messageId, emoji, options = {}) {
|
|
111
242
|
return this.rest.get(Routes2.channelMessageReaction(channelId, messageId, encodeURIComponent(emoji)), {
|
|
112
243
|
query: makeURLSearchParams2(options)
|
|
113
244
|
});
|
|
114
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Deletes a reaction for the current user
|
|
248
|
+
*
|
|
249
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#delete-own-reaction}
|
|
250
|
+
* @param channelId - The id of the channel the message is in
|
|
251
|
+
* @param messageId - The id of the message to delete the reaction for
|
|
252
|
+
* @param emoji - The emoji to delete the reaction for
|
|
253
|
+
*/
|
|
115
254
|
async deleteOwnMessageReaction(channelId, messageId, emoji) {
|
|
116
255
|
await this.rest.delete(Routes2.channelMessageOwnReaction(channelId, messageId, encodeURIComponent(emoji)));
|
|
117
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Deletes a reaction for a user
|
|
259
|
+
*
|
|
260
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#delete-user-reaction}
|
|
261
|
+
* @param channelId - The id of the channel the message is in
|
|
262
|
+
* @param messageId - The id of the message to delete the reaction for
|
|
263
|
+
* @param emoji - The emoji to delete the reaction for
|
|
264
|
+
* @param userId - The id of the user to delete the reaction for
|
|
265
|
+
*/
|
|
118
266
|
async deleteUserMessageReaction(channelId, messageId, emoji, userId) {
|
|
119
267
|
await this.rest.delete(Routes2.channelMessageUserReaction(channelId, messageId, encodeURIComponent(emoji), userId));
|
|
120
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Deletes all reactions for a message
|
|
271
|
+
*
|
|
272
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#delete-all-reactions}
|
|
273
|
+
* @param channelId - The id of the channel the message is in
|
|
274
|
+
* @param messageId - The id of the message to delete the reactions for
|
|
275
|
+
*/
|
|
121
276
|
async deleteAllMessageReactions(channelId, messageId) {
|
|
122
277
|
await this.rest.delete(Routes2.channelMessageAllReactions(channelId, messageId));
|
|
123
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Deletes all reactions of an emoji for a message
|
|
281
|
+
*
|
|
282
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji}
|
|
283
|
+
* @param channelId - The id of the channel the message is in
|
|
284
|
+
* @param messageId - The id of the message to delete the reactions for
|
|
285
|
+
* @param emoji - The emoji to delete the reactions for
|
|
286
|
+
*/
|
|
124
287
|
async deleteAllMessageReactionsForEmoji(channelId, messageId, emoji) {
|
|
125
288
|
await this.rest.delete(Routes2.channelMessageReaction(channelId, messageId, encodeURIComponent(emoji)));
|
|
126
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Adds a reaction to a message
|
|
292
|
+
*
|
|
293
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#create-reaction}
|
|
294
|
+
* @param channelId - The id of the channel the message is in
|
|
295
|
+
* @param messageId - The id of the message to add the reaction to
|
|
296
|
+
* @param emoji - The emoji to add the reaction with
|
|
297
|
+
*/
|
|
127
298
|
async addMessageReaction(channelId, messageId, emoji) {
|
|
128
299
|
await this.rest.put(Routes2.channelMessageOwnReaction(channelId, messageId, encodeURIComponent(emoji)));
|
|
129
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Fetches a channel
|
|
303
|
+
*
|
|
304
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel}
|
|
305
|
+
* @param channelId - The id of the channel
|
|
306
|
+
*/
|
|
130
307
|
async get(channelId) {
|
|
131
308
|
return this.rest.get(Routes2.channel(channelId));
|
|
132
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Edits a channel
|
|
312
|
+
*
|
|
313
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#modify-channel}
|
|
314
|
+
* @param channelId - The id of the channel to edit
|
|
315
|
+
* @param data - The new channel data
|
|
316
|
+
*/
|
|
133
317
|
async edit(channelId, data) {
|
|
134
|
-
return this.rest.patch(Routes2.channel(channelId), {
|
|
318
|
+
return this.rest.patch(Routes2.channel(channelId), {
|
|
319
|
+
body: data
|
|
320
|
+
});
|
|
135
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Deletes a channel
|
|
324
|
+
*
|
|
325
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#deleteclose-channel}
|
|
326
|
+
* @param channelId - The id of the channel to delete
|
|
327
|
+
*/
|
|
136
328
|
async delete(channelId) {
|
|
137
329
|
return this.rest.delete(Routes2.channel(channelId));
|
|
138
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Fetches the messages of a channel
|
|
333
|
+
*
|
|
334
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel-messages}
|
|
335
|
+
* @param channelId - The id of the channel to fetch messages from
|
|
336
|
+
* @param options - The options to use when fetching messages
|
|
337
|
+
*/
|
|
139
338
|
async getMessages(channelId, options = {}) {
|
|
140
339
|
return this.rest.get(Routes2.channelMessages(channelId), {
|
|
141
340
|
query: makeURLSearchParams2(options)
|
|
142
341
|
});
|
|
143
342
|
}
|
|
343
|
+
/**
|
|
344
|
+
* Shows a typing indicator in a channel
|
|
345
|
+
*
|
|
346
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#trigger-typing-indicator}
|
|
347
|
+
* @param channelId - The id of the channel to show the typing indicator in
|
|
348
|
+
*/
|
|
144
349
|
async showTyping(channelId) {
|
|
145
350
|
await this.rest.post(Routes2.channelTyping(channelId));
|
|
146
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Fetches the pinned messages of a channel
|
|
354
|
+
*
|
|
355
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-pinned-messages}
|
|
356
|
+
* @param channelId - The id of the channel to fetch pinned messages from
|
|
357
|
+
*/
|
|
147
358
|
async getPins(channelId) {
|
|
148
359
|
return this.rest.get(Routes2.channelPins(channelId));
|
|
149
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Pins a message in a channel
|
|
363
|
+
*
|
|
364
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#pin-message}
|
|
365
|
+
* @param channelId - The id of the channel to pin the message in
|
|
366
|
+
* @param messageId - The id of the message to pin
|
|
367
|
+
* @param reason - The reason for pinning the message
|
|
368
|
+
*/
|
|
150
369
|
async pinMessage(channelId, messageId, reason) {
|
|
151
|
-
await this.rest.put(Routes2.channelPin(channelId, messageId), {
|
|
370
|
+
await this.rest.put(Routes2.channelPin(channelId, messageId), {
|
|
371
|
+
reason
|
|
372
|
+
});
|
|
152
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Deletes a message
|
|
376
|
+
*
|
|
377
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#delete-message}
|
|
378
|
+
* @param channelId - The id of the channel the message is in
|
|
379
|
+
* @param messageId - The id of the message to delete
|
|
380
|
+
* @param reason - The reason for deleting the message
|
|
381
|
+
*/
|
|
153
382
|
async deleteMessage(channelId, messageId, reason) {
|
|
154
|
-
await this.rest.delete(Routes2.channelMessage(channelId, messageId), {
|
|
383
|
+
await this.rest.delete(Routes2.channelMessage(channelId, messageId), {
|
|
384
|
+
reason
|
|
385
|
+
});
|
|
155
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Bulk deletes messages
|
|
389
|
+
*
|
|
390
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#bulk-delete-messages}
|
|
391
|
+
* @param channelId - The id of the channel the messages are in
|
|
392
|
+
* @param messageIds - The ids of the messages to delete
|
|
393
|
+
*/
|
|
156
394
|
async bulkDeleteMessages(channelId, messageIds, reason) {
|
|
157
|
-
await this.rest.post(Routes2.channelBulkDelete(channelId), {
|
|
395
|
+
await this.rest.post(Routes2.channelBulkDelete(channelId), {
|
|
396
|
+
reason,
|
|
397
|
+
body: {
|
|
398
|
+
messages: messageIds
|
|
399
|
+
}
|
|
400
|
+
});
|
|
158
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Fetches a message
|
|
404
|
+
*
|
|
405
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel-message}
|
|
406
|
+
* @param channelId - The id of the channel the message is in
|
|
407
|
+
* @param messageId - The id of the message to fetch
|
|
408
|
+
*/
|
|
159
409
|
async getMessage(channelId, messageId) {
|
|
160
410
|
return this.rest.get(Routes2.channelMessage(channelId, messageId));
|
|
161
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* Crossposts a message
|
|
414
|
+
*
|
|
415
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#crosspost-message}
|
|
416
|
+
* @param channelId - The id of the channel the message is in
|
|
417
|
+
* @param messageId - The id of the message to crosspost
|
|
418
|
+
*/
|
|
162
419
|
async crosspostMessage(channelId, messageId) {
|
|
163
|
-
return this.rest.post(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
420
|
+
return this.rest.post(Routes2.channelMessageCrosspost(channelId, messageId));
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Unpins a message in a channel
|
|
424
|
+
*
|
|
425
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#unpin-message}
|
|
426
|
+
* @param channelId - The id of the channel to unpin the message in
|
|
427
|
+
* @param messageId - The id of the message to unpin
|
|
428
|
+
* @param reason - The reason for unpinning the message
|
|
429
|
+
*/
|
|
167
430
|
async unpinMessage(channelId, messageId, reason) {
|
|
168
|
-
await this.rest.delete(Routes2.channelPin(channelId, messageId), {
|
|
431
|
+
await this.rest.delete(Routes2.channelPin(channelId, messageId), {
|
|
432
|
+
reason
|
|
433
|
+
});
|
|
169
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* Follows an announcement channel
|
|
437
|
+
*
|
|
438
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#follow-announcement-channel}
|
|
439
|
+
* @param channelId - The id of the announcement channel to follow
|
|
440
|
+
* @param webhookChannelId - The id of the webhook channel to follow the announcements in
|
|
441
|
+
*/
|
|
170
442
|
async followAnnouncements(channelId, webhookChannelId) {
|
|
171
443
|
return this.rest.post(Routes2.channelFollowers(channelId), {
|
|
172
|
-
body: {
|
|
444
|
+
body: {
|
|
445
|
+
webhook_channel_id: webhookChannelId
|
|
446
|
+
}
|
|
173
447
|
});
|
|
174
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Creates a new invite for a channel
|
|
451
|
+
*
|
|
452
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#create-channel-invite}
|
|
453
|
+
* @param channelId - The id of the channel to create an invite for
|
|
454
|
+
* @param data - The data to use when creating the invite
|
|
455
|
+
*/
|
|
175
456
|
async createInvite(channelId, data, reason) {
|
|
176
457
|
return this.rest.post(Routes2.channelInvites(channelId), {
|
|
177
458
|
reason,
|
|
178
459
|
body: data
|
|
179
460
|
});
|
|
180
461
|
}
|
|
462
|
+
/**
|
|
463
|
+
* Fetches the invites of a channel
|
|
464
|
+
*
|
|
465
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel-invites}
|
|
466
|
+
* @param channelId - The id of the channel to fetch invites from
|
|
467
|
+
*/
|
|
181
468
|
async getInvites(channelId) {
|
|
182
469
|
return this.rest.get(Routes2.channelInvites(channelId));
|
|
183
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Fetches the archived threads of a channel
|
|
473
|
+
*
|
|
474
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#list-public-archived-threads}
|
|
475
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#list-private-archived-threads}
|
|
476
|
+
* @param channelId - The id of the channel to fetch archived threads from
|
|
477
|
+
* @param archivedStatus - The archived status of the threads to fetch
|
|
478
|
+
* @param options - The options to use when fetching archived threads
|
|
479
|
+
*/
|
|
184
480
|
async getArchivedThreads(channelId, archivedStatus, options = {}) {
|
|
185
481
|
return this.rest.get(Routes2.channelThreads(channelId, archivedStatus), {
|
|
186
482
|
query: makeURLSearchParams2(options)
|
|
187
483
|
});
|
|
188
484
|
}
|
|
485
|
+
/**
|
|
486
|
+
* Fetches the private joined archived threads of a channel
|
|
487
|
+
*
|
|
488
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads}
|
|
489
|
+
* @param channelId - The id of the channel to fetch joined archived threads from
|
|
490
|
+
* @param options - The options to use when fetching joined archived threads
|
|
491
|
+
*/
|
|
189
492
|
async getJoinedPrivateArchivedThreads(channelId, options = {}) {
|
|
190
493
|
return this.rest.get(Routes2.channelJoinedArchivedThreads(channelId), {
|
|
191
494
|
query: makeURLSearchParams2(options)
|
|
192
495
|
});
|
|
193
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Fetches the webhooks of a channel
|
|
499
|
+
*
|
|
500
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#get-channel-webhooks}
|
|
501
|
+
* @param id - The id of the channel
|
|
502
|
+
*/
|
|
194
503
|
async getWebhooks(id) {
|
|
195
504
|
return this.rest.get(Routes2.channelWebhooks(id));
|
|
196
505
|
}
|
|
@@ -199,356 +508,983 @@ __name(ChannelsAPI, "ChannelsAPI");
|
|
|
199
508
|
|
|
200
509
|
// src/api/guild.ts
|
|
201
510
|
import { makeURLSearchParams as makeURLSearchParams3 } from "@discordjs/rest";
|
|
202
|
-
import {
|
|
203
|
-
Routes as Routes3
|
|
204
|
-
} from "discord-api-types/v10";
|
|
511
|
+
import { Routes as Routes3 } from "discord-api-types/v10";
|
|
205
512
|
var GuildsAPI = class {
|
|
206
513
|
constructor(rest) {
|
|
207
514
|
this.rest = rest;
|
|
208
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Fetches a guild
|
|
518
|
+
*
|
|
519
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild}
|
|
520
|
+
* @param guildId - The id of the guild
|
|
521
|
+
*/
|
|
209
522
|
async get(guildId) {
|
|
210
523
|
return this.rest.get(Routes3.guild(guildId));
|
|
211
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* Fetches a guild preview
|
|
527
|
+
*
|
|
528
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-preview}
|
|
529
|
+
* @param guildId - The id of the guild to fetch the preview from
|
|
530
|
+
*/
|
|
212
531
|
async getPreview(guildId) {
|
|
213
532
|
return this.rest.get(Routes3.guildPreview(guildId));
|
|
214
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* Creates a guild
|
|
536
|
+
*
|
|
537
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild}
|
|
538
|
+
* @param data - The guild to create
|
|
539
|
+
*/
|
|
215
540
|
async create(data) {
|
|
216
|
-
return this.rest.post(Routes3.guilds(), {
|
|
541
|
+
return this.rest.post(Routes3.guilds(), {
|
|
542
|
+
body: data
|
|
543
|
+
});
|
|
217
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Edits a guild
|
|
547
|
+
*
|
|
548
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild}
|
|
549
|
+
* @param guildId - The id of the guild to edit
|
|
550
|
+
* @param data - The new guild data
|
|
551
|
+
* @param reason - The reason for editing this guild
|
|
552
|
+
*/
|
|
218
553
|
async edit(guildId, data, reason) {
|
|
219
|
-
return this.rest.patch(Routes3.guild(guildId), {
|
|
554
|
+
return this.rest.patch(Routes3.guild(guildId), {
|
|
555
|
+
reason,
|
|
556
|
+
body: data
|
|
557
|
+
});
|
|
220
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* Deletes a guild
|
|
561
|
+
*
|
|
562
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#delete-guild}
|
|
563
|
+
* @param guildId - The id of the guild to delete
|
|
564
|
+
* @param reason - The reason for deleting this guild
|
|
565
|
+
*/
|
|
221
566
|
async delete(guildId, reason) {
|
|
222
|
-
await this.rest.delete(Routes3.guild(guildId), {
|
|
567
|
+
await this.rest.delete(Routes3.guild(guildId), {
|
|
568
|
+
reason
|
|
569
|
+
});
|
|
223
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* Fetches all the members of a guild
|
|
573
|
+
*
|
|
574
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#list-guild-members}
|
|
575
|
+
* @param guildId - The id of the guild
|
|
576
|
+
* @param options - The options to use when fetching the guild members
|
|
577
|
+
*/
|
|
224
578
|
async getMembers(guildId, options = {}) {
|
|
225
579
|
return this.rest.get(Routes3.guildMembers(guildId), {
|
|
226
580
|
query: makeURLSearchParams3(options)
|
|
227
581
|
});
|
|
228
582
|
}
|
|
583
|
+
/**
|
|
584
|
+
* Fetches a guild's channels
|
|
585
|
+
*
|
|
586
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-channels}
|
|
587
|
+
* @param guildId - The id of the guild to fetch the channels from
|
|
588
|
+
*/
|
|
229
589
|
async getChannels(guildId) {
|
|
230
590
|
return this.rest.get(Routes3.guildChannels(guildId));
|
|
231
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* Creates a guild channel
|
|
594
|
+
*
|
|
595
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild-channel}
|
|
596
|
+
* @param guildId - The id of the guild to create the channel in
|
|
597
|
+
* @param data - The data to create the new channel
|
|
598
|
+
* @param reason - The reason for creating this channel
|
|
599
|
+
*/
|
|
232
600
|
async createChannel(guildId, data, reason) {
|
|
233
601
|
return this.rest.post(Routes3.guildChannels(guildId), {
|
|
234
602
|
reason,
|
|
235
603
|
body: data
|
|
236
604
|
});
|
|
237
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* Edits a guild channel's positions
|
|
608
|
+
*
|
|
609
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions}
|
|
610
|
+
* @param guildId - The id of the guild to edit the channel positions from
|
|
611
|
+
* @param data - The data to edit the channel positions with
|
|
612
|
+
* @param reason - The reason for editing the channel positions
|
|
613
|
+
*/
|
|
238
614
|
async setChannelPositions(guildId, data, reason) {
|
|
239
|
-
await this.rest.patch(Routes3.guildChannels(guildId), {
|
|
615
|
+
await this.rest.patch(Routes3.guildChannels(guildId), {
|
|
616
|
+
reason,
|
|
617
|
+
body: data
|
|
618
|
+
});
|
|
240
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* Fetches the active threads in a guild
|
|
622
|
+
*
|
|
623
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#list-active-guild-threads}
|
|
624
|
+
* @param guildId - The id of the guild to fetch the active threads from
|
|
625
|
+
*/
|
|
241
626
|
async getActiveThreads(guildId) {
|
|
242
627
|
return this.rest.get(Routes3.guildActiveThreads(guildId));
|
|
243
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* Fetches a guild member ban
|
|
631
|
+
*
|
|
632
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-bans}
|
|
633
|
+
* @param guildId - The id of the guild to fetch the ban from
|
|
634
|
+
*/
|
|
244
635
|
async getMemberBans(guildId) {
|
|
245
636
|
return this.rest.get(Routes3.guildBans(guildId));
|
|
246
637
|
}
|
|
638
|
+
/**
|
|
639
|
+
* Bans a user from a guild
|
|
640
|
+
*
|
|
641
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild-ban}
|
|
642
|
+
* @param guildId - The id of the guild to ban the member in
|
|
643
|
+
* @param userId - The id of the user to ban
|
|
644
|
+
* @param options - Options for banning the user
|
|
645
|
+
* @param reason - The reason for banning the user
|
|
646
|
+
*/
|
|
247
647
|
async banUser(guildId, userId, options = {}, reason) {
|
|
248
|
-
await this.rest.put(Routes3.guildBan(guildId, userId), {
|
|
648
|
+
await this.rest.put(Routes3.guildBan(guildId, userId), {
|
|
649
|
+
reason,
|
|
650
|
+
body: options
|
|
651
|
+
});
|
|
249
652
|
}
|
|
653
|
+
/**
|
|
654
|
+
* Unbans a user from a guild
|
|
655
|
+
*
|
|
656
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#remove-guild-ban}
|
|
657
|
+
* @param guildId - The id of the guild to unban the member in
|
|
658
|
+
* @param userId - The id of the user to unban
|
|
659
|
+
* @param reason - The reason for unbanning the user
|
|
660
|
+
*/
|
|
250
661
|
async unbanUser(guildId, userId, reason) {
|
|
251
|
-
await this.rest.delete(Routes3.guildBan(guildId, userId), {
|
|
662
|
+
await this.rest.delete(Routes3.guildBan(guildId, userId), {
|
|
663
|
+
reason
|
|
664
|
+
});
|
|
252
665
|
}
|
|
666
|
+
/**
|
|
667
|
+
* Gets all the roles in a guild
|
|
668
|
+
*
|
|
669
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-roles}
|
|
670
|
+
* @param guildId - The id of the guild to fetch the roles from
|
|
671
|
+
*/
|
|
253
672
|
async getRoles(guildId) {
|
|
254
673
|
return this.rest.get(Routes3.guildRoles(guildId));
|
|
255
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* Creates a guild role
|
|
677
|
+
*
|
|
678
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#create-guild-role}
|
|
679
|
+
* @param guildId - The id of the guild to create the role in
|
|
680
|
+
* @param data - The data to create the role with
|
|
681
|
+
* @param reason - The reason for creating the role
|
|
682
|
+
*/
|
|
256
683
|
async createRole(guildId, data, reason) {
|
|
257
|
-
return this.rest.post(Routes3.guildRoles(guildId), {
|
|
684
|
+
return this.rest.post(Routes3.guildRoles(guildId), {
|
|
685
|
+
reason,
|
|
686
|
+
body: data
|
|
687
|
+
});
|
|
258
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* Sets role positions in a guild
|
|
691
|
+
*
|
|
692
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-role-positions}
|
|
693
|
+
* @param guildId - The id of the guild to set role positions for
|
|
694
|
+
* @param data - The data for setting a role position
|
|
695
|
+
* @param reason - The reason for setting the role position
|
|
696
|
+
*/
|
|
259
697
|
async setRolePositions(guildId, data, reason) {
|
|
260
698
|
return this.rest.patch(Routes3.guildRoles(guildId), {
|
|
261
699
|
reason,
|
|
262
700
|
body: data
|
|
263
701
|
});
|
|
264
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Edits a guild role
|
|
705
|
+
*
|
|
706
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-role}
|
|
707
|
+
* @param guildId - The id of the guild to edit the role in
|
|
708
|
+
* @param roleId - The id of the role to edit
|
|
709
|
+
* @param data - data for editing the role
|
|
710
|
+
* @param reason - The reason for editing the role
|
|
711
|
+
*/
|
|
265
712
|
async editRole(guildId, roleId, data, reason) {
|
|
266
713
|
return this.rest.patch(Routes3.guildRole(guildId, roleId), {
|
|
267
714
|
reason,
|
|
268
715
|
body: data
|
|
269
716
|
});
|
|
270
717
|
}
|
|
718
|
+
/**
|
|
719
|
+
* Deletes a guild role
|
|
720
|
+
*
|
|
721
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#delete-guild-role}
|
|
722
|
+
* @param guildId - The id of the guild to delete the role in
|
|
723
|
+
* @param roleId - The id of the role to delete
|
|
724
|
+
* @param reason - The reason for deleting the role
|
|
725
|
+
*/
|
|
271
726
|
async deleteRole(guildId, roleId, reason) {
|
|
272
|
-
await this.rest.delete(Routes3.guildRole(guildId, roleId), {
|
|
727
|
+
await this.rest.delete(Routes3.guildRole(guildId, roleId), {
|
|
728
|
+
reason
|
|
729
|
+
});
|
|
273
730
|
}
|
|
731
|
+
/**
|
|
732
|
+
* Edits the multi-factor-authentication (MFA) level of a guild
|
|
733
|
+
*
|
|
734
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-mfa-level}
|
|
735
|
+
* @param guildId - The id of the guild to edit the MFA level for
|
|
736
|
+
* @param level - The new MFA level
|
|
737
|
+
* @param reason - The reason for editing the MFA level
|
|
738
|
+
*/
|
|
274
739
|
async editMFALevel(guildId, level, reason) {
|
|
275
740
|
return this.rest.post(Routes3.guildMFA(guildId), {
|
|
276
741
|
reason,
|
|
277
|
-
body: {
|
|
742
|
+
body: {
|
|
743
|
+
mfa_level: level
|
|
744
|
+
}
|
|
278
745
|
});
|
|
279
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* Fetch the number of members that can be pruned from a guild
|
|
749
|
+
*
|
|
750
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-prune-count}
|
|
751
|
+
* @param guildId - The id of the guild to fetch the number of pruned members from
|
|
752
|
+
* @param options - The options for fetching the number of pruned members
|
|
753
|
+
*/
|
|
280
754
|
async getPruneCount(guildId, options = {}) {
|
|
281
755
|
return this.rest.get(Routes3.guildPrune(guildId), {
|
|
282
756
|
query: makeURLSearchParams3(options)
|
|
283
757
|
});
|
|
284
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Prunes members in a guild
|
|
761
|
+
*
|
|
762
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#begin-guild-prune}
|
|
763
|
+
* @param guildId - The id of the guild to prune members in
|
|
764
|
+
* @param options - The options for pruning members
|
|
765
|
+
* @param reason - The reason for pruning members
|
|
766
|
+
*/
|
|
285
767
|
async beginPrune(guildId, options = {}, reason) {
|
|
286
768
|
return this.rest.post(Routes3.guildPrune(guildId), {
|
|
287
769
|
body: options,
|
|
288
770
|
reason
|
|
289
771
|
});
|
|
290
772
|
}
|
|
773
|
+
/**
|
|
774
|
+
* Fetches voice regions for a guild
|
|
775
|
+
*
|
|
776
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-voice-regions}
|
|
777
|
+
* @param guildId - The id of the guild to fetch the voice regions from
|
|
778
|
+
*/
|
|
291
779
|
async getVoiceRegions(guildId) {
|
|
292
780
|
return this.rest.get(Routes3.guildVoiceRegions(guildId));
|
|
293
781
|
}
|
|
782
|
+
/**
|
|
783
|
+
* Fetches the invites for a guild
|
|
784
|
+
*
|
|
785
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-invites}
|
|
786
|
+
* @param guildId - The id of the guild to fetch the invites from
|
|
787
|
+
*/
|
|
294
788
|
async getInvites(guildId) {
|
|
295
789
|
return this.rest.get(Routes3.guildInvites(guildId));
|
|
296
790
|
}
|
|
791
|
+
/**
|
|
792
|
+
* Fetches the integrations for a guild
|
|
793
|
+
*
|
|
794
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-integrations}
|
|
795
|
+
* @param guildId - The id of the guild to fetch the integrations from
|
|
796
|
+
*/
|
|
297
797
|
async getIntegrations(guildId) {
|
|
298
798
|
return this.rest.get(Routes3.guildIntegrations(guildId));
|
|
299
799
|
}
|
|
800
|
+
/**
|
|
801
|
+
* Deletes an integration from a guild
|
|
802
|
+
*
|
|
803
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#delete-guild-integration}
|
|
804
|
+
* @param guildId - The id of the guild to delete the integration from
|
|
805
|
+
* @param integrationId - The id of the integration to delete
|
|
806
|
+
* @param reason - The reason for deleting the integration
|
|
807
|
+
*/
|
|
300
808
|
async deleteIntegration(guildId, integrationId, reason) {
|
|
301
|
-
await this.rest.delete(Routes3.guildIntegration(guildId, integrationId), {
|
|
809
|
+
await this.rest.delete(Routes3.guildIntegration(guildId, integrationId), {
|
|
810
|
+
reason
|
|
811
|
+
});
|
|
302
812
|
}
|
|
813
|
+
/**
|
|
814
|
+
* Fetches the widget settings for a guild
|
|
815
|
+
*
|
|
816
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget-settings}
|
|
817
|
+
* @param guildId - The id of the guild to fetch the widget settings from
|
|
818
|
+
*/
|
|
303
819
|
async getWidgetSettings(guildId) {
|
|
304
820
|
return this.rest.get(Routes3.guildWidgetSettings(guildId));
|
|
305
821
|
}
|
|
822
|
+
/**
|
|
823
|
+
* Edits the widget settings for a guild
|
|
824
|
+
*
|
|
825
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-widget}
|
|
826
|
+
* @param guildId - The id of the guild to edit the widget settings from
|
|
827
|
+
* @param data - The new widget settings data
|
|
828
|
+
* @param reason - The reason for editing the widget settings
|
|
829
|
+
*/
|
|
306
830
|
async editWidgetSettings(guildId, data, reason) {
|
|
307
831
|
return this.rest.patch(Routes3.guildWidgetSettings(guildId), {
|
|
308
832
|
reason,
|
|
309
833
|
body: data
|
|
310
834
|
});
|
|
311
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* Fetches the widget for a guild
|
|
838
|
+
*
|
|
839
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget}
|
|
840
|
+
* @param guildId - The id of the guild to fetch the widget from
|
|
841
|
+
*/
|
|
312
842
|
async getWidget(guildId) {
|
|
313
843
|
return this.rest.get(Routes3.guildWidgetJSON(guildId));
|
|
314
844
|
}
|
|
845
|
+
/**
|
|
846
|
+
* Fetches the vanity url for a guild
|
|
847
|
+
*
|
|
848
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-vanity-url}
|
|
849
|
+
* @param guildId - The id of the guild to fetch the vanity url from
|
|
850
|
+
*/
|
|
315
851
|
async getVanityURL(guildId) {
|
|
316
852
|
return this.rest.get(Routes3.guildVanityUrl(guildId));
|
|
317
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Fetches the widget image for a guild
|
|
856
|
+
*
|
|
857
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget-image}
|
|
858
|
+
* @param guildId - The id of the guild to fetch the widget image from
|
|
859
|
+
* @param style - The style of the widget image
|
|
860
|
+
*/
|
|
318
861
|
async getWidgetImage(guildId, style) {
|
|
319
862
|
return this.rest.get(Routes3.guildWidgetImage(guildId), {
|
|
320
|
-
query: makeURLSearchParams3({
|
|
863
|
+
query: makeURLSearchParams3({
|
|
864
|
+
style
|
|
865
|
+
})
|
|
321
866
|
});
|
|
322
867
|
}
|
|
868
|
+
/**
|
|
869
|
+
* Fetches the welcome screen for a guild
|
|
870
|
+
*
|
|
871
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen}
|
|
872
|
+
* @param guildId - The id of the guild to fetch the welcome screen from
|
|
873
|
+
*/
|
|
323
874
|
async getWelcomeScreen(guildId) {
|
|
324
875
|
return this.rest.get(Routes3.guildWelcomeScreen(guildId));
|
|
325
876
|
}
|
|
877
|
+
/**
|
|
878
|
+
* Edits the welcome screen for a guild
|
|
879
|
+
*
|
|
880
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen}
|
|
881
|
+
* @param guildId - The id of the guild to edit the welcome screen for
|
|
882
|
+
* @param data - The new welcome screen data
|
|
883
|
+
* @param reason - The reason for editing the welcome screen
|
|
884
|
+
*/
|
|
326
885
|
async editWelcomeScreen(guildId, data, reason) {
|
|
327
886
|
return this.rest.patch(Routes3.guildWelcomeScreen(guildId), {
|
|
328
887
|
reason,
|
|
329
888
|
body: data
|
|
330
889
|
});
|
|
331
890
|
}
|
|
891
|
+
/**
|
|
892
|
+
* Edits a user's voice state in a guild
|
|
893
|
+
*
|
|
894
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-user-voice-state}
|
|
895
|
+
* @param guildId - The id of the guild to edit the current user's voice state in
|
|
896
|
+
* @param userId - The id of the user to edit the voice state for
|
|
897
|
+
* @param data - The data for editing the voice state
|
|
898
|
+
* @param reason - The reason for editing the voice state
|
|
899
|
+
*/
|
|
332
900
|
async editUserVoiceState(guildId, userId, data, reason) {
|
|
333
|
-
await this.rest.patch(Routes3.guildVoiceState(guildId, userId), {
|
|
901
|
+
await this.rest.patch(Routes3.guildVoiceState(guildId, userId), {
|
|
902
|
+
reason,
|
|
903
|
+
body: data
|
|
904
|
+
});
|
|
334
905
|
}
|
|
906
|
+
/**
|
|
907
|
+
* Fetches all emojis for a guild
|
|
908
|
+
*
|
|
909
|
+
* @see {@link https://discord.com/developers/docs/resources/emoji#list-guild-emojis}
|
|
910
|
+
* @param guildId - The id of the guild to fetch the emojis from
|
|
911
|
+
*/
|
|
335
912
|
async getEmojis(guildId) {
|
|
336
913
|
return this.rest.get(Routes3.guildEmojis(guildId));
|
|
337
914
|
}
|
|
915
|
+
/**
|
|
916
|
+
* Fetches an emoji for a guild
|
|
917
|
+
*
|
|
918
|
+
* @see {@link https://discord.com/developers/docs/resources/emoji#get-guild-emoji}
|
|
919
|
+
* @param guildId - The id of the guild to fetch the emoji from
|
|
920
|
+
* @param emojiId - The id of the emoji to fetch
|
|
921
|
+
*/
|
|
338
922
|
async getEmoji(guildId, emojiId) {
|
|
339
923
|
return this.rest.get(Routes3.guildEmoji(guildId, emojiId));
|
|
340
924
|
}
|
|
925
|
+
/**
|
|
926
|
+
* Creates a new emoji for a guild
|
|
927
|
+
*
|
|
928
|
+
* @see {@link https://discord.com/developers/docs/resources/emoji#create-guild-emoji}
|
|
929
|
+
* @param guildId - The id of the guild to create the emoji from
|
|
930
|
+
* @param data - The data for creating the emoji
|
|
931
|
+
* @param reason - The reason for creating the emoji
|
|
932
|
+
*/
|
|
341
933
|
async createEmoji(guildId, data, reason) {
|
|
342
934
|
return this.rest.post(Routes3.guildEmojis(guildId), {
|
|
343
935
|
reason,
|
|
344
936
|
body: data
|
|
345
937
|
});
|
|
346
938
|
}
|
|
939
|
+
/**
|
|
940
|
+
* Edits an emoji for a guild
|
|
941
|
+
*
|
|
942
|
+
* @see {@link https://discord.com/developers/docs/resources/emoji#modify-guild-emoji}
|
|
943
|
+
* @param guildId - The id of the guild to edit the emoji from
|
|
944
|
+
* @param emojiId - The id of the emoji to edit
|
|
945
|
+
* @param data - The data for editing the emoji
|
|
946
|
+
* @param reason - The reason for editing the emoji
|
|
947
|
+
*/
|
|
347
948
|
async editEmoji(guildId, emojiId, data, reason) {
|
|
348
949
|
return this.rest.patch(Routes3.guildEmoji(guildId, emojiId), {
|
|
349
950
|
reason,
|
|
350
951
|
body: data
|
|
351
952
|
});
|
|
352
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Deletes an emoji for a guild
|
|
956
|
+
*
|
|
957
|
+
* @see {@link https://discord.com/developers/docs/resources/emoji#delete-guild-emoji}
|
|
958
|
+
* @param guildId - The id of the guild to delete the emoji from
|
|
959
|
+
* @param emojiId - The id of the emoji to delete
|
|
960
|
+
* @param reason - The reason for deleting the emoji
|
|
961
|
+
*/
|
|
353
962
|
async deleteEmoji(guildId, emojiId, reason) {
|
|
354
|
-
await this.rest.delete(Routes3.guildEmoji(guildId, emojiId), {
|
|
963
|
+
await this.rest.delete(Routes3.guildEmoji(guildId, emojiId), {
|
|
964
|
+
reason
|
|
965
|
+
});
|
|
355
966
|
}
|
|
967
|
+
/**
|
|
968
|
+
* Fetches all scheduled events for a guild
|
|
969
|
+
*
|
|
970
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild}
|
|
971
|
+
* @param guildId - The id of the guild to fetch the scheduled events from
|
|
972
|
+
* @param options - The options for fetching the scheduled events
|
|
973
|
+
*/
|
|
356
974
|
async getScheduledEvents(guildId, options = {}) {
|
|
357
975
|
return this.rest.get(Routes3.guildScheduledEvents(guildId), {
|
|
358
976
|
query: makeURLSearchParams3(options)
|
|
359
977
|
});
|
|
360
978
|
}
|
|
979
|
+
/**
|
|
980
|
+
* Creates a new scheduled event for a guild
|
|
981
|
+
*
|
|
982
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event}
|
|
983
|
+
* @param guildId - The id of the guild to create the scheduled event from
|
|
984
|
+
* @param data - The data to create the event with
|
|
985
|
+
* @param reason - The reason for creating the scheduled event
|
|
986
|
+
*/
|
|
361
987
|
async createScheduledEvent(guildId, data, reason) {
|
|
362
988
|
return this.rest.post(Routes3.guildScheduledEvents(guildId), {
|
|
363
989
|
reason,
|
|
364
990
|
body: data
|
|
365
991
|
});
|
|
366
992
|
}
|
|
993
|
+
/**
|
|
994
|
+
* Fetches a scheduled event for a guild
|
|
995
|
+
*
|
|
996
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event}
|
|
997
|
+
* @param guildId - The id of the guild to fetch the scheduled event from
|
|
998
|
+
* @param eventId - The id of the scheduled event to fetch
|
|
999
|
+
* @param options - The options for fetching the scheduled event
|
|
1000
|
+
*/
|
|
367
1001
|
async getScheduledEvent(guildId, eventId, options = {}) {
|
|
368
1002
|
return this.rest.get(Routes3.guildScheduledEvent(guildId, eventId), {
|
|
369
1003
|
query: makeURLSearchParams3(options)
|
|
370
1004
|
});
|
|
371
1005
|
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Edits a scheduled event for a guild
|
|
1008
|
+
*
|
|
1009
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event}
|
|
1010
|
+
* @param guildId - The id of the guild to edit the scheduled event from
|
|
1011
|
+
* @param eventId - The id of the scheduled event to edit
|
|
1012
|
+
* @param data - The new event data
|
|
1013
|
+
* @param reason - The reason for editing the scheduled event
|
|
1014
|
+
*/
|
|
372
1015
|
async editScheduledEvent(guildId, eventId, data, reason) {
|
|
373
1016
|
return this.rest.patch(Routes3.guildScheduledEvent(guildId, eventId), {
|
|
374
1017
|
reason,
|
|
375
1018
|
body: data
|
|
376
1019
|
});
|
|
377
1020
|
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Deletes a scheduled event for a guild
|
|
1023
|
+
*
|
|
1024
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event}
|
|
1025
|
+
* @param guildId - The id of the guild to delete the scheduled event from
|
|
1026
|
+
* @param eventId - The id of the scheduled event to delete
|
|
1027
|
+
* @param reason - The reason for deleting the scheduled event
|
|
1028
|
+
*/
|
|
378
1029
|
async deleteScheduledEvent(guildId, eventId, reason) {
|
|
379
|
-
await this.rest.delete(Routes3.guildScheduledEvent(guildId, eventId), {
|
|
1030
|
+
await this.rest.delete(Routes3.guildScheduledEvent(guildId, eventId), {
|
|
1031
|
+
reason
|
|
1032
|
+
});
|
|
380
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Gets all users that are interested in a scheduled event
|
|
1036
|
+
*
|
|
1037
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users}
|
|
1038
|
+
* @param guildId - The id of the guild to fetch the scheduled event users from
|
|
1039
|
+
* @param eventId - The id of the scheduled event to fetch the users for
|
|
1040
|
+
* @param options - The options for fetching the scheduled event users
|
|
1041
|
+
*/
|
|
381
1042
|
async getScheduledEventUsers(guildId, eventId, options = {}) {
|
|
382
1043
|
return this.rest.get(Routes3.guildScheduledEventUsers(guildId, eventId), {
|
|
383
1044
|
query: makeURLSearchParams3(options)
|
|
384
1045
|
});
|
|
385
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Fetches all the templates for a guild
|
|
1049
|
+
*
|
|
1050
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-template#get-guild-templates}
|
|
1051
|
+
* @param guildId - The id of the guild to fetch the templates from
|
|
1052
|
+
*/
|
|
386
1053
|
async getTemplates(guildId) {
|
|
387
1054
|
return this.rest.get(Routes3.guildTemplates(guildId));
|
|
388
1055
|
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Syncs a template for a guild
|
|
1058
|
+
*
|
|
1059
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-template#sync-guild-template}
|
|
1060
|
+
* @param guildId - The id of the guild to sync the template from
|
|
1061
|
+
* @param templateCode - The code of the template to sync
|
|
1062
|
+
*/
|
|
389
1063
|
async syncTemplate(guildId, templateCode) {
|
|
390
1064
|
return this.rest.put(Routes3.guildTemplate(guildId, templateCode));
|
|
391
1065
|
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Edits a template for a guild
|
|
1068
|
+
*
|
|
1069
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-template#modify-guild-template}
|
|
1070
|
+
* @param guildId - The id of the guild to edit the template from
|
|
1071
|
+
* @param templateCode - The code of the template to edit
|
|
1072
|
+
* @param data - The data for editing the template
|
|
1073
|
+
*/
|
|
392
1074
|
async editTemplate(guildId, templateCode, data) {
|
|
393
1075
|
return this.rest.patch(Routes3.guildTemplate(guildId, templateCode), {
|
|
394
1076
|
body: data
|
|
395
1077
|
});
|
|
396
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Deletes a template for a guild
|
|
1081
|
+
*
|
|
1082
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-template#delete-guild-template}
|
|
1083
|
+
* @param guildId - The id of the guild to delete the template from
|
|
1084
|
+
* @param templateCode - The code of the template to delete
|
|
1085
|
+
*/
|
|
397
1086
|
async deleteTemplate(guildId, templateCode) {
|
|
398
1087
|
await this.rest.delete(Routes3.guildTemplate(guildId, templateCode));
|
|
399
1088
|
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Fetches all the stickers for a guild
|
|
1091
|
+
*
|
|
1092
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#list-guild-stickers}
|
|
1093
|
+
* @param guildId - The id of the guild to fetch the stickers from
|
|
1094
|
+
*/
|
|
400
1095
|
async getStickers(guildId) {
|
|
401
1096
|
return this.rest.get(Routes3.guildStickers(guildId));
|
|
402
1097
|
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Fetches a sticker for a guild
|
|
1100
|
+
*
|
|
1101
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#get-guild-sticker}
|
|
1102
|
+
* @param guildId - The id of the guild to fetch the sticker from
|
|
1103
|
+
* @param stickerId - The id of the sticker to fetch
|
|
1104
|
+
*/
|
|
403
1105
|
async getSticker(guildId, stickerId) {
|
|
404
1106
|
return this.rest.get(Routes3.guildSticker(guildId, stickerId));
|
|
405
1107
|
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Creates a sticker for a guild
|
|
1110
|
+
*
|
|
1111
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#create-guild-sticker}
|
|
1112
|
+
* @param guildId - The id of the guild to create the sticker for
|
|
1113
|
+
* @param data - The data for creating the sticker
|
|
1114
|
+
* @param reason - The reason for creating the sticker
|
|
1115
|
+
*/
|
|
406
1116
|
async createSticker(guildId, { file, ...body }, reason) {
|
|
407
|
-
const fileData = {
|
|
1117
|
+
const fileData = {
|
|
1118
|
+
...file,
|
|
1119
|
+
key: "file"
|
|
1120
|
+
};
|
|
408
1121
|
return this.rest.post(Routes3.guildStickers(guildId), {
|
|
409
1122
|
appendToFormData: true,
|
|
410
1123
|
body,
|
|
411
|
-
files: [
|
|
1124
|
+
files: [
|
|
1125
|
+
fileData
|
|
1126
|
+
],
|
|
412
1127
|
reason
|
|
413
1128
|
});
|
|
414
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Edits a sticker for a guild
|
|
1132
|
+
*
|
|
1133
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#modify-guild-sticker}
|
|
1134
|
+
* @param guildId - The id of the guild to edit the sticker from
|
|
1135
|
+
* @param stickerId - The id of the sticker to edit
|
|
1136
|
+
* @param data - The data for editing the sticker
|
|
1137
|
+
* @param reason - The reason for editing the sticker
|
|
1138
|
+
*/
|
|
415
1139
|
async editSticker(guildId, stickerId, data, reason) {
|
|
416
1140
|
return this.rest.patch(Routes3.guildSticker(guildId, stickerId), {
|
|
417
1141
|
reason,
|
|
418
1142
|
body: data
|
|
419
1143
|
});
|
|
420
1144
|
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Deletes a sticker for a guild
|
|
1147
|
+
*
|
|
1148
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#delete-guild-sticker}
|
|
1149
|
+
* @param guildId - The id of the guild to delete the sticker from
|
|
1150
|
+
* @param stickerId - The id of the sticker to delete
|
|
1151
|
+
* @param reason - The reason for deleting the sticker
|
|
1152
|
+
*/
|
|
421
1153
|
async deleteSticker(guildId, stickerId, reason) {
|
|
422
|
-
await this.rest.delete(Routes3.guildSticker(guildId, stickerId), {
|
|
1154
|
+
await this.rest.delete(Routes3.guildSticker(guildId, stickerId), {
|
|
1155
|
+
reason
|
|
1156
|
+
});
|
|
423
1157
|
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Fetches the audit logs for a guild
|
|
1160
|
+
*
|
|
1161
|
+
* @see {@link https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log}
|
|
1162
|
+
* @param guildId - The id of the guild to fetch the audit logs from
|
|
1163
|
+
* @param options - The options for fetching the audit logs
|
|
1164
|
+
*/
|
|
424
1165
|
async getAuditLogs(guildId, options = {}) {
|
|
425
1166
|
return this.rest.get(Routes3.guildAuditLog(guildId), {
|
|
426
1167
|
query: makeURLSearchParams3(options)
|
|
427
1168
|
});
|
|
428
1169
|
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Fetches all auto moderation rules for a guild
|
|
1172
|
+
*
|
|
1173
|
+
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild}
|
|
1174
|
+
* @param guildId - The id of the guild to fetch the auto moderation rules from
|
|
1175
|
+
*/
|
|
429
1176
|
async getAutoModerationRules(guildId) {
|
|
430
1177
|
return this.rest.get(Routes3.guildAutoModerationRules(guildId));
|
|
431
1178
|
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Fetches an auto moderation rule for a guild
|
|
1181
|
+
*
|
|
1182
|
+
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#get-auto-moderation-rule}
|
|
1183
|
+
* @param guildId - The id of the guild to fetch the auto moderation rule from
|
|
1184
|
+
* @param ruleId - The id of the auto moderation rule to fetch
|
|
1185
|
+
*/
|
|
432
1186
|
async getAutoModerationRule(guildId, ruleId) {
|
|
433
|
-
return this.rest.get(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
1187
|
+
return this.rest.get(Routes3.guildAutoModerationRule(guildId, ruleId));
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Creates a new auto moderation rule for a guild
|
|
1191
|
+
*
|
|
1192
|
+
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule}
|
|
1193
|
+
* @param guildId - The id of the guild to create the auto moderation rule from
|
|
1194
|
+
* @param data - The data for creating the auto moderation rule
|
|
1195
|
+
*/
|
|
437
1196
|
async createAutoModerationRule(guildId, data, reason) {
|
|
438
1197
|
return this.rest.post(Routes3.guildAutoModerationRules(guildId), {
|
|
439
1198
|
reason,
|
|
440
1199
|
body: data
|
|
441
1200
|
});
|
|
442
1201
|
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Edits an auto moderation rule for a guild
|
|
1204
|
+
*
|
|
1205
|
+
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule}
|
|
1206
|
+
* @param guildId - The id of the guild to edit the auto moderation rule from
|
|
1207
|
+
* @param ruleId - The id of the auto moderation rule to edit
|
|
1208
|
+
* @param data - The data for editing the auto moderation rule
|
|
1209
|
+
* @param reason - The reason for editing the auto moderation rule
|
|
1210
|
+
*/
|
|
443
1211
|
async editAutoModerationRule(guildId, ruleId, data, reason) {
|
|
444
1212
|
return this.rest.patch(Routes3.guildAutoModerationRule(guildId, ruleId), {
|
|
445
1213
|
reason,
|
|
446
1214
|
body: data
|
|
447
1215
|
});
|
|
448
1216
|
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Deletes an auto moderation rule for a guild
|
|
1219
|
+
*
|
|
1220
|
+
* @see {@link https://discord.com/developers/docs/resources/auto-moderation#delete-auto-moderation-rule}
|
|
1221
|
+
* @param guildId - The id of the guild to delete the auto moderation rule from
|
|
1222
|
+
* @param ruleId - The id of the auto moderation rule to delete
|
|
1223
|
+
* @param reason - The reason for deleting the auto moderation rule
|
|
1224
|
+
*/
|
|
449
1225
|
async deleteAutoModerationRule(guildId, ruleId, reason) {
|
|
450
|
-
await this.rest.delete(Routes3.guildAutoModerationRule(guildId, ruleId), {
|
|
1226
|
+
await this.rest.delete(Routes3.guildAutoModerationRule(guildId, ruleId), {
|
|
1227
|
+
reason
|
|
1228
|
+
});
|
|
451
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Fetches a guild member
|
|
1232
|
+
*
|
|
1233
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#get-guild-member}
|
|
1234
|
+
* @param guildId - The id of the guild
|
|
1235
|
+
* @param userId - The id of the user
|
|
1236
|
+
*/
|
|
452
1237
|
async getMember(guildId, userId) {
|
|
453
1238
|
return this.rest.get(Routes3.guildMember(guildId, userId));
|
|
454
1239
|
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Searches for guild members
|
|
1242
|
+
*
|
|
1243
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#search-guild-members}
|
|
1244
|
+
* @param guildId - The id of the guild to search in
|
|
1245
|
+
* @param query - The query to search for
|
|
1246
|
+
* @param limit - The maximum number of members to return
|
|
1247
|
+
*/
|
|
455
1248
|
async searchForMembers(guildId, options) {
|
|
456
1249
|
return this.rest.get(Routes3.guildMembersSearch(guildId), {
|
|
457
1250
|
query: makeURLSearchParams3(options)
|
|
458
1251
|
});
|
|
459
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Edits a guild member
|
|
1255
|
+
*
|
|
1256
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-member}
|
|
1257
|
+
* @param guildId - The id of the guild
|
|
1258
|
+
* @param userId - The id of the user
|
|
1259
|
+
* @param data - The data to use when editing the guild member
|
|
1260
|
+
* @param reason - The reason for editing this guild member
|
|
1261
|
+
*/
|
|
460
1262
|
async editMember(guildId, userId, data = {}, reason) {
|
|
461
1263
|
return this.rest.patch(Routes3.guildMember(guildId, userId), {
|
|
462
1264
|
reason,
|
|
463
1265
|
body: data
|
|
464
1266
|
});
|
|
465
1267
|
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Adds a role to a guild member
|
|
1270
|
+
*
|
|
1271
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#add-guild-member-role}
|
|
1272
|
+
* @param guildId - The id of the guild
|
|
1273
|
+
* @param userId - The id of the user
|
|
1274
|
+
* @param roleId - The id of the role
|
|
1275
|
+
* @param reason - The reason for adding this role to the guild member
|
|
1276
|
+
*/
|
|
466
1277
|
async addRoleToMember(guildId, userId, roleId, reason) {
|
|
467
|
-
await this.rest.put(Routes3.guildMemberRole(guildId, userId, roleId), {
|
|
1278
|
+
await this.rest.put(Routes3.guildMemberRole(guildId, userId, roleId), {
|
|
1279
|
+
reason
|
|
1280
|
+
});
|
|
468
1281
|
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Removes a role from a guild member
|
|
1284
|
+
*
|
|
1285
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#remove-guild-member-role}
|
|
1286
|
+
* @param guildId - The id of the guild
|
|
1287
|
+
* @param userId - The id of the user
|
|
1288
|
+
* @param roleId - The id of the role
|
|
1289
|
+
* @param reason - The reason for removing this role from the guild member
|
|
1290
|
+
*/
|
|
469
1291
|
async removeRoleFromMember(guildId, userId, roleId, reason) {
|
|
470
|
-
await this.rest.delete(Routes3.guildMemberRole(guildId, userId, roleId), {
|
|
1292
|
+
await this.rest.delete(Routes3.guildMemberRole(guildId, userId, roleId), {
|
|
1293
|
+
reason
|
|
1294
|
+
});
|
|
471
1295
|
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Fetches a guild template
|
|
1298
|
+
*
|
|
1299
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-template#get-guild-template}
|
|
1300
|
+
* @param templateCode - The code of the template
|
|
1301
|
+
*/
|
|
472
1302
|
async getTemplate(templateCode) {
|
|
473
1303
|
return this.rest.get(Routes3.template(templateCode));
|
|
474
1304
|
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Creates a new template
|
|
1307
|
+
*
|
|
1308
|
+
* @see {@link https://discord.com/developers/docs/resources/guild-template#create-guild-template}
|
|
1309
|
+
* @param templateCode - The code of the template
|
|
1310
|
+
* @param data - The data to use when creating the template
|
|
1311
|
+
*/
|
|
475
1312
|
async createTemplate(templateCode, data) {
|
|
476
|
-
return this.rest.post(Routes3.template(templateCode), {
|
|
1313
|
+
return this.rest.post(Routes3.template(templateCode), {
|
|
1314
|
+
body: data
|
|
1315
|
+
});
|
|
477
1316
|
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Fetches webhooks for a guild
|
|
1319
|
+
*
|
|
1320
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#get-guild-webhooks}
|
|
1321
|
+
* @param id - The id of the guild
|
|
1322
|
+
*/
|
|
478
1323
|
async getWebhooks(id) {
|
|
479
1324
|
return this.rest.get(Routes3.guildWebhooks(id));
|
|
480
1325
|
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Sets the voice state for the current user
|
|
1328
|
+
*
|
|
1329
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state}
|
|
1330
|
+
* @param guildId - The id of the guild
|
|
1331
|
+
* @param options - The options to use when setting the voice state
|
|
1332
|
+
*/
|
|
1333
|
+
async setVoiceState(guildId, options = {}) {
|
|
1334
|
+
return this.rest.patch(Routes3.guildVoiceState(guildId, "@me"), {
|
|
1335
|
+
body: options
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
481
1338
|
};
|
|
482
1339
|
__name(GuildsAPI, "GuildsAPI");
|
|
483
1340
|
|
|
484
1341
|
// src/api/interactions.ts
|
|
485
|
-
import {
|
|
486
|
-
InteractionResponseType,
|
|
487
|
-
Routes as Routes4
|
|
488
|
-
} from "discord-api-types/v10";
|
|
1342
|
+
import { InteractionResponseType, Routes as Routes4 } from "discord-api-types/v10";
|
|
489
1343
|
var InteractionsAPI = class {
|
|
490
1344
|
constructor(rest, webhooks) {
|
|
491
1345
|
this.rest = rest;
|
|
492
1346
|
this.webhooks = webhooks;
|
|
493
1347
|
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Replies to an interaction
|
|
1350
|
+
*
|
|
1351
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1352
|
+
* @param interactionId - The id of the interaction
|
|
1353
|
+
* @param interactionToken - The token of the interaction
|
|
1354
|
+
* @param data - The data to use when replying
|
|
1355
|
+
*/
|
|
494
1356
|
async reply(interactionId, interactionToken, { files, ...data }) {
|
|
495
1357
|
await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
|
|
496
1358
|
files,
|
|
1359
|
+
auth: false,
|
|
497
1360
|
body: {
|
|
498
1361
|
type: InteractionResponseType.ChannelMessageWithSource,
|
|
499
1362
|
data
|
|
500
1363
|
}
|
|
501
1364
|
});
|
|
502
1365
|
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Defers the reply to an interaction
|
|
1368
|
+
*
|
|
1369
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1370
|
+
* @param interactionId - The id of the interaction
|
|
1371
|
+
* @param interactionToken - The token of the interaction
|
|
1372
|
+
*/
|
|
503
1373
|
async defer(interactionId, interactionToken) {
|
|
504
1374
|
await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
|
|
1375
|
+
auth: false,
|
|
505
1376
|
body: {
|
|
506
1377
|
type: InteractionResponseType.DeferredChannelMessageWithSource
|
|
507
1378
|
}
|
|
508
1379
|
});
|
|
509
1380
|
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Defers an update from a message component interaction
|
|
1383
|
+
*
|
|
1384
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1385
|
+
* @param interactionId - The id of the interaction
|
|
1386
|
+
* @param interactionToken - The token of the interaction
|
|
1387
|
+
*/
|
|
510
1388
|
async deferMessageUpdate(interactionId, interactionToken) {
|
|
511
1389
|
await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
|
|
1390
|
+
auth: false,
|
|
512
1391
|
body: {
|
|
513
1392
|
type: InteractionResponseType.DeferredMessageUpdate
|
|
514
1393
|
}
|
|
515
1394
|
});
|
|
516
1395
|
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Reply to a deferred interaction
|
|
1398
|
+
*
|
|
1399
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message}
|
|
1400
|
+
* @param applicationId - The application id of the interaction
|
|
1401
|
+
* @param interactionToken - The token of the interaction
|
|
1402
|
+
* @param data - The data to use when replying
|
|
1403
|
+
*/
|
|
517
1404
|
async followUp(applicationId, interactionToken, data) {
|
|
518
1405
|
await this.webhooks.execute(applicationId, interactionToken, data);
|
|
519
1406
|
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Edits the initial reply to an interaction
|
|
1409
|
+
*
|
|
1410
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response}
|
|
1411
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message}
|
|
1412
|
+
* @param applicationId - The application id of the interaction
|
|
1413
|
+
* @param interactionToken - The token of the interaction
|
|
1414
|
+
* @param data - The data to use when editing the reply
|
|
1415
|
+
* @param messageId - The id of the message to edit. If omitted, the original reply will be edited
|
|
1416
|
+
*/
|
|
520
1417
|
async editReply(applicationId, interactionToken, data, messageId) {
|
|
521
1418
|
return this.webhooks.editMessage(applicationId, interactionToken, messageId ?? "@original", data);
|
|
522
1419
|
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Fetches the initial reply to an interaction
|
|
1422
|
+
*
|
|
1423
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response}
|
|
1424
|
+
* @param applicationId - The application id of the interaction
|
|
1425
|
+
* @param interactionToken - The token of the interaction
|
|
1426
|
+
*/
|
|
523
1427
|
async getOriginalReply(applicationId, interactionToken) {
|
|
524
|
-
return this.webhooks.getMessage(
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
1428
|
+
return this.webhooks.getMessage(applicationId, interactionToken, "@original");
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Deletes the initial reply to an interaction
|
|
1432
|
+
*
|
|
1433
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response}
|
|
1434
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message}
|
|
1435
|
+
* @param applicationId - The application id of the interaction
|
|
1436
|
+
* @param interactionToken - The token of the interaction
|
|
1437
|
+
* @param messageId - The id of the message to delete. If omitted, the original reply will be deleted
|
|
1438
|
+
*/
|
|
530
1439
|
async deleteReply(applicationId, interactionToken, messageId) {
|
|
531
1440
|
await this.webhooks.deleteMessage(applicationId, interactionToken, messageId ?? "@original");
|
|
532
1441
|
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Updates the the message the component interaction was triggered on
|
|
1444
|
+
*
|
|
1445
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1446
|
+
* @param interactionId - The id of the interaction
|
|
1447
|
+
* @param interactionToken - The token of the interaction
|
|
1448
|
+
* @param data - The data to use when updating the interaction
|
|
1449
|
+
*/
|
|
533
1450
|
async updateMessage(interactionId, interactionToken, { files, ...data }) {
|
|
534
1451
|
await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
|
|
535
1452
|
files,
|
|
1453
|
+
auth: false,
|
|
536
1454
|
body: {
|
|
537
1455
|
type: InteractionResponseType.UpdateMessage,
|
|
538
1456
|
data
|
|
539
1457
|
}
|
|
540
1458
|
});
|
|
541
1459
|
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Sends an autocomplete response to an interaction
|
|
1462
|
+
*
|
|
1463
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1464
|
+
* @param interactionId - The id of the interaction
|
|
1465
|
+
* @param interactionToken - The token of the interaction
|
|
1466
|
+
* @param data - Data for the autocomplete response
|
|
1467
|
+
*/
|
|
542
1468
|
async createAutocompleteResponse(interactionId, interactionToken, data) {
|
|
543
1469
|
await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
|
|
1470
|
+
auth: false,
|
|
544
1471
|
body: {
|
|
545
1472
|
type: InteractionResponseType.ApplicationCommandAutocompleteResult,
|
|
546
1473
|
data
|
|
547
1474
|
}
|
|
548
1475
|
});
|
|
549
1476
|
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Sends a modal response to an interaction
|
|
1479
|
+
*
|
|
1480
|
+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1481
|
+
* @param interactionId - The id of the interaction
|
|
1482
|
+
* @param interactionToken - The token of the interaction
|
|
1483
|
+
* @param data - The modal to send
|
|
1484
|
+
*/
|
|
550
1485
|
async createModal(interactionId, interactionToken, data) {
|
|
551
1486
|
await this.rest.post(Routes4.interactionCallback(interactionId, interactionToken), {
|
|
1487
|
+
auth: false,
|
|
552
1488
|
body: {
|
|
553
1489
|
type: InteractionResponseType.Modal,
|
|
554
1490
|
data
|
|
@@ -565,13 +1501,28 @@ var InvitesAPI = class {
|
|
|
565
1501
|
constructor(rest) {
|
|
566
1502
|
this.rest = rest;
|
|
567
1503
|
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Fetches an invite
|
|
1506
|
+
*
|
|
1507
|
+
* @see {@link https://discord.com/developers/docs/resources/invite#get-invite}
|
|
1508
|
+
* @param code - The invite code
|
|
1509
|
+
*/
|
|
568
1510
|
async get(code, options = {}) {
|
|
569
1511
|
return this.rest.get(Routes5.invite(code), {
|
|
570
1512
|
query: makeURLSearchParams4(options)
|
|
571
1513
|
});
|
|
572
1514
|
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Deletes an invite
|
|
1517
|
+
*
|
|
1518
|
+
* @see {@link https://discord.com/developers/docs/resources/invite#delete-invite}
|
|
1519
|
+
* @param code - The invite code
|
|
1520
|
+
* @param reason - The reason for deleting the invite
|
|
1521
|
+
*/
|
|
573
1522
|
async delete(code, reason) {
|
|
574
|
-
await this.rest.delete(Routes5.invite(code), {
|
|
1523
|
+
await this.rest.delete(Routes5.invite(code), {
|
|
1524
|
+
reason
|
|
1525
|
+
});
|
|
575
1526
|
}
|
|
576
1527
|
};
|
|
577
1528
|
__name(InvitesAPI, "InvitesAPI");
|
|
@@ -579,19 +1530,28 @@ __name(InvitesAPI, "InvitesAPI");
|
|
|
579
1530
|
// src/api/oauth2.ts
|
|
580
1531
|
import { URL } from "node:url";
|
|
581
1532
|
import { makeURLSearchParams as makeURLSearchParams5 } from "@discordjs/rest";
|
|
582
|
-
import {
|
|
583
|
-
Routes as Routes6,
|
|
584
|
-
RouteBases
|
|
585
|
-
} from "discord-api-types/v10";
|
|
1533
|
+
import { Routes as Routes6, RouteBases } from "discord-api-types/v10";
|
|
586
1534
|
var OAuth2API = class {
|
|
587
1535
|
constructor(rest) {
|
|
588
1536
|
this.rest = rest;
|
|
589
1537
|
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Creates an OAuth2 authorization URL given the options
|
|
1540
|
+
*
|
|
1541
|
+
* @see {@link https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-authorization-url-example}
|
|
1542
|
+
* @param options - The options for creating the authorization URL
|
|
1543
|
+
*/
|
|
590
1544
|
generateAuthorizationURL(options) {
|
|
591
1545
|
const url = new URL(`${RouteBases.api}${Routes6.oauth2Authorization()}`);
|
|
592
1546
|
url.search = makeURLSearchParams5(options).toString();
|
|
593
1547
|
return url.toString();
|
|
594
1548
|
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Performs an OAuth2 token exchange, giving you an access token
|
|
1551
|
+
*
|
|
1552
|
+
* @see {@link https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-access-token-exchange-example}
|
|
1553
|
+
* @param options - The options for the token exchange request
|
|
1554
|
+
*/
|
|
595
1555
|
async tokenExchange(options) {
|
|
596
1556
|
return this.rest.post(Routes6.oauth2TokenExchange(), {
|
|
597
1557
|
body: makeURLSearchParams5(options),
|
|
@@ -601,6 +1561,12 @@ var OAuth2API = class {
|
|
|
601
1561
|
}
|
|
602
1562
|
});
|
|
603
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Refreshes an OAuth2 access token, giving you a new one
|
|
1566
|
+
*
|
|
1567
|
+
* @see {@link https://discord.com/developers/docs/topics/oauth2#authorization-code-grant-refresh-token-exchange-example}
|
|
1568
|
+
* @param options - The options for the refresh token request
|
|
1569
|
+
*/
|
|
604
1570
|
async refreshToken(options) {
|
|
605
1571
|
return this.rest.post(Routes6.oauth2TokenExchange(), {
|
|
606
1572
|
body: makeURLSearchParams5(options),
|
|
@@ -610,6 +1576,14 @@ var OAuth2API = class {
|
|
|
610
1576
|
}
|
|
611
1577
|
});
|
|
612
1578
|
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Fetches the bearer token for the current application
|
|
1581
|
+
*
|
|
1582
|
+
* @remarks
|
|
1583
|
+
* This is primarily used for testing purposes
|
|
1584
|
+
* @see {@link https://discord.com/developers/docs/topics/oauth2#client-credentials-grant}
|
|
1585
|
+
* @param options - The options for the client credentials grant request
|
|
1586
|
+
*/
|
|
613
1587
|
async getToken(options) {
|
|
614
1588
|
return this.rest.post(Routes6.oauth2TokenExchange(), {
|
|
615
1589
|
body: makeURLSearchParams5(options),
|
|
@@ -619,9 +1593,19 @@ var OAuth2API = class {
|
|
|
619
1593
|
}
|
|
620
1594
|
});
|
|
621
1595
|
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Fetches the current bot's application information
|
|
1598
|
+
*
|
|
1599
|
+
* @see {@link https://discord.com/developers/docs/topics/oauth2#get-current-bot-application-information}
|
|
1600
|
+
*/
|
|
622
1601
|
async getCurrentBotApplicationInformation() {
|
|
623
1602
|
return this.rest.get(Routes6.oauth2CurrentApplication());
|
|
624
1603
|
}
|
|
1604
|
+
/**
|
|
1605
|
+
* Fetches the current authorization information
|
|
1606
|
+
*
|
|
1607
|
+
* @see {@link https://discord.com/developers/docs/topics/oauth2#get-current-authorization-information}
|
|
1608
|
+
*/
|
|
625
1609
|
async getCurrentAuthorizationInformation() {
|
|
626
1610
|
return this.rest.get(Routes6.oauth2CurrentAuthorization());
|
|
627
1611
|
}
|
|
@@ -629,18 +1613,27 @@ var OAuth2API = class {
|
|
|
629
1613
|
__name(OAuth2API, "OAuth2API");
|
|
630
1614
|
|
|
631
1615
|
// src/api/roleConnections.ts
|
|
632
|
-
import {
|
|
633
|
-
Routes as Routes7
|
|
634
|
-
} from "discord-api-types/v10";
|
|
1616
|
+
import { Routes as Routes7 } from "discord-api-types/v10";
|
|
635
1617
|
var RoleConnectionsAPI = class {
|
|
636
1618
|
constructor(rest) {
|
|
637
1619
|
this.rest = rest;
|
|
638
1620
|
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Gets the role connection metadata records for the application
|
|
1623
|
+
*
|
|
1624
|
+
* @see {@link https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records}
|
|
1625
|
+
* @param applicationId - The id of the application to get role connection metadata records for
|
|
1626
|
+
*/
|
|
639
1627
|
async getMetadataRecords(applicationId) {
|
|
640
|
-
return this.rest.get(
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
1628
|
+
return this.rest.get(Routes7.applicationRoleConnectionMetadata(applicationId));
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Updates the role connection metadata records for the application
|
|
1632
|
+
*
|
|
1633
|
+
* @see {@link https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records}
|
|
1634
|
+
* @param applicationId - The id of the application to update role connection metadata records for
|
|
1635
|
+
* @param options - The new role connection metadata records
|
|
1636
|
+
*/
|
|
644
1637
|
async updateMetadataRecords(applicationId, options) {
|
|
645
1638
|
return this.rest.put(Routes7.applicationRoleConnectionMetadata(applicationId), {
|
|
646
1639
|
body: options
|
|
@@ -650,16 +1643,25 @@ var RoleConnectionsAPI = class {
|
|
|
650
1643
|
__name(RoleConnectionsAPI, "RoleConnectionsAPI");
|
|
651
1644
|
|
|
652
1645
|
// src/api/sticker.ts
|
|
653
|
-
import {
|
|
654
|
-
Routes as Routes8
|
|
655
|
-
} from "discord-api-types/v10";
|
|
1646
|
+
import { Routes as Routes8 } from "discord-api-types/v10";
|
|
656
1647
|
var StickersAPI = class {
|
|
657
1648
|
constructor(rest) {
|
|
658
1649
|
this.rest = rest;
|
|
659
1650
|
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Fetches all of the nitro sticker packs
|
|
1653
|
+
*
|
|
1654
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#list-nitro-sticker-packs}
|
|
1655
|
+
*/
|
|
660
1656
|
async getNitroStickers() {
|
|
661
1657
|
return this.rest.get(Routes8.nitroStickerPacks());
|
|
662
1658
|
}
|
|
1659
|
+
/**
|
|
1660
|
+
* Fetches a sticker
|
|
1661
|
+
*
|
|
1662
|
+
* @see {@link https://discord.com/developers/docs/resources/sticker#get-sticker}
|
|
1663
|
+
* @param stickerId - The id of the sticker
|
|
1664
|
+
*/
|
|
663
1665
|
async get(stickerId) {
|
|
664
1666
|
return this.rest.get(Routes8.sticker(stickerId));
|
|
665
1667
|
}
|
|
@@ -667,42 +1669,105 @@ var StickersAPI = class {
|
|
|
667
1669
|
__name(StickersAPI, "StickersAPI");
|
|
668
1670
|
|
|
669
1671
|
// src/api/thread.ts
|
|
670
|
-
import {
|
|
671
|
-
Routes as Routes9
|
|
672
|
-
} from "discord-api-types/v10";
|
|
1672
|
+
import { Routes as Routes9 } from "discord-api-types/v10";
|
|
673
1673
|
var ThreadsAPI = class {
|
|
674
1674
|
constructor(rest) {
|
|
675
1675
|
this.rest = rest;
|
|
676
1676
|
}
|
|
1677
|
+
/**
|
|
1678
|
+
* Fetches a thread
|
|
1679
|
+
*
|
|
1680
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-channel}
|
|
1681
|
+
* @param threadId - The id of the thread
|
|
1682
|
+
*/
|
|
677
1683
|
async get(threadId) {
|
|
678
1684
|
return this.rest.get(Routes9.channel(threadId));
|
|
679
1685
|
}
|
|
1686
|
+
/**
|
|
1687
|
+
* Creates a new thread
|
|
1688
|
+
*
|
|
1689
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#start-thread-from-message}
|
|
1690
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#start-thread-without-message}
|
|
1691
|
+
* @param channelId - The id of the channel to start the thread in
|
|
1692
|
+
* @param data - The data to use when starting the thread
|
|
1693
|
+
*/
|
|
680
1694
|
async create(channelId, { message_id, ...body }) {
|
|
681
|
-
return this.rest.post(Routes9.threads(channelId, message_id), {
|
|
1695
|
+
return this.rest.post(Routes9.threads(channelId, message_id), {
|
|
1696
|
+
body
|
|
1697
|
+
});
|
|
682
1698
|
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Creates a new forum post
|
|
1701
|
+
*
|
|
1702
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel}
|
|
1703
|
+
* @param channelId - The id of the forum channel to start the thread in
|
|
1704
|
+
* @param data - The data to use when starting the thread
|
|
1705
|
+
*/
|
|
683
1706
|
async createForumThread(channelId, { message, ...optionsBody }) {
|
|
684
1707
|
const { files, ...messageBody } = message;
|
|
685
1708
|
const body = {
|
|
686
1709
|
...optionsBody,
|
|
687
1710
|
message: messageBody
|
|
688
1711
|
};
|
|
689
|
-
return this.rest.post(Routes9.threads(channelId), {
|
|
1712
|
+
return this.rest.post(Routes9.threads(channelId), {
|
|
1713
|
+
files,
|
|
1714
|
+
body
|
|
1715
|
+
});
|
|
690
1716
|
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Adds the current user to a thread
|
|
1719
|
+
*
|
|
1720
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#join-thread}
|
|
1721
|
+
* @param threadId - The id of the thread to join
|
|
1722
|
+
*/
|
|
691
1723
|
async join(threadId) {
|
|
692
1724
|
await this.rest.put(Routes9.threadMembers(threadId, "@me"));
|
|
693
1725
|
}
|
|
1726
|
+
/**
|
|
1727
|
+
* Adds a member to a thread
|
|
1728
|
+
*
|
|
1729
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#add-thread-member}
|
|
1730
|
+
* @param threadId - The id of the thread to add the member to
|
|
1731
|
+
* @param userId - The id of the user to add to the thread
|
|
1732
|
+
*/
|
|
694
1733
|
async addMember(threadId, userId) {
|
|
695
1734
|
await this.rest.put(Routes9.threadMembers(threadId, userId));
|
|
696
1735
|
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Removes the current user from a thread
|
|
1738
|
+
*
|
|
1739
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#leave-thread}
|
|
1740
|
+
* @param threadId - The id of the thread to leave
|
|
1741
|
+
*/
|
|
697
1742
|
async leave(threadId) {
|
|
698
1743
|
await this.rest.delete(Routes9.threadMembers(threadId, "@me"));
|
|
699
1744
|
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Removes a member from a thread
|
|
1747
|
+
*
|
|
1748
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#remove-thread-member}
|
|
1749
|
+
* @param threadId - The id of the thread to remove the member from
|
|
1750
|
+
* @param userId - The id of the user to remove from the thread
|
|
1751
|
+
*/
|
|
700
1752
|
async removeMember(threadId, userId) {
|
|
701
1753
|
await this.rest.delete(Routes9.threadMembers(threadId, userId));
|
|
702
1754
|
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Fetches a member of a thread
|
|
1757
|
+
*
|
|
1758
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#get-thread-member}
|
|
1759
|
+
* @param threadId - The id of the thread to fetch the member from
|
|
1760
|
+
* @param userId - The id of the user
|
|
1761
|
+
*/
|
|
703
1762
|
async getMember(threadId, userId) {
|
|
704
1763
|
return this.rest.get(Routes9.threadMembers(threadId, userId));
|
|
705
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Fetches all members of a thread
|
|
1767
|
+
*
|
|
1768
|
+
* @see {@link https://discord.com/developers/docs/resources/channel#list-thread-members}
|
|
1769
|
+
* @param threadId - The id of the thread to fetch the members from
|
|
1770
|
+
*/
|
|
706
1771
|
async getAllMembers(threadId) {
|
|
707
1772
|
return this.rest.get(Routes9.threadMembers(threadId));
|
|
708
1773
|
}
|
|
@@ -711,57 +1776,119 @@ __name(ThreadsAPI, "ThreadsAPI");
|
|
|
711
1776
|
|
|
712
1777
|
// src/api/user.ts
|
|
713
1778
|
import { makeURLSearchParams as makeURLSearchParams6 } from "@discordjs/rest";
|
|
714
|
-
import {
|
|
715
|
-
Routes as Routes10
|
|
716
|
-
} from "discord-api-types/v10";
|
|
1779
|
+
import { Routes as Routes10 } from "discord-api-types/v10";
|
|
717
1780
|
var UsersAPI = class {
|
|
718
1781
|
constructor(rest) {
|
|
719
1782
|
this.rest = rest;
|
|
720
1783
|
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Fetches a user by their id
|
|
1786
|
+
*
|
|
1787
|
+
* @see {@link https://discord.com/developers/docs/resources/user#get-user}
|
|
1788
|
+
* @param userId - The id of the user to fetch
|
|
1789
|
+
*/
|
|
721
1790
|
async get(userId) {
|
|
722
1791
|
return this.rest.get(Routes10.user(userId));
|
|
723
1792
|
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Returns the user object of the requester's account
|
|
1795
|
+
*
|
|
1796
|
+
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user}
|
|
1797
|
+
*/
|
|
724
1798
|
async getCurrent() {
|
|
725
1799
|
return this.rest.get(Routes10.user("@me"));
|
|
726
1800
|
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Returns a list of partial guild objects the current user is a member of
|
|
1803
|
+
*
|
|
1804
|
+
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user-guilds}
|
|
1805
|
+
* @param options - The options to use when fetching the current user's guilds
|
|
1806
|
+
*/
|
|
727
1807
|
async getGuilds(options = {}) {
|
|
728
1808
|
return this.rest.get(Routes10.userGuilds(), {
|
|
729
1809
|
query: makeURLSearchParams6(options)
|
|
730
1810
|
});
|
|
731
1811
|
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Leaves the guild with the given id
|
|
1814
|
+
*
|
|
1815
|
+
* @see {@link https://discord.com/developers/docs/resources/user#leave-guild}
|
|
1816
|
+
* @param guildId - The id of the guild
|
|
1817
|
+
*/
|
|
732
1818
|
async leaveGuild(guildId) {
|
|
733
1819
|
await this.rest.delete(Routes10.userGuild(guildId));
|
|
734
1820
|
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Edits the current user
|
|
1823
|
+
*
|
|
1824
|
+
* @see {@link https://discord.com/developers/docs/resources/user#modify-current-user}
|
|
1825
|
+
* @param user - The new data for the current user
|
|
1826
|
+
*/
|
|
735
1827
|
async edit(user) {
|
|
736
|
-
return this.rest.patch(Routes10.user("@me"), {
|
|
1828
|
+
return this.rest.patch(Routes10.user("@me"), {
|
|
1829
|
+
body: user
|
|
1830
|
+
});
|
|
737
1831
|
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Fetches the guild member for the current user
|
|
1834
|
+
*
|
|
1835
|
+
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user-guild-member}
|
|
1836
|
+
* @param guildId - The id of the guild
|
|
1837
|
+
*/
|
|
738
1838
|
async getGuildMember(guildId) {
|
|
739
1839
|
return this.rest.get(Routes10.userGuildMember(guildId));
|
|
740
1840
|
}
|
|
1841
|
+
/**
|
|
1842
|
+
* Edits the guild member for the current user
|
|
1843
|
+
*
|
|
1844
|
+
* @see {@link https://discord.com/developers/docs/resources/guild#modify-current-member}
|
|
1845
|
+
* @param guildId - The id of the guild
|
|
1846
|
+
* @param member - The new data for the guild member
|
|
1847
|
+
* @param reason - The reason for editing this guild member
|
|
1848
|
+
*/
|
|
741
1849
|
async editGuildMember(guildId, member = {}, reason) {
|
|
742
1850
|
return this.rest.patch(Routes10.guildMember(guildId, "@me"), {
|
|
743
1851
|
reason,
|
|
744
1852
|
body: member
|
|
745
1853
|
});
|
|
746
1854
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
1855
|
+
/**
|
|
1856
|
+
* Opens a new DM channel with a user
|
|
1857
|
+
*
|
|
1858
|
+
* @see {@link https://discord.com/developers/docs/resources/user#create-dm}
|
|
1859
|
+
* @param userId - The id of the user to open a DM channel with
|
|
1860
|
+
*/
|
|
752
1861
|
async createDM(userId) {
|
|
753
1862
|
return this.rest.post(Routes10.userChannels(), {
|
|
754
|
-
body: {
|
|
1863
|
+
body: {
|
|
1864
|
+
recipient_id: userId
|
|
1865
|
+
}
|
|
755
1866
|
});
|
|
756
1867
|
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Gets the current user's connections
|
|
1870
|
+
*
|
|
1871
|
+
* @see {@link https://discord.com/developers/docs/resources/user#get-user-connections}
|
|
1872
|
+
*/
|
|
757
1873
|
async getConnections() {
|
|
758
1874
|
return this.rest.get(Routes10.userConnections());
|
|
759
1875
|
}
|
|
1876
|
+
/**
|
|
1877
|
+
* Gets the current user's active application role connection
|
|
1878
|
+
*
|
|
1879
|
+
* @see {@link https://discord.com/developers/docs/resources/user#get-user-application-role-connection}
|
|
1880
|
+
* @param applicationId - The id of the application
|
|
1881
|
+
*/
|
|
760
1882
|
async getApplicationRoleConnection(applicationId) {
|
|
761
|
-
return this.rest.get(
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1883
|
+
return this.rest.get(Routes10.userApplicationRoleConnection(applicationId));
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Updates the current user's application role connection
|
|
1887
|
+
*
|
|
1888
|
+
* @see {@link https://discord.com/developers/docs/resources/user#update-user-application-role-connection}
|
|
1889
|
+
* @param applicationId - The id of the application
|
|
1890
|
+
* @param options - The options to use when updating the application role connection
|
|
1891
|
+
*/
|
|
765
1892
|
async updateApplicationRoleConnection(applicationId, options) {
|
|
766
1893
|
return this.rest.put(Routes10.userApplicationRoleConnection(applicationId), {
|
|
767
1894
|
body: options
|
|
@@ -776,6 +1903,11 @@ var VoiceAPI = class {
|
|
|
776
1903
|
constructor(rest) {
|
|
777
1904
|
this.rest = rest;
|
|
778
1905
|
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Fetches all voice regions
|
|
1908
|
+
*
|
|
1909
|
+
* @see {@link https://discord.com/developers/docs/resources/voice#list-voice-regions}
|
|
1910
|
+
*/
|
|
779
1911
|
async getVoiceRegions() {
|
|
780
1912
|
return this.rest.get(Routes11.voiceRegions());
|
|
781
1913
|
}
|
|
@@ -784,41 +1916,91 @@ __name(VoiceAPI, "VoiceAPI");
|
|
|
784
1916
|
|
|
785
1917
|
// src/api/webhook.ts
|
|
786
1918
|
import { makeURLSearchParams as makeURLSearchParams7 } from "@discordjs/rest";
|
|
787
|
-
import {
|
|
788
|
-
Routes as Routes12
|
|
789
|
-
} from "discord-api-types/v10";
|
|
1919
|
+
import { Routes as Routes12 } from "discord-api-types/v10";
|
|
790
1920
|
var WebhooksAPI = class {
|
|
791
1921
|
constructor(rest) {
|
|
792
1922
|
this.rest = rest;
|
|
793
1923
|
}
|
|
1924
|
+
/**
|
|
1925
|
+
* Fetches a webhook
|
|
1926
|
+
*
|
|
1927
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook}
|
|
1928
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook-with-token}
|
|
1929
|
+
* @param id - The id of the webhook
|
|
1930
|
+
* @param token - The token of the webhook
|
|
1931
|
+
*/
|
|
794
1932
|
async get(id, token) {
|
|
795
1933
|
return this.rest.get(Routes12.webhook(id, token));
|
|
796
1934
|
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Creates a new webhook
|
|
1937
|
+
*
|
|
1938
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#create-webhook}
|
|
1939
|
+
* @param channelId - The id of the channel to create the webhook in
|
|
1940
|
+
* @param data - The data to use when creating the webhook
|
|
1941
|
+
* @param reason - The reason for creating the webhook
|
|
1942
|
+
*/
|
|
797
1943
|
async create(channelId, data, reason) {
|
|
798
1944
|
return this.rest.post(Routes12.channelWebhooks(channelId), {
|
|
799
1945
|
reason,
|
|
800
1946
|
body: data
|
|
801
1947
|
});
|
|
802
1948
|
}
|
|
1949
|
+
/**
|
|
1950
|
+
* Edits a webhook
|
|
1951
|
+
*
|
|
1952
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#modify-webhook}
|
|
1953
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token}
|
|
1954
|
+
* @param id - The id of the webhook to edit
|
|
1955
|
+
* @param webhook - The new webhook data
|
|
1956
|
+
* @param options - The options to use when editing the webhook
|
|
1957
|
+
*/
|
|
803
1958
|
async edit(id, webhook, { token, reason } = {}) {
|
|
804
|
-
return this.rest.patch(Routes12.webhook(id, token), {
|
|
1959
|
+
return this.rest.patch(Routes12.webhook(id, token), {
|
|
1960
|
+
reason,
|
|
1961
|
+
body: webhook
|
|
1962
|
+
});
|
|
805
1963
|
}
|
|
1964
|
+
/**
|
|
1965
|
+
* Deletes a webhook
|
|
1966
|
+
*
|
|
1967
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#delete-webhook}
|
|
1968
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token}
|
|
1969
|
+
* @param id - The id of the webhook to delete
|
|
1970
|
+
* @param options - The options to use when deleting the webhook
|
|
1971
|
+
*/
|
|
806
1972
|
async delete(id, { token, reason } = {}) {
|
|
807
|
-
await this.rest.delete(Routes12.webhook(id, token), {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
1973
|
+
await this.rest.delete(Routes12.webhook(id, token), {
|
|
1974
|
+
reason
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Executes a webhook
|
|
1979
|
+
*
|
|
1980
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-webhook}
|
|
1981
|
+
* @param id - The id of the webhook
|
|
1982
|
+
* @param token - The token of the webhook
|
|
1983
|
+
* @param data - The data to use when executing the webhook
|
|
1984
|
+
*/
|
|
1985
|
+
async execute(id, token, { wait, thread_id, files, ...body }) {
|
|
815
1986
|
return this.rest.post(Routes12.webhook(id, token), {
|
|
816
|
-
query: makeURLSearchParams7({
|
|
1987
|
+
query: makeURLSearchParams7({
|
|
1988
|
+
wait,
|
|
1989
|
+
thread_id
|
|
1990
|
+
}),
|
|
817
1991
|
files,
|
|
818
1992
|
body,
|
|
819
1993
|
auth: false
|
|
820
1994
|
});
|
|
821
1995
|
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Executes a slack webhook
|
|
1998
|
+
*
|
|
1999
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook}
|
|
2000
|
+
* @param id - The id of the webhook
|
|
2001
|
+
* @param token - The token of the webhook
|
|
2002
|
+
* @param options - The options to use when executing the webhook
|
|
2003
|
+
*/
|
|
822
2004
|
async executeSlack(id, token, body, options = {}) {
|
|
823
2005
|
await this.rest.post(Routes12.webhookPlatform(id, token, "slack"), {
|
|
824
2006
|
query: makeURLSearchParams7(options),
|
|
@@ -826,6 +2008,14 @@ var WebhooksAPI = class {
|
|
|
826
2008
|
auth: false
|
|
827
2009
|
});
|
|
828
2010
|
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Executes a github webhook
|
|
2013
|
+
*
|
|
2014
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook}
|
|
2015
|
+
* @param id - The id of the webhook
|
|
2016
|
+
* @param token - The token of the webhook
|
|
2017
|
+
* @param options - The options to use when executing the webhook
|
|
2018
|
+
*/
|
|
829
2019
|
async executeGitHub(id, token, body, options = {}) {
|
|
830
2020
|
await this.rest.post(Routes12.webhookPlatform(id, token, "github"), {
|
|
831
2021
|
query: makeURLSearchParams7(options),
|
|
@@ -833,19 +2023,48 @@ var WebhooksAPI = class {
|
|
|
833
2023
|
auth: false
|
|
834
2024
|
});
|
|
835
2025
|
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Fetches an associated message from a webhook
|
|
2028
|
+
*
|
|
2029
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook-message}
|
|
2030
|
+
* @param id - The id of the webhook
|
|
2031
|
+
* @param token - The token of the webhook
|
|
2032
|
+
* @param messageId - The id of the message to fetch
|
|
2033
|
+
* @param options - The options to use when fetching the message
|
|
2034
|
+
*/
|
|
836
2035
|
async getMessage(id, token, messageId, options = {}) {
|
|
837
2036
|
return this.rest.get(Routes12.webhookMessage(id, token, messageId), {
|
|
838
2037
|
query: makeURLSearchParams7(options),
|
|
839
2038
|
auth: false
|
|
840
2039
|
});
|
|
841
2040
|
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Edits an associated message from a webhook
|
|
2043
|
+
*
|
|
2044
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#edit-webhook-message}
|
|
2045
|
+
* @param id - The id of the webhook
|
|
2046
|
+
* @param token - The token of the webhook
|
|
2047
|
+
* @param messageId - The id of the message to edit
|
|
2048
|
+
* @param data - The data to use when editing the message
|
|
2049
|
+
*/
|
|
842
2050
|
async editMessage(id, token, messageId, { thread_id, ...body }) {
|
|
843
2051
|
return this.rest.patch(Routes12.webhookMessage(id, token, messageId), {
|
|
844
|
-
query: makeURLSearchParams7({
|
|
2052
|
+
query: makeURLSearchParams7({
|
|
2053
|
+
thread_id
|
|
2054
|
+
}),
|
|
845
2055
|
auth: false,
|
|
846
2056
|
body
|
|
847
2057
|
});
|
|
848
2058
|
}
|
|
2059
|
+
/**
|
|
2060
|
+
* Deletes an associated message from a webhook
|
|
2061
|
+
*
|
|
2062
|
+
* @see {@link https://discord.com/developers/docs/resources/webhook#delete-webhook-message}
|
|
2063
|
+
* @param id - The id of the webhook
|
|
2064
|
+
* @param token - The token of the webhook
|
|
2065
|
+
* @param messageId - The id of the message to delete
|
|
2066
|
+
* @param options - The options to use when deleting the message
|
|
2067
|
+
*/
|
|
849
2068
|
async deleteMessage(id, token, messageId, options = {}) {
|
|
850
2069
|
await this.rest.delete(Routes12.webhookMessage(id, token, messageId), {
|
|
851
2070
|
query: makeURLSearchParams7(options),
|
|
@@ -872,18 +2091,6 @@ var API = class {
|
|
|
872
2091
|
this.webhooks = new WebhooksAPI(rest);
|
|
873
2092
|
this.interactions = new InteractionsAPI(rest, this.webhooks);
|
|
874
2093
|
}
|
|
875
|
-
applicationCommands;
|
|
876
|
-
channels;
|
|
877
|
-
guilds;
|
|
878
|
-
interactions;
|
|
879
|
-
invites;
|
|
880
|
-
oauth2;
|
|
881
|
-
roleConnections;
|
|
882
|
-
stickers;
|
|
883
|
-
threads;
|
|
884
|
-
users;
|
|
885
|
-
voice;
|
|
886
|
-
webhooks;
|
|
887
2094
|
};
|
|
888
2095
|
__name(API, "API");
|
|
889
2096
|
|
|
@@ -893,14 +2100,8 @@ import { calculateShardId } from "@discordjs/util";
|
|
|
893
2100
|
import { WebSocketShardEvents } from "@discordjs/ws";
|
|
894
2101
|
import { DiscordSnowflake } from "@sapphire/snowflake";
|
|
895
2102
|
import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
|
|
896
|
-
import {
|
|
897
|
-
GatewayDispatchEvents,
|
|
898
|
-
GatewayOpcodes
|
|
899
|
-
} from "discord-api-types/v10";
|
|
2103
|
+
import { GatewayDispatchEvents, GatewayOpcodes } from "discord-api-types/v10";
|
|
900
2104
|
var Client = class extends AsyncEventEmitter {
|
|
901
|
-
rest;
|
|
902
|
-
ws;
|
|
903
|
-
api;
|
|
904
2105
|
constructor({ rest, ws }) {
|
|
905
2106
|
super();
|
|
906
2107
|
this.rest = rest;
|
|
@@ -910,6 +2111,13 @@ var Client = class extends AsyncEventEmitter {
|
|
|
910
2111
|
this.emit(dispatch.t, this.wrapIntrinsicProps(dispatch.d, shardId));
|
|
911
2112
|
});
|
|
912
2113
|
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Requests guild members from the gateway.
|
|
2116
|
+
*
|
|
2117
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#request-guild-members}
|
|
2118
|
+
* @param options - The options for the request
|
|
2119
|
+
* @param timeout - The timeout for waiting for each guild members chunk event
|
|
2120
|
+
*/
|
|
913
2121
|
async requestGuildMembers(options, timeout = 1e4) {
|
|
914
2122
|
const shardId = calculateShardId(options.guild_id, await this.ws.getShardCount());
|
|
915
2123
|
const nonce = options.nonce ?? DiscordSnowflake.generate().toString();
|
|
@@ -932,6 +2140,7 @@ var Client = class extends AsyncEventEmitter {
|
|
|
932
2140
|
});
|
|
933
2141
|
await this.ws.send(shardId, {
|
|
934
2142
|
op: GatewayOpcodes.RequestGuildMembers,
|
|
2143
|
+
// eslint-disable-next-line id-length
|
|
935
2144
|
d: {
|
|
936
2145
|
...options,
|
|
937
2146
|
nonce
|
|
@@ -939,16 +2148,30 @@ var Client = class extends AsyncEventEmitter {
|
|
|
939
2148
|
});
|
|
940
2149
|
return promise;
|
|
941
2150
|
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Updates the voice state of the bot user
|
|
2153
|
+
*
|
|
2154
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#update-voice-state}
|
|
2155
|
+
* @param options - The options for updating the voice state
|
|
2156
|
+
*/
|
|
942
2157
|
async updateVoiceState(options) {
|
|
943
2158
|
const shardId = calculateShardId(options.guild_id, await this.ws.getShardCount());
|
|
944
2159
|
await this.ws.send(shardId, {
|
|
945
2160
|
op: GatewayOpcodes.VoiceStateUpdate,
|
|
2161
|
+
// eslint-disable-next-line id-length
|
|
946
2162
|
d: options
|
|
947
2163
|
});
|
|
948
2164
|
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Updates the presence of the bot user
|
|
2167
|
+
*
|
|
2168
|
+
* @param shardId - The id of the shard to update the presence in
|
|
2169
|
+
* @param options - The options for updating the presence
|
|
2170
|
+
*/
|
|
949
2171
|
async updatePresence(shardId, options) {
|
|
950
2172
|
await this.ws.send(shardId, {
|
|
951
2173
|
op: GatewayOpcodes.PresenceUpdate,
|
|
2174
|
+
// eslint-disable-next-line id-length
|
|
952
2175
|
d: options
|
|
953
2176
|
});
|
|
954
2177
|
}
|
|
@@ -975,7 +2198,10 @@ function withFiles(files, options) {
|
|
|
975
2198
|
name: file.name ?? index.toString(),
|
|
976
2199
|
data: file.data
|
|
977
2200
|
}));
|
|
978
|
-
return {
|
|
2201
|
+
return {
|
|
2202
|
+
body,
|
|
2203
|
+
files: outputFiles
|
|
2204
|
+
};
|
|
979
2205
|
}
|
|
980
2206
|
__name(withFiles, "withFiles");
|
|
981
2207
|
|