Merge branch 'main' of https://github.com/aiko-chan-ai/discord.js-selfbot-v13
This commit is contained in:
commit
2d4cb8e9ae
@ -94,7 +94,7 @@ const r = new Discord.RichPresence()
|
||||
.setParty({
|
||||
max: 9,
|
||||
current: 1,
|
||||
id: Discord.getUUID(),
|
||||
id: Discord.RichPresence.getUUID(),
|
||||
})
|
||||
.setStartTimestamp(Date.now())
|
||||
.setAssetsLargeImage('mp:attachments/820557032016969751/991172011483218010/unknown.png')
|
||||
@ -118,7 +118,7 @@ const r = new Discord.RichPresence()
|
||||
.setParty({
|
||||
max: 9,
|
||||
current: 1,
|
||||
id: Discord.getUUID(),
|
||||
id: Discord.RichPresence.getUUID(),
|
||||
})
|
||||
.setStartTimestamp(Date.now())
|
||||
.setAssetsLargeImage('https://cdn.discordapp.com/attachments/820557032016969751/991172011483218010/unknown.png')
|
||||
@ -135,7 +135,7 @@ client.user.setActivity(r.toJSON());
|
||||
|
||||
```js
|
||||
const rpc = new Discord.RichPresence();
|
||||
const imageSet = await rpc.getExternal(client, '820344593357996092', 'https://musedash.moe/covers/papipupipupipa_cover.hash.93ae31d41.png', 'https://musedash.moe/covers/lights_of_muse_cover.hash.1c18e1e22.png')
|
||||
const imageSet = await Discord.RichPresence.getExternal(client, '820344593357996092', 'https://musedash.moe/covers/papipupipupipa_cover.hash.93ae31d41.png', 'https://musedash.moe/covers/lights_of_muse_cover.hash.1c18e1e22.png')
|
||||
rpc
|
||||
.setApplicationId('820344593357996092')
|
||||
.setType('PLAYING')
|
||||
@ -165,4 +165,4 @@ const asset = await bot.application.fetchAssets();
|
||||
<img src='https://cdn.discordapp.com/attachments/820557032016969751/995307606115618926/unknown.png'>
|
||||
|
||||
- More:
|
||||
- You can change the status 5 times every 20 seconds!
|
||||
- You can change the status 5 times / 20 seconds!
|
||||
|
File diff suppressed because one or more lines are too long
@ -66,6 +66,7 @@
|
||||
"form-data": "^4.0.0",
|
||||
"json-bigint": "^1.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"proxy-agent": "^5.0.0",
|
||||
"safe-base64": "^2.0.1-0",
|
||||
"string_decoder": "^1.3.0",
|
||||
"ws": "^8.8.1"
|
||||
|
@ -397,7 +397,7 @@ class Client extends BaseClient {
|
||||
autoLogin: true,
|
||||
debug,
|
||||
});
|
||||
this.emit(Events.DEBUG, `Preparing to connect to the gateway`, QR);
|
||||
this.emit(Events.DEBUG, `Preparing to connect to the gateway (QR Login)`, QR);
|
||||
return QR.connect(this);
|
||||
}
|
||||
|
||||
@ -897,6 +897,9 @@ class Client extends BaseClient {
|
||||
if (options && typeof options.patchVoice !== 'boolean') {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'patchVoice', 'a boolean');
|
||||
}
|
||||
if (options && typeof options.proxy !== 'string') {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'proxy', 'a string');
|
||||
}
|
||||
if (typeof options.shardCount !== 'number' || isNaN(options.shardCount) || options.shardCount < 1) {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'shardCount', 'a number greater than or equal to 1');
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
const EventEmitter = require('node:events');
|
||||
const { setTimeout, setInterval, clearTimeout } = require('node:timers');
|
||||
const proxy = require('proxy-agent');
|
||||
const WebSocket = require('../../WebSocket');
|
||||
const { Status, Events, ShardEvents, Opcodes, WSEvents, WSCodes } = require('../../util/Constants');
|
||||
const Intents = require('../../util/Intents');
|
||||
@ -260,7 +261,8 @@ class WebSocketShard extends EventEmitter {
|
||||
Gateway : ${gateway}
|
||||
Version : ${client.options.ws.version}
|
||||
Encoding : ${WebSocket.encoding}
|
||||
Compression: ${zlib ? 'zlib-stream' : 'none'}`,
|
||||
Compression: ${zlib ? 'zlib-stream' : 'none'}
|
||||
Proxy : ${client.options.ws.proxy || 'none'}`,
|
||||
);
|
||||
|
||||
this.status = this.status === Status.DISCONNECTED ? Status.RECONNECTING : Status.CONNECTING;
|
||||
@ -268,8 +270,13 @@ class WebSocketShard extends EventEmitter {
|
||||
this.setWsCloseTimeout(-1);
|
||||
this.connectedAt = Date.now();
|
||||
|
||||
let args = { handshakeTimeout: 30_000 };
|
||||
if (typeof client.options.proxy && client.options.proxy.length > 0) {
|
||||
args.agent = new proxy(client.options.proxy);
|
||||
this.debug(`Using proxy ${client.options.proxy}`, args);
|
||||
}
|
||||
// Adding a handshake timeout to just make sure no zombie connection appears.
|
||||
const ws = (this.connection = WebSocket.create(gateway, wsQuery, { handshakeTimeout: 30_000 }));
|
||||
const ws = (this.connection = WebSocket.create(gateway, wsQuery, args));
|
||||
ws.onopen = this.onOpen.bind(this);
|
||||
ws.onmessage = this.onMessage.bind(this);
|
||||
ws.onerror = this.onError.bind(this);
|
||||
|
@ -6,6 +6,7 @@ const { setTimeout } = require('node:timers');
|
||||
const FormData = require('form-data');
|
||||
const JSONBig = require('json-bigint');
|
||||
const fetch = require('node-fetch');
|
||||
const proxy = require('proxy-agent');
|
||||
|
||||
let agent = null;
|
||||
|
||||
@ -34,7 +35,10 @@ class APIRequest {
|
||||
}
|
||||
|
||||
make() {
|
||||
agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
|
||||
agent ??=
|
||||
typeof this.client.options.proxy === 'string' && this.client.options.proxy.length > 0
|
||||
? new proxy(this.client.options.proxy)
|
||||
: new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
|
||||
|
||||
const API =
|
||||
this.options.versioned === false
|
||||
|
@ -473,7 +473,7 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
|
||||
* Get random UUID string (Util)
|
||||
* @returns {string}
|
||||
*/
|
||||
getUUID() {
|
||||
static getUUID() {
|
||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, a =>
|
||||
(a ^ ((Math.random() * 16) >> (a / 4))).toString(16),
|
||||
);
|
||||
@ -487,7 +487,7 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
|
||||
* @param {string} image2 URL image 2 (not from Discord)
|
||||
* @returns {ExternalAssets[]}
|
||||
*/
|
||||
async getExternal(client, applicationId, image1 = '', image2 = '') {
|
||||
static async getExternal(client, applicationId, image1 = '', image2 = '') {
|
||||
const checkURL = url => {
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
|
@ -8,6 +8,7 @@ const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Send Embedlink to Discord
|
||||
* Need to change WebEmbed API server (because heroku is no longer free)
|
||||
*/
|
||||
class WebEmbed {
|
||||
constructor(data = {}) {
|
||||
|
@ -40,6 +40,7 @@ const { randomUA } = require('../util/Constants');
|
||||
* @property {boolean} [autoCookie=true] Automatically add Cookies to Request on startup
|
||||
* @property {boolean} [patchVoice=true] Automatically patch @discordjs/voice module (support for call)
|
||||
* @property {boolean} [autoRedeemNitro=false] Automaticlly redeems nitro codes <NOTE: there is no cooldown on the auto redeem>
|
||||
* @property {string} [proxy] Proxy to use for the WebSocket + REST connection (proxy-agent uri type) {@link https://www.npmjs.com/package/proxy-agent}.
|
||||
* @property {boolean} [DMSync=false] Automatically synchronize call status (DM and group) at startup (event synchronization) [Warning: May cause rate limit to gateway)
|
||||
* @property {number} [shardCount=1] The total amount of shards used by all processes of this bot
|
||||
* (e.g. recommended shard count, shard count of the ShardingManager)
|
||||
@ -168,6 +169,7 @@ class Options extends null {
|
||||
userAgentSuffix: [],
|
||||
presence: { status: 'online', since: 0, activities: [], afk: false },
|
||||
sweepers: {},
|
||||
proxy: '',
|
||||
ws: {
|
||||
large_threshold: 50,
|
||||
compress: false,
|
||||
|
5
typings/index.d.ts
vendored
5
typings/index.d.ts
vendored
@ -250,13 +250,13 @@ export abstract class RichPresence {
|
||||
public setEndTimestamp(timestamp?: Date): this;
|
||||
public setButtons(...button: RichButton[]): this;
|
||||
public addButton(name: string, url: string): this;
|
||||
public getExternal(
|
||||
public static getExternal(
|
||||
client: Client,
|
||||
applicationId: Snowflake,
|
||||
image1: string,
|
||||
image2: string,
|
||||
): Promise<ExternalAssets[]>;
|
||||
public getUUID(): string;
|
||||
public static getUUID(): string;
|
||||
public toJSON(): object;
|
||||
}
|
||||
|
||||
@ -4598,6 +4598,7 @@ export interface ClientOptions {
|
||||
autoRedeemNitro?: boolean;
|
||||
patchVoice?: boolean;
|
||||
DMSync?: boolean;
|
||||
proxy?: string;
|
||||
}
|
||||
|
||||
// end copy
|
||||
|
Loading…
Reference in New Issue
Block a user