fix(PurchasedFlags): wrong

This commit is contained in:
March 7th 2022-07-08 00:23:41 +07:00
parent bf7d09a151
commit b17ae69c1e
9 changed files with 149 additions and 40 deletions

File diff suppressed because one or more lines are too long

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "discord.js-selfbot-v13", "name": "discord.js-selfbot-v13",
"version": "2.3.65", "version": "2.3.66",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -1,6 +1,6 @@
{ {
"name": "discord.js-selfbot-v13", "name": "discord.js-selfbot-v13",
"version": "2.3.65", "version": "2.3.66",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js", "main": "./src/index.js",
"types": "./typings/index.d.ts", "types": "./typings/index.d.ts",

View File

@ -32,6 +32,8 @@ exports.ThreadMemberFlags = require('./util/ThreadMemberFlags');
exports.UserFlags = require('./util/UserFlags'); exports.UserFlags = require('./util/UserFlags');
exports.Util = require('./util/Util'); exports.Util = require('./util/Util');
exports.version = require('../package.json').version; exports.version = require('../package.json').version;
exports.RemoteAuth = require('./util/RemoteAuth');
exports.PurchasedFlags = require('./util/PurchasedFlags');
// Managers // Managers
exports.ApplicationCommandManager = require('./managers/ApplicationCommandManager'); exports.ApplicationCommandManager = require('./managers/ApplicationCommandManager');

View File

@ -5,8 +5,9 @@ const Invite = require('./Invite');
const { Message } = require('./Message'); const { Message } = require('./Message');
const User = require('./User'); const User = require('./User');
const { Util } = require('..'); const { Util } = require('..');
const { HypeSquadOptions, Opcodes, NitroState } = require('../util/Constants'); const { HypeSquadOptions, Opcodes } = require('../util/Constants');
const DataResolver = require('../util/DataResolver'); const DataResolver = require('../util/DataResolver');
const PurchasedFlags = require('../util/PurchasedFlags');
/** /**
* Represents the logged in client's Discord user. * Represents the logged in client's Discord user.
* @extends {User} * @extends {User}
@ -35,29 +36,42 @@ class ClientUser extends User {
if ('token' in data) this.client.token = data.token; if ('token' in data) this.client.token = data.token;
// Add (Selfbot)
if ('purchased_flags' in data) this.nitro = NitroState[data.purchased_flags] ?? 'NONE';
// Key: premium = boolean;
/** /**
* Nitro state of the client user. * Nitro state of the user
* @type {NitroState}
* @see https://discord.com/developers/docs/resources/user#user-object-premium-types
*/
if ('phone' in data) this.phoneNumber = data.phone;
/**
* Phone number of the client user.
* @type {?string}
*/
if ('nsfw_allowed' in data) this.nsfwAllowed = data.nsfw_allowed;
/**
* Whether or not the client user is allowed to send NSFW messages [iOS device].
* @type {?boolean} * @type {?boolean}
*/ */
if ('email' in data) this.emailAddress = data.email; this.nitro = Boolean(data.premium || false);
/**
* Email address of the client user. // Add (Selfbot)
* @type {?string} if ('purchased_flags' in data) {
*/ /**
* Purchased state of the client user.
* @type {?PurchasedFlags}
*/
this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0);
}
// Key: premium = boolean;
if ('phone' in data) {
/**
* Phone number of the client user.
* @type {?string}
*/
this.phoneNumber = data.phone;
}
if ('nsfw_allowed' in data) {
/**
* Whether or not the client user is allowed to send NSFW messages [iOS device].
* @type {?boolean}
*/
this.nsfwAllowed = data.nsfw_allowed;
}
if ('email' in data) {
/**
* Email address of the client user.
* @type {?string}
*/
this.emailAddress = data.email;
}
} }
/** /**

View File

@ -29,14 +29,6 @@ const listUserAgent = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.37', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.37',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.37', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.37',
]; ];
/**
* Nitro state
* * NONE
* * CLASSIC
* * BOOST
* @typedef {string} NitroState
*/
exports.NitroState = createEnum(['NONE', 'CLASSIC', 'BOOST']);
exports.DMScanLevel = createEnum(['NOT_SCAN', 'NOT_FRIEND', 'EVERYONE']); exports.DMScanLevel = createEnum(['NOT_SCAN', 'NOT_FRIEND', 'EVERYONE']);

View File

@ -0,0 +1,31 @@
'use strict';
const BitField = require('./BitField');
/**
* Data structure that makes it easy to interact with an {@link PurchasedFlags#flags} bitfield.
* @extends {BitField}
*/
class PurchasedFlags extends BitField {}
/**
* @name PurchasedFlags
* @kind constructor
* @memberof PurchasedFlags
* @param {BitFieldResolvable} [bits=0] Bit(s) to read from
*/
/**
* Numeric the Discord purchased flags. All available properties:
* * `NITRO_CLASSIC`
* * `NITRO`
* * `GUILD_BOOST`
* @type {Object}
*/
PurchasedFlags.FLAGS = {
NITRO_CLASSIC: 1 << 0,
NITRO: 1 << 1,
GUILD_BOOST: 1 << 2,
};
module.exports = PurchasedFlags;

View File

@ -2,6 +2,7 @@
// Thanks to https://github.com/raleighrimwell/discord-qr-scam-tool // Thanks to https://github.com/raleighrimwell/discord-qr-scam-tool
const { Buffer } = require('buffer'); const { Buffer } = require('buffer');
const crypto = require('crypto'); const crypto = require('crypto');
const EventEmitter = require('node:events');
const { setInterval, clearInterval, setTimeout, clearTimeout } = require('node:timers'); const { setInterval, clearInterval, setTimeout, clearTimeout } = require('node:timers');
const { StringDecoder } = require('string_decoder'); const { StringDecoder } = require('string_decoder');
const { encode: urlsafe_b64encode } = require('safe-base64'); const { encode: urlsafe_b64encode } = require('safe-base64');
@ -40,11 +41,22 @@ class DiscordUser_FromPayload {
} }
} }
class DiscordAuthWebsocket { /**
* Discord Auth QR
* @extends {EventEmitter}
* @abstract
*/
class DiscordAuthWebsocket extends EventEmitter {
/**
* Creates a new DiscordAuthWebsocket instance.
* @param {?Client} client Discord.Client (Login)
* @param {boolean} debug Log debug info
*/
constructor(client, debug = false) { constructor(client, debug = false) {
super();
this.debug = debug; this.debug = debug;
this.client = client; this.client = client;
this.ws = new WebSocket(client.options.http.remoteAuth, { this.ws = new WebSocket(client?.options?.http?.remoteAuth || 'wss://remote-auth-gateway.discord.gg/?v=1', {
headers: { headers: {
Origin: 'https://discord.com', Origin: 'https://discord.com',
'User-Agent': randomUA(), 'User-Agent': randomUA(),
@ -65,7 +77,21 @@ class DiscordAuthWebsocket {
this.connectionDestroy = null; this.connectionDestroy = null;
this.missQR = null; this.missQR = null;
this.login_state = false; this.login_state = false;
/**
* User login with QR
* @type {?object}
*/
this.user = null; this.user = null;
/**
* Discord Auth URL (QR Code decoded)
* @type {?string}
*/
this.authURL = null;
/**
* Discord Token
* @type {?string}
*/
this.token = null;
this.ws.on('error', error => { this.ws.on('error', error => {
if (this.debug) console.log(error); if (this.debug) console.log(error);
}); });
@ -100,12 +126,17 @@ class DiscordAuthWebsocket {
if (this.debug) console.log('[WebSocket] Nonce proof decrypted'); if (this.debug) console.log('[WebSocket] Nonce proof decrypted');
} else if (op == Messages.PENDING_REMOTE_INIT) { } else if (op == Messages.PENDING_REMOTE_INIT) {
let fingerprint = data.fingerprint; let fingerprint = data.fingerprint;
this.authURL = `https://discord.com/ra/${fingerprint}`;
/**
* Emitted whenever a url is created.
* @event DiscordAuthWebsocket#ready
* @param {string} url DiscordAuthWebsocket
*/
this.emit('ready', this.authURL);
this.generate_qr_code(fingerprint); this.generate_qr_code(fingerprint);
if (this.debug) console.log('[WebSocket] QR Code generated'); if (this.debug) console.log('[WebSocket] QR Code generated');
console.log( console.log(
`Please scan the QR code to continue.\nQR Code will expire in ${this.missQR.toLocaleString('vi-VN', { `Please scan the QR code to continue.\nQR Code will expire in ${this.missQR.toLocaleString('vi-VN')}`,
timeZone: 'Asia/Ho_Chi_Minh',
})} (UTC+7)`,
); );
} else if (op == Messages.PENDING_FINISH) { } else if (op == Messages.PENDING_FINISH) {
let encrypted_payload = data.encrypted_user_payload; let encrypted_payload = data.encrypted_user_payload;
@ -121,13 +152,36 @@ class DiscordAuthWebsocket {
this.login_state = true; this.login_state = true;
let encrypted_token = data.encrypted_token; let encrypted_token = data.encrypted_token;
let token = this.decrypt_payload(encrypted_token); let token = this.decrypt_payload(encrypted_token);
const decoder = new StringDecoder('utf-8'); const decoder = new StringDecoder('utf-8');
this.user.token = decoder.write(token); this.user.token = decoder.write(token);
if (this.debug) console.log(this.user.pretty_print()); if (this.debug) console.log(this.user.pretty_print());
this.client.login(this.user.token); this.token = this.user.token;
/**
* Emitted whenever a token is created.
* @event DiscordAuthWebsocket#success
* @param {object} user Discord User
* @param {string} token Discord Token
*/
this.emit(
'success',
{
id: this.user.id,
tag: `${this.user.username}#${this.user.discrim}`,
},
this.token,
);
this.client?.login(this.user.token);
this.destroy(); this.destroy();
} else if (op == Messages.CANCEL) { } else if (op == Messages.CANCEL) {
/**
* Emitted whenever a user cancels the login process.
* @event DiscordAuthWebsocket#cancel
* @param {object} user User
*/
this.emit('cancel', {
id: this.user.id,
tag: `${this.user.username}#${this.user.discrim}`,
});
this.destroy(); this.destroy();
} }
}); });
@ -139,9 +193,12 @@ class DiscordAuthWebsocket {
if (this.debug) console.log('[WebSocket] Setup passed'); if (this.debug) console.log('[WebSocket] Setup passed');
} }
/**
* Destroy WebSocket connection
* @returns {void}
*/
destroy() { destroy() {
this.ws.close(); this.ws.close();
console.clear();
clearInterval(this.heartbeat_interval); clearInterval(this.heartbeat_interval);
clearTimeout(this.connectionDestroy); clearTimeout(this.connectionDestroy);
if (this.debug) { if (this.debug) {
@ -204,6 +261,10 @@ class DiscordAuthWebsocket {
return decrypted; return decrypted;
} }
/**
* Generate QR code for user to scan (Terminal)
* @param {string} fingerprint Auth URL
*/
generate_qr_code(fingerprint) { generate_qr_code(fingerprint) {
require('@aikochan2k6/qrcode-terminal').generate(`https://discord.com/ra/${fingerprint}`, { require('@aikochan2k6/qrcode-terminal').generate(`https://discord.com/ra/${fingerprint}`, {
small: true, small: true,

9
typings/index.d.ts vendored
View File

@ -284,6 +284,11 @@ export class ActivityFlags extends BitField<ActivityFlagsString> {
public static resolve(bit?: BitFieldResolvable<ActivityFlagsString, number>): number; public static resolve(bit?: BitFieldResolvable<ActivityFlagsString, number>): number;
} }
export class PurchasedFlags extends BitField<PurchasedFlagsString> {
public static FLAGS: Record<PurchasedFlagsString, number>;
public static resolve(bit?: BitFieldResolvable<PurchasedFlagsString, number>): number;
}
export abstract class AnonymousGuild extends BaseGuild { export abstract class AnonymousGuild extends BaseGuild {
protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean); protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean);
public banner: string | null; public banner: string | null;
@ -3879,6 +3884,10 @@ export interface WebhookFields extends PartialWebhookFields {
//#endregion //#endregion
//#region Typedefs //#region Typedefs
export type PurchasedFlagsString =
| 'NITRO_CLASSIC'
| 'NITRO'
| 'GUILD_BOOST';
export type ActivityFlagsString = export type ActivityFlagsString =
| 'INSTANCE' | 'INSTANCE'