@@ -6,6 +6,7 @@ const Team = require('./Team');
6
6
const Application = require ( './interfaces/Application' ) ;
7
7
const ApplicationCommandManager = require ( '../managers/ApplicationCommandManager' ) ;
8
8
const ApplicationFlagsBitField = require ( '../util/ApplicationFlagsBitField' ) ;
9
+ const DataResolver = require ( '../util/DataResolver' ) ;
9
10
const PermissionsBitField = require ( '../util/PermissionsBitField' ) ;
10
11
11
12
/**
@@ -119,6 +120,16 @@ class ClientApplication extends Application {
119
120
this . botRequireCodeGrant ??= null ;
120
121
}
121
122
123
+ if ( 'bot' in data ) {
124
+ /**
125
+ * The bot associated with this application.
126
+ * @type {?User }
127
+ */
128
+ this . bot = this . client . users . _add ( data . bot ) ;
129
+ } else {
130
+ this . bot ??= null ;
131
+ }
132
+
122
133
if ( 'bot_public' in data ) {
123
134
/**
124
135
* If this application's bot is public
@@ -129,6 +140,16 @@ class ClientApplication extends Application {
129
140
this . botPublic ??= null ;
130
141
}
131
142
143
+ if ( 'interactions_endpoint_url' in data ) {
144
+ /**
145
+ * This application's interaction endpoint URL.
146
+ * @type {?string }
147
+ */
148
+ this . interactionsEndpointURL = data . interactions_endpoint_url ;
149
+ } else {
150
+ this . interactionsEndpointURL ??= null ;
151
+ }
152
+
132
153
if ( 'role_connections_verification_url' in data ) {
133
154
/**
134
155
* This application's role connection verification entry point URL
@@ -168,6 +189,55 @@ class ClientApplication extends Application {
168
189
return ! this . name ;
169
190
}
170
191
192
+ /**
193
+ * Options used for editing an application.
194
+ * @typedef {Object } ClientApplicationEditOptions
195
+ * @property {string } [customInstallURL] The application's custom installation URL
196
+ * @property {string } [description] The application's description
197
+ * @property {string } [roleConnectionsVerificationURL] The application's role connection verification URL
198
+ * @property {ClientApplicationInstallParams } [installParams]
199
+ * Settings for the application's default in-app authorization
200
+ * @property {ApplicationFlagsResolvable } [flags] The flags for the application
201
+ * @property {?(BufferResolvable|Base64Resolvable) } [icon] The application's icon
202
+ * @property {?(BufferResolvable|Base64Resolvable) } [coverImage] The application's cover image
203
+ * @property {string } [interactionsEndpointURL] The application's interaction endpoint URL
204
+ * @property {string[] } [tags] The application's tags
205
+ */
206
+
207
+ /**
208
+ * Edits this application.
209
+ * @param {ClientApplicationEditOptions } [options] The options for editing this application
210
+ * @returns {Promise<ClientApplication> }
211
+ */
212
+ async edit ( {
213
+ customInstallURL,
214
+ description,
215
+ roleConnectionsVerificationURL,
216
+ installParams,
217
+ flags,
218
+ icon,
219
+ coverImage,
220
+ interactionsEndpointURL,
221
+ tags,
222
+ } = { } ) {
223
+ const data = await this . client . rest . patch ( Routes . currentApplication ( ) , {
224
+ body : {
225
+ custom_install_url : customInstallURL ,
226
+ description,
227
+ role_connections_verification_url : roleConnectionsVerificationURL ,
228
+ install_params : installParams ,
229
+ flags : flags === undefined ? undefined : ApplicationFlagsBitField . resolve ( flags ) ,
230
+ icon : icon && ( await DataResolver . resolveImage ( icon ) ) ,
231
+ cover_image : coverImage && ( await DataResolver . resolveImage ( coverImage ) ) ,
232
+ interactions_endpoint_url : interactionsEndpointURL ,
233
+ tags,
234
+ } ,
235
+ } ) ;
236
+
237
+ this . _patch ( data ) ;
238
+ return this ;
239
+ }
240
+
171
241
/**
172
242
* Obtains this application from Discord.
173
243
* @returns {Promise<ClientApplication> }
0 commit comments