djs-selfbot-v13 1.0.1 → 3.1.5
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/README.md +15 -42
- package/package.json +9 -24
- 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/GuildMemberRemove.js +1 -1
- package/src/client/actions/GuildMemberUpdate.js +1 -1
- 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/GUILD_MEMBER_ADD.js +1 -1
- 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 +2 -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 +124 -310
- 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 +222 -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 +874 -1226
- package/typings/rawDataTypes.d.ts +68 -9
- package/LICENSE +0 -674
- 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
|
@@ -3,19 +3,24 @@
|
|
|
3
3
|
const { setInterval } = require('node:timers');
|
|
4
4
|
const { Collection } = require('@discordjs/collection');
|
|
5
5
|
const Invite = require('./Invite');
|
|
6
|
-
const { Message } = require('./Message');
|
|
7
6
|
const User = require('./User');
|
|
8
|
-
const { Util } = require('..');
|
|
9
|
-
const { Error: Error_ } = require('../errors');
|
|
10
|
-
const { Opcodes, NitroType, HypeSquadType } = require('../util/Constants');
|
|
11
7
|
const DataResolver = require('../util/DataResolver');
|
|
12
8
|
const PremiumUsageFlags = require('../util/PremiumUsageFlags');
|
|
13
9
|
const PurchasedFlags = require('../util/PurchasedFlags');
|
|
10
|
+
const Util = require('../util/Util');
|
|
11
|
+
|
|
14
12
|
/**
|
|
15
13
|
* Represents the logged in client's Discord user.
|
|
16
14
|
* @extends {User}
|
|
17
15
|
*/
|
|
18
16
|
class ClientUser extends User {
|
|
17
|
+
#packageName = null;
|
|
18
|
+
#intervalSamsungPresence = setInterval(() => {
|
|
19
|
+
this.client.emit('debug', `[UPDATE] Samsung Presence: ${this.#packageName}`);
|
|
20
|
+
if (!this.#packageName) return;
|
|
21
|
+
this.setSamsungActivity(this.#packageName, 'UPDATE');
|
|
22
|
+
}, 1000 * 60 * 10).unref();
|
|
23
|
+
|
|
19
24
|
_patch(data) {
|
|
20
25
|
super._patch(data);
|
|
21
26
|
|
|
@@ -29,7 +34,7 @@ class ClientUser extends User {
|
|
|
29
34
|
|
|
30
35
|
if ('mfa_enabled' in data) {
|
|
31
36
|
/**
|
|
32
|
-
* If the bot's {@link
|
|
37
|
+
* If the bot's {@link Application#owner Owner} has MFA enabled on their account
|
|
33
38
|
* @type {?boolean}
|
|
34
39
|
*/
|
|
35
40
|
this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
|
|
@@ -39,30 +44,24 @@ class ClientUser extends User {
|
|
|
39
44
|
|
|
40
45
|
if ('token' in data) this.client.token = data.token;
|
|
41
46
|
|
|
42
|
-
// Todo: Add (Selfbot)
|
|
43
|
-
if ('premium_type' in data) {
|
|
44
|
-
const nitro = NitroType[data.premium_type ?? 0];
|
|
45
|
-
/**
|
|
46
|
-
* Nitro type of the client user.
|
|
47
|
-
* @type {NitroType}
|
|
48
|
-
*/
|
|
49
|
-
this.nitroType = nitro ?? `UNKNOWN_TYPE_${data.premium_type}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
if ('purchased_flags' in data) {
|
|
53
48
|
/**
|
|
54
49
|
* Purchased state of the client user.
|
|
55
|
-
* @type {
|
|
50
|
+
* @type {Readonly<PurchasedFlags>}
|
|
56
51
|
*/
|
|
57
|
-
this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0);
|
|
52
|
+
this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0).freeze();
|
|
53
|
+
} else {
|
|
54
|
+
this.purchasedFlags = new PurchasedFlags().freeze();
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
if ('premium_usage_flags' in data) {
|
|
61
58
|
/**
|
|
62
59
|
* Premium usage state of the client user.
|
|
63
|
-
* @type {
|
|
60
|
+
* @type {Readonly<PremiumUsageFlags>}
|
|
64
61
|
*/
|
|
65
62
|
this.premiumUsageFlags = new PremiumUsageFlags(data.premium_usage_flags || 0);
|
|
63
|
+
} else {
|
|
64
|
+
this.premiumUsageFlags = new PremiumUsageFlags().freeze();
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
if ('phone' in data) {
|
|
@@ -70,7 +69,7 @@ class ClientUser extends User {
|
|
|
70
69
|
* Phone number of the client user.
|
|
71
70
|
* @type {?string}
|
|
72
71
|
*/
|
|
73
|
-
this.
|
|
72
|
+
this.phone = data.phone;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
if ('nsfw_allowed' in data) {
|
|
@@ -86,50 +85,37 @@ class ClientUser extends User {
|
|
|
86
85
|
* Email address of the client user.
|
|
87
86
|
* @type {?string}
|
|
88
87
|
*/
|
|
89
|
-
this.
|
|
88
|
+
this.email = data.email;
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
if ('bio' in data) {
|
|
92
|
+
/**
|
|
93
|
+
* About me (User)
|
|
94
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
95
|
+
* @type {?string}
|
|
96
|
+
*/
|
|
93
97
|
this.bio = data.bio;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
if ('pronouns' in data) {
|
|
101
|
+
/**
|
|
102
|
+
* Pronouns (User)
|
|
103
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
104
|
+
* @type {?string}
|
|
105
|
+
*/
|
|
97
106
|
this.pronouns = data.pronouns;
|
|
98
107
|
}
|
|
99
108
|
|
|
100
|
-
if (
|
|
109
|
+
if ('premium_type' in data) {
|
|
101
110
|
/**
|
|
102
|
-
*
|
|
103
|
-
* @type {
|
|
104
|
-
* @
|
|
111
|
+
* Premium types denote the level of premium a user has.
|
|
112
|
+
* @type {number}
|
|
113
|
+
* @see {@link https://discord-userdoccers.vercel.app/resources/user#premium-type}
|
|
105
114
|
*/
|
|
106
|
-
this.
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!this._intervalSamsungPresence) {
|
|
110
|
-
this._intervalSamsungPresence = setInterval(() => {
|
|
111
|
-
this.client.emit('debug', `Samsung Presence: ${this._packageName}`);
|
|
112
|
-
if (!this._packageName) return;
|
|
113
|
-
this.setSamsungActivity(this._packageName, 'UPDATE');
|
|
114
|
-
}, 1000 * 60 * 10).unref();
|
|
115
|
-
// 20 minutes max
|
|
115
|
+
this.premiumType = data.premium_type;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
/**
|
|
120
|
-
* Patch note
|
|
121
|
-
* @param {Object} data Note data
|
|
122
|
-
* @private
|
|
123
|
-
*/
|
|
124
|
-
_patchNote(data) {
|
|
125
|
-
/**
|
|
126
|
-
* The notes cache of the client user.
|
|
127
|
-
* @type {Collection<Snowflake, string>}
|
|
128
|
-
* @private
|
|
129
|
-
*/
|
|
130
|
-
this.notes = data ? new Collection(Object.entries(data)) : new Collection();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
119
|
/**
|
|
134
120
|
* Represents the client user's presence
|
|
135
121
|
* @type {ClientPresence}
|
|
@@ -165,22 +151,16 @@ class ClientUser extends User {
|
|
|
165
151
|
* <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
|
|
166
152
|
* every hour. Use this sparingly!</info>
|
|
167
153
|
* @param {string} username The new username
|
|
168
|
-
* @param {string} password
|
|
154
|
+
* @param {string} password Current Password
|
|
169
155
|
* @returns {Promise<ClientUser>}
|
|
170
156
|
* @example
|
|
171
157
|
* // Set username
|
|
172
|
-
* client.user.setUsername('discordjs')
|
|
158
|
+
* client.user.setUsername('discordjs', 'passw@rd')
|
|
173
159
|
* .then(user => console.log(`My new username is ${user.username}`))
|
|
174
160
|
* .catch(console.error);
|
|
175
161
|
*/
|
|
176
162
|
setUsername(username, password) {
|
|
177
|
-
|
|
178
|
-
throw new Error('A password is required to change a username.');
|
|
179
|
-
}
|
|
180
|
-
return this.edit({
|
|
181
|
-
username,
|
|
182
|
-
password: this.client.password ? this.client.password : password,
|
|
183
|
-
});
|
|
163
|
+
return this.edit({ username, password });
|
|
184
164
|
}
|
|
185
165
|
|
|
186
166
|
/**
|
|
@@ -197,191 +177,12 @@ class ClientUser extends User {
|
|
|
197
177
|
avatar = avatar && (await DataResolver.resolveImage(avatar));
|
|
198
178
|
return this.edit({ avatar });
|
|
199
179
|
}
|
|
200
|
-
/**
|
|
201
|
-
* Sets the banner of the logged in client.
|
|
202
|
-
* @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
|
|
203
|
-
* @returns {Promise<ClientUser>}
|
|
204
|
-
* @example
|
|
205
|
-
* // Set banner
|
|
206
|
-
* client.user.setBanner('./banner.png')
|
|
207
|
-
* .then(user => console.log(`New banner set!`))
|
|
208
|
-
* .catch(console.error);
|
|
209
|
-
*/
|
|
210
|
-
async setBanner(banner) {
|
|
211
|
-
if (this.nitroType !== 'NITRO_BOOST') {
|
|
212
|
-
throw new Error('You must be a Nitro Boosted User to change your banner.');
|
|
213
|
-
}
|
|
214
|
-
banner = banner && (await DataResolver.resolveImage(banner));
|
|
215
|
-
return this.edit({ banner });
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Set HyperSquad House
|
|
220
|
-
* @param {HypeSquadType} type
|
|
221
|
-
* * `LEAVE`: 0
|
|
222
|
-
* * `HOUSE_BRAVERY`: 1
|
|
223
|
-
* * `HOUSE_BRILLIANCE`: 2
|
|
224
|
-
* * `HOUSE_BALANCE`: 3
|
|
225
|
-
* @returns {Promise<void>}
|
|
226
|
-
* @example
|
|
227
|
-
* // Set HyperSquad HOUSE_BRAVERY
|
|
228
|
-
* client.user.setHypeSquad(1); || client.user.setHypeSquad('HOUSE_BRAVERY');
|
|
229
|
-
* // Leave
|
|
230
|
-
* client.user.setHypeSquad(0);
|
|
231
|
-
*/
|
|
232
|
-
async setHypeSquad(type) {
|
|
233
|
-
const id = typeof type === 'string' ? HypeSquadType[type] : type;
|
|
234
|
-
if (!id && id !== 0) throw new Error('Invalid HypeSquad type.');
|
|
235
|
-
if (id !== 0) {
|
|
236
|
-
const data = await this.client.api.hypesquad.online.post({
|
|
237
|
-
data: { house_id: id },
|
|
238
|
-
});
|
|
239
|
-
return data;
|
|
240
|
-
} else {
|
|
241
|
-
const data = await this.client.api.hypesquad.online.delete();
|
|
242
|
-
return data;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Set Accent color
|
|
248
|
-
* @param {ColorResolvable} color Color to set
|
|
249
|
-
* @returns {Promise<ClientUser>}
|
|
250
|
-
*/
|
|
251
|
-
setAccentColor(color = null) {
|
|
252
|
-
return this.edit({ accent_color: color ? Util.resolveColor(color) : null });
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Set discriminator
|
|
257
|
-
* @param {User.discriminator} discriminator It is #1234
|
|
258
|
-
* @param {string} password The password of the account
|
|
259
|
-
* @returns {Promise<ClientUser>}
|
|
260
|
-
*/
|
|
261
|
-
setDiscriminator(discriminator, password) {
|
|
262
|
-
if (this.nitroType == 'NONE') throw new Error('You must be a Nitro User to change your discriminator.');
|
|
263
|
-
if (!password && !this.client.password) {
|
|
264
|
-
throw new Error('A password is required to change a discriminator.');
|
|
265
|
-
}
|
|
266
|
-
return this.edit({
|
|
267
|
-
discriminator,
|
|
268
|
-
username: this.username,
|
|
269
|
-
password: this.client.password ? this.client.password : password,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Set About me
|
|
275
|
-
* @param {string | null} bio Bio to set
|
|
276
|
-
* @returns {Promise<ClientUser>}
|
|
277
|
-
*/
|
|
278
|
-
setAboutMe(bio = null) {
|
|
279
|
-
return this.edit({
|
|
280
|
-
bio,
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Change the email
|
|
286
|
-
* @param {Email<string>} email Email to change
|
|
287
|
-
* @param {string} password Password of the account
|
|
288
|
-
* @returns {Promise<ClientUser>}
|
|
289
|
-
*/
|
|
290
|
-
setEmail(email, password) {
|
|
291
|
-
throw new Error('This method is not available yet. Please use the official Discord client to change your email.');
|
|
292
|
-
// eslint-disable-next-line no-unreachable
|
|
293
|
-
if (!password && !this.client.password) {
|
|
294
|
-
throw new Error('A password is required to change a email.');
|
|
295
|
-
}
|
|
296
|
-
return this.edit({
|
|
297
|
-
email,
|
|
298
|
-
password: this.client.password ? this.client.password : password,
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Set new password
|
|
304
|
-
* @param {string} oldPassword Old password
|
|
305
|
-
* @param {string} newPassword New password to set
|
|
306
|
-
* @returns {Promise<ClientUser>}
|
|
307
|
-
*/
|
|
308
|
-
setPassword(oldPassword, newPassword) {
|
|
309
|
-
if (!oldPassword && !this.client.password) {
|
|
310
|
-
throw new Error('A password is required to change a password.');
|
|
311
|
-
}
|
|
312
|
-
if (!newPassword) throw new Error('New password is required.');
|
|
313
|
-
return this.edit({
|
|
314
|
-
password: this.client.password ? this.client.password : oldPassword,
|
|
315
|
-
new_password: newPassword,
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Disable account
|
|
321
|
-
* @param {string} password Password of the account
|
|
322
|
-
* @returns {Promise<ClientUser>}
|
|
323
|
-
*/
|
|
324
|
-
async disableAccount(password) {
|
|
325
|
-
if (!password && !this.client.password) {
|
|
326
|
-
throw new Error('A password is required to disable an account.');
|
|
327
|
-
}
|
|
328
|
-
const data = await this.client.api.users['@me'].disable.post({
|
|
329
|
-
data: {
|
|
330
|
-
password: this.client.password ? this.client.password : password,
|
|
331
|
-
},
|
|
332
|
-
});
|
|
333
|
-
return data;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Set selfdeaf (Global)
|
|
338
|
-
* @param {boolean} status Whether or not the ClientUser is deafened
|
|
339
|
-
* @returns {boolean}
|
|
340
|
-
*/
|
|
341
|
-
setDeaf(status) {
|
|
342
|
-
if (typeof status !== 'boolean') throw new Error('Deaf status must be a boolean.');
|
|
343
|
-
this.client.ws.broadcast({
|
|
344
|
-
op: Opcodes.VOICE_STATE_UPDATE,
|
|
345
|
-
d: { self_deaf: status },
|
|
346
|
-
});
|
|
347
|
-
return status;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Set selfmute (Global)
|
|
352
|
-
* @param {boolean} status Whether or not the ClientUser is muted
|
|
353
|
-
* @returns {boolean}
|
|
354
|
-
*/
|
|
355
|
-
setMute(status) {
|
|
356
|
-
if (typeof status !== 'boolean') throw new Error('Mute status must be a boolean.');
|
|
357
|
-
this.client.ws.broadcast({
|
|
358
|
-
op: Opcodes.VOICE_STATE_UPDATE,
|
|
359
|
-
d: { self_mute: status },
|
|
360
|
-
});
|
|
361
|
-
return status;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Delete account. Warning: Cannot be changed once used!
|
|
366
|
-
* @param {string} password Password of the account
|
|
367
|
-
* @returns {Promise<ClientUser>}
|
|
368
|
-
*/
|
|
369
|
-
async deleteAccount(password) {
|
|
370
|
-
if (!password && !this.client.password) {
|
|
371
|
-
throw new Error('A password is required to delete an account.');
|
|
372
|
-
}
|
|
373
|
-
const data = await this.client.api.users['@me/delete'].post({
|
|
374
|
-
data: {
|
|
375
|
-
password: this.client.password ? this.client.password : password,
|
|
376
|
-
},
|
|
377
|
-
});
|
|
378
|
-
return data;
|
|
379
|
-
}
|
|
380
180
|
|
|
381
181
|
/**
|
|
382
182
|
* Options for setting activities
|
|
383
183
|
* @typedef {Object} ActivitiesOptions
|
|
384
|
-
* @property {string}
|
|
184
|
+
* @property {string} name Name of the activity
|
|
185
|
+
* @property {string} [state] State of the activity
|
|
385
186
|
* @property {ActivityType|number} [type] Type of the activity
|
|
386
187
|
* @property {string} [url] Twitch / YouTube stream URL
|
|
387
188
|
*/
|
|
@@ -402,7 +203,6 @@ class ClientUser extends User {
|
|
|
402
203
|
* @example
|
|
403
204
|
* // Set the client user's presence
|
|
404
205
|
* client.user.setPresence({ activities: [{ name: 'with discord.js' }], status: 'idle' });
|
|
405
|
-
* @see {@link https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/RichPresence.md}
|
|
406
206
|
*/
|
|
407
207
|
setPresence(data) {
|
|
408
208
|
return this.client.presence.set(data);
|
|
@@ -433,7 +233,7 @@ class ClientUser extends User {
|
|
|
433
233
|
/**
|
|
434
234
|
* Options for setting an activity.
|
|
435
235
|
* @typedef {Object} ActivityOptions
|
|
436
|
-
* @property {string}
|
|
236
|
+
* @property {string} name Name of the activity
|
|
437
237
|
* @property {string} [url] Twitch / YouTube stream URL
|
|
438
238
|
* @property {ActivityType|number} [type] Type of the activity
|
|
439
239
|
* @property {number|number[]} [shardId] Shard Id(s) to have the activity set on
|
|
@@ -441,24 +241,18 @@ class ClientUser extends User {
|
|
|
441
241
|
|
|
442
242
|
/**
|
|
443
243
|
* Sets the activity the client user is playing.
|
|
444
|
-
* @param {string|ActivityOptions}
|
|
244
|
+
* @param {string|ActivityOptions} name Activity being played, or options for setting the activity
|
|
445
245
|
* @param {ActivityOptions} [options] Options for setting the activity
|
|
446
246
|
* @returns {ClientPresence}
|
|
447
247
|
* @example
|
|
448
248
|
* // Set the client user's activity
|
|
449
249
|
* client.user.setActivity('discord.js', { type: 'WATCHING' });
|
|
450
|
-
* @see {@link https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/RichPresence.md}
|
|
451
250
|
*/
|
|
452
251
|
setActivity(name, options = {}) {
|
|
453
|
-
if (!name) {
|
|
454
|
-
return this.setPresence({ activities: [], shardId: options.shardId });
|
|
455
|
-
}
|
|
252
|
+
if (!name) return this.setPresence({ activities: [], shardId: options.shardId });
|
|
456
253
|
|
|
457
254
|
const activity = Object.assign({}, options, typeof name === 'object' ? name : { name });
|
|
458
|
-
return this.setPresence({
|
|
459
|
-
activities: [activity],
|
|
460
|
-
shardId: activity.shardId,
|
|
461
|
-
});
|
|
255
|
+
return this.setPresence({ activities: [activity], shardId: activity.shardId });
|
|
462
256
|
}
|
|
463
257
|
|
|
464
258
|
/**
|
|
@@ -471,6 +265,81 @@ class ClientUser extends User {
|
|
|
471
265
|
return this.setPresence({ afk, shardId });
|
|
472
266
|
}
|
|
473
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Sets the banner of the logged in client.
|
|
270
|
+
* @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
|
|
271
|
+
* @returns {Promise<ClientUser>}
|
|
272
|
+
* @example
|
|
273
|
+
* // Set banner
|
|
274
|
+
* client.user.setBanner('./banner.png')
|
|
275
|
+
* .then(user => console.log(`New banner set!`))
|
|
276
|
+
* .catch(console.error);
|
|
277
|
+
*/
|
|
278
|
+
async setBanner(banner) {
|
|
279
|
+
banner = banner && (await DataResolver.resolveImage(banner));
|
|
280
|
+
return this.edit({ banner });
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Set HyperSquad House
|
|
285
|
+
* @param {string|number} type
|
|
286
|
+
* * `LEAVE`: 0
|
|
287
|
+
* * `HOUSE_BRAVERY`: 1
|
|
288
|
+
* * `HOUSE_BRILLIANCE`: 2
|
|
289
|
+
* * `HOUSE_BALANCE`: 3
|
|
290
|
+
* @returns {Promise<void>}
|
|
291
|
+
* @example
|
|
292
|
+
* // Set HyperSquad HOUSE_BRAVERY
|
|
293
|
+
* client.user.setHypeSquad(1); || client.user.setHypeSquad('HOUSE_BRAVERY');
|
|
294
|
+
* // Leave
|
|
295
|
+
* client.user.setHypeSquad(0);
|
|
296
|
+
*/
|
|
297
|
+
setHypeSquad(type) {
|
|
298
|
+
switch (type) {
|
|
299
|
+
case 'LEAVE': {
|
|
300
|
+
type = 0;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case 'HOUSE_BRAVERY': {
|
|
304
|
+
type = 1;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
case 'HOUSE_BRILLIANCE': {
|
|
308
|
+
type = 2;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
case 'HOUSE_BALANCE': {
|
|
312
|
+
type = 3;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (type == 0) {
|
|
317
|
+
return this.client.api.hypesquad.online.delete();
|
|
318
|
+
} else {
|
|
319
|
+
return this.client.api.hypesquad.online.post({
|
|
320
|
+
data: { house_id: type },
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Set Accent color
|
|
327
|
+
* @param {ColorResolvable} color Color to set
|
|
328
|
+
* @returns {Promise<ClientUser>}
|
|
329
|
+
*/
|
|
330
|
+
setAccentColor(color = null) {
|
|
331
|
+
return this.edit({ accent_color: color ? Util.resolveColor(color) : null });
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Set About me
|
|
336
|
+
* @param {string} [bio=null] Bio to set
|
|
337
|
+
* @returns {Promise<ClientUser>}
|
|
338
|
+
*/
|
|
339
|
+
setAboutMe(bio = null) {
|
|
340
|
+
return this.edit({ bio });
|
|
341
|
+
}
|
|
342
|
+
|
|
474
343
|
/**
|
|
475
344
|
* Create an invite [Friend Invites]
|
|
476
345
|
* maxAge: 604800 | maxUses: 1
|
|
@@ -504,63 +373,10 @@ class ClientUser extends User {
|
|
|
504
373
|
|
|
505
374
|
/**
|
|
506
375
|
* Revoke all friend invites
|
|
507
|
-
* @returns {Promise<
|
|
508
|
-
*/
|
|
509
|
-
async revokeAllFriendInvites() {
|
|
510
|
-
const data = await this.client.api.users['@me'].invites.delete();
|
|
511
|
-
const collection = new Collection();
|
|
512
|
-
for (const invite of data) {
|
|
513
|
-
collection.set(invite.code, new Invite(this.client, invite));
|
|
514
|
-
}
|
|
515
|
-
return collection;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Get a collection of messages mentioning clientUser
|
|
520
|
-
* @param {number} [limit=25] Maximum number of messages to get
|
|
521
|
-
* @param {boolean} [mentionRoles=true] Whether or not to mention roles
|
|
522
|
-
* @param {boolean} [mentionEveryone=true] Whether or not to mention `@everyone`
|
|
523
|
-
* @returns {Promise<Collection<Snowflake, Message>>}
|
|
524
|
-
*/
|
|
525
|
-
async getMentions(limit = 25, mentionRoles = true, mentionEveryone = true) {
|
|
526
|
-
// https://canary.discord.com/api/v9/users/@me/mentions?limit=25&roles=true&everyone=true
|
|
527
|
-
const data = await this.client.api.users['@me'].mentions.get({
|
|
528
|
-
query: {
|
|
529
|
-
limit,
|
|
530
|
-
roles: mentionRoles,
|
|
531
|
-
everyone: mentionEveryone,
|
|
532
|
-
},
|
|
533
|
-
});
|
|
534
|
-
const collection = new Collection();
|
|
535
|
-
for (const msg of data) {
|
|
536
|
-
collection.set(msg.id, new Message(this.client, msg));
|
|
537
|
-
}
|
|
538
|
-
return collection;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Change Theme color
|
|
543
|
-
* @param {ColorResolvable} primary The primary color of the user's profile
|
|
544
|
-
* @param {ColorResolvable} accent The accent color of the user's profile
|
|
545
|
-
* @returns {Promise<ClientUser>}
|
|
376
|
+
* @returns {Promise<void>}
|
|
546
377
|
*/
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
// Check nitro
|
|
550
|
-
if (this.nitroType !== 'NITRO_BOOST') {
|
|
551
|
-
throw new Error_('NITRO_BOOST_REQUIRED', 'themeColors');
|
|
552
|
-
}
|
|
553
|
-
primary = Util.resolveColor(primary) || this.themeColors[0];
|
|
554
|
-
accent = Util.resolveColor(accent) || this.themeColors[1];
|
|
555
|
-
const data_ = await this.client.api.users['@me'].profile.patch({
|
|
556
|
-
data: {
|
|
557
|
-
theme_colors: [primary, accent],
|
|
558
|
-
},
|
|
559
|
-
});
|
|
560
|
-
this._ProfilePatch({
|
|
561
|
-
user_profile: data_,
|
|
562
|
-
});
|
|
563
|
-
return this;
|
|
378
|
+
revokeAllFriendInvites() {
|
|
379
|
+
return this.client.api.users['@me'].invites.delete();
|
|
564
380
|
}
|
|
565
381
|
|
|
566
382
|
/**
|
|
@@ -586,8 +402,8 @@ class ClientUser extends User {
|
|
|
586
402
|
update: type,
|
|
587
403
|
},
|
|
588
404
|
});
|
|
589
|
-
if (type !== 'STOP') this
|
|
590
|
-
else this
|
|
405
|
+
if (type !== 'STOP') this.#packageName = packageName;
|
|
406
|
+
else this.#packageName = null;
|
|
591
407
|
return this;
|
|
592
408
|
}
|
|
593
409
|
|
|
@@ -597,9 +413,7 @@ class ClientUser extends User {
|
|
|
597
413
|
* @returns {Promise<void>}
|
|
598
414
|
*/
|
|
599
415
|
stopRinging(channel) {
|
|
600
|
-
|
|
601
|
-
if (!channel) return false;
|
|
602
|
-
return this.client.api.channels(id).call['stop-ringing'].post({
|
|
416
|
+
return this.client.api.channels(this.client.channels.resolveId(channel)).call['stop-ringing'].post({
|
|
603
417
|
data: {},
|
|
604
418
|
});
|
|
605
419
|
}
|