djs-selfbot-v13 3.1.5 → 3.1.7

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.
Files changed (152) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +42 -15
  3. package/package.json +24 -9
  4. package/src/client/BaseClient.js +3 -2
  5. package/src/client/Client.js +539 -187
  6. package/src/client/actions/Action.js +13 -18
  7. package/src/client/actions/ActionsManager.js +1 -7
  8. package/src/client/actions/AutoModerationActionExecution.js +0 -1
  9. package/src/client/actions/AutoModerationRuleCreate.js +0 -1
  10. package/src/client/actions/AutoModerationRuleDelete.js +0 -1
  11. package/src/client/actions/AutoModerationRuleUpdate.js +0 -1
  12. package/src/client/actions/GuildMemberRemove.js +1 -1
  13. package/src/client/actions/GuildMemberUpdate.js +1 -1
  14. package/src/client/actions/InteractionCreate.js +115 -0
  15. package/src/client/actions/MessageCreate.js +4 -0
  16. package/src/client/actions/PresenceUpdate.js +16 -17
  17. package/src/client/websocket/WebSocketManager.js +31 -11
  18. package/src/client/websocket/WebSocketShard.js +38 -39
  19. package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
  20. package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
  21. package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
  22. package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
  23. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +13 -16
  24. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
  25. package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
  26. package/src/client/websocket/handlers/GUILD_CREATE.js +0 -7
  27. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -1
  28. package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
  29. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
  30. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
  31. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
  32. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
  33. package/src/client/websocket/handlers/INTERACTION_CREATE.js +16 -0
  34. package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
  35. package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +0 -1
  36. package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
  37. package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
  38. package/src/client/websocket/handlers/READY.js +137 -47
  39. package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +5 -7
  40. package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +4 -6
  41. package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +9 -32
  42. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
  43. package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +8 -2
  44. package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
  45. package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +5 -1
  46. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
  47. package/src/client/websocket/handlers/index.js +20 -15
  48. package/src/errors/Messages.js +69 -24
  49. package/src/index.js +43 -12
  50. package/src/managers/ApplicationCommandManager.js +12 -9
  51. package/src/managers/ApplicationCommandPermissionsManager.js +11 -3
  52. package/src/managers/ChannelManager.js +4 -2
  53. package/src/managers/ClientUserSettingManager.js +279 -161
  54. package/src/managers/DeveloperPortalManager.js +104 -0
  55. package/src/managers/GuildApplicationCommandManager.js +28 -0
  56. package/src/managers/GuildBanManager.js +1 -1
  57. package/src/managers/GuildChannelManager.js +0 -2
  58. package/src/managers/GuildFolderManager.js +24 -0
  59. package/src/managers/GuildForumThreadManager.js +28 -22
  60. package/src/managers/GuildMemberManager.js +216 -40
  61. package/src/managers/GuildSettingManager.js +15 -22
  62. package/src/managers/MessageManager.js +44 -42
  63. package/src/managers/PermissionOverwriteManager.js +1 -1
  64. package/src/managers/ReactionUserManager.js +5 -5
  65. package/src/managers/RelationshipManager.js +74 -81
  66. package/src/managers/SessionManager.js +57 -0
  67. package/src/managers/ThreadManager.js +45 -12
  68. package/src/managers/ThreadMemberManager.js +1 -1
  69. package/src/managers/UserManager.js +10 -6
  70. package/src/rest/APIRequest.js +20 -42
  71. package/src/rest/CaptchaSolver.js +132 -0
  72. package/src/rest/DiscordAPIError.js +16 -17
  73. package/src/rest/RESTManager.js +21 -1
  74. package/src/rest/RequestHandler.js +21 -35
  75. package/src/structures/ApplicationCommand.js +456 -19
  76. package/src/structures/ApplicationRoleConnectionMetadata.js +0 -3
  77. package/src/structures/AutoModerationRule.js +5 -5
  78. package/src/structures/AutocompleteInteraction.js +0 -1
  79. package/src/structures/BaseGuildTextChannel.js +12 -10
  80. package/src/structures/BaseGuildVoiceChannel.js +18 -16
  81. package/src/structures/{CallState.js → Call.js} +12 -17
  82. package/src/structures/CategoryChannel.js +0 -2
  83. package/src/structures/Channel.js +3 -2
  84. package/src/structures/ClientApplication.js +204 -0
  85. package/src/structures/ClientPresence.js +8 -12
  86. package/src/structures/ClientUser.js +338 -117
  87. package/src/structures/ContextMenuInteraction.js +1 -1
  88. package/src/structures/DMChannel.js +92 -29
  89. package/src/structures/DeveloperPortalApplication.js +520 -0
  90. package/src/structures/ForumChannel.js +10 -0
  91. package/src/structures/Guild.js +271 -135
  92. package/src/structures/GuildAuditLogs.js +5 -0
  93. package/src/structures/GuildChannel.js +2 -16
  94. package/src/structures/GuildFolder.js +75 -0
  95. package/src/structures/GuildMember.js +145 -27
  96. package/src/structures/Interaction.js +62 -1
  97. package/src/structures/InteractionResponse.js +114 -0
  98. package/src/structures/Invite.js +52 -35
  99. package/src/structures/Message.js +202 -222
  100. package/src/structures/MessageAttachment.js +0 -11
  101. package/src/structures/MessageButton.js +67 -1
  102. package/src/structures/MessageEmbed.js +1 -1
  103. package/src/structures/MessageMentions.js +2 -3
  104. package/src/structures/MessagePayload.js +46 -4
  105. package/src/structures/MessageReaction.js +1 -1
  106. package/src/structures/MessageSelectMenu.js +252 -1
  107. package/src/structures/Modal.js +180 -75
  108. package/src/structures/PartialGroupDMChannel.js +433 -0
  109. package/src/structures/Presence.js +2 -2
  110. package/src/structures/RichPresence.js +34 -14
  111. package/src/structures/Role.js +2 -18
  112. package/src/structures/SelectMenuInteraction.js +151 -2
  113. package/src/structures/Session.js +81 -0
  114. package/src/structures/Team.js +49 -0
  115. package/src/structures/TextInputComponent.js +70 -0
  116. package/src/structures/ThreadChannel.js +19 -0
  117. package/src/structures/User.js +345 -117
  118. package/src/structures/UserContextMenuInteraction.js +2 -2
  119. package/src/structures/VoiceState.js +39 -74
  120. package/src/structures/WebEmbed.js +52 -38
  121. package/src/structures/Webhook.js +11 -17
  122. package/src/structures/interfaces/Application.js +23 -146
  123. package/src/structures/interfaces/TextBasedChannel.js +256 -411
  124. package/src/util/ApplicationFlags.js +1 -1
  125. package/src/util/Constants.js +284 -106
  126. package/src/util/Formatters.js +2 -16
  127. package/src/util/LimitedCollection.js +1 -1
  128. package/src/util/Options.js +68 -48
  129. package/src/util/Permissions.js +0 -5
  130. package/src/util/PurchasedFlags.js +0 -2
  131. package/src/util/RemoteAuth.js +356 -221
  132. package/src/util/Sweepers.js +1 -1
  133. package/src/util/Util.js +36 -76
  134. package/src/util/Voice.js +1456 -0
  135. package/src/util/arRPC/index.js +229 -0
  136. package/src/util/arRPC/process/detectable.json +1 -0
  137. package/src/util/arRPC/process/index.js +102 -0
  138. package/src/util/arRPC/process/native/index.js +5 -0
  139. package/src/util/arRPC/process/native/linux.js +37 -0
  140. package/src/util/arRPC/process/native/win32.js +25 -0
  141. package/src/util/arRPC/transports/ipc.js +281 -0
  142. package/src/util/arRPC/transports/websocket.js +128 -0
  143. package/typings/enums.d.ts +73 -18
  144. package/typings/index.d.ts +1250 -898
  145. package/typings/rawDataTypes.d.ts +9 -68
  146. package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +0 -78
  147. package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +0 -12
  148. package/src/managers/UserNoteManager.js +0 -53
  149. package/src/structures/GroupDMChannel.js +0 -387
  150. package/src/util/AttachmentFlags.js +0 -38
  151. package/src/util/InviteFlags.js +0 -29
  152. package/src/util/RoleFlags.js +0 -37
@@ -3,6 +3,7 @@
3
3
  const { Collection } = require('@discordjs/collection');
4
4
  const GuildChannel = require('./GuildChannel');
5
5
  const TextBasedChannel = require('./interfaces/TextBasedChannel');
6
+ const InteractionManager = require('../managers/InteractionManager');
6
7
  const MessageManager = require('../managers/MessageManager');
7
8
  const { VideoQualityModes } = require('../util/Constants');
8
9
  const Permissions = require('../util/Permissions');
@@ -27,6 +28,12 @@ class BaseGuildVoiceChannel extends GuildChannel {
27
28
  */
28
29
  this.nsfw = Boolean(data.nsfw);
29
30
 
31
+ /**
32
+ * A manager of the interactions sent to this channel
33
+ * @type {InteractionManager}
34
+ */
35
+ this.interactions = new InteractionManager(this);
36
+
30
37
  this._patch(data);
31
38
  }
32
39
 
@@ -88,15 +95,7 @@ class BaseGuildVoiceChannel extends GuildChannel {
88
95
  }
89
96
 
90
97
  if ('nsfw' in data) {
91
- this.nsfw = data.nsfw;
92
- }
93
-
94
- if ('status' in data) {
95
- /**
96
- * The status of the voice channel (max 500 characters)
97
- * @type {?string}
98
- */
99
- this.status = data.status;
98
+ this.nsfw = Boolean(data.nsfw);
100
99
  }
101
100
  }
102
101
 
@@ -171,11 +170,11 @@ class BaseGuildVoiceChannel extends GuildChannel {
171
170
  * Sets the bitrate of the channel.
172
171
  * @param {number} bitrate The new bitrate
173
172
  * @param {string} [reason] Reason for changing the channel's bitrate
174
- * @returns {Promise<BaseGuildVoiceChannel>}
173
+ * @returns {Promise<VoiceChannel>}
175
174
  * @example
176
175
  * // Set the bitrate of a voice channel
177
- * channel.setBitrate(48_000)
178
- * .then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
176
+ * voiceChannel.setBitrate(48_000)
177
+ * .then(vc => console.log(`Set bitrate to ${vc.bitrate}bps for ${vc.name}`))
179
178
  * .catch(console.error);
180
179
  */
181
180
  setBitrate(bitrate, reason) {
@@ -202,11 +201,11 @@ class BaseGuildVoiceChannel extends GuildChannel {
202
201
  * Sets the user limit of the channel.
203
202
  * @param {number} userLimit The new user limit
204
203
  * @param {string} [reason] Reason for changing the user limit
205
- * @returns {Promise<BaseGuildVoiceChannel>}
204
+ * @returns {Promise<VoiceChannel>}
206
205
  * @example
207
206
  * // Set the user limit of a voice channel
208
- * channel.setUserLimit(42)
209
- * .then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
207
+ * voiceChannel.setUserLimit(42)
208
+ * .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`))
210
209
  * .catch(console.error);
211
210
  */
212
211
  setUserLimit(userLimit, reason) {
@@ -217,7 +216,7 @@ class BaseGuildVoiceChannel extends GuildChannel {
217
216
  * Sets the camera video quality mode of the channel.
218
217
  * @param {VideoQualityMode|number} videoQualityMode The new camera video quality mode.
219
218
  * @param {string} [reason] Reason for changing the camera video quality mode.
220
- * @returns {Promise<BaseGuildVoiceChannel>}
219
+ * @returns {Promise<VoiceChannel>}
221
220
  */
222
221
  setVideoQualityMode(videoQualityMode, reason) {
223
222
  return this.edit({ videoQualityMode }, reason);
@@ -230,6 +229,9 @@ class BaseGuildVoiceChannel extends GuildChannel {
230
229
  sendTyping() {}
231
230
  createMessageCollector() {}
232
231
  awaitMessages() {}
232
+ createMessageComponentCollector() {}
233
+ awaitMessageComponent() {}
234
+ bulkDelete() {}
233
235
  fetchWebhooks() {}
234
236
  createWebhook() {}
235
237
  setRateLimitPerUser() {}
@@ -7,7 +7,7 @@ const Base = require('./Base');
7
7
  * Represents a call
8
8
  * @extends {Base}
9
9
  */
10
- class CallState extends Base {
10
+ class Call extends Base {
11
11
  constructor(client, data) {
12
12
  super(client);
13
13
  /**
@@ -16,11 +16,14 @@ class CallState extends Base {
16
16
  */
17
17
  this.channelId = data.channel_id;
18
18
 
19
- this._ringing = [];
19
+ /**
20
+ * The list of user ID who is ringing
21
+ * @type {Collection<Snowflake, User>}
22
+ */
23
+ this.ringing = new Collection();
20
24
 
21
25
  this._patch(data);
22
26
  }
23
-
24
27
  _patch(data) {
25
28
  if ('region' in data) {
26
29
  /**
@@ -30,34 +33,26 @@ class CallState extends Base {
30
33
  this.region = data.region;
31
34
  }
32
35
  if ('ringing' in data) {
33
- this._ringing = data.ringing;
36
+ for (const userId of data.ringing) {
37
+ this.ringing.set(userId, this.client.users.cache.get(userId));
38
+ }
34
39
  }
35
40
  }
36
-
37
41
  /**
38
42
  * The channel of the call
39
- * @type {?DMChannel|GroupDMChannel}
43
+ * @type {?DMChannel|PartialGroupDMChannel}
40
44
  */
41
45
  get channel() {
42
46
  return this.client.channels.cache.get(this.channelId);
43
47
  }
44
-
45
48
  /**
46
49
  * Sets the voice region of the call
47
50
  * @param {string} region Region of the call
48
51
  * @returns {Promise<void>}
49
52
  */
50
- setRTCRegion(region) {
53
+ setVoiceRegion(region) {
51
54
  return this.client.api.channels(this.channelId).call.patch({ data: { region } });
52
55
  }
53
-
54
- /**
55
- * The list of user ID who is ringing
56
- * @type {Collection<Snowflake, User>}
57
- */
58
- get ringing() {
59
- return new Collection(this._ringing.map(id => [id, this.client.users.cache.get(id)]));
60
- }
61
56
  }
62
57
 
63
- module.exports = CallState;
58
+ module.exports = Call;
@@ -62,8 +62,6 @@ class CategoryChannel extends GuildChannel {
62
62
  * @property {?DefaultReactionEmoji} [defaultReactionEmoji] The emoji to set as the default reaction emoji
63
63
  * @property {number} [defaultThreadRateLimitPerUser] The rate limit per user (slowmode) to set on forum posts
64
64
  * @property {?SortOrderType} [defaultSortOrder] The default sort order mode to set on the new channel
65
- * @property {number} [defaultThreadRateLimitPerUser] The initial rate limit per user (slowmode)
66
- * to set on newly created threads in a channel.
67
65
  * @property {string} [reason] Reason for creating the new channel
68
66
  */
69
67
 
@@ -53,6 +53,7 @@ class Channel extends Base {
53
53
  if ('flags' in data) {
54
54
  /**
55
55
  * The flags that are applied to the channel.
56
+ * <info>This is only `null` in a {@link PartialGroupDMChannel}. In all other cases, it is not `null`.</info>
56
57
  * @type {?Readonly<ChannelFlags>}
57
58
  */
58
59
  this.flags = new ChannelFlags(data.flags).freeze();
@@ -202,8 +203,8 @@ class Channel extends Base {
202
203
  if ((data.recipients && data.type !== ChannelTypes.GROUP_DM) || data.type === ChannelTypes.DM) {
203
204
  channel = new DMChannel(client, data);
204
205
  } else if (data.type === ChannelTypes.GROUP_DM) {
205
- const GroupDMChannel = require('./GroupDMChannel');
206
- channel = new GroupDMChannel(client, data);
206
+ const PartialGroupDMChannel = require('./PartialGroupDMChannel');
207
+ channel = new PartialGroupDMChannel(client, data);
207
208
  }
208
209
  } else {
209
210
  guild ??= client.guilds.cache.get(data.guild_id);
@@ -0,0 +1,204 @@
1
+ 'use strict';
2
+
3
+ const { Collection } = require('@discordjs/collection');
4
+ const { ApplicationRoleConnectionMetadata } = require('./ApplicationRoleConnectionMetadata');
5
+ const Team = require('./Team');
6
+ const Application = require('./interfaces/Application');
7
+ const ApplicationCommandManager = require('../managers/ApplicationCommandManager');
8
+ const ApplicationFlags = require('../util/ApplicationFlags');
9
+ const { ApplicationRoleConnectionMetadataTypes } = require('../util/Constants');
10
+ const Permissions = require('../util/Permissions');
11
+
12
+ /**
13
+ * @typedef {Object} ClientApplicationInstallParams
14
+ * @property {InviteScope[]} scopes The scopes to add the application to the server with
15
+ * @property {Readonly<Permissions>} permissions The permissions this bot will request upon joining
16
+ */
17
+
18
+ /**
19
+ * Represents a Client OAuth2 Application.
20
+ * @extends {Application}
21
+ */
22
+ class ClientApplication extends Application {
23
+ constructor(client, data, user) {
24
+ super(client, data);
25
+
26
+ /**
27
+ * The application command manager for this application
28
+ * @type {ApplicationCommandManager}
29
+ */
30
+ this.commands = new ApplicationCommandManager(this.client, undefined, user);
31
+ }
32
+
33
+ _patch(data) {
34
+ super._patch(data);
35
+
36
+ /**
37
+ * The tags this application has (max of 5)
38
+ * @type {string[]}
39
+ */
40
+ this.tags = data.tags ?? [];
41
+
42
+ if ('install_params' in data) {
43
+ /**
44
+ * Settings for this application's default in-app authorization
45
+ * @type {?ClientApplicationInstallParams}
46
+ */
47
+ this.installParams = {
48
+ scopes: data.install_params.scopes,
49
+ permissions: new Permissions(data.install_params.permissions).freeze(),
50
+ };
51
+ } else {
52
+ this.installParams ??= null;
53
+ }
54
+
55
+ if ('custom_install_url' in data) {
56
+ /**
57
+ * This application's custom installation URL
58
+ * @type {?string}
59
+ */
60
+ this.customInstallURL = data.custom_install_url;
61
+ } else {
62
+ this.customInstallURL = null;
63
+ }
64
+
65
+ if ('flags' in data) {
66
+ /**
67
+ * The flags this application has
68
+ * @type {ApplicationFlags}
69
+ */
70
+ this.flags = new ApplicationFlags(data.flags).freeze();
71
+ }
72
+
73
+ if ('cover_image' in data) {
74
+ /**
75
+ * The hash of the application's cover image
76
+ * @type {?string}
77
+ */
78
+ this.cover = data.cover_image;
79
+ } else {
80
+ this.cover ??= null;
81
+ }
82
+
83
+ if ('rpc_origins' in data) {
84
+ /**
85
+ * The application's RPC origins, if enabled
86
+ * @type {string[]}
87
+ */
88
+ this.rpcOrigins = data.rpc_origins;
89
+ } else {
90
+ this.rpcOrigins ??= [];
91
+ }
92
+
93
+ if ('bot_require_code_grant' in data) {
94
+ /**
95
+ * If this application's bot requires a code grant when using the OAuth2 flow
96
+ * @type {?boolean}
97
+ */
98
+ this.botRequireCodeGrant = data.bot_require_code_grant;
99
+ } else {
100
+ this.botRequireCodeGrant ??= null;
101
+ }
102
+
103
+ if ('bot_public' in data) {
104
+ /**
105
+ * If this application's bot is public
106
+ * @type {?boolean}
107
+ */
108
+ this.botPublic = data.bot_public;
109
+ } else {
110
+ this.botPublic ??= null;
111
+ }
112
+
113
+ if ('popular_application_command_ids' in data) {
114
+ /**
115
+ * List of popular command
116
+ * @type {?Collection<Snowflake, ApplicationCommand>}
117
+ */
118
+ this.popularCommands = new Collection();
119
+ data.popular_application_command_ids.forEach(id => {
120
+ this.popularCommands.set(id, this.commands?.cache?.get(id));
121
+ });
122
+ }
123
+
124
+ /**
125
+ * The owner of this OAuth application
126
+ * @type {?(User|Team)}
127
+ */
128
+ this.owner = data.team
129
+ ? new Team(this.client, data.team)
130
+ : data.owner
131
+ ? this.client.users._add(data.owner)
132
+ : this.owner ?? null;
133
+ }
134
+
135
+ /**
136
+ * Whether this application is partial
137
+ * @type {boolean}
138
+ * @readonly
139
+ */
140
+ get partial() {
141
+ return !this.name;
142
+ }
143
+
144
+ /**
145
+ * Obtains this application from Discord.
146
+ * @returns {Promise<ClientApplication>}
147
+ */
148
+ async fetch() {
149
+ const app = await this.client.api.oauth2.authorize.get({
150
+ query: {
151
+ client_id: this.id,
152
+ scope: 'bot applications.commands',
153
+ },
154
+ });
155
+ const user = this.client.users._add(app.bot);
156
+ user._partial = false;
157
+ this._patch(app.application);
158
+ return this;
159
+ }
160
+
161
+ /**
162
+ * Gets this application's role connection metadata records
163
+ * @returns {Promise<ApplicationRoleConnectionMetadata[]>}
164
+ */
165
+ async fetchRoleConnectionMetadataRecords() {
166
+ const metadata = await this.client.api.applications(this.id)('role-connections').metadata.get();
167
+ return metadata.map(data => new ApplicationRoleConnectionMetadata(data));
168
+ }
169
+
170
+ /**
171
+ * Data for creating or editing an application role connection metadata.
172
+ * @typedef {Object} ApplicationRoleConnectionMetadataEditOptions
173
+ * @property {string} name The name of the metadata field
174
+ * @property {?Object<Locale, string>} [nameLocalizations] The name localizations for the metadata field
175
+ * @property {string} description The description of the metadata field
176
+ * @property {?Object<Locale, string>} [descriptionLocalizations] The description localizations for the metadata field
177
+ * @property {string} key The dictionary key of the metadata field
178
+ * @property {ApplicationRoleConnectionMetadataType} type The type of the metadata field
179
+ */
180
+
181
+ /**
182
+ * Updates this application's role connection metadata records
183
+ * @param {ApplicationRoleConnectionMetadataEditOptions[]} records The new role connection metadata records
184
+ * @returns {Promise<ApplicationRoleConnectionMetadata[]>}
185
+ */
186
+ async editRoleConnectionMetadataRecords(records) {
187
+ const newRecords = await this.client.api
188
+ .applications(this.client.user.id)('role-connections')
189
+ .metadata.put({
190
+ data: records.map(record => ({
191
+ type: typeof record.type === 'string' ? ApplicationRoleConnectionMetadataTypes[record.type] : record.type,
192
+ key: record.key,
193
+ name: record.name,
194
+ name_localizations: record.nameLocalizations,
195
+ description: record.description,
196
+ description_localizations: record.descriptionLocalizations,
197
+ })),
198
+ });
199
+
200
+ return newRecords.map(data => new ApplicationRoleConnectionMetadata(data));
201
+ }
202
+ }
203
+
204
+ module.exports = ClientApplication;
@@ -2,9 +2,7 @@
2
2
 
3
3
  const { Presence } = require('./Presence');
4
4
  const { TypeError } = require('../errors');
5
- const { ActivityTypes, Opcodes } = require('../util/Constants');
6
-
7
- const CustomStatusActivityTypes = [ActivityTypes.CUSTOM, ActivityTypes[ActivityTypes.CUSTOM]];
5
+ const { Opcodes, ActivityTypes } = require('../util/Constants');
8
6
 
9
7
  /**
10
8
  * Represents the client's presence.
@@ -22,6 +20,7 @@ class ClientPresence extends Presence {
22
20
  */
23
21
  set(presence) {
24
22
  const packet = this._parse(presence);
23
+ // Parse with custom class
25
24
  this._patch(packet, true);
26
25
  if (typeof presence.shardId === 'undefined') {
27
26
  this.client.ws.broadcast({ op: Opcodes.STATUS_UPDATE, d: packet });
@@ -32,6 +31,8 @@ class ClientPresence extends Presence {
32
31
  } else {
33
32
  this.client.ws.shards.get(presence.shardId).send({ op: Opcodes.STATUS_UPDATE, d: packet });
34
33
  }
34
+ // Parse with default class
35
+ // this._patch(packet, false);
35
36
  return this;
36
37
  }
37
38
 
@@ -45,20 +46,15 @@ class ClientPresence extends Presence {
45
46
  const data = {
46
47
  activities: [],
47
48
  afk: typeof afk === 'boolean' ? afk : false,
48
- since: typeof since === 'number' && !Number.isNaN(since) ? since : null,
49
+ since: 0,
49
50
  status: status ?? this.status,
50
51
  };
51
52
  if (activities?.length) {
52
53
  for (const [i, activity] of activities.entries()) {
53
- if (typeof activity.name !== 'string') throw new TypeError('INVALID_TYPE', `activities[${i}].name`, 'string');
54
-
55
- activity.type ??= ActivityTypes.PLAYING;
56
-
57
- if (CustomStatusActivityTypes.includes(activity.type) && !activity.state) {
58
- activity.state = activity.name;
59
- activity.name = 'Custom Status';
54
+ if (![ActivityTypes.CUSTOM, 'CUSTOM'].includes(activity.type) && typeof activity.name !== 'string') {
55
+ throw new TypeError('INVALID_TYPE', `activities[${i}].name`, 'string');
60
56
  }
61
-
57
+ activity.type ??= 0;
62
58
  data.activities.push(
63
59
  Object.assign(activity, {
64
60
  type: typeof activity.type === 'number' ? activity.type : ActivityTypes[activity.type],