snowtransfer 0.17.7 → 0.18.1

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +4 -5
  4. package/dist/Constants.d.ts +59 -0
  5. package/dist/Constants.js +123 -0
  6. package/dist/Endpoints.d.ts +120 -0
  7. package/dist/Endpoints.js +121 -0
  8. package/dist/RequestHandler.d.ts +258 -0
  9. package/dist/RequestHandler.js +629 -0
  10. package/dist/SnowTransfer.d.ts +70 -0
  11. package/dist/SnowTransfer.js +105 -0
  12. package/dist/StateMachine.d.ts +89 -0
  13. package/dist/StateMachine.js +208 -0
  14. package/dist/StateMachineGraph.d.ts +3 -0
  15. package/dist/StateMachineGraph.js +23 -0
  16. package/dist/Types.d.ts +76 -0
  17. package/dist/Types.js +2 -0
  18. package/dist/index.d.ts +25 -4102
  19. package/dist/index.js +63 -46
  20. package/dist/methods/Assets.d.ts +290 -0
  21. package/dist/methods/Assets.js +326 -0
  22. package/dist/methods/AuditLog.d.ts +40 -0
  23. package/dist/methods/AuditLog.js +44 -0
  24. package/dist/methods/AutoModeration.d.ts +122 -0
  25. package/dist/methods/AutoModeration.js +135 -0
  26. package/dist/methods/Bot.d.ts +65 -0
  27. package/dist/methods/Bot.js +75 -0
  28. package/dist/methods/Channel.d.ts +866 -0
  29. package/dist/methods/Channel.js +982 -0
  30. package/dist/methods/Entitlements.d.ts +87 -0
  31. package/dist/methods/Entitlements.js +99 -0
  32. package/dist/methods/Guild.d.ts +722 -0
  33. package/dist/methods/Guild.js +785 -0
  34. package/dist/methods/GuildScheduledEvent.d.ts +138 -0
  35. package/dist/methods/GuildScheduledEvent.js +155 -0
  36. package/dist/methods/GuildTemplate.d.ts +110 -0
  37. package/dist/methods/GuildTemplate.js +124 -0
  38. package/dist/methods/Interaction.d.ts +339 -0
  39. package/dist/methods/Interaction.js +359 -0
  40. package/dist/methods/Invite.d.ts +81 -0
  41. package/dist/methods/Invite.js +107 -0
  42. package/dist/methods/Sku.d.ts +58 -0
  43. package/dist/methods/Sku.js +66 -0
  44. package/dist/methods/StageInstance.d.ts +86 -0
  45. package/dist/methods/StageInstance.js +97 -0
  46. package/dist/methods/User.d.ts +167 -0
  47. package/dist/methods/User.js +184 -0
  48. package/dist/methods/Voice.d.ts +44 -0
  49. package/dist/methods/Voice.js +52 -0
  50. package/dist/methods/Webhook.d.ts +265 -0
  51. package/dist/methods/Webhook.js +256 -0
  52. package/dist/tokenless.d.ts +19 -0
  53. package/dist/tokenless.js +31 -0
  54. package/package.json +16 -11
  55. package/dist/index.js.map +0 -1
@@ -0,0 +1,982 @@
1
+ "use strict";
2
+ const Endpoints = require("../Endpoints");
3
+ const Constants = require("../Constants");
4
+ const v10_1 = require("discord-api-types/v10");
5
+ /**
6
+ * Methods for interacting with Channels and Messages
7
+ * @since 0.1.0
8
+ */
9
+ class ChannelMethods {
10
+ requestHandler;
11
+ options;
12
+ /**
13
+ * Create a new Channel Method handler
14
+ *
15
+ * Usually SnowTransfer creates a method handler for you, this is here for completion
16
+ *
17
+ * You can access the methods listed via `client.channel.method`, where `client` is an initialized SnowTransfer instance
18
+ * @param requestHandler request handler that calls the rest api
19
+ * @param options Options for the SnowTransfer instance
20
+ */
21
+ constructor(requestHandler, options) {
22
+ this.requestHandler = requestHandler;
23
+ this.options = options;
24
+ }
25
+ /**
26
+ * Get a channel via Id
27
+ * @since 0.1.0
28
+ * @param channelId Id of the channel
29
+ * @returns [discord channel](https://discord.com/developers/docs/resources/channel#channel-object) object
30
+ *
31
+ * @example
32
+ * const client = new SnowTransfer("TOKEN")
33
+ * const channel = await client.channel.getChannel("channel id")
34
+ */
35
+ async getChannel(channelId) {
36
+ return this.requestHandler.request(Endpoints.CHANNEL(channelId), {}, "get", "json");
37
+ }
38
+ async editChannel(channelId, data, reason) {
39
+ return this.requestHandler.request(Endpoints.CHANNEL(channelId), {}, "patch", "json", data, Constants.reasonHeader(reason));
40
+ }
41
+ /**
42
+ * Delete a channel or thread via Id
43
+ *
44
+ * This either **deletes** a Guild Channel/thread or **closes** a Direct Message Channel
45
+ *
46
+ * **Be careful with deleting Guild Channels as this cannot be undone!**
47
+ *
48
+ * When deleting a category, this does **not** delete the child channels of a category. They will just have their `parent_id` removed.
49
+ *
50
+ * For community guilds, the rules channel and the community updates channel cannot be deleted.
51
+ * @since 0.1.0
52
+ * @param channelId Id of the channel
53
+ * @param reason Reason for deleting the channel
54
+ * @returns [discord channel](https://discord.com/developers/docs/resources/channel#channel-object) object
55
+ *
56
+ * | Permissions needed | Condition |
57
+ * |--------------------|--------------------------------|
58
+ * | MANAGE_CHANNELS | if channel is not a DM channel |
59
+ * | MANAGE_THREADS | if channel is a thread |
60
+ *
61
+ * @example
62
+ * // Deletes a channel via id because it wasn't needed anymore
63
+ * const client = new SnowTransfer("TOKEN")
64
+ * client.channel.deleteChannel("channel id", "No longer needed")
65
+ */
66
+ async deleteChannel(channelId, reason) {
67
+ return this.requestHandler.request(Endpoints.CHANNEL(channelId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
68
+ }
69
+ /**
70
+ * Get a list of messages from a channel
71
+ * @since 0.1.0
72
+ * @param channelId Id of the channel
73
+ * @param options Options for getting channel messages
74
+ * @returns Array of [discord message](https://discord.com/developers/docs/resources/channel#message-object) objects
75
+ *
76
+ * | Permissions needed | Condition |
77
+ * |----------------------|----------------------------------------------------------------------------------|
78
+ * | VIEW_CHANNEL | if channel is not a DM channel |
79
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel, unless you want the API to return an empty Array |
80
+ *
81
+ * @example
82
+ * // Fetch the last 20 messages from a channel
83
+ * const client = new SnowTransfer("TOKEN")
84
+ * const options = {
85
+ * limit: 20
86
+ * }
87
+ * const messages = await client.channel.getChannelMessages("channel id", options)
88
+ */
89
+ async getChannelMessages(channelId, options) {
90
+ const query = { limit: 50, ...options };
91
+ if (query.around) {
92
+ delete query.before;
93
+ delete query.after;
94
+ }
95
+ else if (query.before) {
96
+ delete query.around;
97
+ delete query.after;
98
+ }
99
+ else if (query.after) {
100
+ delete query.before;
101
+ delete query.around;
102
+ }
103
+ if (query.limit < Constants.GET_CHANNEL_MESSAGES_MIN_RESULTS ||
104
+ query.limit > Constants.GET_CHANNEL_MESSAGES_MAX_RESULTS)
105
+ throw new RangeError(`Amount of messages that may be requested has to be between ${Constants.GET_CHANNEL_MESSAGES_MIN_RESULTS} and ${Constants.GET_CHANNEL_MESSAGES_MAX_RESULTS}`);
106
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGES(channelId), query, "get", "json");
107
+ }
108
+ /**
109
+ * Get a single message via Id
110
+ * @since 0.1.0
111
+ * @param channelId Id of the channel
112
+ * @param messageId Id of the message
113
+ * @returns [discord message](https://discord.com/developers/docs/resources/channel#message-object) object
114
+ *
115
+ * | Permissions needed | Condition |
116
+ * |----------------------|--------------------------------|
117
+ * | VIEW_CHANNEL | if channel is not a DM channel |
118
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel |
119
+ *
120
+ * @example
121
+ * // Get a single message from a channel via id
122
+ * const client = new SnowTransfer("TOKEN")
123
+ * const message = await client.channel.getChannelMessage("channel id", "message id")
124
+ */
125
+ async getChannelMessage(channelId, messageId) {
126
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE(channelId, messageId), {}, "get", "json");
127
+ }
128
+ /**
129
+ * Creates a new Message within a channel or thread
130
+ *
131
+ * **Make sure to use a filename with a proper extension (e.g. png, jpeg, etc.) when you want to upload files**
132
+ * @since 0.1.0
133
+ * @param channelId Id of the Channel or thread to send a message to
134
+ * @param data Data to send, if data is a string it will be used as the content of the message,
135
+ * if data is not a string you should take a look at the properties below to know what you may send
136
+ * @param options Options for sending this message
137
+ * @returns [discord message](https://discord.com/developers/docs/resources/channel#message-object) object
138
+ *
139
+ * | Permissions needed | Condition |
140
+ * |--------------------------|---------------------------------------------------------------|
141
+ * | VIEW_CHANNEL | if channel is not a DM channel |
142
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel and message is a reply |
143
+ * | SEND_MESSAGES | if channel is not a DM channel and if channel is not a thread |
144
+ * | SEND_TTS_MESSAGES | if channel is not a DM channel and tts is set to true |
145
+ * | SEND_MESSAGES_IN_THREADS | if channel is a thread |
146
+ *
147
+ * @example
148
+ * // Make a bot say "hi" within a channel
149
+ * // createMessage sends the passed data as content, when you give it a string
150
+ * const client = new SnowTransfer("TOKEN")
151
+ * client.channel.createMessage("channel id", "hi")
152
+ *
153
+ * @example
154
+ * // Send a rich embed object
155
+ * const client = new SnowTransfer("TOKEN")
156
+ * const embedData = {
157
+ * title: "This is a nice embed",
158
+ * description: "But winter is so cold",
159
+ * fields: [
160
+ * { name: "Brr", value: "Insert snowflake emoji here" }
161
+ * ]
162
+ * }
163
+ * client.channel.createMessage("channel id", { embeds: [embedData] })
164
+ *
165
+ * @example
166
+ * // Send a file with a comment
167
+ * const client = new SnowTransfer("TOKEN")
168
+ * // fileData will be a buffer with the data of the png image.
169
+ * const fileData = fs.readFileSync("nice_picture.png") // You should probably use fs.promises.readFile, since it is asynchronous, synchronous methods block the thread.
170
+ * client.channel.createMessage("channel id", { content: "This is a nice picture", files: [{ name: "Optional_Filename.png", file: fileData }] })
171
+ */
172
+ async createMessage(channelId, data) {
173
+ if (typeof data !== "string" &&
174
+ !data.content &&
175
+ (!data.message_reference || (data.message_reference?.type !== v10_1.MessageReferenceType.Forward)) &&
176
+ !data.embeds?.length &&
177
+ !data.sticker_ids?.length &&
178
+ !data.components?.length &&
179
+ !data.files?.length &&
180
+ !data.poll)
181
+ throw new Error("Missing content, message_reference type 1, embeds, sticker_ids, components, files, or poll");
182
+ if (typeof data === "string")
183
+ data = { content: data };
184
+ const payload = Constants.cloneUserInput(data);
185
+ if ((payload.content || payload.embeds) &&
186
+ payload.flags &&
187
+ (payload.flags & v10_1.MessageFlags.IsComponentsV2) === v10_1.MessageFlags.IsComponentsV2)
188
+ throw new Error("The message flags was set to include IsComponentsV2, but content and/or embeds were also present. You can either have content/embeds or components v2, not both.");
189
+ // Sanitize the message
190
+ payload.allowed_mentions ??= this.options.allowed_mentions;
191
+ if (payload.files)
192
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGES(channelId), {}, "post", "multipart", await Constants.standardMultipartHandler(payload));
193
+ else
194
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGES(channelId), {}, "post", "json", payload);
195
+ }
196
+ /**
197
+ * Creates a new voice Message within a channel or thread
198
+ * @since 0.10.0
199
+ * @param channelId Id of the Channel or thread to send a message to
200
+ * @param data Buffer of the audio file to send. Tested file types are ogg, mp3, m4a, wav, flac. Other file types work, but some can only be embedded on mobile. Try it and see:tm:
201
+ * @param audioDurationSeconds The duration of the audio file in seconds
202
+ * @param waveform A preview of the entire voice message, with 1 byte per datapoint encoded in base64.
203
+ * Official clients sample the recording at most once per 100 milliseconds, but will downsample so that no more than 256 datapoints are in the waveform.
204
+ * If you have no clue what you're doing or don't want to mess with audio processing, leave this as an empty string (default).
205
+ * Refer to Constants.generateWaveform for guidance on computing it yourself.
206
+ * @returns non editable [discord message](https://discord.com/developers/docs/resources/channel#message-object) object
207
+ *
208
+ * | Permissions needed | Condition |
209
+ * |--------------------------|---------------------------------------------------------------|
210
+ * | VIEW_CHANNEL | if channel is not a DM channel |
211
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel and message is a reply |
212
+ * | SEND_MESSAGES | if channel is not a DM channel and if channel is not a thread |
213
+ * | SEND_MESSAGES_IN_THREADS | if channel is a thread |
214
+ *
215
+ * @example
216
+ * // Send a voice message that has a duration of 6 seconds
217
+ * const client = new SnowTransfer("TOKEN")
218
+ * // fileData will be a buffer with the data of the ogg audio
219
+ * const fileData = fs.readFileSync("6-second-long-audio.ogg") // You should probably use fs.promises.readFile, since it is asynchronous, synchronous methods block the thread.
220
+ * client.channel.createVoiceMessage("channel id", fileData, 6)
221
+ */
222
+ // Code for this function was provided by flazepe on Discord. Thank you <3 https://github.com/flazepe
223
+ async createVoiceMessage(channelId, data, audioDurationSeconds, waveform = "") {
224
+ // create attachment
225
+ const { upload_url, upload_filename } = await this.requestHandler.request(Endpoints.CHANNEL_ATTACHMENTS(channelId), {}, "post", "json", {
226
+ files: [{
227
+ id: "69420",
228
+ filename: "voice-message.ogg",
229
+ file_size: data.byteLength
230
+ }]
231
+ }).then(d => d.attachments[0]);
232
+ // @ts-expect-error A Buffer is compatible as BodyInit. Trust. upload file to cdn
233
+ const uploaded = await this.requestHandler.options.fetch(upload_url, { method: "PUT", body: data });
234
+ if (!uploaded.ok)
235
+ throw new Error(`Uploading the voice message audio failed with status ${uploaded.status}: ${await uploaded.text().catch(() => "")}`);
236
+ // Actually send the voice message
237
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGES(channelId), {}, "post", "json", {
238
+ attachments: [{
239
+ id: "42069",
240
+ uploaded_filename: upload_filename,
241
+ filename: "voice-message.ogg",
242
+ duration_secs: audioDurationSeconds,
243
+ waveform
244
+ }],
245
+ flags: v10_1.MessageFlags.IsVoiceMessage
246
+ });
247
+ }
248
+ /**
249
+ * Crosspost a message in a news channel to all following channels
250
+ * @since 0.3.0
251
+ * @param channelId Id of the news channel
252
+ * @param messageId Id of the message
253
+ * @returns [discord message](https://discord.com/developers/docs/resources/channel#message-object) object
254
+ *
255
+ * | Permissions needed | Condition |
256
+ * |--------------------|------------------------------------------------|
257
+ * | VIEW_CHANNEL | always |
258
+ * | SEND_MESSAGES | if the message was sent by the current user |
259
+ * | MANAGE_MESSAGES | if the message wasn't sent by the current user |
260
+ *
261
+ * @example
262
+ * // Crosspost a message
263
+ * const client = new SnowTransfer("TOKEN")
264
+ * client.channel.crosspostMessage("channel id", "message id")
265
+ */
266
+ async crosspostMessage(channelId, messageId) {
267
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE_CROSSPOST(channelId, messageId), {}, "post", "json");
268
+ }
269
+ /**
270
+ * Adds a reaction to a message
271
+ * @since 0.1.0
272
+ * @param channelId Id of the channel
273
+ * @param messageId Id of the message
274
+ * @param emoji uri encoded reaction emoji to add
275
+ * you may either use a discord emoji in the format `:emoji_name:emoji_id` or a unicode emoji,
276
+ * which can be found [here](http://www.unicode.org/emoji/charts/full-emoji-list.html)
277
+ * @returns Resolves the Promise on successful execution
278
+ *
279
+ * | Permissions needed | Condition |
280
+ * |----------------------|------------------------------------------------------------------------------------|
281
+ * | VIEW_CHANNEL | if channel is not a DM channel |
282
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel |
283
+ * | ADD_REACTIONS | When no other user has reacted with the emoji used and channel is not a DM channel |
284
+ *
285
+ * @example
286
+ * // This example uses a discord emoji
287
+ * const client = new SnowTransfer("TOKEN")
288
+ * client.channel.createReaction("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))
289
+ *
290
+ * @example
291
+ * // using a utf-8 emoji
292
+ * const client = new SnowTransfer("TOKEN")
293
+ * client.channel.createReaction("channel Id", "message Id", encodeURIComponent("😀"))
294
+ */
295
+ async createReaction(channelId, messageId, emoji) {
296
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE_REACTION_USER(channelId, messageId, emoji, "@me"), {}, "put", "json");
297
+ }
298
+ /**
299
+ * Delete a reaction added by the current user from a message
300
+ * @since 0.1.0
301
+ * @param channelId Id of the channel
302
+ * @param messageId Id of the message
303
+ * @param emoji reaction emoji
304
+ * @returns Resolves the Promise on successful execution
305
+ *
306
+ * | Permission | Condition |
307
+ * |----------------------|--------------------------------|
308
+ * | VIEW_CHANNEL | if channel is not a DM channel |
309
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel |
310
+ *
311
+ * @example
312
+ * // This example uses a discord emoji
313
+ * const client = new SnowTransfer("TOKEN")
314
+ * client.channel.deleteReactionSelf("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))
315
+ *
316
+ * @example
317
+ * // using a utf-8 emoji
318
+ * const client = new SnowTransfer("TOKEN")
319
+ * client.channel.deleteReactionSelf("channel Id", "message Id", encodeURIComponent("😀"))
320
+ */
321
+ async deleteReactionSelf(channelId, messageId, emoji) {
322
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE_REACTION_USER(channelId, messageId, emoji, "@me"), {}, "delete", "json");
323
+ }
324
+ /**
325
+ * Delete a reaction from a message in a guild channel
326
+ * @since 0.1.0
327
+ * @param channelId Id of the guild channel
328
+ * @param messageId Id of the message
329
+ * @param emoji reaction emoji
330
+ * @param userId Id of the user
331
+ * @returns Resolves the Promise on successful execution
332
+ *
333
+ * | Permission | Condition |
334
+ * |----------------------|-----------|
335
+ * | MANAGE_MESSAGES | always |
336
+ * | VIEW_CHANNEL | always |
337
+ * | READ_MESSAGE_HISTORY | always |
338
+ *
339
+ * @example
340
+ * // This example uses a discord emoji
341
+ * const client = new SnowTransfer("TOKEN")
342
+ * client.channel.deleteReaction("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"), "user Id")
343
+ *
344
+ * @example
345
+ * // using a utf-8 emoji
346
+ * const client = new SnowTransfer("TOKEN")
347
+ * // If a user Id is not supplied, the emoji from that message will be removed for all users
348
+ * client.channel.deleteReaction("channel Id", "message Id", encodeURIComponent("😀"))
349
+ */
350
+ async deleteReaction(channelId, messageId, emoji, userId) {
351
+ return this.requestHandler.request(userId ? Endpoints.CHANNEL_MESSAGE_REACTION_USER(channelId, messageId, emoji, userId) : Endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, emoji), {}, "delete", "json");
352
+ }
353
+ /**
354
+ * Get a list of users that reacted with a certain emoji on a certain message
355
+ * @since 0.1.0
356
+ * @param channelId Id of the channel
357
+ * @param messageId Id of the message
358
+ * @param emoji reaction emoji
359
+ * @param options Options for getting users
360
+ * @returns Array of [user objects](https://discord.com/developers/docs/resources/user#user-object)
361
+ *
362
+ * | Permissions needed | Condition |
363
+ * |----------------------|--------------------------------|
364
+ * | VIEW_CHANNEL | if channel is not a DM channel |
365
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel |
366
+ *
367
+ * @example
368
+ * // This example uses a discord emoji
369
+ * const client = new SnowTransfer("TOKEN")
370
+ * const reactions = await client.channel.getReactions("channel Id", "message Id", encodeURIComponent("awooo:322522663304036352"))
371
+ */
372
+ async getReactions(channelId, messageId, emoji, options) {
373
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, emoji), options, "get", "json");
374
+ }
375
+ /**
376
+ * Delete all reactions from a message in a guild channel
377
+ * @since 0.1.0
378
+ * @param channelId Id of the guild channel
379
+ * @param messageId Id of the message
380
+ * @returns Resolves the Promise on successful execution
381
+ *
382
+ * | Permissions needed | Condition |
383
+ * |----------------------|-----------|
384
+ * | VIEW_CHANNEL | always |
385
+ * | READ_MESSAGE_HISTORY | always |
386
+ * | MANAGE_MESSAGES | always |
387
+ *
388
+ * @example
389
+ * const client = new SnowTransfer("TOKEN")
390
+ * client.channel.deleteAllReactions("channel Id", "message Id")
391
+ */
392
+ async deleteAllReactions(channelId, messageId) {
393
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE_REACTIONS(channelId, messageId), {}, "delete", "json");
394
+ }
395
+ /**
396
+ * Edit a message sent by the current user or edit the message flags of another user's message
397
+ * @since 0.1.0
398
+ * @param channelId Id of the channel
399
+ * @param messageId Id of the message
400
+ * @param data Data to send
401
+ * @param options Options for editing this message
402
+ * @returns [discord message](https://discord.com/developers/docs/resources/channel#message-object) object
403
+ *
404
+ * | Permissions needed | Condition |
405
+ * |--------------------|--------------------------------------------------|
406
+ * | VIEW_CHANNEL | if channel is not a DM channel |
407
+ * | MANAGE_MESSAGES | When editing someone else's message to set flags |
408
+ *
409
+ * @example
410
+ * // Simple ping response
411
+ * const client = new SnowTransfer("TOKEN")
412
+ * const time = Date.now()
413
+ * const message = await client.channel.createMessage("channel id", "pong")
414
+ * client.channel.editMessage("channel id", message.id, `pong ${Date.now() - time}ms`)
415
+ */
416
+ async editMessage(channelId, messageId, data) {
417
+ if (typeof data === "string")
418
+ data = { content: data };
419
+ const payload = Constants.cloneUserInput(data);
420
+ if ((payload.content || payload.embeds) &&
421
+ payload.flags &&
422
+ (payload.flags & v10_1.MessageFlags.IsComponentsV2) === v10_1.MessageFlags.IsComponentsV2)
423
+ throw new Error("The message flags was set to include IsComponentsV2, but content and/or embeds were also present. You can either have content/embeds or components v2, not both.");
424
+ // Sanitize the message
425
+ payload.allowed_mentions ??= this.options.allowed_mentions;
426
+ if (payload.files)
427
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE(channelId, messageId), {}, "patch", "multipart", await Constants.standardMultipartHandler(payload));
428
+ else
429
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE(channelId, messageId), {}, "patch", "json", payload);
430
+ }
431
+ /**
432
+ * Delete a message
433
+ * @since 0.1.0
434
+ * @param channelId Id of the channel
435
+ * @param messageId Id of the message
436
+ * @param reason Reason for deleting the message
437
+ * @returns Resolves the Promise on successful execution
438
+ *
439
+ * | Permissions needed | Condition |
440
+ * |--------------------|----------------------------------------------|
441
+ * | VIEW_CHANNEL | if channel is not a DM channel |
442
+ * | MANAGE_MESSAGES | When the bot isn't the author of the message |
443
+ *
444
+ * @example
445
+ * // Delete a message
446
+ * const client = new SnowTransfer("TOKEN")
447
+ * client.channel.deleteMessage("channel id", "message id")
448
+ */
449
+ async deleteMessage(channelId, messageId, reason) {
450
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE(channelId, messageId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
451
+ }
452
+ /**
453
+ * Bulk delete messages from a guild channel, messages may not be older than 2 weeks
454
+ * @since 0.18.0
455
+ * @param channelId Id of the guild channel
456
+ * @param messages array of message ids to delete
457
+ * @param reason Reason for deleting the messages
458
+ * @returns Resolves the Promise on successful execution
459
+ *
460
+ * | Permissions needed | Condition |
461
+ * |--------------------|-----------|
462
+ * | VIEW_CHANNEL | always |
463
+ * | MANAGE_MESSAGES | always |
464
+ *
465
+ * @example
466
+ * // Bulk deletes 2 messages with a reason of "spam"
467
+ * const client = new SnowTransfer("TOKEN")
468
+ * client.channel.deleteMessages("channel id", ["message id 1", "message id 2"], "spam")
469
+ */
470
+ async deleteMessages(channelId, messages, reason) {
471
+ if (messages.length < Constants.BULK_DELETE_MESSAGES_MIN || messages.length > Constants.BULK_DELETE_MESSAGES_MAX)
472
+ throw new RangeError(`Amount of messages to be deleted has to be between ${Constants.BULK_DELETE_MESSAGES_MIN} and ${Constants.BULK_DELETE_MESSAGES_MAX}`);
473
+ // (Current date - (discord epoch + 2 weeks)) * (2**22) weird constant that everybody seems to use
474
+ const oldestSnowflake = BigInt(Date.now() - 1421280000000) * (BigInt(2) ** BigInt(22));
475
+ const forbiddenMessage = messages.find(m => BigInt(m) < oldestSnowflake);
476
+ if (forbiddenMessage)
477
+ throw new Error(`The message ${forbiddenMessage} is older than 2 weeks and may not be deleted using the bulk delete endpoint`);
478
+ const data = { messages };
479
+ return this.requestHandler.request(Endpoints.CHANNEL_BULK_DELETE(channelId), {}, "post", "json", data, Constants.reasonHeader(reason));
480
+ }
481
+ /**
482
+ * Modify the permission overwrites of a guild channel
483
+ * @since 0.1.0
484
+ * @param channelId Id of the guild channel
485
+ * @param permissionId Id of the permission overwrite
486
+ * @param data modified [permission overwrite](https://discord.com/developers/docs/resources/channel#edit-channel-permissions-json-params) object
487
+ * @param reason Reason for editing the channel permission
488
+ * @returns Resolves the Promise on successful execution
489
+ *
490
+ * | Permissions needed | Condition |
491
+ * |--------------------|----------------------------|
492
+ * | MANAGE_CHANNELS | if channel is not a thread |
493
+ * | MANAGE_THREADS | if channel is a thread |
494
+ * | MANAGE_ROLES | always |
495
+ * | VIEW_CHANNEL | always |
496
+ *
497
+ * @example
498
+ * // Edits the permissions of a user to allow viewing the channel only
499
+ * const client = new SnowTransfer("TOKEN")
500
+ * client.channel.editChannelPermission("channel id", "user id", { allow: String(1 << 10), type: 1 })
501
+ */
502
+ async editChannelPermission(channelId, permissionId, data, reason) {
503
+ return this.requestHandler.request(Endpoints.CHANNEL_PERMISSION(channelId, permissionId), {}, "put", "json", data, Constants.reasonHeader(reason));
504
+ }
505
+ /**
506
+ * Get a list of invites for a guild channel
507
+ * @since 0.1.0
508
+ * @param channelId Id of the guild channel
509
+ * @returns Array of [invite objects](https://discord.com/developers/docs/resources/invite#invite-object) (with metadata)
510
+ *
511
+ * | Permissions needed | Condition |
512
+ * |--------------------|-----------|
513
+ * | VIEW_CHANNEL | always |
514
+ * | MANAGE_CHANNELS | always |
515
+ *
516
+ * @example
517
+ * const client = new SnowTransfer("TOKEN")
518
+ * const invites = await client.channel.getChannelInvites("channel id")
519
+ */
520
+ async getChannelInvites(channelId) {
521
+ return this.requestHandler.request(Endpoints.CHANNEL_INVITES(channelId), {}, "get", "json");
522
+ }
523
+ /**
524
+ * Create an invite for a guild channel
525
+ *
526
+ * If no data argument is passed, the invite will be created with the defaults
527
+ * @since 0.1.0
528
+ * @param channelId Id of the channel
529
+ * @param data invite data (optional)
530
+ * @param reason Reason for creating the invite
531
+ * @returns [Invite object](https://discord.com/developers/docs/resources/invite#invite-object) (with metadata)
532
+ *
533
+ * | Permissions needed | Condition |
534
+ * |-----------------------|--------------------------------------------------------------------------|
535
+ * | VIEW_CHANNEL | always |
536
+ * | CREATE_INSTANT_INVITE | always |
537
+ * | MANAGE_ROLES | If specifying role_ids. You cannot specify a role higher than the sender |
538
+ *
539
+ * @example
540
+ * // Creates a unique permanent invite with infinite uses
541
+ * const client = new SnowTransfer("TOKEN")
542
+ * const invite = await client.channel.createChannelInvite("channel id", { max_age: 0, max_uses: 0, unique: true })
543
+ */
544
+ async createChannelInvite(channelId, data, reason) {
545
+ const payload = { max_age: 86400, max_uses: 0, temporary: false, unique: false, ...data };
546
+ const targetUsers = payload?.target_users;
547
+ if (targetUsers?.length) {
548
+ delete payload.target_users;
549
+ const form = new FormData();
550
+ await Constants.standardAddToFormHandler(form, "target_users_file", `Users\n${targetUsers.join(",\n")},`, "target_users_file.csv");
551
+ form.append("payload_json", JSON.stringify(payload));
552
+ return this.requestHandler.request(Endpoints.CHANNEL_INVITES(channelId), {}, "post", "multipart", form, Constants.reasonHeader(reason));
553
+ }
554
+ return this.requestHandler.request(Endpoints.CHANNEL_INVITES(channelId), {}, "post", "json", payload, Constants.reasonHeader(reason));
555
+ }
556
+ /**
557
+ * Delete a permission overwrite from a guild channel
558
+ * @since 0.1.0
559
+ * @param channelId Id of the guild channel
560
+ * @param permissionId Id of the permission overwrite
561
+ * @param reason Reason for deleting the permission
562
+ * @returns Resolves the Promise on successful execution
563
+ *
564
+ * | Permissions needed | Condition |
565
+ * |--------------------|----------------------------|
566
+ * | MANAGE_CHANNELS | if channel is not a thread |
567
+ * | MANAGE_THREADS | if channel is a thread |
568
+ * | MANAGE_ROLES | always |
569
+ * | VIEW_CHANNEL | always |
570
+ *
571
+ * @example
572
+ * // Deletes the permission overwrite of a user
573
+ * const client = new SnowTransfer("TOKEN")
574
+ * client.channel.deleteChannelPermission("channel id", "user id", "Abusing channel")
575
+ */
576
+ async deleteChannelPermission(channelId, permissionId, reason) {
577
+ return this.requestHandler.request(Endpoints.CHANNEL_PERMISSION(channelId, permissionId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
578
+ }
579
+ /**
580
+ * Follow an announcement channel to another channel
581
+ * @since 0.7.0
582
+ * @param channelId The Id of the announcement channel
583
+ * @param webhookChannelId The Id of the channel messages will be sent to
584
+ * @param reason Reason for following the annoucement channel
585
+ * @returns A [followed channel](https://discord.com/developers/docs/resources/channel#followed-channel-object) object
586
+ *
587
+ * | Permissions needed | Condition |
588
+ * |--------------------|-----------|
589
+ * | MANAGE_WEBHOOKS | always |
590
+ *
591
+ * @example
592
+ * // Follows an announcement channel to a text channel
593
+ * const client = new SnowTransfer("TOKEN")
594
+ * client.channel.followAnnouncementChannel("news channel id", "text channel id")
595
+ */
596
+ async followAnnouncementChannel(channelId, webhookChannelId, reason) {
597
+ return this.requestHandler.request(Endpoints.CHANNEL_FOLLOWERS(channelId), {}, "post", "json", { webhook_channel_id: webhookChannelId }, Constants.reasonHeader(reason));
598
+ }
599
+ /**
600
+ * Send an indicator that the current user is typing within a channel.
601
+ *
602
+ * **You should generally avoid this method unless used for longer computations (>1s)**
603
+ * @since 0.1.0
604
+ * @param channelId Id of the channel
605
+ * @returns Resolves the Promise on successful execution
606
+ *
607
+ * | Permissions needed | Condition |
608
+ * |--------------------------|--------------------------------|
609
+ * | VIEW_CHANNEL | if channel is not a DM channel |
610
+ * | SEND_MESSAGES | if channel is not a thread |
611
+ * | SEND_MESSAGES_IN_THREADS | if channel is a thread |
612
+ *
613
+ * @example
614
+ * const client = new SnowTransfer("TOKEN")
615
+ * client.channel.startChannelTyping("channel id")
616
+ */
617
+ async startChannelTyping(channelId) {
618
+ return this.requestHandler.request(Endpoints.CHANNEL_TYPING(channelId), {}, "post", "json");
619
+ }
620
+ /**
621
+ * Get a list of pinned messages for a channel
622
+ * @since 0.1.0
623
+ * @param channelId Id of the channel
624
+ * @returns Array of [message objects](https://discord.com/developers/docs/resources/channel#message-object)
625
+ *
626
+ * | Permissions needed | Condition |
627
+ * |----------------------|--------------------------------|
628
+ * | VIEW_CHANNEL | if channel is not a DM channel |
629
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel |
630
+ *
631
+ * @example
632
+ * const client = new SnowTransfer("TOKEN")
633
+ * const messages = await client.channel.getChannelPinnedMessages("channel id")
634
+ */
635
+ async getChannelPinnedMessages(channelId, options) {
636
+ return this.requestHandler.request(Endpoints.CHANNEL_PINS(channelId), options, "get", "json");
637
+ }
638
+ /**
639
+ * Pin a message within a channel
640
+ * @since 0.18.0
641
+ * @param channelId Id of the channel
642
+ * @param messageId Id of the message
643
+ * @param reason Reason for pinning the message
644
+ * @returns Resolves the Promise on successful execution
645
+ *
646
+ * | Permissions needed | Condition |
647
+ * |----------------------|--------------------------------|
648
+ * | VIEW_CHANNEL | if channel is not a DM channel |
649
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel |
650
+ * | PIN_MESSAGES | if channel is not a DM channel |
651
+ *
652
+ * @example
653
+ * // Pin a message because it was a good meme
654
+ * const client = new SnowTransfer("TOKEN")
655
+ * client.channel.createChannelPinnedMessage("channel id", "message id", "Good meme")
656
+ */
657
+ async createChannelPinnedMessage(channelId, messageId, reason) {
658
+ return this.requestHandler.request(Endpoints.CHANNEL_PIN(channelId, messageId), {}, "put", "json", {}, Constants.reasonHeader(reason));
659
+ }
660
+ /**
661
+ * Remove a pinned message from a channel
662
+ * @since 0.18.0
663
+ * @param channelId Id of the channel
664
+ * @param messageId Id of the message
665
+ * @param reason Reason for removing the pinned message
666
+ * @returns Resolves the Promise on successful execution
667
+ *
668
+ * | Permissions needed | Condition |
669
+ * |----------------------|--------------------------------|
670
+ * | VIEW_CHANNEL | if channel is not a DM channel |
671
+ * | READ_MESSAGE_HISTORY | if channel is not a DM channel |
672
+ * | PIN_MESSAGES | if channel is not a DM channel |
673
+ *
674
+ * @example
675
+ * // Remove a pinned message because mod abuse :(
676
+ * const client = new SnowTransfer("TOKEN")
677
+ * client.channel.deleteChannelPinnedMessage("channel id", "message id", "Mod abuse")
678
+ */
679
+ async deleteChannelPinnedMessage(channelId, messageId, reason) {
680
+ return this.requestHandler.request(Endpoints.CHANNEL_PIN(channelId, messageId), {}, "delete", "json", {}, Constants.reasonHeader(reason));
681
+ }
682
+ /**
683
+ * Creates a public thread off a message in a guild channel
684
+ * @since 0.3.0
685
+ * @param channelId Id of the guild channel
686
+ * @param messageId Id of the message
687
+ * @param data Thread meta data
688
+ * @param reason Reason for creating the thread
689
+ * @returns [thread channel](https://discord.com/developers/docs/resources/channel#channel-object) object
690
+ *
691
+ * | Permissions needed | Condition |
692
+ * |-----------------------|-----------|
693
+ * | VIEW_CHANNEL | always |
694
+ * | CREATE_PUBLIC_THREADS | always |
695
+ *
696
+ * @example
697
+ * // Create a thread off a cool art piece to discuss
698
+ * const client = new SnowTransfer("TOKEN")
699
+ * const thread = await client.channel.createThreadWithMessage("channel id", "message id", { name: "cool-art", }, "I wanna talk about it!")
700
+ */
701
+ async createThreadWithMessage(channelId, messageId, data, reason) {
702
+ return this.requestHandler.request(Endpoints.CHANNEL_MESSAGE_THREADS(channelId, messageId), {}, "post", "json", data, Constants.reasonHeader(reason));
703
+ }
704
+ async createThreadWithoutMessage(channelId, data, reason) {
705
+ return this.requestHandler.request(Endpoints.CHANNEL_THREADS(channelId), {}, "post", "json", data, Constants.reasonHeader(reason));
706
+ }
707
+ /**
708
+ * Join a thread
709
+ * @since 0.3.0
710
+ * @param threadId Id of the thread
711
+ * @returns Resolves the Promise on successful execution
712
+ *
713
+ * | Permissions needed | Condition |
714
+ * |--------------------|-----------|
715
+ * | VIEW_CHANNEL | always |
716
+ *
717
+ * @example
718
+ * const client = new SnowTransfer("TOKEN")
719
+ * client.channel.joinThread("thread id")
720
+ */
721
+ async joinThread(threadId) {
722
+ return this.requestHandler.request(Endpoints.CHANNEL_THREAD_MEMBER(threadId, "@me"), {}, "put", "json");
723
+ }
724
+ /**
725
+ * Add a user to a thread
726
+ *
727
+ * CurrentUser must be a member of the thread
728
+ * @since 0.18.0
729
+ * @param threadId Id of the thread
730
+ * @param userId Id of the user to add
731
+ * @returns Resolves the Promise on successful execution
732
+ *
733
+ * | Permissions needed | Condition |
734
+ * |-----------------------------|-----------|
735
+ * | CurrentUser added to Thread | always |
736
+ * | SEND_MESSAGES_IN_THREADS | always |
737
+ *
738
+ * @example
739
+ * const client = new SnowTransfer("TOKEN")
740
+ * client.channel.joinThreadMember("thread id", "user id")
741
+ */
742
+ async joinThreadMember(threadId, userId) {
743
+ return this.requestHandler.request(Endpoints.CHANNEL_THREAD_MEMBER(threadId, userId), {}, "put", "json");
744
+ }
745
+ /**
746
+ * Leave a thread
747
+ * @since 0.3.0
748
+ * @param threadId Id of the thread
749
+ * @returns Resolves the Promise on successful execution
750
+ *
751
+ * @example
752
+ * const client = new SnowTransfer("TOKEN")
753
+ * client.channel.leaveThread("thread id")
754
+ */
755
+ async leaveThread(threadId) {
756
+ return this.requestHandler.request(Endpoints.CHANNEL_THREAD_MEMBER(threadId, "@me"), {}, "delete", "json");
757
+ }
758
+ /**
759
+ * Remove a user from a thread
760
+ * @since 0.18.0
761
+ * @param threadId Id of the thread
762
+ * @param userId Id of the user to remove
763
+ * @returns Resolves the Promise on successful execution
764
+ *
765
+ * | Permissions needed | Condition |
766
+ * |--------------------|------------------------------------------------------|
767
+ * | MANAGE_THREADS | if the current user is not the creator of the thread |
768
+ *
769
+ * @example
770
+ * const client = new SnowTransfer("TOKEN")
771
+ * client.channel.deleteThreadMember("thread id", "user id")
772
+ */
773
+ async deleteThreadMember(threadId, userId) {
774
+ return this.requestHandler.request(Endpoints.CHANNEL_THREAD_MEMBER(threadId, userId), {}, "delete", "json");
775
+ }
776
+ /**
777
+ * Gets a member of a thread
778
+ * @since 0.3.0
779
+ * @param threadId Id of the thread
780
+ * @param userId Id of the user
781
+ * @param withMember If a member object should be present
782
+ * @returns A [thread member](https://discord.com/developers/docs/resources/channel#thread-member-object)
783
+ *
784
+ * | Permissions needed | Condition |
785
+ * |--------------------|-----------|
786
+ * | VIEW_CHANNEL | always |
787
+ *
788
+ * @example
789
+ * const client = new SnowTransfer("TOKEN")
790
+ * const member = await client.channel.getThreadMember("thread id", "user id")
791
+ */
792
+ async getThreadMember(threadId, userId, withMember) {
793
+ return this.requestHandler.request(Endpoints.CHANNEL_THREAD_MEMBER(threadId, userId), { with_member: withMember }, "get", "json");
794
+ }
795
+ /**
796
+ * Gets all members within a thread
797
+ * @since 0.3.0
798
+ * @param channelId Id of the Thread
799
+ * @param options Options for getting members
800
+ * @returns Array of [thread members](https://discord.com/developers/docs/resources/channel#thread-member-object)
801
+ *
802
+ * | Permissions needed | Condition |
803
+ * |--------------------|-----------|
804
+ * | VIEW_CHANNEL | always |
805
+ *
806
+ * | Intents |
807
+ * |---------------|
808
+ * | GUILD_MEMBERS |
809
+ *
810
+ * @example
811
+ * const client = new SnowTransfer("TOKEN")
812
+ * const members = await client.channel.getThreadMembers("thread id")
813
+ */
814
+ async getThreadMembers(channelId, options) {
815
+ return this.requestHandler.request(Endpoints.CHANNEL_THREAD_MEMBERS(channelId), options, "get", "json");
816
+ }
817
+ /**
818
+ * Gets all threads that are public and archived within a guild channel
819
+ * @since 0.3.0
820
+ * @param channelId Id of the guild channel
821
+ * @param options Options for getting threads
822
+ * @returns Object containing [public threads](https://discord.com/developers/docs/resources/channel#channel-object), [thread members](https://discord.com/developers/docs/resources/channel#thread-member-object) of the CurrentUser, and if there are more results in the pagination
823
+ *
824
+ * | Permissions needed | Condition |
825
+ * |----------------------|-----------|
826
+ * | VIEW_CHANNEL | always |
827
+ * | READ_MESSAGE_HISTORY | always |
828
+ *
829
+ * @example
830
+ * const client = new SnowTransfer("TOKEN")
831
+ * const result = await client.channel.getChannelArchivedPublicThreads("channel id")
832
+ */
833
+ async getChannelArchivedPublicThreads(channelId, options) {
834
+ return this.requestHandler.request(Endpoints.CHANNEL_THREADS_ARCHIVED_PUBLIC(channelId), options, "get", "json");
835
+ }
836
+ /**
837
+ * Gets all threads that are private and archived within a guild channel
838
+ *
839
+ * CurrentUser must be a member of the thread if they do not have MANAGE_THREADS permissions
840
+ * @since 0.3.0
841
+ * @param channelId Id of the Channel
842
+ * @param options Options for getting threads
843
+ * @returns Object containing [private threads](https://discord.com/developers/docs/resources/channel#channel-object), [thread members](https://discord.com/developers/docs/resources/channel#thread-member-object) of the CurrentUser, and if there are more results in the pagination
844
+ *
845
+ * | Permissions needed | Condition |
846
+ * |----------------------|--------------------------------------|
847
+ * | VIEW_CHANNEL | always |
848
+ * | READ_MESSAGE_HISTORY | always |
849
+ * | MANAGE_THREADS | if CurrentUser isn't added to Thread |
850
+ *
851
+ * @example
852
+ * const client = new SnowTransfer("TOKEN")
853
+ * const result = await client.channel.getChannelArchivedPrivateThreads("channel id")
854
+ */
855
+ async getChannelArchivedPrivateThreads(channelId, options) {
856
+ return this.requestHandler.request(Endpoints.CHANNEL_THREADS_ARCHIVED_PRIVATE(channelId), options, "get", "json");
857
+ }
858
+ /**
859
+ * Gets all threads that are private and archived within a guild channel that the CurrentUser is apart of
860
+ *
861
+ * CurrentUser must be a member of the thread if they do not have MANAGE_THREADS permissions
862
+ * @since 0.3.0
863
+ * @param channelId Id of the Channel
864
+ * @param options Option for getting threads
865
+ * @returns Object containing [private threads](https://discord.com/developers/docs/resources/channel#channel-object), [thread members](https://discord.com/developers/docs/resources/channel#thread-member-object) of the CurrentUser, and if there are more results in the pagination
866
+ *
867
+ * | Permissions needed | Condition |
868
+ * |--------------------|-----------|
869
+ * | VIEW_CHANNEL | always |
870
+ *
871
+ * @example
872
+ * const client = new SnowTransfer("TOKEN")
873
+ * const result = await client.channel.getChannelArchivedPrivateThreadsUser("channel id")
874
+ */
875
+ async getChannelArchivedPrivateThreadsUser(channelId, options) {
876
+ return this.requestHandler.request(Endpoints.CHANNEL_THREADS_ARCHIVED_PRIVATE_USER(channelId), options, "get", "json");
877
+ }
878
+ /**
879
+ * Refreshes Discord CDN attachments by URL to give you non-expired links. This also works on attachments the token may not have access to through means like guild bot presence
880
+ * @since 0.10.7
881
+ * @param attachments A list of Discord CDN attachment URLs. Does not require the URL(s) to have the expiration info parameters
882
+ * @returns Object containing a list of the original URLs inputted and refreshed URLs
883
+ *
884
+ * @example
885
+ * const client = new SnowTransfer("TOKEN")
886
+ * const result = await client.channel.refreshAttachmentURLs("https://cdn.discordapp.com/attachments/1109362097952931840/1277799507911905280/traveler.gif")
887
+ */
888
+ async refreshAttachmentURLs(attachments) {
889
+ return this.requestHandler.request(Endpoints.ATTACHMENTS_REFRESH_URLS, {}, "post", "json", {
890
+ attachment_urls: Array.isArray(attachments) ? attachments : [attachments]
891
+ });
892
+ }
893
+ /**
894
+ * Get a list of users that voted for this specific answer
895
+ * @since 0.13.0
896
+ * @param channelId Id of the channel
897
+ * @param messageId Id of the message
898
+ * @param answerId Id of the answer
899
+ * @param options Options for getting the poll answers
900
+ * @returns An [answer object](https://discord.com/developers/docs/resources/poll#get-answer-voters-response-body)
901
+ *
902
+ * @example
903
+ * // Get whoever voted for an answer
904
+ * const client = new SnowTransfer("TOKEN")
905
+ * const data = await client.channel.getPollAnswerVoters("channel id", "message id", "answer id")
906
+ */
907
+ async getPollAnswerVoters(channelId, messageId, answerId, options) {
908
+ return this.requestHandler.request(Endpoints.POLL_ANSWER(channelId, messageId, answerId), options, "get", "json");
909
+ }
910
+ /**
911
+ * Immediately ends the poll. You cannot end polls from other users
912
+ * @since 0.13.0
913
+ * @param channelId Id of the channel
914
+ * @param messageId Id of the message
915
+ * @returns A [message object](https://discord.com/developers/docs/resources/message#message-object)
916
+ *
917
+ * @example
918
+ * // End a poll that the bot made
919
+ * const client = new SnowTransfer("TOKEN")
920
+ * client.channel.endPoll("channel id", "message id")
921
+ */
922
+ async endPoll(channelId, messageId) {
923
+ return this.requestHandler.request(Endpoints.POLL_EXPIRE(channelId, messageId), {}, "post", "json");
924
+ }
925
+ /**
926
+ * Sets a voice channel's status message
927
+ * @since 0.17.0
928
+ * @param channelId Id of the channel
929
+ * @param status The new status of the voice channel
930
+ * @param reason Reason for changing the status
931
+ * @returns Resolves the Promise on successful execution
932
+ *
933
+ * | Permissions needed | Condition |
934
+ * |--------------------------|---------------------------------------|
935
+ * | VIEW_CHANNEL | always |
936
+ * | SET_VOICE_CHANNEL_STATUS | always |
937
+ * | MANAGE_CHANNELS | if CurrentUser isn't in voice channel |
938
+ *
939
+ * @example
940
+ * // Sets the status to poggers
941
+ * const client = new SnowTransfer("TOKEN")
942
+ * client.channel.setVoiceChannelStatus("channel id", "poggers")
943
+ *
944
+ * @example
945
+ * // clears the status
946
+ * client.channel.setVoiceChannelStatus("channel id", "")
947
+ */
948
+ async setVoiceChannelStatus(channelId, status, reason) {
949
+ return this.requestHandler.request(Endpoints.CHANNEL_VOICE_STATUS(channelId), {}, "put", "json", { status }, Constants.reasonHeader(reason));
950
+ }
951
+ /**
952
+ * Sets a voice channel's "vibe" as Discord calls it, but it's actually just an image over all participants of a channel others in and not in the channel can see
953
+ * @since 0.17.6
954
+ * @param channelId Id of the channel
955
+ * @param imageUrl URL of an image to display
956
+ * @param reason Reason for changing the image
957
+ * @returns A [Guild Voice Channel](https://discord.com/developers/docs/resources/channel#channel-object)
958
+ *
959
+ * | Permissions needed | Condition |
960
+ * |--------------------------|---------------------------------------|
961
+ * | VIEW_CHANNEL | always |
962
+ * | SET_VOICE_CHANNEL_STATUS | always |
963
+ * | MANAGE_CHANNELS | if CurrentUser isn't in voice channel |
964
+ *
965
+ * @example
966
+ * // Sets the "vibe" image of the voice channel to Rick
967
+ * const client = new SnowTransfer("TOKEN")
968
+ * client.channel.setVoiceChannelHangout("channel id", "https://i3.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg")
969
+ *
970
+ * @example
971
+ * // clears the image
972
+ * client.channel.setVoiceChannelHangout("channel id", "")
973
+ */
974
+ async setVoiceChannelHangout(channelId, imageUrl, reason) {
975
+ return this.requestHandler.request(Endpoints.CHANNEL_VOICE_HANGOUT(channelId), {}, "post", "json", { url: imageUrl }, Constants.reasonHeader(reason));
976
+ }
977
+ }
978
+ module.exports = ChannelMethods;
979
+ // Wolke >>
980
+ // https://www.youtube.com/watch?v=LIlZCmETvsY have a weird video to distract yourself from the problems that will come upon ya
981
+ // PapiOphidian >>
982
+ // Thanks, Wolke :)