@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,502 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Interaction = require("./Interaction");
|
|
4
|
+
const Message = require("./Message");
|
|
5
|
+
const { InteractionResponseTypes } = require("../Constants");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents an unknown interaction. See Interaction for more properties.
|
|
9
|
+
* Note: Methods are not guaranteed to work properly, they are all added just in case you know which to use.
|
|
10
|
+
* @extends Interaction
|
|
11
|
+
* @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
|
|
12
|
+
* @prop {(DMChannel | TextChannel | NewsChannel)?} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached.
|
|
13
|
+
* @prop {Object?} data The data attached to the interaction
|
|
14
|
+
* @prop {String?} guildID The ID of the guild in which the interaction was created
|
|
15
|
+
* @prop {Member?} member The member who triggered the interaction (This is only sent when the interaction is invoked within a guild)
|
|
16
|
+
* @prop {Message?} message The message the interaction came from (Message Component only). If the message is ephemeral, this will be an object with `id` and `flags` keys.
|
|
17
|
+
* @prop {User?} user The user who triggered the interaction (This is only sent when the interaction is invoked within a dm)
|
|
18
|
+
*/
|
|
19
|
+
class UnknownInteraction extends Interaction {
|
|
20
|
+
constructor(info, client) {
|
|
21
|
+
super(info, client);
|
|
22
|
+
|
|
23
|
+
if (info.channel_id !== undefined) {
|
|
24
|
+
this.channel = this._client.getChannel(info.channel_id) || {
|
|
25
|
+
id: info.channel_id,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (info.data !== undefined) {
|
|
30
|
+
this.data = info.data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (info.guild_id !== undefined) {
|
|
34
|
+
this.guildID = info.guild_id;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (info.member !== undefined) {
|
|
38
|
+
this.member = this._resolveMember(info.member, info);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (info.message !== undefined) {
|
|
42
|
+
this.message = new Message(info.message, this._client);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (info.user !== undefined) {
|
|
46
|
+
this.user = this._client.users.update(info.user, client);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Acknowledges the autocomplete interaction with a result of choices.
|
|
52
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
|
53
|
+
* @arg {Object} data The data object
|
|
54
|
+
* @arg {Object} data.data The data to return to discord
|
|
55
|
+
* @arg {Number} data.type The type of [interaction response](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type) to send
|
|
56
|
+
* @returns {Promise}
|
|
57
|
+
*/
|
|
58
|
+
async acknowledge(data) {
|
|
59
|
+
if (this.acknowledged === true) {
|
|
60
|
+
throw new Error("You have already acknowledged this interaction.");
|
|
61
|
+
}
|
|
62
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, data).then(() => this.update());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Respond to the interaction with a followup message
|
|
67
|
+
* @arg {String | Object} content A string or object. If an object is passed:
|
|
68
|
+
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
69
|
+
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
70
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
71
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
72
|
+
* @arg {Array<Object>} [content.attachments] An array of attachment objects with the filename and description
|
|
73
|
+
* @arg {String} [content.attachments[].description] The description of the file
|
|
74
|
+
* @arg {String} [content.attachments[].filename] The name of the file
|
|
75
|
+
* @arg {Number} content.attachments[].id The index of the file
|
|
76
|
+
* @arg {Array<Object>} [content.components] An array of component objects
|
|
77
|
+
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
|
|
78
|
+
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
|
|
79
|
+
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
|
80
|
+
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
|
81
|
+
* @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
|
|
82
|
+
* @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
|
|
83
|
+
* @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
|
|
84
|
+
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
|
85
|
+
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
|
86
|
+
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
|
87
|
+
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
|
88
|
+
* @arg {String} [content.components[].options[].description] The description for this option
|
|
89
|
+
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
|
90
|
+
* @arg {String} content.components[].options[].label The label for this option
|
|
91
|
+
* @arg {Number | String} content.components[].options[].value The value for this option
|
|
92
|
+
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
|
|
93
|
+
* @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
|
|
94
|
+
* @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
|
|
95
|
+
* @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)
|
|
96
|
+
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
|
97
|
+
* @arg {String} [content.content] A content string
|
|
98
|
+
* @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
|
|
99
|
+
* @arg {Array<Object>} [options.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
|
|
100
|
+
* @arg {Number} [content.flags] 64 for Ephemeral
|
|
101
|
+
* @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
|
|
102
|
+
* @arg {Boolean} [content.tts] Set the message TTS flag
|
|
103
|
+
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
104
|
+
* @arg {Buffer} file.file A buffer containing file data
|
|
105
|
+
* @arg {String} file.name What to name the file
|
|
106
|
+
* @returns {Promise<Message?>}
|
|
107
|
+
*/
|
|
108
|
+
async createFollowup(content, file) {
|
|
109
|
+
if (this.acknowledged === false) {
|
|
110
|
+
throw new Error("createFollowup cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, pong, or result first.");
|
|
111
|
+
}
|
|
112
|
+
if (content !== undefined) {
|
|
113
|
+
if (typeof content !== "object" || content === null) {
|
|
114
|
+
content = {
|
|
115
|
+
content: "" + content,
|
|
116
|
+
};
|
|
117
|
+
} else if (content.content !== undefined && typeof content.content !== "string") {
|
|
118
|
+
content.content = "" + content.content;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (file) {
|
|
122
|
+
content.file = file;
|
|
123
|
+
}
|
|
124
|
+
return this._client.executeWebhook.call(this._client, this.applicationID, this.token, Object.assign({ wait: true }, content));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Acknowledges the interaction with a message. If already acknowledged runs createFollowup
|
|
129
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction, use createFollowup if you have already responded with a different interaction response.
|
|
130
|
+
* @arg {String | Object} content A string or object. If an object is passed:
|
|
131
|
+
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
132
|
+
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
133
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
134
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
135
|
+
* @arg {Array<Object>} [content.attachments] An array of attachment objects with the filename and description
|
|
136
|
+
* @arg {String} [content.attachments[].description] The description of the file
|
|
137
|
+
* @arg {String} [content.attachments[].filename] The name of the file
|
|
138
|
+
* @arg {Number} content.attachments[].id The index of the file
|
|
139
|
+
* @arg {Array<Object>} [content.components] An array of component objects
|
|
140
|
+
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
|
|
141
|
+
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
|
|
142
|
+
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
|
143
|
+
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
|
144
|
+
* @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
|
|
145
|
+
* @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
|
|
146
|
+
* @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
|
|
147
|
+
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
|
148
|
+
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
|
149
|
+
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
|
150
|
+
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
|
151
|
+
* @arg {String} [content.components[].options[].description] The description for this option
|
|
152
|
+
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
|
153
|
+
* @arg {String} content.components[].options[].label The label for this option
|
|
154
|
+
* @arg {Number | String} content.components[].options[].value The value for this option
|
|
155
|
+
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
|
|
156
|
+
* @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
|
|
157
|
+
* @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
|
|
158
|
+
* @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)
|
|
159
|
+
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
|
160
|
+
* @arg {String} [content.content] A content string
|
|
161
|
+
* @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
|
|
162
|
+
* @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
|
|
163
|
+
* @arg {Number} [content.flags] 64 for Ephemeral
|
|
164
|
+
* @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
|
|
165
|
+
* @arg {Boolean} [content.tts] Set the message TTS flag
|
|
166
|
+
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
167
|
+
* @arg {Buffer} file.file A buffer containing file data
|
|
168
|
+
* @arg {String} file.name What to name the file
|
|
169
|
+
* @returns {Promise}
|
|
170
|
+
*/
|
|
171
|
+
async createMessage(content, file) {
|
|
172
|
+
if (this.acknowledged === true) {
|
|
173
|
+
return this.createFollowup(content, file);
|
|
174
|
+
}
|
|
175
|
+
if (content !== undefined) {
|
|
176
|
+
if (typeof content !== "object" || content === null) {
|
|
177
|
+
content = {
|
|
178
|
+
content: "" + content,
|
|
179
|
+
};
|
|
180
|
+
} else if (content.content !== undefined && typeof content.content !== "string") {
|
|
181
|
+
content.content = "" + content.content;
|
|
182
|
+
}
|
|
183
|
+
if (content.content !== undefined || content.embeds || content.allowedMentions) {
|
|
184
|
+
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
188
|
+
type: InteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE,
|
|
189
|
+
data: content,
|
|
190
|
+
}, file).then(() => this.update());
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Acknowledges the interaction with a defer response
|
|
195
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
|
196
|
+
* @arg {Number} [flags] 64 for Ephemeral
|
|
197
|
+
* @returns {Promise}
|
|
198
|
+
*/
|
|
199
|
+
async defer(flags) {
|
|
200
|
+
if (this.acknowledged === true) {
|
|
201
|
+
throw new Error("You have already acknowledged this interaction.");
|
|
202
|
+
}
|
|
203
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
204
|
+
type: InteractionResponseTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
|
205
|
+
data: {
|
|
206
|
+
flags: flags || 0,
|
|
207
|
+
},
|
|
208
|
+
}).then(() => this.update());
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Acknowledges the interaction with a defer message update response (Message Component only)
|
|
213
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
|
214
|
+
* @returns {Promise}
|
|
215
|
+
*/
|
|
216
|
+
async deferUpdate() {
|
|
217
|
+
if (this.acknowledged === true) {
|
|
218
|
+
throw new Error("You have already acknowledged this interaction.");
|
|
219
|
+
}
|
|
220
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
221
|
+
type: InteractionResponseTypes.DEFERRED_UPDATE_MESSAGE,
|
|
222
|
+
}).then(() => this.update());
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Delete a message
|
|
227
|
+
* @arg {String} messageID the id of the message to delete, or "@original" for the original response.
|
|
228
|
+
* @returns {Promise}
|
|
229
|
+
*/
|
|
230
|
+
async deleteMessage(messageID) {
|
|
231
|
+
if (this.acknowledged === false) {
|
|
232
|
+
throw new Error("deleteMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, or pong first.");
|
|
233
|
+
}
|
|
234
|
+
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, messageID);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Delete the Original message (or the parent message for components)
|
|
239
|
+
* Warning: Will error with ephemeral messages.
|
|
240
|
+
* @returns {Promise}
|
|
241
|
+
*/
|
|
242
|
+
async deleteOriginalMessage() {
|
|
243
|
+
if (this.acknowledged === false) {
|
|
244
|
+
throw new Error("deleteOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, or pong first.");
|
|
245
|
+
}
|
|
246
|
+
return this._client.deleteWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Edit a message
|
|
251
|
+
* @arg {String} messageID the id of the message to edit, or "@original" for the original response.
|
|
252
|
+
* @arg {Object} content Interaction message edit options
|
|
253
|
+
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
254
|
+
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
255
|
+
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
|
|
256
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
257
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
258
|
+
* @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
|
|
259
|
+
* @arg {String} [content.attachments[].description] The description of the file
|
|
260
|
+
* @arg {String} [content.attachments[].filename] The name of the file. This is not required if you are attaching a new file
|
|
261
|
+
* @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
|
|
262
|
+
* @arg {Array<Object>} [content.components] An array of component objects
|
|
263
|
+
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
|
|
264
|
+
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
|
|
265
|
+
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
|
266
|
+
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
|
267
|
+
* @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
|
|
268
|
+
* @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
|
|
269
|
+
* @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
|
|
270
|
+
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
|
271
|
+
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
|
272
|
+
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
|
273
|
+
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
|
274
|
+
* @arg {String} [content.components[].options[].description] The description for this option
|
|
275
|
+
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
|
276
|
+
* @arg {String} content.components[].options[].label The label for this option
|
|
277
|
+
* @arg {Number | String} content.components[].options[].value The value for this option
|
|
278
|
+
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
|
|
279
|
+
* @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
|
|
280
|
+
* @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
|
|
281
|
+
* @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)
|
|
282
|
+
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
|
283
|
+
* @arg {String} [content.content] A content string
|
|
284
|
+
* @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
|
|
285
|
+
* @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
|
|
286
|
+
* @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. Polls can only be added when editing a deferred interaction response
|
|
287
|
+
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
288
|
+
* @arg {Buffer} file.file A buffer containing file data
|
|
289
|
+
* @arg {String} file.name What to name the file
|
|
290
|
+
* @returns {Promise<Message>}
|
|
291
|
+
*/
|
|
292
|
+
async editMessage(messageID, content, file) {
|
|
293
|
+
if (this.acknowledged === false) {
|
|
294
|
+
throw new Error("editMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, pong, or result first.");
|
|
295
|
+
}
|
|
296
|
+
if (content !== undefined) {
|
|
297
|
+
if (typeof content !== "object" || content === null) {
|
|
298
|
+
content = {
|
|
299
|
+
content: "" + content,
|
|
300
|
+
};
|
|
301
|
+
} else if (content.content !== undefined && typeof content.content !== "string") {
|
|
302
|
+
content.content = "" + content.content;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (file) {
|
|
306
|
+
content.file = file;
|
|
307
|
+
}
|
|
308
|
+
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, messageID, content);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Edit the Original response message
|
|
313
|
+
* @arg {Object} content Interaction message edit options (or the parent message for components)
|
|
314
|
+
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
315
|
+
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
316
|
+
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
|
|
317
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
318
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
319
|
+
* @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
|
|
320
|
+
* @arg {String} [content.attachments[].description] The description of the file
|
|
321
|
+
* @arg {String} [content.attachments[].filename] The name of the file. This is not required if you are attaching a new file
|
|
322
|
+
* @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
|
|
323
|
+
* @arg {Array<Object>} [content.components] An array of component objects
|
|
324
|
+
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
|
|
325
|
+
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
|
|
326
|
+
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
|
327
|
+
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
|
328
|
+
* @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
|
|
329
|
+
* @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
|
|
330
|
+
* @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
|
|
331
|
+
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
|
332
|
+
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
|
333
|
+
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
|
334
|
+
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
|
335
|
+
* @arg {String} [content.components[].options[].description] The description for this option
|
|
336
|
+
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
|
337
|
+
* @arg {String} content.components[].options[].label The label for this option
|
|
338
|
+
* @arg {Number | String} content.components[].options[].value The value for this option
|
|
339
|
+
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
|
|
340
|
+
* @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
|
|
341
|
+
* @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
|
|
342
|
+
* @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)
|
|
343
|
+
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
|
344
|
+
* @arg {String} [content.content] A content string
|
|
345
|
+
* @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
|
|
346
|
+
* @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
|
|
347
|
+
* @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. Polls can only be added when editing a deferred interaction response
|
|
348
|
+
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
349
|
+
* @arg {Buffer} file.file A buffer containing file data
|
|
350
|
+
* @arg {String} file.name What to name the file
|
|
351
|
+
* @returns {Promise<Message>}
|
|
352
|
+
*/
|
|
353
|
+
async editOriginalMessage(content, file) {
|
|
354
|
+
if (this.acknowledged === false) {
|
|
355
|
+
throw new Error("editOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, pong, or result first.");
|
|
356
|
+
}
|
|
357
|
+
if (content !== undefined) {
|
|
358
|
+
if (typeof content !== "object" || content === null) {
|
|
359
|
+
content = {
|
|
360
|
+
content: "" + content,
|
|
361
|
+
};
|
|
362
|
+
} else if (content.content !== undefined && typeof content.content !== "string") {
|
|
363
|
+
content.content = "" + content.content;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (file) {
|
|
367
|
+
content.file = file;
|
|
368
|
+
}
|
|
369
|
+
return this._client.editWebhookMessage.call(this._client, this.applicationID, this.token, "@original", content);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Acknowledges the interaction by editing the parent message. If already acknowledged runs editOriginalMessage (Message Component only)
|
|
374
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction, use edit if you have already responded with a different interaction response.
|
|
375
|
+
* Warning: Will error with ephemeral messages.
|
|
376
|
+
* @arg {String | Object} content What to edit the message with
|
|
377
|
+
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
|
|
378
|
+
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
379
|
+
* @arg {Boolean} [content.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
|
|
380
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
381
|
+
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
382
|
+
* @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
|
|
383
|
+
* @arg {String} [content.attachments[].description] The description of the file
|
|
384
|
+
* @arg {String} [content.attachments[].filename] The name of the file. This is not required if you are attaching a new file
|
|
385
|
+
* @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
|
|
386
|
+
* @arg {Array<Object>} [content.components] An array of component objects
|
|
387
|
+
* @arg {String} [content.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
|
|
388
|
+
* @arg {Boolean} [content.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
|
|
389
|
+
* @arg {Object} [content.components[].emoji] The emoji to be displayed in the component (type 2)
|
|
390
|
+
* @arg {String} [content.components[].label] The label to be displayed in the component (type 2)
|
|
391
|
+
* @arg {Array<Object>} [content.components[].default_values] default values for the component (type 5,6,7,8 only)
|
|
392
|
+
* @arg {String} [content.components[].default_values[].id] id of a user, role, or channel
|
|
393
|
+
* @arg {String} [content.components[].default_values[].type] type of value that id represents (user, role, or channel)
|
|
394
|
+
* @arg {Number} [content.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
|
395
|
+
* @arg {Number} [content.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
|
396
|
+
* @arg {Array<Object>} [content.components[].options] The options for this component (type 3 only)
|
|
397
|
+
* @arg {Boolean} [content.components[].options[].default] Whether this option should be the default value selected
|
|
398
|
+
* @arg {String} [content.components[].options[].description] The description for this option
|
|
399
|
+
* @arg {Object} [content.components[].options[].emoji] The emoji to be displayed in this option
|
|
400
|
+
* @arg {String} content.components[].options[].label The label for this option
|
|
401
|
+
* @arg {Number | String} content.components[].options[].value The value for this option
|
|
402
|
+
* @arg {String} [content.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
|
|
403
|
+
* @arg {String} [content.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
|
|
404
|
+
* @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
|
|
405
|
+
* @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)
|
|
406
|
+
* @arg {String} [content.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
|
407
|
+
* @arg {String} [content.content] A content string
|
|
408
|
+
* @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
|
|
409
|
+
* @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
|
|
410
|
+
* @arg {Number} [content.flags] 64 for Ephemeral
|
|
411
|
+
* @arg {Boolean} [content.tts] Set the message TTS flag
|
|
412
|
+
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
413
|
+
* @arg {Buffer} file.file A buffer containing file data
|
|
414
|
+
* @arg {String} file.name What to name the file
|
|
415
|
+
* @returns {Promise}
|
|
416
|
+
*/
|
|
417
|
+
async editParent(content, file) {
|
|
418
|
+
if (this.acknowledged === true) {
|
|
419
|
+
return this.editOriginalMessage(content);
|
|
420
|
+
}
|
|
421
|
+
if (content !== undefined) {
|
|
422
|
+
if (typeof content !== "object" || content === null) {
|
|
423
|
+
content = {
|
|
424
|
+
content: "" + content,
|
|
425
|
+
};
|
|
426
|
+
} else if (content.content !== undefined && typeof content.content !== "string") {
|
|
427
|
+
content.content = "" + content.content;
|
|
428
|
+
}
|
|
429
|
+
if (content.content !== undefined || content.embeds || content.allowedMentions) {
|
|
430
|
+
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
434
|
+
type: InteractionResponseTypes.UPDATE_MESSAGE,
|
|
435
|
+
data: content,
|
|
436
|
+
}, file).then(() => this.update());
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Get the Original response message (or the parent message for components)
|
|
441
|
+
* Warning: Will error with ephemeral messages.
|
|
442
|
+
* @returns {Promise<Message>}
|
|
443
|
+
*/
|
|
444
|
+
async getOriginalMessage() {
|
|
445
|
+
if (this.acknowledged === false) {
|
|
446
|
+
throw new Error("getOriginalMessage cannot be used to acknowledge an interaction, please use acknowledge, createMessage, defer, deferUpdate, editParent, or pong first.");
|
|
447
|
+
}
|
|
448
|
+
return this._client.getWebhookMessage.call(this._client, this.applicationID, this.token, "@original");
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Responds to the interaction by launching the Activity associated with the app
|
|
453
|
+
* Note: Only available for apps with Activities enabled. You can **not** use more than 1 initial interaction response per interaction
|
|
454
|
+
* @returns {Promise<Object>} Resolves with the interaction callback response. The ID of the launched activity instance is in `interaction.activityInstanceID` and `resource.activityInstance.id`
|
|
455
|
+
*/
|
|
456
|
+
async launchActivity() {
|
|
457
|
+
if (this.acknowledged === true) {
|
|
458
|
+
throw new Error("You have already acknowledged this interaction.");
|
|
459
|
+
}
|
|
460
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
461
|
+
type: InteractionResponseTypes.LAUNCH_ACTIVITY,
|
|
462
|
+
withResponse: true,
|
|
463
|
+
}).then((response) => {
|
|
464
|
+
this.update();
|
|
465
|
+
return response;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Acknowledges the ping interaction with a pong response (Ping Only)
|
|
471
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
|
472
|
+
* @returns {Promise}
|
|
473
|
+
*/
|
|
474
|
+
async pong() {
|
|
475
|
+
if (this.acknowledged === true) {
|
|
476
|
+
throw new Error("You have already acknowledged this interaction.");
|
|
477
|
+
}
|
|
478
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
479
|
+
type: InteractionResponseTypes.PONG,
|
|
480
|
+
}).then(() => this.update());
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Acknowledges the autocomplete interaction with a result of choices.
|
|
485
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
|
486
|
+
* @arg {Array<Object>} choices The autocomplete choices to return to the user
|
|
487
|
+
* @arg {String | Number} choices[].name The choice display name
|
|
488
|
+
* @arg {String} choices[].value The choice value to return to the bot
|
|
489
|
+
* @returns {Promise}
|
|
490
|
+
*/
|
|
491
|
+
async result(choices) {
|
|
492
|
+
if (this.acknowledged === true) {
|
|
493
|
+
throw new Error("You have already acknowledged this interaction.");
|
|
494
|
+
}
|
|
495
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
496
|
+
type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
|
|
497
|
+
data: { choices },
|
|
498
|
+
}).then(() => this.update());
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
module.exports = UnknownInteraction;
|