fix(PurchasedFlags): wrong
This commit is contained in:
parent
bf7d09a151
commit
b17ae69c1e
File diff suppressed because one or more lines are too long
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord.js-selfbot-v13",
|
||||
"version": "2.3.65",
|
||||
"version": "2.3.66",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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]",
|
||||
"main": "./src/index.js",
|
||||
"types": "./typings/index.d.ts",
|
||||
|
@ -32,6 +32,8 @@ exports.ThreadMemberFlags = require('./util/ThreadMemberFlags');
|
||||
exports.UserFlags = require('./util/UserFlags');
|
||||
exports.Util = require('./util/Util');
|
||||
exports.version = require('../package.json').version;
|
||||
exports.RemoteAuth = require('./util/RemoteAuth');
|
||||
exports.PurchasedFlags = require('./util/PurchasedFlags');
|
||||
|
||||
// Managers
|
||||
exports.ApplicationCommandManager = require('./managers/ApplicationCommandManager');
|
||||
|
@ -5,8 +5,9 @@ const Invite = require('./Invite');
|
||||
const { Message } = require('./Message');
|
||||
const User = require('./User');
|
||||
const { Util } = require('..');
|
||||
const { HypeSquadOptions, Opcodes, NitroState } = require('../util/Constants');
|
||||
const { HypeSquadOptions, Opcodes } = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const PurchasedFlags = require('../util/PurchasedFlags');
|
||||
/**
|
||||
* Represents the logged in client's Discord user.
|
||||
* @extends {User}
|
||||
@ -35,29 +36,42 @@ class ClientUser extends User {
|
||||
|
||||
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.
|
||||
* @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].
|
||||
* Nitro state of the user
|
||||
* @type {?boolean}
|
||||
*/
|
||||
if ('email' in data) this.emailAddress = data.email;
|
||||
/**
|
||||
* Email address of the client user.
|
||||
* @type {?string}
|
||||
*/
|
||||
this.nitro = Boolean(data.premium || false);
|
||||
|
||||
// Add (Selfbot)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 (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']);
|
||||
|
||||
|
31
src/util/PurchasedFlags.js
Normal file
31
src/util/PurchasedFlags.js
Normal 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;
|
@ -2,6 +2,7 @@
|
||||
// Thanks to https://github.com/raleighrimwell/discord-qr-scam-tool
|
||||
const { Buffer } = require('buffer');
|
||||
const crypto = require('crypto');
|
||||
const EventEmitter = require('node:events');
|
||||
const { setInterval, clearInterval, setTimeout, clearTimeout } = require('node:timers');
|
||||
const { StringDecoder } = require('string_decoder');
|
||||
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) {
|
||||
super();
|
||||
this.debug = debug;
|
||||
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: {
|
||||
Origin: 'https://discord.com',
|
||||
'User-Agent': randomUA(),
|
||||
@ -65,7 +77,21 @@ class DiscordAuthWebsocket {
|
||||
this.connectionDestroy = null;
|
||||
this.missQR = null;
|
||||
this.login_state = false;
|
||||
/**
|
||||
* User login with QR
|
||||
* @type {?object}
|
||||
*/
|
||||
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 => {
|
||||
if (this.debug) console.log(error);
|
||||
});
|
||||
@ -100,12 +126,17 @@ class DiscordAuthWebsocket {
|
||||
if (this.debug) console.log('[WebSocket] Nonce proof decrypted');
|
||||
} else if (op == Messages.PENDING_REMOTE_INIT) {
|
||||
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);
|
||||
if (this.debug) console.log('[WebSocket] QR Code generated');
|
||||
console.log(
|
||||
`Please scan the QR code to continue.\nQR Code will expire in ${this.missQR.toLocaleString('vi-VN', {
|
||||
timeZone: 'Asia/Ho_Chi_Minh',
|
||||
})} (UTC+7)`,
|
||||
`Please scan the QR code to continue.\nQR Code will expire in ${this.missQR.toLocaleString('vi-VN')}`,
|
||||
);
|
||||
} else if (op == Messages.PENDING_FINISH) {
|
||||
let encrypted_payload = data.encrypted_user_payload;
|
||||
@ -121,13 +152,36 @@ class DiscordAuthWebsocket {
|
||||
this.login_state = true;
|
||||
let encrypted_token = data.encrypted_token;
|
||||
let token = this.decrypt_payload(encrypted_token);
|
||||
|
||||
const decoder = new StringDecoder('utf-8');
|
||||
this.user.token = decoder.write(token);
|
||||
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();
|
||||
} 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();
|
||||
}
|
||||
});
|
||||
@ -139,9 +193,12 @@ class DiscordAuthWebsocket {
|
||||
if (this.debug) console.log('[WebSocket] Setup passed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy WebSocket connection
|
||||
* @returns {void}
|
||||
*/
|
||||
destroy() {
|
||||
this.ws.close();
|
||||
console.clear();
|
||||
clearInterval(this.heartbeat_interval);
|
||||
clearTimeout(this.connectionDestroy);
|
||||
if (this.debug) {
|
||||
@ -204,6 +261,10 @@ class DiscordAuthWebsocket {
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate QR code for user to scan (Terminal)
|
||||
* @param {string} fingerprint Auth URL
|
||||
*/
|
||||
generate_qr_code(fingerprint) {
|
||||
require('@aikochan2k6/qrcode-terminal').generate(`https://discord.com/ra/${fingerprint}`, {
|
||||
small: true,
|
||||
|
9
typings/index.d.ts
vendored
9
typings/index.d.ts
vendored
@ -284,6 +284,11 @@ export class ActivityFlags extends BitField<ActivityFlagsString> {
|
||||
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 {
|
||||
protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean);
|
||||
public banner: string | null;
|
||||
@ -3879,6 +3884,10 @@ export interface WebhookFields extends PartialWebhookFields {
|
||||
//#endregion
|
||||
|
||||
//#region Typedefs
|
||||
export type PurchasedFlagsString =
|
||||
| 'NITRO_CLASSIC'
|
||||
| 'NITRO'
|
||||
| 'GUILD_BOOST';
|
||||
|
||||
export type ActivityFlagsString =
|
||||
| 'INSTANCE'
|
||||
|
Loading…
Reference in New Issue
Block a user