@zygout/eris 0.19.0 → 0.19.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.
- package/LICENSE +20 -20
- package/README.md +109 -80
- package/esm.mjs +72 -72
- package/index.d.ts +4407 -4397
- package/index.js +75 -75
- package/lib/Client.js +4708 -4683
- package/lib/Constants.d.ts +990 -988
- package/lib/Constants.js +1163 -1161
- package/lib/command/Command.js +552 -552
- package/lib/command/CommandClient.js +460 -460
- package/lib/errors/DiscordHTTPError.js +63 -63
- package/lib/errors/DiscordRESTError.js +77 -77
- package/lib/gateway/Shard.js +3029 -3029
- package/lib/gateway/ShardManager.js +164 -164
- package/lib/rest/Endpoints.js +172 -172
- package/lib/rest/RequestHandler.js +459 -459
- package/lib/structures/ApplicationCommand.js +125 -125
- package/lib/structures/AutoModerationRule.js +143 -143
- package/lib/structures/AutocompleteInteraction.js +80 -80
- package/lib/structures/Base.js +81 -81
- package/lib/structures/CategoryChannel.js +77 -77
- package/lib/structures/Channel.js +98 -98
- package/lib/structures/CommandInteraction.js +473 -473
- package/lib/structures/ComponentInteraction.js +538 -538
- package/lib/structures/DMChannel.js +278 -278
- package/lib/structures/Entitlement.js +77 -77
- package/lib/structures/ExtendedUser.js +46 -46
- package/lib/structures/ForumChannel.js +24 -24
- package/lib/structures/GroupChannel.js +106 -106
- package/lib/structures/Guild.js +1677 -1677
- package/lib/structures/GuildAuditLogEntry.js +190 -190
- package/lib/structures/GuildChannel.js +128 -128
- package/lib/structures/GuildIntegration.js +99 -99
- package/lib/structures/GuildPreview.js +97 -97
- package/lib/structures/GuildScheduledEvent.js +176 -176
- package/lib/structures/GuildTemplate.js +76 -76
- package/lib/structures/GuildTextableChannel.js +260 -260
- package/lib/structures/Interaction.js +133 -133
- package/lib/structures/Invite.js +143 -143
- package/lib/structures/Lobby.js +108 -108
- package/lib/structures/LobbyMember.js +59 -59
- package/lib/structures/MediaChannel.js +216 -216
- package/lib/structures/Member.js +371 -371
- package/lib/structures/Message.js +708 -708
- package/lib/structures/ModalSubmitInteraction.js +478 -478
- package/lib/structures/NewsChannel.js +34 -34
- package/lib/structures/NewsThreadChannel.js +12 -12
- package/lib/structures/Permission.js +80 -80
- package/lib/structures/PermissionOverwrite.js +32 -32
- package/lib/structures/PingInteraction.js +39 -39
- package/lib/structures/PrivateThreadChannel.js +25 -25
- package/lib/structures/PublicThreadChannel.js +26 -26
- package/lib/structures/Role.js +163 -163
- package/lib/structures/SKU.js +80 -80
- package/lib/structures/SoundboardSound.js +79 -79
- package/lib/structures/StageChannel.js +59 -59
- package/lib/structures/StageInstance.js +55 -55
- package/lib/structures/Subscription.js +69 -69
- package/lib/structures/TextChannel.js +202 -202
- package/lib/structures/ThreadChannel.js +143 -143
- package/lib/structures/ThreadMember.js +59 -59
- package/lib/structures/UnavailableGuild.js +26 -26
- package/lib/structures/UnknownInteraction.js +502 -502
- package/lib/structures/User.js +296 -296
- package/lib/structures/VoiceChannel.js +166 -166
- package/lib/structures/VoiceState.js +84 -84
- package/lib/util/BrowserWebSocket.js +76 -76
- package/lib/util/Bucket.js +89 -89
- package/lib/util/Collection.js +202 -202
- package/lib/util/MultipartData.js +70 -70
- package/lib/util/Opus.js +33 -33
- package/lib/util/SequentialBucket.js +83 -83
- package/lib/util/emitDeprecation.js +26 -26
- package/lib/voice/Piper.js +300 -300
- package/lib/voice/SharedStream.js +238 -238
- package/lib/voice/VoiceConnection.js +1440 -1440
- package/lib/voice/VoiceConnectionManager.js +151 -151
- package/lib/voice/VoiceDataStream.js +22 -22
- package/lib/voice/streams/BaseTransformer.js +40 -40
- package/lib/voice/streams/DCAOpusTransformer.js +78 -78
- package/lib/voice/streams/FFmpegDuplex.js +192 -192
- package/lib/voice/streams/FFmpegOggTransformer.js +35 -35
- package/lib/voice/streams/FFmpegPCMTransformer.js +26 -26
- package/lib/voice/streams/OggOpusTransformer.js +108 -108
- package/lib/voice/streams/PCMOpusTransformer.js +61 -61
- package/lib/voice/streams/VolumeTransformer.js +50 -50
- package/lib/voice/streams/WebmOpusTransformer.js +258 -258
- package/package.json +83 -82
|
@@ -1,260 +1,260 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const Collection = require("../util/Collection");
|
|
4
|
-
const GuildChannel = require("./GuildChannel");
|
|
5
|
-
const Message = require("./Message");
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Represents a textable guild channel. You also probably want to look at NewsChannel, StageChannel, TextChannel, ThreadChannel, and VoiceChannel. See GuildChannel for more properties
|
|
9
|
-
* @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
|
|
10
|
-
* @prop {Collection<Message>} messages Collection of Messages in this channel
|
|
11
|
-
* @prop {Number} rateLimitPerUser The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions)
|
|
12
|
-
*/
|
|
13
|
-
class GuildTextableChannel extends GuildChannel {
|
|
14
|
-
constructor(data, client, messageLimit) {
|
|
15
|
-
super(data, client);
|
|
16
|
-
this.messages = new Collection(Message, messageLimit == null ? client.options.messageLimit : messageLimit);
|
|
17
|
-
this.lastMessageID = data.last_message_id || null;
|
|
18
|
-
this.update(data);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
update(data) {
|
|
22
|
-
super.update(data);
|
|
23
|
-
if (data.rate_limit_per_user !== undefined) {
|
|
24
|
-
this.rateLimitPerUser = data.rate_limit_per_user;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Add a reaction to a message
|
|
30
|
-
* @arg {String} messageID The ID of the message
|
|
31
|
-
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
32
|
-
* @returns {Promise}
|
|
33
|
-
*/
|
|
34
|
-
addMessageReaction(messageID, reaction) {
|
|
35
|
-
return this._client.addMessageReaction.call(this._client, this.id, messageID, reaction);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create a message in the channel
|
|
40
|
-
* @arg {String | Object} content A string or object. If an object is passed:
|
|
41
|
-
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
42
|
-
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
43
|
-
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
|
|
44
|
-
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
45
|
-
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
46
|
-
* @arg {Array<Object>} [content.attachments] An array of attachment objects with the filename and description
|
|
47
|
-
* @arg {String} [content.attachments[].description] The description of the file
|
|
48
|
-
* @arg {String} [content.attachments[].filename] The name of the file
|
|
49
|
-
* @arg {Number} content.attachments[].id The index of the file
|
|
50
|
-
* @arg {Array<Object>} [content.components] An array of [component objects](https://discord.dev/interactions/message-components#component-object)
|
|
51
|
-
* @arg {String} [content.content] A content string
|
|
52
|
-
* @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
|
|
53
|
-
* @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
|
|
54
|
-
* @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
|
|
55
|
-
* @arg {Number} [content.flags] A number representing the [flags](https://discord.dev/resources/channel#message-object-message-flags) to apply to the message (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS)
|
|
56
|
-
* @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages
|
|
57
|
-
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages
|
|
58
|
-
* @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
|
|
59
|
-
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
|
|
60
|
-
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
|
|
61
|
-
* @arg {String} [content.messageReference.type=0] The type of reference. Either `0` (REPLY) or `1` (FORWARDED). Will become required in the future
|
|
62
|
-
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
|
|
63
|
-
* @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
|
|
64
|
-
* @arg {String | Number} [content.nonce] A nonce value which will also appear in the messageCreate event
|
|
65
|
-
* @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
|
|
66
|
-
* @arg {Boolean} [content.tts] Set the message TTS flag
|
|
67
|
-
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
68
|
-
* @arg {Buffer} file.file A buffer containing file data
|
|
69
|
-
* @arg {String} file.name What to name the file
|
|
70
|
-
* @returns {Promise<Message>}
|
|
71
|
-
*/
|
|
72
|
-
createMessage(content, file) {
|
|
73
|
-
return this._client.createMessage.call(this._client, this.id, content, file);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Delete a message
|
|
78
|
-
* @arg {String} messageID The ID of the message
|
|
79
|
-
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
80
|
-
* @returns {Promise}
|
|
81
|
-
*/
|
|
82
|
-
deleteMessage(messageID, reason) {
|
|
83
|
-
return this._client.deleteMessage.call(this._client, this.id, messageID, reason);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Bulk delete messages (bot accounts only)
|
|
88
|
-
* @arg {Array<String>} messageIDs Array of message IDs to delete
|
|
89
|
-
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
90
|
-
* @returns {Promise}
|
|
91
|
-
*/
|
|
92
|
-
deleteMessages(messageIDs, reason) {
|
|
93
|
-
return this._client.deleteMessages.call(this._client, this.id, messageIDs, reason);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Edit a message
|
|
98
|
-
* @arg {String} messageID The ID of the message
|
|
99
|
-
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
|
|
100
|
-
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
101
|
-
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
102
|
-
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
103
|
-
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
104
|
-
* @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
|
|
105
|
-
* @arg {String} [content.attachments[].description] The description of the file
|
|
106
|
-
* @arg {String} [content.attachments[].filename] The name of the file. This is not required if you are attaching a new file
|
|
107
|
-
* @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
|
|
108
|
-
* @arg {Array<Object>} [content.components] An array of [component objects](https://discord.dev/interactions/message-components#component-object)
|
|
109
|
-
* @arg {String} [content.content] A content string
|
|
110
|
-
* @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
|
|
111
|
-
* @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
|
|
112
|
-
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
|
|
113
|
-
* @arg {Buffer} content.file[].file A buffer containing file data
|
|
114
|
-
* @arg {String} content.file[].name What to name the file
|
|
115
|
-
* @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
|
|
116
|
-
* @returns {Promise<Message>}
|
|
117
|
-
*/
|
|
118
|
-
editMessage(messageID, content) {
|
|
119
|
-
return this._client.editMessage.call(this._client, this.id, messageID, content);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Immediately end a poll. Note: You cannot end polls from other users.
|
|
124
|
-
* @arg {String} messageID The ID of the message that the poll is in
|
|
125
|
-
* @returns {Promise<Message>}
|
|
126
|
-
*/
|
|
127
|
-
endPoll(messageID) {
|
|
128
|
-
return this._client.endPoll.call(this._client, this.id, messageID);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Get a previous message in the channel
|
|
133
|
-
* @arg {String} messageID The ID of the message
|
|
134
|
-
* @returns {Promise<Message>}
|
|
135
|
-
*/
|
|
136
|
-
getMessage(messageID) {
|
|
137
|
-
return this._client.getMessage.call(this._client, this.id, messageID);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Get a list of users who reacted with a specific reaction
|
|
142
|
-
* @arg {String} messageID The ID of the message
|
|
143
|
-
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
144
|
-
* @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
|
|
145
|
-
* @arg {String} [options.after] Get users after this user ID
|
|
146
|
-
* @arg {Number} [options.limit=100] The maximum number of users to get
|
|
147
|
-
* @arg {Number} [options.type=0] The type of reaction (`0` for normal, `1` for burst)
|
|
148
|
-
* @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
|
|
149
|
-
* @arg {String} [after] [DEPRECATED] Get users after this user ID
|
|
150
|
-
* @returns {Promise<Array<User>>}
|
|
151
|
-
*/
|
|
152
|
-
getMessageReaction(messageID, reaction, options, before, after) {
|
|
153
|
-
return this._client.getMessageReaction.call(this._client, this.id, messageID, reaction, options, before, after);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Get previous messages in the channel
|
|
158
|
-
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
|
159
|
-
* @arg {String} [options.after] Get messages after this message ID
|
|
160
|
-
* @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
|
|
161
|
-
* @arg {String} [options.before] Get messages before this message ID
|
|
162
|
-
* @arg {Number} [options.limit=50] The max number of messages to get
|
|
163
|
-
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
|
164
|
-
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
|
165
|
-
* @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
|
|
166
|
-
* @returns {Promise<Array<Message>>}
|
|
167
|
-
*/
|
|
168
|
-
getMessages(options, before, after, around) {
|
|
169
|
-
return this._client.getMessages.call(this._client, this.id, options, before, after, around);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Get a list of users that voted for a specific poll answer
|
|
174
|
-
* @arg {String} messageID The ID of the message that the poll is in
|
|
175
|
-
* @arg {Number} answerID The ID of the answer to get voters for
|
|
176
|
-
* @arg {Object} [options] Options for the request
|
|
177
|
-
* @arg {String} [options.after] Get users after this user ID
|
|
178
|
-
* @arg {Number} [options.limit=25] The max number of users to get
|
|
179
|
-
* @returns {Promise<Array<User>>} An array of users who voted for this answer
|
|
180
|
-
*/
|
|
181
|
-
getPollAnswerVoters(messageID, answerID, options) {
|
|
182
|
-
return this._client.getPollAnswerVoters.call(this._client, this.id, messageID, answerID, options);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Purge previous messages in the channel with an optional filter
|
|
187
|
-
* @arg {Object} options Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
|
188
|
-
* @arg {String} [options.after] Get messages after this message ID
|
|
189
|
-
* @arg {String} [options.before] Get messages before this message ID
|
|
190
|
-
* @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object
|
|
191
|
-
* @arg {Number} options.limit The max number of messages to search through, -1 for no limit
|
|
192
|
-
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
|
193
|
-
* @arg {Function} [filter] [DEPRECATED] Optional filter function that returns a boolean when passed a Message object
|
|
194
|
-
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
|
195
|
-
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
|
196
|
-
* @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs
|
|
197
|
-
* @returns {Promise<Number>} Resolves with the number of messages deleted
|
|
198
|
-
*/
|
|
199
|
-
purge(limit, filter, before, after, reason) {
|
|
200
|
-
return this._client.purgeChannel.call(this._client, this.id, limit, filter, before, after, reason);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Remove a reaction from a message
|
|
205
|
-
* @arg {String} messageID The ID of the message
|
|
206
|
-
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
207
|
-
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for
|
|
208
|
-
* @returns {Promise}
|
|
209
|
-
*/
|
|
210
|
-
removeMessageReaction(messageID, reaction, userID) {
|
|
211
|
-
return this._client.removeMessageReaction.call(this._client, this.id, messageID, reaction, userID);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Remove all reactions from a message for a single emoji
|
|
216
|
-
* @arg {String} messageID The ID of the message
|
|
217
|
-
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
218
|
-
* @returns {Promise}
|
|
219
|
-
*/
|
|
220
|
-
removeMessageReactionEmoji(messageID, reaction) {
|
|
221
|
-
return this._client.removeMessageReactionEmoji.call(this._client, this.id, messageID, reaction);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Remove all reactions from a message
|
|
226
|
-
* @arg {String} messageID The ID of the message
|
|
227
|
-
* @returns {Promise}
|
|
228
|
-
*/
|
|
229
|
-
removeMessageReactions(messageID) {
|
|
230
|
-
return this._client.removeMessageReactions.call(this._client, this.id, messageID);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Send typing status in the channel
|
|
235
|
-
* @returns {Promise}
|
|
236
|
-
*/
|
|
237
|
-
sendTyping() {
|
|
238
|
-
return this._client.sendChannelTyping.call(this._client, this.id);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Un-send a message. You're welcome Programmix
|
|
243
|
-
* @arg {String} messageID The ID of the message
|
|
244
|
-
* @returns {Promise}
|
|
245
|
-
*/
|
|
246
|
-
unsendMessage(messageID) {
|
|
247
|
-
return this._client.deleteMessage.call(this.client, this.id, messageID);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
toJSON(props = []) {
|
|
251
|
-
return super.toJSON([
|
|
252
|
-
"lastMessageID",
|
|
253
|
-
"lastPinTimestamp",
|
|
254
|
-
"rateLimitPerUser",
|
|
255
|
-
...props,
|
|
256
|
-
]);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
module.exports = GuildTextableChannel;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Collection = require("../util/Collection");
|
|
4
|
+
const GuildChannel = require("./GuildChannel");
|
|
5
|
+
const Message = require("./Message");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a textable guild channel. You also probably want to look at NewsChannel, StageChannel, TextChannel, ThreadChannel, and VoiceChannel. See GuildChannel for more properties
|
|
9
|
+
* @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
|
|
10
|
+
* @prop {Collection<Message>} messages Collection of Messages in this channel
|
|
11
|
+
* @prop {Number} rateLimitPerUser The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions)
|
|
12
|
+
*/
|
|
13
|
+
class GuildTextableChannel extends GuildChannel {
|
|
14
|
+
constructor(data, client, messageLimit) {
|
|
15
|
+
super(data, client);
|
|
16
|
+
this.messages = new Collection(Message, messageLimit == null ? client.options.messageLimit : messageLimit);
|
|
17
|
+
this.lastMessageID = data.last_message_id || null;
|
|
18
|
+
this.update(data);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
update(data) {
|
|
22
|
+
super.update(data);
|
|
23
|
+
if (data.rate_limit_per_user !== undefined) {
|
|
24
|
+
this.rateLimitPerUser = data.rate_limit_per_user;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Add a reaction to a message
|
|
30
|
+
* @arg {String} messageID The ID of the message
|
|
31
|
+
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
32
|
+
* @returns {Promise}
|
|
33
|
+
*/
|
|
34
|
+
addMessageReaction(messageID, reaction) {
|
|
35
|
+
return this._client.addMessageReaction.call(this._client, this.id, messageID, reaction);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a message in the channel
|
|
40
|
+
* @arg {String | Object} content A string or object. If an object is passed:
|
|
41
|
+
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
42
|
+
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
43
|
+
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
|
|
44
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
45
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
46
|
+
* @arg {Array<Object>} [content.attachments] An array of attachment objects with the filename and description
|
|
47
|
+
* @arg {String} [content.attachments[].description] The description of the file
|
|
48
|
+
* @arg {String} [content.attachments[].filename] The name of the file
|
|
49
|
+
* @arg {Number} content.attachments[].id The index of the file
|
|
50
|
+
* @arg {Array<Object>} [content.components] An array of [component objects](https://discord.dev/interactions/message-components#component-object)
|
|
51
|
+
* @arg {String} [content.content] A content string
|
|
52
|
+
* @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
|
|
53
|
+
* @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
|
|
54
|
+
* @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
|
|
55
|
+
* @arg {Number} [content.flags] A number representing the [flags](https://discord.dev/resources/channel#message-object-message-flags) to apply to the message (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS)
|
|
56
|
+
* @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages
|
|
57
|
+
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages
|
|
58
|
+
* @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
|
|
59
|
+
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
|
|
60
|
+
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
|
|
61
|
+
* @arg {String} [content.messageReference.type=0] The type of reference. Either `0` (REPLY) or `1` (FORWARDED). Will become required in the future
|
|
62
|
+
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
|
|
63
|
+
* @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
|
|
64
|
+
* @arg {String | Number} [content.nonce] A nonce value which will also appear in the messageCreate event
|
|
65
|
+
* @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
|
|
66
|
+
* @arg {Boolean} [content.tts] Set the message TTS flag
|
|
67
|
+
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
68
|
+
* @arg {Buffer} file.file A buffer containing file data
|
|
69
|
+
* @arg {String} file.name What to name the file
|
|
70
|
+
* @returns {Promise<Message>}
|
|
71
|
+
*/
|
|
72
|
+
createMessage(content, file) {
|
|
73
|
+
return this._client.createMessage.call(this._client, this.id, content, file);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Delete a message
|
|
78
|
+
* @arg {String} messageID The ID of the message
|
|
79
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
80
|
+
* @returns {Promise}
|
|
81
|
+
*/
|
|
82
|
+
deleteMessage(messageID, reason) {
|
|
83
|
+
return this._client.deleteMessage.call(this._client, this.id, messageID, reason);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Bulk delete messages (bot accounts only)
|
|
88
|
+
* @arg {Array<String>} messageIDs Array of message IDs to delete
|
|
89
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
90
|
+
* @returns {Promise}
|
|
91
|
+
*/
|
|
92
|
+
deleteMessages(messageIDs, reason) {
|
|
93
|
+
return this._client.deleteMessages.call(this._client, this.id, messageIDs, reason);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Edit a message
|
|
98
|
+
* @arg {String} messageID The ID of the message
|
|
99
|
+
* @arg {String | Array | Object} content A string, array of strings, or object. If an object is passed:
|
|
100
|
+
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
101
|
+
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
102
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
103
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
104
|
+
* @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
|
|
105
|
+
* @arg {String} [content.attachments[].description] The description of the file
|
|
106
|
+
* @arg {String} [content.attachments[].filename] The name of the file. This is not required if you are attaching a new file
|
|
107
|
+
* @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
|
|
108
|
+
* @arg {Array<Object>} [content.components] An array of [component objects](https://discord.dev/interactions/message-components#component-object)
|
|
109
|
+
* @arg {String} [content.content] A content string
|
|
110
|
+
* @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
|
|
111
|
+
* @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
|
|
112
|
+
* @arg {Object | Array<Object>} [content.file] A file object (or an Array of them)
|
|
113
|
+
* @arg {Buffer} content.file[].file A buffer containing file data
|
|
114
|
+
* @arg {String} content.file[].name What to name the file
|
|
115
|
+
* @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
|
|
116
|
+
* @returns {Promise<Message>}
|
|
117
|
+
*/
|
|
118
|
+
editMessage(messageID, content) {
|
|
119
|
+
return this._client.editMessage.call(this._client, this.id, messageID, content);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Immediately end a poll. Note: You cannot end polls from other users.
|
|
124
|
+
* @arg {String} messageID The ID of the message that the poll is in
|
|
125
|
+
* @returns {Promise<Message>}
|
|
126
|
+
*/
|
|
127
|
+
endPoll(messageID) {
|
|
128
|
+
return this._client.endPoll.call(this._client, this.id, messageID);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Get a previous message in the channel
|
|
133
|
+
* @arg {String} messageID The ID of the message
|
|
134
|
+
* @returns {Promise<Message>}
|
|
135
|
+
*/
|
|
136
|
+
getMessage(messageID) {
|
|
137
|
+
return this._client.getMessage.call(this._client, this.id, messageID);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get a list of users who reacted with a specific reaction
|
|
142
|
+
* @arg {String} messageID The ID of the message
|
|
143
|
+
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
144
|
+
* @arg {Object} [options] Options for the request. If this is a number, it is treated as `options.limit` ([DEPRECATED] behavior)
|
|
145
|
+
* @arg {String} [options.after] Get users after this user ID
|
|
146
|
+
* @arg {Number} [options.limit=100] The maximum number of users to get
|
|
147
|
+
* @arg {Number} [options.type=0] The type of reaction (`0` for normal, `1` for burst)
|
|
148
|
+
* @arg {String} [before] [DEPRECATED] Get users before this user ID. Discord no longer supports this parameter
|
|
149
|
+
* @arg {String} [after] [DEPRECATED] Get users after this user ID
|
|
150
|
+
* @returns {Promise<Array<User>>}
|
|
151
|
+
*/
|
|
152
|
+
getMessageReaction(messageID, reaction, options, before, after) {
|
|
153
|
+
return this._client.getMessageReaction.call(this._client, this.id, messageID, reaction, options, before, after);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Get previous messages in the channel
|
|
158
|
+
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
|
159
|
+
* @arg {String} [options.after] Get messages after this message ID
|
|
160
|
+
* @arg {String} [options.around] Get messages around this message ID (does not work with limit > 100)
|
|
161
|
+
* @arg {String} [options.before] Get messages before this message ID
|
|
162
|
+
* @arg {Number} [options.limit=50] The max number of messages to get
|
|
163
|
+
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
|
164
|
+
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
|
165
|
+
* @arg {String} [around] [DEPRECATED] Get messages around this message ID (does not work with limit > 100)
|
|
166
|
+
* @returns {Promise<Array<Message>>}
|
|
167
|
+
*/
|
|
168
|
+
getMessages(options, before, after, around) {
|
|
169
|
+
return this._client.getMessages.call(this._client, this.id, options, before, after, around);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Get a list of users that voted for a specific poll answer
|
|
174
|
+
* @arg {String} messageID The ID of the message that the poll is in
|
|
175
|
+
* @arg {Number} answerID The ID of the answer to get voters for
|
|
176
|
+
* @arg {Object} [options] Options for the request
|
|
177
|
+
* @arg {String} [options.after] Get users after this user ID
|
|
178
|
+
* @arg {Number} [options.limit=25] The max number of users to get
|
|
179
|
+
* @returns {Promise<Array<User>>} An array of users who voted for this answer
|
|
180
|
+
*/
|
|
181
|
+
getPollAnswerVoters(messageID, answerID, options) {
|
|
182
|
+
return this._client.getPollAnswerVoters.call(this._client, this.id, messageID, answerID, options);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Purge previous messages in the channel with an optional filter
|
|
187
|
+
* @arg {Object} options Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
|
|
188
|
+
* @arg {String} [options.after] Get messages after this message ID
|
|
189
|
+
* @arg {String} [options.before] Get messages before this message ID
|
|
190
|
+
* @arg {Function} [options.filter] Optional filter function that returns a boolean when passed a Message object
|
|
191
|
+
* @arg {Number} options.limit The max number of messages to search through, -1 for no limit
|
|
192
|
+
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
|
193
|
+
* @arg {Function} [filter] [DEPRECATED] Optional filter function that returns a boolean when passed a Message object
|
|
194
|
+
* @arg {String} [before] [DEPRECATED] Get messages before this message ID
|
|
195
|
+
* @arg {String} [after] [DEPRECATED] Get messages after this message ID
|
|
196
|
+
* @arg {String} [reason] [DEPRECATED] The reason to be displayed in audit logs
|
|
197
|
+
* @returns {Promise<Number>} Resolves with the number of messages deleted
|
|
198
|
+
*/
|
|
199
|
+
purge(limit, filter, before, after, reason) {
|
|
200
|
+
return this._client.purgeChannel.call(this._client, this.id, limit, filter, before, after, reason);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Remove a reaction from a message
|
|
205
|
+
* @arg {String} messageID The ID of the message
|
|
206
|
+
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
207
|
+
* @arg {String} [userID="@me"] The ID of the user to remove the reaction for
|
|
208
|
+
* @returns {Promise}
|
|
209
|
+
*/
|
|
210
|
+
removeMessageReaction(messageID, reaction, userID) {
|
|
211
|
+
return this._client.removeMessageReaction.call(this._client, this.id, messageID, reaction, userID);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Remove all reactions from a message for a single emoji
|
|
216
|
+
* @arg {String} messageID The ID of the message
|
|
217
|
+
* @arg {String} reaction The reaction (Unicode string if Unicode emoji, `emojiName:emojiID` if custom emoji)
|
|
218
|
+
* @returns {Promise}
|
|
219
|
+
*/
|
|
220
|
+
removeMessageReactionEmoji(messageID, reaction) {
|
|
221
|
+
return this._client.removeMessageReactionEmoji.call(this._client, this.id, messageID, reaction);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Remove all reactions from a message
|
|
226
|
+
* @arg {String} messageID The ID of the message
|
|
227
|
+
* @returns {Promise}
|
|
228
|
+
*/
|
|
229
|
+
removeMessageReactions(messageID) {
|
|
230
|
+
return this._client.removeMessageReactions.call(this._client, this.id, messageID);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Send typing status in the channel
|
|
235
|
+
* @returns {Promise}
|
|
236
|
+
*/
|
|
237
|
+
sendTyping() {
|
|
238
|
+
return this._client.sendChannelTyping.call(this._client, this.id);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Un-send a message. You're welcome Programmix
|
|
243
|
+
* @arg {String} messageID The ID of the message
|
|
244
|
+
* @returns {Promise}
|
|
245
|
+
*/
|
|
246
|
+
unsendMessage(messageID) {
|
|
247
|
+
return this._client.deleteMessage.call(this.client, this.id, messageID);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
toJSON(props = []) {
|
|
251
|
+
return super.toJSON([
|
|
252
|
+
"lastMessageID",
|
|
253
|
+
"lastPinTimestamp",
|
|
254
|
+
"rateLimitPerUser",
|
|
255
|
+
...props,
|
|
256
|
+
]);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
module.exports = GuildTextableChannel;
|