djs-selfbot-v13 3.1.7 → 3.1.8
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 +1 -1
- package/README.md +18 -45
- package/package.json +8 -37
- package/src/client/BaseClient.js +2 -3
- package/src/client/Client.js +187 -539
- package/src/client/actions/Action.js +18 -13
- package/src/client/actions/ActionsManager.js +7 -1
- package/src/client/actions/AutoModerationActionExecution.js +1 -0
- package/src/client/actions/AutoModerationRuleCreate.js +1 -0
- package/src/client/actions/AutoModerationRuleDelete.js +1 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -0
- package/src/client/actions/MessageCreate.js +0 -4
- package/src/client/actions/PresenceUpdate.js +17 -16
- package/src/client/websocket/WebSocketManager.js +11 -31
- package/src/client/websocket/WebSocketShard.js +39 -38
- package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
- package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
- package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -13
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
- package/src/client/websocket/handlers/GUILD_CREATE.js +7 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
- package/src/client/websocket/handlers/READY.js +47 -137
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +6 -4
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +32 -9
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
- package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +1 -5
- package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/index.js +15 -20
- package/src/errors/Messages.js +24 -69
- package/src/index.js +12 -43
- package/src/managers/ApplicationCommandManager.js +9 -12
- package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
- package/src/managers/ChannelManager.js +3 -4
- package/src/managers/ClientUserSettingManager.js +161 -279
- package/src/managers/GuildBanManager.js +1 -1
- package/src/managers/GuildChannelManager.js +2 -0
- package/src/managers/GuildForumThreadManager.js +22 -28
- package/src/managers/GuildMemberManager.js +40 -216
- package/src/managers/GuildSettingManager.js +22 -15
- package/src/managers/MessageManager.js +42 -44
- package/src/managers/PermissionOverwriteManager.js +1 -1
- package/src/managers/ReactionUserManager.js +5 -5
- package/src/managers/RelationshipManager.js +81 -74
- package/src/managers/ThreadManager.js +12 -45
- package/src/managers/ThreadMemberManager.js +1 -1
- package/src/managers/UserManager.js +6 -10
- package/src/managers/UserNoteManager.js +53 -0
- package/src/rest/APIRequest.js +42 -20
- package/src/rest/DiscordAPIError.js +17 -16
- package/src/rest/RESTManager.js +1 -21
- package/src/rest/RequestHandler.js +35 -21
- package/src/structures/ApplicationCommand.js +19 -456
- package/src/structures/ApplicationRoleConnectionMetadata.js +3 -0
- package/src/structures/AutoModerationRule.js +5 -5
- package/src/structures/AutocompleteInteraction.js +1 -0
- package/src/structures/BaseGuildTextChannel.js +10 -12
- package/src/structures/BaseGuildVoiceChannel.js +16 -18
- package/src/structures/{Call.js → CallState.js} +17 -12
- package/src/structures/CategoryChannel.js +2 -0
- package/src/structures/Channel.js +2 -3
- package/src/structures/ClientPresence.js +12 -8
- package/src/structures/ClientUser.js +117 -336
- package/src/structures/ContextMenuInteraction.js +1 -1
- package/src/structures/DMChannel.js +29 -92
- package/src/structures/ForumChannel.js +0 -10
- package/src/structures/GroupDMChannel.js +387 -0
- package/src/structures/Guild.js +135 -271
- package/src/structures/GuildAuditLogs.js +0 -5
- package/src/structures/GuildChannel.js +16 -2
- package/src/structures/GuildMember.js +27 -145
- package/src/structures/Interaction.js +1 -62
- package/src/structures/Invite.js +35 -52
- package/src/structures/Message.js +228 -202
- package/src/structures/MessageAttachment.js +11 -0
- package/src/structures/MessageButton.js +1 -67
- package/src/structures/MessageEmbed.js +1 -1
- package/src/structures/MessageMentions.js +3 -2
- package/src/structures/MessagePayload.js +4 -46
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +1 -252
- package/src/structures/Modal.js +75 -180
- package/src/structures/Presence.js +2 -2
- package/src/structures/RichPresence.js +14 -34
- package/src/structures/Role.js +18 -2
- package/src/structures/SelectMenuInteraction.js +2 -151
- package/src/structures/Team.js +0 -49
- package/src/structures/TextInputComponent.js +0 -70
- package/src/structures/ThreadChannel.js +0 -19
- package/src/structures/User.js +117 -345
- package/src/structures/UserContextMenuInteraction.js +2 -2
- package/src/structures/VoiceState.js +74 -39
- package/src/structures/WebEmbed.js +38 -52
- package/src/structures/Webhook.js +17 -11
- package/src/structures/interfaces/Application.js +146 -23
- package/src/structures/interfaces/TextBasedChannel.js +411 -256
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/AttachmentFlags.js +38 -0
- package/src/util/Constants.js +106 -284
- package/src/util/Formatters.js +16 -2
- package/src/util/InviteFlags.js +29 -0
- package/src/util/LimitedCollection.js +1 -1
- package/src/util/Options.js +48 -68
- package/src/util/Permissions.js +5 -0
- package/src/util/PurchasedFlags.js +2 -0
- package/src/util/RemoteAuth.js +221 -356
- package/src/util/RoleFlags.js +37 -0
- package/src/util/Sweepers.js +1 -1
- package/src/util/Util.js +76 -36
- package/typings/enums.d.ts +18 -73
- package/typings/index.d.ts +873 -1225
- package/typings/rawDataTypes.d.ts +68 -9
- package/src/client/actions/InteractionCreate.js +0 -115
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +0 -23
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +0 -11
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +0 -55
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +0 -16
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +0 -18
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +0 -30
- package/src/client/websocket/handlers/MESSAGE_ACK.js +0 -16
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
- package/src/managers/DeveloperPortalManager.js +0 -104
- package/src/managers/GuildApplicationCommandManager.js +0 -28
- package/src/managers/GuildFolderManager.js +0 -24
- package/src/managers/SessionManager.js +0 -57
- package/src/rest/CaptchaSolver.js +0 -132
- package/src/structures/ClientApplication.js +0 -204
- package/src/structures/DeveloperPortalApplication.js +0 -520
- package/src/structures/GuildFolder.js +0 -75
- package/src/structures/InteractionResponse.js +0 -114
- package/src/structures/PartialGroupDMChannel.js +0 -433
- package/src/structures/Session.js +0 -81
- package/src/util/Voice.js +0 -1456
- package/src/util/arRPC/index.js +0 -229
- package/src/util/arRPC/process/detectable.json +0 -1
- package/src/util/arRPC/process/index.js +0 -102
- package/src/util/arRPC/process/native/index.js +0 -5
- package/src/util/arRPC/process/native/linux.js +0 -37
- package/src/util/arRPC/process/native/win32.js +0 -25
- package/src/util/arRPC/transports/ipc.js +0 -281
- package/src/util/arRPC/transports/websocket.js +0 -128
|
@@ -1,520 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const { Collection } = require('@discordjs/collection');
|
|
3
|
-
const { ApplicationRoleConnectionMetadata } = require('./ApplicationRoleConnectionMetadata');
|
|
4
|
-
const Base = require('./Base');
|
|
5
|
-
const ApplicationFlags = require('../util/ApplicationFlags');
|
|
6
|
-
const { ClientApplicationAssetTypes, Endpoints, ApplicationRoleConnectionMetadataTypes } = require('../util/Constants');
|
|
7
|
-
const DataResolver = require('../util/DataResolver');
|
|
8
|
-
const Permissions = require('../util/Permissions');
|
|
9
|
-
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
|
10
|
-
|
|
11
|
-
const AssetTypes = Object.keys(ClientApplicationAssetTypes);
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Represents an OAuth2 Application.
|
|
15
|
-
* @extends {Base}
|
|
16
|
-
* @abstract
|
|
17
|
-
*/
|
|
18
|
-
class DeveloperPortalApplication extends Base {
|
|
19
|
-
constructor(client, data) {
|
|
20
|
-
super(client);
|
|
21
|
-
this._patch(data);
|
|
22
|
-
}
|
|
23
|
-
_patch(data) {
|
|
24
|
-
/**
|
|
25
|
-
* The application's id
|
|
26
|
-
* @type {Snowflake}
|
|
27
|
-
*/
|
|
28
|
-
this.id = data.id;
|
|
29
|
-
|
|
30
|
-
if ('name' in data) {
|
|
31
|
-
/**
|
|
32
|
-
* The name of the application
|
|
33
|
-
* @type {?string}
|
|
34
|
-
*/
|
|
35
|
-
this.name = data.name;
|
|
36
|
-
} else {
|
|
37
|
-
this.name ??= null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if ('description' in data) {
|
|
41
|
-
/**
|
|
42
|
-
* The application's description
|
|
43
|
-
* @type {?string}
|
|
44
|
-
*/
|
|
45
|
-
this.description = data.description;
|
|
46
|
-
} else {
|
|
47
|
-
this.description ??= null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if ('icon' in data) {
|
|
51
|
-
/**
|
|
52
|
-
* The application's icon hash
|
|
53
|
-
* @type {?string}
|
|
54
|
-
*/
|
|
55
|
-
this.icon = data.icon;
|
|
56
|
-
} else {
|
|
57
|
-
this.icon ??= null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if ('bot' in data) {
|
|
61
|
-
/**
|
|
62
|
-
* Bot application
|
|
63
|
-
* @type {User}
|
|
64
|
-
*/
|
|
65
|
-
this.bot = this.client.users._add(data.bot);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The tags this application has (max of 5)
|
|
70
|
-
* @type {string[]}
|
|
71
|
-
*/
|
|
72
|
-
this.tags = data.tags ?? [];
|
|
73
|
-
|
|
74
|
-
if ('install_params' in data) {
|
|
75
|
-
/**
|
|
76
|
-
* Settings for this application's default in-app authorization
|
|
77
|
-
* @type {?ClientApplicationInstallParams}
|
|
78
|
-
*/
|
|
79
|
-
this.installParams = {
|
|
80
|
-
scopes: data.install_params.scopes,
|
|
81
|
-
permissions: new Permissions(data.install_params.permissions).freeze(),
|
|
82
|
-
};
|
|
83
|
-
} else {
|
|
84
|
-
this.installParams ??= null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if ('custom_install_url' in data) {
|
|
88
|
-
/**
|
|
89
|
-
* This application's custom installation URL
|
|
90
|
-
* @type {?string}
|
|
91
|
-
*/
|
|
92
|
-
this.customInstallURL = data.custom_install_url;
|
|
93
|
-
} else {
|
|
94
|
-
this.customInstallURL = null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if ('flags' in data) {
|
|
98
|
-
/**
|
|
99
|
-
* The flags this application has
|
|
100
|
-
* @type {ApplicationFlags}
|
|
101
|
-
*/
|
|
102
|
-
this.flags = new ApplicationFlags(data.flags).freeze();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if ('cover_image' in data) {
|
|
106
|
-
/**
|
|
107
|
-
* The hash of the application's cover image
|
|
108
|
-
* @type {?string}
|
|
109
|
-
*/
|
|
110
|
-
this.cover = data.cover_image;
|
|
111
|
-
} else {
|
|
112
|
-
this.cover ??= null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if ('rpc_origins' in data) {
|
|
116
|
-
/**
|
|
117
|
-
* The application's RPC origins, if enabled
|
|
118
|
-
* @type {string[]}
|
|
119
|
-
*/
|
|
120
|
-
this.rpcOrigins = data.rpc_origins;
|
|
121
|
-
} else {
|
|
122
|
-
this.rpcOrigins ??= [];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if ('bot_require_code_grant' in data) {
|
|
126
|
-
/**
|
|
127
|
-
* If this application's bot requires a code grant when using the OAuth2 flow
|
|
128
|
-
* @type {?boolean}
|
|
129
|
-
*/
|
|
130
|
-
this.botRequireCodeGrant = data.bot_require_code_grant;
|
|
131
|
-
} else {
|
|
132
|
-
this.botRequireCodeGrant ??= null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if ('bot_public' in data) {
|
|
136
|
-
/**
|
|
137
|
-
* If this application's bot is public
|
|
138
|
-
* @type {?boolean}
|
|
139
|
-
*/
|
|
140
|
-
this.botPublic = data.bot_public;
|
|
141
|
-
} else {
|
|
142
|
-
this.botPublic ??= null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* The owner of this OAuth application
|
|
147
|
-
* @type {?(User|Team)}
|
|
148
|
-
*/
|
|
149
|
-
this.owner = null;
|
|
150
|
-
if (data.owner.username == `team${data.owner.id}` && data.owner.discriminator == '0000') {
|
|
151
|
-
this.owner = this.client.developerPortal.teams.get(data.owner.id);
|
|
152
|
-
} else {
|
|
153
|
-
this.owner = data.owner ? this.client.users._add(data.owner) : this.owner ?? null;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Redirect URIs for this application
|
|
158
|
-
* @type {Array<string>}
|
|
159
|
-
*/
|
|
160
|
-
this.redirectURIs = data.redirect_uris ?? [];
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* BOT_HTTP_INTERACTIONS feature flag
|
|
164
|
-
* @type {?string}
|
|
165
|
-
*/
|
|
166
|
-
this.interactionEndpointURL = data.interactions_endpoint_url ?? null;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Public key
|
|
170
|
-
* @type {?string}
|
|
171
|
-
*/
|
|
172
|
-
this.publicKey = data.verify_key ?? null;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @typedef {Object} Tester
|
|
176
|
-
* @property {number} state The state of the tester (2: Accepted, 1: Pending)
|
|
177
|
-
* @property {User} user The user that the tester is
|
|
178
|
-
*/
|
|
179
|
-
/**
|
|
180
|
-
* User tester
|
|
181
|
-
* @type {Collection<Snowflake, Tester>}
|
|
182
|
-
*/
|
|
183
|
-
this.testers = new Collection(); // <Snowflake, User>
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Terms of service URL
|
|
187
|
-
* @type {?string}
|
|
188
|
-
*/
|
|
189
|
-
this.TermsOfService = data.terms_of_service_url ?? null;
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Privacy policy URL
|
|
193
|
-
* @type {?string}
|
|
194
|
-
*/
|
|
195
|
-
this.PrivacyPolicy = data.privacy_policy_url ?? null;
|
|
196
|
-
|
|
197
|
-
if ('role_connections_verification_url' in data) {
|
|
198
|
-
/**
|
|
199
|
-
* This application's role connection verification entry point URL
|
|
200
|
-
* @type {?string}
|
|
201
|
-
*/
|
|
202
|
-
this.roleConnectionsVerificationURL = data.role_connections_verification_url;
|
|
203
|
-
} else {
|
|
204
|
-
this.roleConnectionsVerificationURL ??= null;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* The timestamp the application was created at
|
|
209
|
-
* @type {number}
|
|
210
|
-
* @readonly
|
|
211
|
-
*/
|
|
212
|
-
get createdTimestamp() {
|
|
213
|
-
return SnowflakeUtil.timestampFrom(this.id);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* The time the application was created at
|
|
218
|
-
* @type {Date}
|
|
219
|
-
* @readonly
|
|
220
|
-
*/
|
|
221
|
-
get createdAt() {
|
|
222
|
-
return new Date(this.createdTimestamp);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* A link to the application's icon.
|
|
227
|
-
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
|
|
228
|
-
* @returns {?string}
|
|
229
|
-
*/
|
|
230
|
-
iconURL({ format, size } = {}) {
|
|
231
|
-
if (!this.icon) return null;
|
|
232
|
-
return this.client.rest.cdn.AppIcon(this.id, this.icon, { format, size });
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* A link to this application's cover image.
|
|
237
|
-
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
|
|
238
|
-
* @returns {?string}
|
|
239
|
-
*/
|
|
240
|
-
coverURL({ format, size } = {}) {
|
|
241
|
-
if (!this.cover) return null;
|
|
242
|
-
return Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.cover, { format, size });
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Asset data.
|
|
247
|
-
* @typedef {Object} ApplicationAsset
|
|
248
|
-
* @property {Snowflake} id The asset's id
|
|
249
|
-
* @property {string} name The asset's name
|
|
250
|
-
* @property {string} type The asset's type
|
|
251
|
-
*/
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Gets the application's rich presence assets.
|
|
255
|
-
* @returns {Promise<Array<ApplicationAsset>>}
|
|
256
|
-
* @deprecated This will be removed in the next major as it is unsupported functionality.
|
|
257
|
-
*/
|
|
258
|
-
async fetchAssets() {
|
|
259
|
-
const assets = await this.client.api.oauth2.applications(this.id).assets.get();
|
|
260
|
-
return assets.map(a => ({
|
|
261
|
-
id: a.id,
|
|
262
|
-
name: a.name,
|
|
263
|
-
type: AssetTypes[a.type - 1],
|
|
264
|
-
}));
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Whether this application is partial
|
|
269
|
-
* @type {boolean}
|
|
270
|
-
* @readonly
|
|
271
|
-
*/
|
|
272
|
-
get partial() {
|
|
273
|
-
return !this.name;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Obtains this application from Discord.
|
|
278
|
-
* @returns {Promise<DeveloperPortalApplication>}
|
|
279
|
-
*/
|
|
280
|
-
async fetch() {
|
|
281
|
-
const app = await this.client.api.applications[this.id].get();
|
|
282
|
-
this._patch(app);
|
|
283
|
-
return this;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Gets all testers for this application.
|
|
288
|
-
* @returns {Promise<DeveloperPortalApplication>}
|
|
289
|
-
*/
|
|
290
|
-
async fetchTesters() {
|
|
291
|
-
const app = await this.client.api.applications[this.id].allowlist.get();
|
|
292
|
-
this.testers = new Collection();
|
|
293
|
-
for (const tester of app || []) {
|
|
294
|
-
this.testers.set(tester.user.id, {
|
|
295
|
-
state: tester.state,
|
|
296
|
-
user: this.client.users._add(tester.user),
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
return this;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Add user to this application's allowlist.
|
|
304
|
-
* @param {string} username Username of the user to add
|
|
305
|
-
* @param {string} discriminator Discriminator of the user to add
|
|
306
|
-
* @returns {Promise<DeveloperPortalApplication>}
|
|
307
|
-
*/
|
|
308
|
-
async addTester(username, discriminator) {
|
|
309
|
-
const app = await this.client.api.applications[this.id].allowlist.post({
|
|
310
|
-
data: {
|
|
311
|
-
username,
|
|
312
|
-
discriminator,
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
this.testers.set(app.user.id, {
|
|
316
|
-
state: app.state,
|
|
317
|
-
user: this.client.users._add(app.user),
|
|
318
|
-
});
|
|
319
|
-
return this;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Delete user from this application's allowlist.
|
|
324
|
-
* @param {UserResolvable} user User
|
|
325
|
-
* @returns {Promise<DeveloperPortalApplication>}
|
|
326
|
-
*/
|
|
327
|
-
async deleteTester(user) {
|
|
328
|
-
const userId = this.client.users.resolveId(user);
|
|
329
|
-
await this.client.api.applications[this.id].allowlist[userId].delete();
|
|
330
|
-
this.testers.delete(userId);
|
|
331
|
-
return this;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* The data for editing a application.
|
|
336
|
-
* @typedef {Object} ApplicationEditData
|
|
337
|
-
* @property {string} [name] The name of the app
|
|
338
|
-
* @property {string} [description] The description of the app
|
|
339
|
-
* @property {?(BufferResolvable|Base64Resolvable)} [icon] The icon of the app
|
|
340
|
-
* @property {?(BufferResolvable|Base64Resolvable)} [cover] The application's default rich presence invite
|
|
341
|
-
* @property {boolean} [botPublic] When false only app owner can join the app's bot to guilds
|
|
342
|
-
* @property {boolean} [botRequireCodeGrant] When true the app's bot will only join upon completion of the full oauth2 code grant flow
|
|
343
|
-
* @property {?string} [TermsOfService] ToS URL
|
|
344
|
-
* @property {?string} [PrivacyPolicy] Privacy policy URL
|
|
345
|
-
* @property {number} [flags] The application's public flags
|
|
346
|
-
* @property {Array<string>} [redirectURIs] Redirect URIs (OAuth2 only)
|
|
347
|
-
* @property {Array<string>} [tags] Up to 5 tags describing the content and functionality of the application
|
|
348
|
-
*/
|
|
349
|
-
/**
|
|
350
|
-
* Edits this application.
|
|
351
|
-
* @param {ApplicationEditData} data Edit data for the application
|
|
352
|
-
* @returns {Promise<DeveloperPortalApplication>}
|
|
353
|
-
*/
|
|
354
|
-
async edit(data) {
|
|
355
|
-
const _data = {};
|
|
356
|
-
if (data.name) _data.name = data.name;
|
|
357
|
-
if (typeof data.icon !== 'undefined') {
|
|
358
|
-
_data.icon = await DataResolver.resolveImage(data.icon);
|
|
359
|
-
}
|
|
360
|
-
if (data.description) _data.description = data.description;
|
|
361
|
-
if (typeof data.cover !== 'undefined') {
|
|
362
|
-
_data.cover = await DataResolver.resolveImage(data.cover);
|
|
363
|
-
}
|
|
364
|
-
if (data.botPublic) _data.bot_public = data.botPublic;
|
|
365
|
-
if (data.botRequireCodeGrant) _data.bot_require_code_grant = data.botRequireCodeGrant;
|
|
366
|
-
if (data.TermsOfService) _data.terms_of_service_url = data.TermsOfService;
|
|
367
|
-
if (data.PrivacyPolicy) _data.privacy_policy_url = data.PrivacyPolicy;
|
|
368
|
-
if (data.flags) _data.flags = data.flags;
|
|
369
|
-
if (data.redirectURIs) _data.redirect_uris = data.redirectURIs;
|
|
370
|
-
if (data.tags) _data.tags = data.tags;
|
|
371
|
-
//
|
|
372
|
-
const app = await this.client.api.applications[this.id].patch({ data: _data });
|
|
373
|
-
this._patch(app);
|
|
374
|
-
return this;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Creates a new bot for this application.
|
|
379
|
-
* @returns {Promise<DeveloperPortalApplication>}
|
|
380
|
-
*/
|
|
381
|
-
async createBot() {
|
|
382
|
-
if (this.bot) throw new Error('Application already has a bot.');
|
|
383
|
-
await this.client.api.applications[this.id].bot.post();
|
|
384
|
-
const app = await this.fetch();
|
|
385
|
-
return app;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Reset CLient Secret for this application.
|
|
390
|
-
* @param {number} MFACode The MFA code (if required)
|
|
391
|
-
* @returns {Promise<string>}
|
|
392
|
-
*/
|
|
393
|
-
async resetClientSecret(MFACode) {
|
|
394
|
-
const app = MFACode
|
|
395
|
-
? await this.client.api.applications[this.id].reset.post({
|
|
396
|
-
data: {
|
|
397
|
-
code: MFACode,
|
|
398
|
-
},
|
|
399
|
-
})
|
|
400
|
-
: await this.client.api.applications[this.id].reset.post();
|
|
401
|
-
return app.secret;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Reset Bot Token for this application.
|
|
406
|
-
* @param {number} MFACode The MFA code (if required)
|
|
407
|
-
* @returns {Promise<string>}
|
|
408
|
-
*/
|
|
409
|
-
async resetBotToken(MFACode) {
|
|
410
|
-
const app = MFACode
|
|
411
|
-
? await this.client.api.applications[this.id].bot.reset.post({
|
|
412
|
-
data: {
|
|
413
|
-
code: MFACode,
|
|
414
|
-
},
|
|
415
|
-
})
|
|
416
|
-
: await this.client.api.applications[this.id].bot.reset.post();
|
|
417
|
-
return app.token;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Deletes this application.
|
|
422
|
-
* @param {number} MFACode The MFA code (if required)
|
|
423
|
-
* @returns {Promise<void>}
|
|
424
|
-
*/
|
|
425
|
-
delete(MFACode) {
|
|
426
|
-
return this.client.developerPortal.deleteApplication(this.id, MFACode);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Add new image to this application. (RPC)
|
|
431
|
-
* @param {BufferResolvable|Base64Resolvable} image Image Resolvable
|
|
432
|
-
* @param {string} name Name of the image
|
|
433
|
-
* @returns {ApplicationAsset}
|
|
434
|
-
*/
|
|
435
|
-
async addAsset(image, name) {
|
|
436
|
-
const data = await DataResolver.resolveImage(image);
|
|
437
|
-
const asset = await this.client.api.applications[this.id].assets.post({
|
|
438
|
-
data: {
|
|
439
|
-
type: 1,
|
|
440
|
-
name,
|
|
441
|
-
image: data,
|
|
442
|
-
},
|
|
443
|
-
});
|
|
444
|
-
return {
|
|
445
|
-
id: asset.id,
|
|
446
|
-
name: asset.name,
|
|
447
|
-
type: AssetTypes[asset.type - 1],
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Delete an image from this application. (RPC)
|
|
453
|
-
* @param {Snowflake} id ID of the image
|
|
454
|
-
* @returns {Promise<undefined>}
|
|
455
|
-
*/
|
|
456
|
-
async deleteAsset(id) {
|
|
457
|
-
await this.client.api.applications[this.id].assets[id].delete();
|
|
458
|
-
return undefined;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Gets this application's role connection metadata records
|
|
463
|
-
* @returns {Promise<ApplicationRoleConnectionMetadata[]>}
|
|
464
|
-
*/
|
|
465
|
-
async fetchRoleConnectionMetadataRecords() {
|
|
466
|
-
const metadata = await this.client.api.applications(this.id)('role-connections').metadata.get();
|
|
467
|
-
return metadata.map(data => new ApplicationRoleConnectionMetadata(data));
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
/**
|
|
471
|
-
* Data for creating or editing an application role connection metadata.
|
|
472
|
-
* @typedef {Object} ApplicationRoleConnectionMetadataEditOptions
|
|
473
|
-
* @property {string} name The name of the metadata field
|
|
474
|
-
* @property {?Object<Locale, string>} [nameLocalizations] The name localizations for the metadata field
|
|
475
|
-
* @property {string} description The description of the metadata field
|
|
476
|
-
* @property {?Object<Locale, string>} [descriptionLocalizations] The description localizations for the metadata field
|
|
477
|
-
* @property {string} key The dictionary key of the metadata field
|
|
478
|
-
* @property {ApplicationRoleConnectionMetadataType} type The type of the metadata field
|
|
479
|
-
*/
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Updates this application's role connection metadata records
|
|
483
|
-
* @param {ApplicationRoleConnectionMetadataEditOptions[]} records The new role connection metadata records
|
|
484
|
-
* @returns {Promise<ApplicationRoleConnectionMetadata[]>}
|
|
485
|
-
*/
|
|
486
|
-
async editRoleConnectionMetadataRecords(records) {
|
|
487
|
-
const newRecords = await this.client.api
|
|
488
|
-
.applications(this.client.user.id)('role-connections')
|
|
489
|
-
.metadata.put({
|
|
490
|
-
data: records.map(record => ({
|
|
491
|
-
type: typeof record.type === 'string' ? ApplicationRoleConnectionMetadataTypes[record.type] : record.type,
|
|
492
|
-
key: record.key,
|
|
493
|
-
name: record.name,
|
|
494
|
-
name_localizations: record.nameLocalizations,
|
|
495
|
-
description: record.description,
|
|
496
|
-
description_localizations: record.descriptionLocalizations,
|
|
497
|
-
})),
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
return newRecords.map(data => new ApplicationRoleConnectionMetadata(data));
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* When concatenated with a string, this automatically returns the application's name instead of the
|
|
505
|
-
* Application object.
|
|
506
|
-
* @returns {?string}
|
|
507
|
-
* @example
|
|
508
|
-
* // Logs: Application name: My App
|
|
509
|
-
* console.log(`Application name: ${application}`);
|
|
510
|
-
*/
|
|
511
|
-
toString() {
|
|
512
|
-
return this.name;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
toJSON() {
|
|
516
|
-
return super.toJSON({ createdTimestamp: true });
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
module.exports = DeveloperPortalApplication;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Base = require('./Base');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Guild Folder.
|
|
7
|
-
* @abstract
|
|
8
|
-
*/
|
|
9
|
-
class GuildFolder extends Base {
|
|
10
|
-
constructor(client, data) {
|
|
11
|
-
super(client);
|
|
12
|
-
this._patch(data);
|
|
13
|
-
}
|
|
14
|
-
_patch(data) {
|
|
15
|
-
if ('id' in data) {
|
|
16
|
-
/**
|
|
17
|
-
* The guild folder's id
|
|
18
|
-
* @type {Snowflake}
|
|
19
|
-
*/
|
|
20
|
-
this.id = data.id;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if ('name' in data) {
|
|
24
|
-
/**
|
|
25
|
-
* The guild folder's name
|
|
26
|
-
* @type {string}
|
|
27
|
-
*/
|
|
28
|
-
this.name = data.name;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if ('color' in data) {
|
|
32
|
-
/**
|
|
33
|
-
* The base 10 color of the folder
|
|
34
|
-
* @type {number}
|
|
35
|
-
*/
|
|
36
|
-
this.color = data.color;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if ('guild_ids' in data) {
|
|
40
|
-
/**
|
|
41
|
-
* The guild folder's guild ids
|
|
42
|
-
* @type {Snowflake[]}
|
|
43
|
-
*/
|
|
44
|
-
this.guild_ids = data.guild_ids;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The hexadecimal version of the folder color, with a leading hashtag
|
|
49
|
-
* @type {string}
|
|
50
|
-
* @readonly
|
|
51
|
-
*/
|
|
52
|
-
get hexColor() {
|
|
53
|
-
return `#${this.color.toString(16).padStart(6, '0')}`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Guilds in the folder
|
|
58
|
-
* @type {Collection<Snowflake, Guild>}
|
|
59
|
-
* @readonly
|
|
60
|
-
*/
|
|
61
|
-
get guilds() {
|
|
62
|
-
return this.client.guilds.cache.filter(guild => this.guild_ids.includes(guild.id));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
toJSON() {
|
|
66
|
-
return {
|
|
67
|
-
id: this.id,
|
|
68
|
-
name: this.name,
|
|
69
|
-
color: this.color,
|
|
70
|
-
guild_ids: this.guild_ids,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
module.exports = GuildFolder;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { setTimeout } = require('node:timers');
|
|
4
|
-
const Base = require('./Base');
|
|
5
|
-
const { Events } = require('../util/Constants');
|
|
6
|
-
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Represents a interaction on Discord.
|
|
10
|
-
* @extends {Base}
|
|
11
|
-
*/
|
|
12
|
-
class InteractionResponse extends Base {
|
|
13
|
-
constructor(client, data) {
|
|
14
|
-
super(client);
|
|
15
|
-
/**
|
|
16
|
-
* The id of the channel the interaction was sent in
|
|
17
|
-
* @type {Snowflake}
|
|
18
|
-
*/
|
|
19
|
-
this.channelId = data.channelId;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The id of the guild the interaction was sent in, if any
|
|
23
|
-
* @type {?Snowflake}
|
|
24
|
-
*/
|
|
25
|
-
this.guildId = data.guildId ?? this.channel?.guild?.id ?? null;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The interaction data was sent in
|
|
29
|
-
* @type {Object}
|
|
30
|
-
*/
|
|
31
|
-
this.sendData = data.metadata;
|
|
32
|
-
this._patch(data);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
_patch(data) {
|
|
36
|
-
if ('id' in data) {
|
|
37
|
-
/**
|
|
38
|
-
* The interaction response's ID
|
|
39
|
-
* @type {Snowflake}
|
|
40
|
-
*/
|
|
41
|
-
this.id = data.id;
|
|
42
|
-
}
|
|
43
|
-
if ('nonce' in data) {
|
|
44
|
-
/**
|
|
45
|
-
* The interaction response's nonce
|
|
46
|
-
* @type {Snowflake}
|
|
47
|
-
*/
|
|
48
|
-
this.nonce = data.nonce;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* The timestamp the interaction response was created at
|
|
53
|
-
* @type {number}
|
|
54
|
-
* @readonly
|
|
55
|
-
*/
|
|
56
|
-
get createdTimestamp() {
|
|
57
|
-
return SnowflakeUtil.timestampFrom(this.id);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The time the interaction response was created at
|
|
62
|
-
* @type {Date}
|
|
63
|
-
* @readonly
|
|
64
|
-
*/
|
|
65
|
-
get createdAt() {
|
|
66
|
-
return new Date(this.createdTimestamp);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The channel that the interaction was sent in
|
|
71
|
-
* @type {TextBasedChannels}
|
|
72
|
-
* @readonly
|
|
73
|
-
*/
|
|
74
|
-
get channel() {
|
|
75
|
-
return this.client.channels.resolve(this.channelId);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The guild the inteaaction was sent in (if in a guild channel)
|
|
80
|
-
* @type {?Guild}
|
|
81
|
-
* @readonly
|
|
82
|
-
*/
|
|
83
|
-
get guild() {
|
|
84
|
-
return this.client.guilds.resolve(this.guildId) ?? this.channel?.guild ?? null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Get Modal send from interaction
|
|
89
|
-
* @param {number} time Time to wait for modal
|
|
90
|
-
* @returns {Modal}
|
|
91
|
-
*/
|
|
92
|
-
awaitModal(time) {
|
|
93
|
-
if (!time || typeof time !== 'number' || time < 0) throw new Error('INVALID_TIME');
|
|
94
|
-
return new Promise((resolve, reject) => {
|
|
95
|
-
const handler = modal => {
|
|
96
|
-
timeout.refresh();
|
|
97
|
-
if (modal.nonce != this.nonce || modal.id != this.id) return;
|
|
98
|
-
clearTimeout(timeout);
|
|
99
|
-
this.client.removeListener(Events.INTERACTION_MODAL_CREATE, handler);
|
|
100
|
-
this.client.decrementMaxListeners();
|
|
101
|
-
resolve(modal);
|
|
102
|
-
};
|
|
103
|
-
const timeout = setTimeout(() => {
|
|
104
|
-
this.client.removeListener(Events.INTERACTION_MODAL_CREATE, handler);
|
|
105
|
-
this.client.decrementMaxListeners();
|
|
106
|
-
reject(new Error('MODAL_TIMEOUT'));
|
|
107
|
-
}, time).unref();
|
|
108
|
-
this.client.incrementMaxListeners();
|
|
109
|
-
this.client.on(Events.INTERACTION_MODAL_CREATE, handler);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
module.exports = InteractionResponse;
|