@zygout/eris 0.19.0 → 0.19.2

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 (88) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +71 -80
  3. package/esm.mjs +72 -72
  4. package/index.d.ts +4407 -4397
  5. package/index.js +75 -75
  6. package/lib/Client.js +4708 -4683
  7. package/lib/Constants.d.ts +990 -988
  8. package/lib/Constants.js +1163 -1161
  9. package/lib/command/Command.js +552 -552
  10. package/lib/command/CommandClient.js +460 -460
  11. package/lib/errors/DiscordHTTPError.js +63 -63
  12. package/lib/errors/DiscordRESTError.js +77 -77
  13. package/lib/gateway/Shard.js +3029 -3029
  14. package/lib/gateway/ShardManager.js +164 -164
  15. package/lib/rest/Endpoints.js +172 -172
  16. package/lib/rest/RequestHandler.js +459 -459
  17. package/lib/structures/ApplicationCommand.js +125 -125
  18. package/lib/structures/AutoModerationRule.js +143 -143
  19. package/lib/structures/AutocompleteInteraction.js +80 -80
  20. package/lib/structures/Base.js +81 -81
  21. package/lib/structures/CategoryChannel.js +77 -77
  22. package/lib/structures/Channel.js +98 -98
  23. package/lib/structures/CommandInteraction.js +473 -473
  24. package/lib/structures/ComponentInteraction.js +538 -538
  25. package/lib/structures/DMChannel.js +278 -278
  26. package/lib/structures/Entitlement.js +77 -77
  27. package/lib/structures/ExtendedUser.js +46 -46
  28. package/lib/structures/ForumChannel.js +24 -24
  29. package/lib/structures/GroupChannel.js +106 -106
  30. package/lib/structures/Guild.js +1677 -1677
  31. package/lib/structures/GuildAuditLogEntry.js +190 -190
  32. package/lib/structures/GuildChannel.js +128 -128
  33. package/lib/structures/GuildIntegration.js +99 -99
  34. package/lib/structures/GuildPreview.js +97 -97
  35. package/lib/structures/GuildScheduledEvent.js +176 -176
  36. package/lib/structures/GuildTemplate.js +76 -76
  37. package/lib/structures/GuildTextableChannel.js +260 -260
  38. package/lib/structures/Interaction.js +133 -133
  39. package/lib/structures/Invite.js +143 -143
  40. package/lib/structures/Lobby.js +108 -108
  41. package/lib/structures/LobbyMember.js +59 -59
  42. package/lib/structures/MediaChannel.js +216 -216
  43. package/lib/structures/Member.js +371 -371
  44. package/lib/structures/Message.js +708 -708
  45. package/lib/structures/ModalSubmitInteraction.js +478 -478
  46. package/lib/structures/NewsChannel.js +34 -34
  47. package/lib/structures/NewsThreadChannel.js +12 -12
  48. package/lib/structures/Permission.js +80 -80
  49. package/lib/structures/PermissionOverwrite.js +32 -32
  50. package/lib/structures/PingInteraction.js +39 -39
  51. package/lib/structures/PrivateThreadChannel.js +25 -25
  52. package/lib/structures/PublicThreadChannel.js +26 -26
  53. package/lib/structures/Role.js +163 -163
  54. package/lib/structures/SKU.js +80 -80
  55. package/lib/structures/SoundboardSound.js +79 -79
  56. package/lib/structures/StageChannel.js +59 -59
  57. package/lib/structures/StageInstance.js +55 -55
  58. package/lib/structures/Subscription.js +69 -69
  59. package/lib/structures/TextChannel.js +202 -202
  60. package/lib/structures/ThreadChannel.js +143 -143
  61. package/lib/structures/ThreadMember.js +59 -59
  62. package/lib/structures/UnavailableGuild.js +26 -26
  63. package/lib/structures/UnknownInteraction.js +502 -502
  64. package/lib/structures/User.js +296 -296
  65. package/lib/structures/VoiceChannel.js +166 -166
  66. package/lib/structures/VoiceState.js +84 -84
  67. package/lib/util/BrowserWebSocket.js +76 -76
  68. package/lib/util/Bucket.js +89 -89
  69. package/lib/util/Collection.js +202 -202
  70. package/lib/util/MultipartData.js +70 -70
  71. package/lib/util/Opus.js +33 -33
  72. package/lib/util/SequentialBucket.js +83 -83
  73. package/lib/util/emitDeprecation.js +26 -26
  74. package/lib/voice/Piper.js +300 -300
  75. package/lib/voice/SharedStream.js +238 -238
  76. package/lib/voice/VoiceConnection.js +1440 -1440
  77. package/lib/voice/VoiceConnectionManager.js +151 -151
  78. package/lib/voice/VoiceDataStream.js +22 -22
  79. package/lib/voice/streams/BaseTransformer.js +40 -40
  80. package/lib/voice/streams/DCAOpusTransformer.js +78 -78
  81. package/lib/voice/streams/FFmpegDuplex.js +192 -192
  82. package/lib/voice/streams/FFmpegOggTransformer.js +35 -35
  83. package/lib/voice/streams/FFmpegPCMTransformer.js +26 -26
  84. package/lib/voice/streams/OggOpusTransformer.js +108 -108
  85. package/lib/voice/streams/PCMOpusTransformer.js +61 -61
  86. package/lib/voice/streams/VolumeTransformer.js +50 -50
  87. package/lib/voice/streams/WebmOpusTransformer.js +258 -258
  88. package/package.json +83 -82
@@ -1,278 +1,278 @@
1
- "use strict";
2
-
3
- const Collection = require("../util/Collection");
4
- const Channel = require("./Channel");
5
- const Message = require("./Message");
6
- const User = require("./User");
7
-
8
- const emitDeprecation = require("../util/emitDeprecation");
9
-
10
- /**
11
- * Represents a DM channel. See Channel for more properties
12
- * @extends Channel
13
- * @prop {String?} lastMessageID The ID of the last message in the channel. This can be null if there has never been a message in the channel
14
- * @prop {Number?} lastPinTimestamp The timestamp of the last pinned message
15
- * @prop {Collection<Message>} messages Collection of Messages in this channel
16
- * @prop {Collection<User>} recipients The recipient in this private channel (this should always contain one entry)
17
- */
18
- class DMChannel extends Channel {
19
- constructor(data, client) {
20
- super(data, client);
21
-
22
- this.lastMessageID = data.last_message_id;
23
- this.recipients = new Collection(User);
24
- data.recipients.forEach((recipient) => {
25
- this.recipients.add(client.users.add(recipient, client));
26
- });
27
- this.messages = new Collection(Message, client.options.messageLimit);
28
-
29
- this.update(data);
30
- }
31
-
32
- update(data) {
33
- this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
34
- }
35
-
36
- /**
37
- * Add a reaction to a message
38
- * @arg {String} messageID The ID of the message
39
- * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
40
- * @returns {Promise}
41
- */
42
- addMessageReaction(messageID, reaction) {
43
- return this._client.addMessageReaction.call(this._client, this.id, messageID, reaction);
44
- }
45
-
46
- /**
47
- * Create a message in the channel
48
- * @arg {String | Object} content A string or object. If an object is passed:
49
- * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
50
- * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
51
- * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
52
- * @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
53
- * @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
54
- * @arg {Array<Object>} [content.attachments] An array of attachment objects with the filename and description
55
- * @arg {String} [content.attachments[].description] The description of the file
56
- * @arg {String} [content.attachments[].filename] The name of the file
57
- * @arg {Number} content.attachments[].id The index of the file
58
- * @arg {Array<Object>} [content.components] An array of component objects
59
- * @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
60
- * @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
61
- * @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
62
- * @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
63
- * @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
64
- * @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
65
- * @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
66
- * @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
67
- * @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
68
- * @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
69
- * @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
70
- * @arg {String} [content.components[].options[].description] The description for this option
71
- * @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
72
- * @arg {String} content.components[].options[].label The label for this option
73
- * @arg {Number | String} content.components[].options[].value The value for this option
74
- * @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
75
- * @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
76
- * @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 1-4, `custom_id` is required; if 5, `url` is required; if 6, `sku_id` is required
77
- * @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container; if 18, it is a label (modals only); if 19, it is a file upload (modals only); if 21, it is a radio group (modals only); if 22, it is a checkbox group (modals only); if 23, it is a checkbox (modals only)
78
- * @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
79
- * @arg {String} [content.content] A content string
80
- * @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
81
- * @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
82
- * @arg {Boolean} [content.enforceNonce] If true and `content.nonce` is present, if multiple messages are sent with the same nonce within a few minutes of each other, that message will be returned and no new message created
83
- * @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages
84
- * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages
85
- * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
86
- * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
87
- * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
88
- * @arg {String} [content.messageReference.type=0] The type of reference. Either `0` (REPLY) or `1` (FORWARDED). Will become required in the future
89
- * @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
90
- * @arg {Object} [content.poll] A poll object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/poll#poll-object) for object structure
91
- * @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
92
- * @arg {Boolean} [content.tts] Set the message TTS flag
93
- * @arg {Object | Array<Object>} [file] A file object (or an Array of them)
94
- * @arg {Buffer} file.file A buffer containing file data
95
- * @arg {String} file.name What to name the file
96
- * @returns {Promise<Message>}
97
- */
98
- createMessage(content, file) {
99
- return this._client.createMessage.call(this._client, this.id, content, file);
100
- }
101
-
102
- /**
103
- * Close the DM Channel. This doesn't really concern bots with DMs.
104
- * @returns {Promise<DMChannel>}
105
- */
106
- delete() {
107
- return this._client.deleteChannel.call(this._client, this.id);
108
- }
109
-
110
- /**
111
- * Delete a message
112
- * @arg {String} messageID The ID of the message
113
- * @returns {Promise}
114
- */
115
- deleteMessage(messageID) {
116
- return this._client.deleteMessage.call(this._client, this.id, messageID);
117
- }
118
-
119
- /**
120
- * Edit a message
121
- * @arg {String} messageID The ID of the message
122
- * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
123
- * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
124
- * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
125
- * @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
126
- * @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
127
- * @arg {Array<Object>} [content.attachments] An array of attachment objects that will be appended to the message, including new files. Only the provided files will be appended
128
- * @arg {String} [content.attachments[].description] The description of the file
129
- * @arg {String} [content.attachments[].filename] The name of the file. This is not required if you are attaching a new file
130
- * @arg {Number | String} content.attachments[].id The ID of the file. If you are attaching a new file, this would be the index of the file
131
- * @arg {Array<Object>} [content.components] An array of component objects
132
- * @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
133
- * @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
134
- * @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
135
- * @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
136
- * @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
137
- * @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
138
- * @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
139
- * @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
140
- * @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
141
- * @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
142
- * @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
143
- * @arg {String} [content.components[].options[].description] The description for this option
144
- * @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
145
- * @arg {String} content.components[].options[].label The label for this option
146
- * @arg {Number | String} content.components[].options[].value The value for this option
147
- * @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
148
- * @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
149
- * @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 1-4, `custom_id` is required; if 5, `url` is required; if 6, `sku_id` is required
150
- * @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container; if 18, it is a label (modals only); if 19, it is a file upload (modals only); if 21, it is a radio group (modals only); if 22, it is a checkbox group (modals only); if 23, it is a checkbox (modals only)
151
- * @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
152
- * @arg {String} [content.content] A content string
153
- * @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
154
- * @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
155
- * @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
156
- * @arg {Buffer} content.file[].file A buffer containing file data
157
- * @arg {String} content.file[].name What to name the file
158
- * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
159
- * @returns {Promise<Message>}
160
- */
161
- editMessage(messageID, content) {
162
- return this._client.editMessage.call(this._client, this.id, messageID, content);
163
- }
164
-
165
- /**
166
- * Get a previous message in the channel
167
- * @arg {String} messageID The ID of the message
168
- * @returns {Promise<Message>}
169
- */
170
- getMessage(messageID) {
171
- return this._client.getMessage.call(this._client, this.id, messageID);
172
- }
173
-
174
- /**
175
- * Get a list of users who reacted with a specific reaction
176
- * @arg {String} messageID The ID of the message
177
- * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
178
- * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
179
- * @arg {String} [options.after] Get users after this user ID
180
- * @arg {Number} [options.limit=100] The maximum number of users to get
181
- * @arg {Number} [options.type=0] The type of reaction (`0` for normal, `1` for burst)
182
- * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
183
- * @arg {String} [after] [DEPRECATED] Get users after this user ID
184
- * @returns {Promise<Array<User>>}
185
- */
186
- getMessageReaction(messageID, reaction, options, before, after) {
187
- return this._client.getMessageReaction.call(this._client, this.id, messageID, reaction, options, before, after);
188
- }
189
-
190
- /**
191
- * Get previous messages in the channel
192
- * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
193
- * @arg {String} [options.after] Get messages after this message ID
194
- * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
195
- * @arg {String} [options.before] Get messages before this message ID
196
- * @arg {Number} [options.limit=50] The max number of messages to get
197
- * @arg {String} [before] [DEPRECATED] Get messages before this message ID
198
- * @arg {String} [after] [DEPRECATED] Get messages after this message ID
199
- * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
200
- * @returns {Promise<Array<Message>>}
201
- */
202
- getMessages(options, before, after, around) {
203
- return this._client.getMessages.call(this._client, this.id, options, before, after, around);
204
- }
205
-
206
- /**
207
- * Get pinned messages in the channel
208
- * @arg {Object} [options] The options to use to get pinned messages
209
- * @arg {Date} [options.before] Get pinned messages before this date
210
- * @arg {Number} [options.limit=50] The max number of pinned messages to get (1-50, default 50)
211
- * @returns {Promise<{hasMore: Boolean, items: Array<{pinnedAt: Number, message: Message}>}>}
212
- */
213
- getPins(options) {
214
- return this._client.getPins.call(this._client, this.id, options);
215
- }
216
-
217
- /**
218
- * Pin a message
219
- * @arg {String} messageID The ID of the message
220
- * @returns {Promise}
221
- */
222
- pinMessage(messageID) {
223
- return this._client.pinMessage.call(this._client, this.id, messageID);
224
- }
225
-
226
- /**
227
- * Remove a reaction from a message
228
- * @arg {String} messageID The ID of the message
229
- * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
230
- * @arg {String} [userID="@me"] The ID of the user to remove the reaction for. Passing this parameter is deprecated and will not be supported in future versions.
231
- * @returns {Promise}
232
- */
233
- removeMessageReaction(messageID, reaction, userID) {
234
- if (userID !== undefined) {
235
- emitDeprecation("DM_REACTION_BEFORE");
236
- this.emit("warn", "[DEPRECATED] removeMessageReaction() was called on a DMChannel with a `userID` argument");
237
- }
238
- return this._client.removeMessageReaction.call(this._client, this.id, messageID, reaction, userID);
239
- }
240
-
241
- /**
242
- * Send typing status in the channel
243
- * @returns {Promise}
244
- */
245
- sendTyping() {
246
- return this._client.sendChannelTyping.call(this._client, this.id);
247
- }
248
-
249
- /**
250
- * Unpin a message
251
- * @arg {String} messageID The ID of the message
252
- * @returns {Promise}
253
- */
254
- unpinMessage(messageID) {
255
- return this._client.unpinMessage.call(this._client, this.id, messageID);
256
- }
257
-
258
- /**
259
- * Un-send a message. You're welcome Programmix
260
- * @arg {String} messageID The ID of the message
261
- * @returns {Promise}
262
- */
263
- unsendMessage(messageID) {
264
- return this._client.deleteMessage.call(this._client, this.id, messageID);
265
- }
266
-
267
- toJSON(props = []) {
268
- return super.toJSON([
269
- "lastMessageID",
270
- "lastPinTimestamp",
271
- "messages",
272
- "recipients",
273
- ...props,
274
- ]);
275
- }
276
- }
277
-
278
- module.exports = DMChannel;
1
+ "use strict";
2
+
3
+ const Collection = require("../util/Collection");
4
+ const Channel = require("./Channel");
5
+ const Message = require("./Message");
6
+ const User = require("./User");
7
+
8
+ const emitDeprecation = require("../util/emitDeprecation");
9
+
10
+ /**
11
+ * Represents a DM channel. See Channel for more properties
12
+ * @extends Channel
13
+ * @prop {String?} lastMessageID The ID of the last message in the channel. This can be null if there has never been a message in the channel
14
+ * @prop {Number?} lastPinTimestamp The timestamp of the last pinned message
15
+ * @prop {Collection<Message>} messages Collection of Messages in this channel
16
+ * @prop {Collection<User>} recipients The recipient in this private channel (this should always contain one entry)
17
+ */
18
+ class DMChannel extends Channel {
19
+ constructor(data, client) {
20
+ super(data, client);
21
+
22
+ this.lastMessageID = data.last_message_id;
23
+ this.recipients = new Collection(User);
24
+ data.recipients.forEach((recipient) => {
25
+ this.recipients.add(client.users.add(recipient, client));
26
+ });
27
+ this.messages = new Collection(Message, client.options.messageLimit);
28
+
29
+ this.update(data);
30
+ }
31
+
32
+ update(data) {
33
+ this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
34
+ }
35
+
36
+ /**
37
+ * Add a reaction to a message
38
+ * @arg {String} messageID The ID of the message
39
+ * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
40
+ * @returns {Promise}
41
+ */
42
+ addMessageReaction(messageID, reaction) {
43
+ return this._client.addMessageReaction.call(this._client, this.id, messageID, reaction);
44
+ }
45
+
46
+ /**
47
+ * Create a message in the channel
48
+ * @arg {String | Object} content A string or object. If an object is passed:
49
+ * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
50
+ * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
51
+ * @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
52
+ * @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
53
+ * @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
54
+ * @arg {Array<Object>} [content.attachments] An array of attachment objects with the filename and description
55
+ * @arg {String} [content.attachments[].description] The description of the file
56
+ * @arg {String} [content.attachments[].filename] The name of the file
57
+ * @arg {Number} content.attachments[].id The index of the file
58
+ * @arg {Array<Object>} [content.components] An array of component objects
59
+ * @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
60
+ * @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
61
+ * @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
62
+ * @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
63
+ * @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
64
+ * @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
65
+ * @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
66
+ * @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
67
+ * @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
68
+ * @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
69
+ * @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
70
+ * @arg {String} [content.components[].options[].description] The description for this option
71
+ * @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
72
+ * @arg {String} content.components[].options[].label The label for this option
73
+ * @arg {Number | String} content.components[].options[].value The value for this option
74
+ * @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
75
+ * @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
76
+ * @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 1-4, `custom_id` is required; if 5, `url` is required; if 6, `sku_id` is required
77
+ * @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container; if 18, it is a label (modals only); if 19, it is a file upload (modals only); if 21, it is a radio group (modals only); if 22, it is a checkbox group (modals only); if 23, it is a checkbox (modals only)
78
+ * @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
79
+ * @arg {String} [content.content] A content string
80
+ * @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
81
+ * @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
82
+ * @arg {Boolean} [content.enforceNonce] If true and `content.nonce` is present, if multiple messages are sent with the same nonce within a few minutes of each other, that message will be returned and no new message created
83
+ * @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages
84
+ * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages
85
+ * @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
86
+ * @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
87
+ * @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
88
+ * @arg {String} [content.messageReference.type=0] The type of reference. Either `0` (REPLY) or `1` (FORWARDED). Will become required in the future
89
+ * @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
90
+ * @arg {Object} [content.poll] A poll object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/poll#poll-object) for object structure
91
+ * @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
92
+ * @arg {Boolean} [content.tts] Set the message TTS flag
93
+ * @arg {Object | Array<Object>} [file] A file object (or an Array of them)
94
+ * @arg {Buffer} file.file A buffer containing file data
95
+ * @arg {String} file.name What to name the file
96
+ * @returns {Promise<Message>}
97
+ */
98
+ createMessage(content, file) {
99
+ return this._client.createMessage.call(this._client, this.id, content, file);
100
+ }
101
+
102
+ /**
103
+ * Close the DM Channel. This doesn't really concern bots with DMs.
104
+ * @returns {Promise<DMChannel>}
105
+ */
106
+ delete() {
107
+ return this._client.deleteChannel.call(this._client, this.id);
108
+ }
109
+
110
+ /**
111
+ * Delete a message
112
+ * @arg {String} messageID The ID of the message
113
+ * @returns {Promise}
114
+ */
115
+ deleteMessage(messageID) {
116
+ return this._client.deleteMessage.call(this._client, this.id, messageID);
117
+ }
118
+
119
+ /**
120
+ * Edit a message
121
+ * @arg {String} messageID The ID of the message
122
+ * @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
123
+ * @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
124
+ * @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
125
+ * @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
126
+ * @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
127
+ * @arg {Array<Object>} [content.attachments] An array of attachment objects that will be appended to the message, including new files. Only the provided files will be appended
128
+ * @arg {String} [content.attachments[].description] The description of the file
129
+ * @arg {String} [content.attachments[].filename] The name of the file. This is not required if you are attaching a new file
130
+ * @arg {Number | String} content.attachments[].id The ID of the file. If you are attaching a new file, this would be the index of the file
131
+ * @arg {Array<Object>} [content.components] An array of component objects
132
+ * @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
133
+ * @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
134
+ * @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
135
+ * @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
136
+ * @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
137
+ * @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
138
+ * @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
139
+ * @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
140
+ * @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
141
+ * @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
142
+ * @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
143
+ * @arg {String} [content.components[].options[].description] The description for this option
144
+ * @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
145
+ * @arg {String} content.components[].options[].label The label for this option
146
+ * @arg {Number | String} content.components[].options[].value The value for this option
147
+ * @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
148
+ * @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
149
+ * @arg {Number} [content.components[].style] The style of the component (type 2 only) - If 1-4, `custom_id` is required; if 5, `url` is required; if 6, `sku_id` is required
150
+ * @arg {Number} content.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container; if 18, it is a label (modals only); if 19, it is a file upload (modals only); if 21, it is a radio group (modals only); if 22, it is a checkbox group (modals only); if 23, it is a checkbox (modals only)
151
+ * @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
152
+ * @arg {String} [content.content] A content string
153
+ * @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
154
+ * @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
155
+ * @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
156
+ * @arg {Buffer} content.file[].file A buffer containing file data
157
+ * @arg {String} content.file[].name What to name the file
158
+ * @arg {Number} [content.flags] A number representing the flags to apply to the message. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#message-object-message-flags) for flags reference
159
+ * @returns {Promise<Message>}
160
+ */
161
+ editMessage(messageID, content) {
162
+ return this._client.editMessage.call(this._client, this.id, messageID, content);
163
+ }
164
+
165
+ /**
166
+ * Get a previous message in the channel
167
+ * @arg {String} messageID The ID of the message
168
+ * @returns {Promise<Message>}
169
+ */
170
+ getMessage(messageID) {
171
+ return this._client.getMessage.call(this._client, this.id, messageID);
172
+ }
173
+
174
+ /**
175
+ * Get a list of users who reacted with a specific reaction
176
+ * @arg {String} messageID The ID of the message
177
+ * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
178
+ * @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
179
+ * @arg {String} [options.after] Get users after this user ID
180
+ * @arg {Number} [options.limit=100] The maximum number of users to get
181
+ * @arg {Number} [options.type=0] The type of reaction (`0` for normal, `1` for burst)
182
+ * @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
183
+ * @arg {String} [after] [DEPRECATED] Get users after this user ID
184
+ * @returns {Promise<Array<User>>}
185
+ */
186
+ getMessageReaction(messageID, reaction, options, before, after) {
187
+ return this._client.getMessageReaction.call(this._client, this.id, messageID, reaction, options, before, after);
188
+ }
189
+
190
+ /**
191
+ * Get previous messages in the channel
192
+ * @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
193
+ * @arg {String} [options.after] Get messages after this message ID
194
+ * @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
195
+ * @arg {String} [options.before] Get messages before this message ID
196
+ * @arg {Number} [options.limit=50] The max number of messages to get
197
+ * @arg {String} [before] [DEPRECATED] Get messages before this message ID
198
+ * @arg {String} [after] [DEPRECATED] Get messages after this message ID
199
+ * @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
200
+ * @returns {Promise<Array<Message>>}
201
+ */
202
+ getMessages(options, before, after, around) {
203
+ return this._client.getMessages.call(this._client, this.id, options, before, after, around);
204
+ }
205
+
206
+ /**
207
+ * Get pinned messages in the channel
208
+ * @arg {Object} [options] The options to use to get pinned messages
209
+ * @arg {Date} [options.before] Get pinned messages before this date
210
+ * @arg {Number} [options.limit=50] The max number of pinned messages to get (1-50, default 50)
211
+ * @returns {Promise<{hasMore: Boolean, items: Array<{pinnedAt: Number, message: Message}>}>}
212
+ */
213
+ getPins(options) {
214
+ return this._client.getPins.call(this._client, this.id, options);
215
+ }
216
+
217
+ /**
218
+ * Pin a message
219
+ * @arg {String} messageID The ID of the message
220
+ * @returns {Promise}
221
+ */
222
+ pinMessage(messageID) {
223
+ return this._client.pinMessage.call(this._client, this.id, messageID);
224
+ }
225
+
226
+ /**
227
+ * Remove a reaction from a message
228
+ * @arg {String} messageID The ID of the message
229
+ * @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
230
+ * @arg {String} [userID="@me"] The ID of the user to remove the reaction for. Passing this parameter is deprecated and will not be supported in future versions.
231
+ * @returns {Promise}
232
+ */
233
+ removeMessageReaction(messageID, reaction, userID) {
234
+ if (userID !== undefined) {
235
+ emitDeprecation("DM_REACTION_BEFORE");
236
+ this.emit("warn", "[DEPRECATED] removeMessageReaction() was called on a DMChannel with a `userID` argument");
237
+ }
238
+ return this._client.removeMessageReaction.call(this._client, this.id, messageID, reaction, userID);
239
+ }
240
+
241
+ /**
242
+ * Send typing status in the channel
243
+ * @returns {Promise}
244
+ */
245
+ sendTyping() {
246
+ return this._client.sendChannelTyping.call(this._client, this.id);
247
+ }
248
+
249
+ /**
250
+ * Unpin a message
251
+ * @arg {String} messageID The ID of the message
252
+ * @returns {Promise}
253
+ */
254
+ unpinMessage(messageID) {
255
+ return this._client.unpinMessage.call(this._client, this.id, messageID);
256
+ }
257
+
258
+ /**
259
+ * Un-send a message. You're welcome Programmix
260
+ * @arg {String} messageID The ID of the message
261
+ * @returns {Promise}
262
+ */
263
+ unsendMessage(messageID) {
264
+ return this._client.deleteMessage.call(this._client, this.id, messageID);
265
+ }
266
+
267
+ toJSON(props = []) {
268
+ return super.toJSON([
269
+ "lastMessageID",
270
+ "lastPinTimestamp",
271
+ "messages",
272
+ "recipients",
273
+ ...props,
274
+ ]);
275
+ }
276
+ }
277
+
278
+ module.exports = DMChannel;