@zygout/eris 0.0.0-stage → 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 -0
- package/README.md +108 -2
- package/esm.mjs +72 -0
- package/index.d.ts +4407 -0
- package/index.js +75 -0
- package/lib/Client.js +4708 -0
- package/lib/Constants.d.ts +990 -0
- package/lib/Constants.js +1163 -0
- package/lib/command/Command.js +552 -0
- package/lib/command/CommandClient.js +460 -0
- package/lib/errors/DiscordHTTPError.js +63 -0
- package/lib/errors/DiscordRESTError.js +77 -0
- package/lib/gateway/Shard.js +3029 -0
- package/lib/gateway/ShardManager.js +164 -0
- package/lib/rest/Endpoints.js +172 -0
- package/lib/rest/RequestHandler.js +459 -0
- package/lib/structures/ApplicationCommand.js +125 -0
- package/lib/structures/AutoModerationRule.js +143 -0
- package/lib/structures/AutocompleteInteraction.js +80 -0
- package/lib/structures/Base.js +81 -0
- package/lib/structures/CategoryChannel.js +77 -0
- package/lib/structures/Channel.js +98 -0
- package/lib/structures/CommandInteraction.js +473 -0
- package/lib/structures/ComponentInteraction.js +538 -0
- package/lib/structures/DMChannel.js +278 -0
- package/lib/structures/Entitlement.js +77 -0
- package/lib/structures/ExtendedUser.js +46 -0
- package/lib/structures/ForumChannel.js +24 -0
- package/lib/structures/GroupChannel.js +106 -0
- package/lib/structures/Guild.js +1677 -0
- package/lib/structures/GuildAuditLogEntry.js +190 -0
- package/lib/structures/GuildChannel.js +128 -0
- package/lib/structures/GuildIntegration.js +99 -0
- package/lib/structures/GuildPreview.js +97 -0
- package/lib/structures/GuildScheduledEvent.js +176 -0
- package/lib/structures/GuildTemplate.js +76 -0
- package/lib/structures/GuildTextableChannel.js +260 -0
- package/lib/structures/Interaction.js +133 -0
- package/lib/structures/Invite.js +143 -0
- package/lib/structures/Lobby.js +108 -0
- package/lib/structures/LobbyMember.js +59 -0
- package/lib/structures/MediaChannel.js +216 -0
- package/lib/structures/Member.js +371 -0
- package/lib/structures/Message.js +708 -0
- package/lib/structures/ModalSubmitInteraction.js +478 -0
- package/lib/structures/NewsChannel.js +34 -0
- package/lib/structures/NewsThreadChannel.js +12 -0
- package/lib/structures/Permission.js +80 -0
- package/lib/structures/PermissionOverwrite.js +32 -0
- package/lib/structures/PingInteraction.js +39 -0
- package/lib/structures/PrivateThreadChannel.js +25 -0
- package/lib/structures/PublicThreadChannel.js +26 -0
- package/lib/structures/Role.js +163 -0
- package/lib/structures/SKU.js +80 -0
- package/lib/structures/SoundboardSound.js +79 -0
- package/lib/structures/StageChannel.js +59 -0
- package/lib/structures/StageInstance.js +55 -0
- package/lib/structures/Subscription.js +69 -0
- package/lib/structures/TextChannel.js +202 -0
- package/lib/structures/ThreadChannel.js +143 -0
- package/lib/structures/ThreadMember.js +59 -0
- package/lib/structures/UnavailableGuild.js +26 -0
- package/lib/structures/UnknownInteraction.js +502 -0
- package/lib/structures/User.js +296 -0
- package/lib/structures/VoiceChannel.js +166 -0
- package/lib/structures/VoiceState.js +84 -0
- package/lib/util/BrowserWebSocket.js +76 -0
- package/lib/util/Bucket.js +89 -0
- package/lib/util/Collection.js +202 -0
- package/lib/util/MultipartData.js +70 -0
- package/lib/util/Opus.js +33 -0
- package/lib/util/SequentialBucket.js +83 -0
- package/lib/util/emitDeprecation.js +26 -0
- package/lib/voice/Piper.js +300 -0
- package/lib/voice/SharedStream.js +238 -0
- package/lib/voice/VoiceConnection.js +1440 -0
- package/lib/voice/VoiceConnectionManager.js +151 -0
- package/lib/voice/VoiceDataStream.js +22 -0
- package/lib/voice/streams/BaseTransformer.js +40 -0
- package/lib/voice/streams/DCAOpusTransformer.js +78 -0
- package/lib/voice/streams/FFmpegDuplex.js +192 -0
- package/lib/voice/streams/FFmpegOggTransformer.js +35 -0
- package/lib/voice/streams/FFmpegPCMTransformer.js +26 -0
- package/lib/voice/streams/OggOpusTransformer.js +108 -0
- package/lib/voice/streams/PCMOpusTransformer.js +61 -0
- package/lib/voice/streams/VolumeTransformer.js +50 -0
- package/lib/voice/streams/WebmOpusTransformer.js +258 -0
- package/package.json +81 -4
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents an entitlement
|
|
7
|
+
* @prop {String} applicationID The ID of the parent application
|
|
8
|
+
* @prop {Boolean} consumed For consumable items, whether or not the entitlement has been consumed
|
|
9
|
+
* @prop {Boolean} deleted Whether the entitlement was deleted
|
|
10
|
+
* @prop {Number?} endsAt Timestamp of when the entitlement is no longer valid
|
|
11
|
+
* @prop {String?} guildID The ID of the guild that is granted access to the SKU, if any
|
|
12
|
+
* @prop {String} id The ID of the entitlement
|
|
13
|
+
* @prop {String} skuID The ID of the SKU
|
|
14
|
+
* @prop {Number?} startsAt Timestamp of when the entitlement starts being valid
|
|
15
|
+
* @prop {Number} type The type of entitlement. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/entitlement#entitlement-object-entitlement-types) for a list of types
|
|
16
|
+
* @prop {String?} userID The ID of the user that is granted access to the SKU, if any
|
|
17
|
+
*/
|
|
18
|
+
class Entitlement extends Base {
|
|
19
|
+
constructor(data, client) {
|
|
20
|
+
super(data.id);
|
|
21
|
+
this._client = client;
|
|
22
|
+
this.applicationID = data.application_id;
|
|
23
|
+
this.guildID = data.guild_id !== undefined ? data.guild_id : null;
|
|
24
|
+
this.skuID = data.sku_id;
|
|
25
|
+
this.type = data.type;
|
|
26
|
+
this.userID = data.user_id !== undefined ? data.user_id : null;
|
|
27
|
+
this.update(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
update(data) {
|
|
31
|
+
if (data.consumed !== undefined) {
|
|
32
|
+
this.consumed = data.consumed;
|
|
33
|
+
}
|
|
34
|
+
if (data.deleted !== undefined) {
|
|
35
|
+
this.deleted = data.deleted;
|
|
36
|
+
}
|
|
37
|
+
if (data.ends_at !== undefined) {
|
|
38
|
+
this.endsAt = data.ends_at ? Date.parse(data.ends_at) : null;
|
|
39
|
+
}
|
|
40
|
+
if (data.starts_at !== undefined) {
|
|
41
|
+
this.startsAt = data.starts_at ? Date.parse(data.starts_at) : null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Mark this entitlement as consumed. Only available for one-time purchase consumable SKUs
|
|
47
|
+
* @returns {Promise}
|
|
48
|
+
*/
|
|
49
|
+
consume() {
|
|
50
|
+
return this._client.consumeEntitlement.call(this._client, this.id);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Delete this entitlement. Only available for test entitlements
|
|
55
|
+
* @returns {Promise}
|
|
56
|
+
*/
|
|
57
|
+
delete() {
|
|
58
|
+
return this._client.deleteTestEntitlement.call(this._client, this.id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
toJSON(props = []) {
|
|
62
|
+
return super.toJSON([
|
|
63
|
+
"applicationID",
|
|
64
|
+
"consumed",
|
|
65
|
+
"deleted",
|
|
66
|
+
"endsAt",
|
|
67
|
+
"guildID",
|
|
68
|
+
"skuID",
|
|
69
|
+
"startsAt",
|
|
70
|
+
"type",
|
|
71
|
+
"userID",
|
|
72
|
+
...props,
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = Entitlement;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const User = require("./User");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents an extended user
|
|
7
|
+
* @extends User
|
|
8
|
+
* @prop {String?} email The email of the user
|
|
9
|
+
* @prop {Boolean?} mfaEnabled Whether the user has enabled two-factor authentication
|
|
10
|
+
* @prop {Number?} premiumType The type of Nitro subscription on the user's account
|
|
11
|
+
* @prop {Boolean?} verified Whether the account email has been verified
|
|
12
|
+
*/
|
|
13
|
+
class ExtendedUser extends User {
|
|
14
|
+
constructor(data, client) {
|
|
15
|
+
super(data, client);
|
|
16
|
+
this.update(data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
update(data) {
|
|
20
|
+
super.update(data);
|
|
21
|
+
if (data.email !== undefined) {
|
|
22
|
+
this.email = data.email;
|
|
23
|
+
}
|
|
24
|
+
if (data.verified !== undefined) {
|
|
25
|
+
this.verified = data.verified;
|
|
26
|
+
}
|
|
27
|
+
if (data.mfa_enabled !== undefined) {
|
|
28
|
+
this.mfaEnabled = data.mfa_enabled;
|
|
29
|
+
}
|
|
30
|
+
if (data.premium_type !== undefined) {
|
|
31
|
+
this.premiumType = data.premium_type;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
toJSON(props = []) {
|
|
36
|
+
return super.toJSON([
|
|
37
|
+
"email",
|
|
38
|
+
"mfaEnabled",
|
|
39
|
+
"premium",
|
|
40
|
+
"verified",
|
|
41
|
+
...props,
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = ExtendedUser;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const MediaChannel = require("./MediaChannel");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a guild forum channel. See MediaChannel for more properties and methods
|
|
7
|
+
* @extends MediaChannel
|
|
8
|
+
* @prop {Number} defaultForumLayout The default forum layout type used to display posts in the channel
|
|
9
|
+
*/
|
|
10
|
+
class ForumChannel extends MediaChannel {
|
|
11
|
+
constructor(data, client) {
|
|
12
|
+
super(data, client);
|
|
13
|
+
this.defaultForumLayout = data.default_forum_layout;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
toJSON(props = []) {
|
|
17
|
+
return super.toJSON([
|
|
18
|
+
"defaultForumLayout",
|
|
19
|
+
...props,
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = ForumChannel;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Channel = require("./Channel");
|
|
4
|
+
const Collection = require("../util/Collection");
|
|
5
|
+
const Endpoints = require("../rest/Endpoints");
|
|
6
|
+
const User = require("./User");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents a group channel. Bots cannot get data for user-created Group channels. See Channel for additional properties
|
|
10
|
+
* @extends Channel
|
|
11
|
+
* @prop {String} applicationID The application ID of the bot that created the group DM
|
|
12
|
+
* @prop {String?} icon The hash of the group channel icon
|
|
13
|
+
* @prop {String?} iconURL The URL of the group channel icon
|
|
14
|
+
* @prop {String?} lastMessageID The ID of the last message in this channel
|
|
15
|
+
* @prop {Number?} lastPinTimestamp The timestamp of the last pinned message
|
|
16
|
+
* @prop {Boolean} managed Whether the group channel is managed by an application (should always be `true`)
|
|
17
|
+
* @prop {String} name The name of the group channel
|
|
18
|
+
* @prop {String} ownerID The ID of the user that is the group owner
|
|
19
|
+
* @prop {Collection<User>} recipients The recipients in the group channel
|
|
20
|
+
*/
|
|
21
|
+
class GroupChannel extends Channel {
|
|
22
|
+
constructor(data, client) {
|
|
23
|
+
super(data, client);
|
|
24
|
+
this.applicationID = data.applicationID;
|
|
25
|
+
this.lastMessageID = data.last_message_id;
|
|
26
|
+
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
27
|
+
this.managed = data.managed;
|
|
28
|
+
this.name = data.name;
|
|
29
|
+
this.ownerID = data.owner_id;
|
|
30
|
+
this.icon = data.icon;
|
|
31
|
+
this.recipients = new Collection(User);
|
|
32
|
+
data.recipients.forEach((recipient) => {
|
|
33
|
+
this.recipients.add(client.users.add(recipient, client));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get iconURL() {
|
|
38
|
+
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon)) : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Add a user to the group
|
|
43
|
+
* @arg {String} userID The ID of the user to add
|
|
44
|
+
* @arg {Object} options The options for adding the user
|
|
45
|
+
* @arg {String} options.accessToken The access token of the user to add. Requires having been authorized with the `gdm.join` scope
|
|
46
|
+
* @arg {String} [options.nick] The nickname to give the user
|
|
47
|
+
* @returns {Promise}
|
|
48
|
+
*/
|
|
49
|
+
addRecipient(userID, options) {
|
|
50
|
+
return this._client.addGroupRecipient.call(this._client, this.id, userID, options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Delete the Group Channel
|
|
55
|
+
* @returns {Promise<GroupChannel>}
|
|
56
|
+
*/
|
|
57
|
+
delete() {
|
|
58
|
+
return this._client.deleteChannel.call(this._client, this.id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get the group's icon with the given format and size
|
|
63
|
+
* @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp")
|
|
64
|
+
* @arg {Number} [size] The size of the icon (any power of two between 16 and 4096)
|
|
65
|
+
* @returns {String?}
|
|
66
|
+
*/
|
|
67
|
+
dynamicIconURL(format, size) {
|
|
68
|
+
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon), format, size) : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Edit the channel's properties
|
|
73
|
+
* @arg {Object} options The properties to edit
|
|
74
|
+
* @arg {String?} [options.icon] The icon of the channel as a base64 data URI (group channels only). Note: base64 strings alone are not base64 data URI strings
|
|
75
|
+
* @arg {String} [options.name] The name of the channel
|
|
76
|
+
* @returns {Promise<GroupChannel>}
|
|
77
|
+
*/
|
|
78
|
+
edit(options) {
|
|
79
|
+
return this._client.editChannel.call(this._client, this.id, options);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Remove a user from the group
|
|
84
|
+
* @arg {String} userID The ID of the target user
|
|
85
|
+
* @returns {Promise}
|
|
86
|
+
*/
|
|
87
|
+
removeRecipient(userID) {
|
|
88
|
+
return this._client.removeGroupRecipient.call(this._client, this.id, userID);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
toJSON(props = []) {
|
|
92
|
+
return super.toJSON([
|
|
93
|
+
"applicationID",
|
|
94
|
+
"icon",
|
|
95
|
+
"lastMessageID",
|
|
96
|
+
"lastPinTimestamp",
|
|
97
|
+
"managed",
|
|
98
|
+
"name",
|
|
99
|
+
"ownerID",
|
|
100
|
+
"recipients",
|
|
101
|
+
...props,
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = GroupChannel;
|