copy eslint + tslint from Discord.js (v13)
This commit is contained in:
@@ -126,7 +126,7 @@ class Client extends BaseClient {
|
||||
this.users = new UserManager(this);
|
||||
|
||||
/** Patch
|
||||
*
|
||||
*
|
||||
*/
|
||||
this.relationships = new RelationshipsManager(this);
|
||||
this.setting = new ClientUserSettingManager(this);
|
||||
@@ -244,44 +244,41 @@ class Client extends BaseClient {
|
||||
* Update Cloudflare Cookie and Discord Fingerprint
|
||||
*/
|
||||
async updateCookie() {
|
||||
/* Auto find fingerprint and add Cookie */
|
||||
let cookie = '';
|
||||
await require('axios')({
|
||||
method: 'get',
|
||||
url: 'https://discord.com/api/v9/experiments',
|
||||
headers: this.options.http.headers,
|
||||
})
|
||||
.then((res) => {
|
||||
if (!'set-cookie' in res.headers) return;
|
||||
res.headers['set-cookie'].map((line) => {
|
||||
line.split('; ').map((arr) => {
|
||||
if (
|
||||
arr.startsWith('Expires') ||
|
||||
arr.startsWith('Path') ||
|
||||
arr.startsWith('Domain') ||
|
||||
arr.startsWith('HttpOnly') ||
|
||||
arr.startsWith('Secure') ||
|
||||
arr.startsWith('Max-Age') ||
|
||||
arr.startsWith('SameSite')
|
||||
) {
|
||||
return;
|
||||
} else {
|
||||
cookie += `${arr}; `;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.options.http.headers['Cookie'] = `${cookie}locale=en`;
|
||||
this.options.http.headers['x-fingerprint'] = res.data.fingerprint;
|
||||
this.emit(Events.DEBUG, `Added Cookie: ${cookie}`);
|
||||
this.emit(Events.DEBUG, `Added Fingerprint: ${res.data.fingerprint}`);
|
||||
})
|
||||
.catch((err) => {
|
||||
this.emit(
|
||||
Events.DEBUG,
|
||||
`Finding Cookie and Fingerprint failed: ${err.message}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
/* Auto find fingerprint and add Cookie */
|
||||
let cookie = '';
|
||||
await require('axios')({
|
||||
method: 'get',
|
||||
url: 'https://discord.com/api/v9/experiments',
|
||||
headers: this.options.http.headers,
|
||||
})
|
||||
.then(res => {
|
||||
if (!'set-cookie' in res.headers) return;
|
||||
res.headers['set-cookie'].map(line => {
|
||||
line.split('; ').map(arr => {
|
||||
if (
|
||||
arr.startsWith('Expires') ||
|
||||
arr.startsWith('Path') ||
|
||||
arr.startsWith('Domain') ||
|
||||
arr.startsWith('HttpOnly') ||
|
||||
arr.startsWith('Secure') ||
|
||||
arr.startsWith('Max-Age') ||
|
||||
arr.startsWith('SameSite')
|
||||
) {
|
||||
return;
|
||||
} else {
|
||||
cookie += `${arr}; `;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.options.http.headers['Cookie'] = `${cookie}locale=en`;
|
||||
this.options.http.headers['x-fingerprint'] = res.data.fingerprint;
|
||||
this.emit(Events.DEBUG, `Added Cookie: ${cookie}`);
|
||||
this.emit(Events.DEBUG, `Added Fingerprint: ${res.data.fingerprint}`);
|
||||
})
|
||||
.catch(err => {
|
||||
this.emit(Events.DEBUG, `Finding Cookie and Fingerprint failed: ${err.message}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the client in, establishing a WebSocket connection to Discord.
|
||||
|
||||
Reference in New Issue
Block a user