mini update

- ClientUserSettingManager (Discum)
- Document (API version, Cookie, ...)
- x-super-properties header Request (Discum)
This commit is contained in:
March 7th 2022-04-05 19:01:20 +07:00
parent f2ee8bab81
commit 26d9e4cbb9
7 changed files with 269 additions and 118 deletions

View File

@ -13,10 +13,17 @@ const client = new Client({
version: 10 version: 10
}, },
http: { http: {
version: 10 version: 10,
header: {
cookie: '', // If you want to use cookies, here is the place
}
} }
}); });
/* Discord fingerprint ??? idk ... */
/**
* const { data } = await axios.get('https://discord.com/api/v9/experiments');
* client.options.http.header['x-fingerprint'] = data.fingerprint
*/
``` ```
## Client Settings ## Client Settings

View File

@ -4,42 +4,11 @@ const CachedManager = require('./CachedManager');
const { default: Collection } = require('@discordjs/collection'); const { default: Collection } = require('@discordjs/collection');
const { Error, TypeError } = require('../errors/DJSError'); const { Error, TypeError } = require('../errors/DJSError');
const { remove } = require('lodash'); const { remove } = require('lodash');
const { localeObject, DMScanLevel, stickerAnimationMode } = require('../util/Constants')
/** /**
* Manages API methods for users and stores their cache. * Manages API methods for users and stores their cache.
* @extends {CachedManager} * @extends {CachedManager}
*/ */
const localeObject = {
DANISH: 'da',
GERMAN: 'de',
ENGLISH_UK: 'en-GB',
ENGLISH_US: 'en-US',
SPANISH: 'es-ES',
FRENCH: 'fr',
CROATIAN: 'hr',
ITALIAN: 'it',
LITHUANIAN: 'lt',
HUNGARIAN: 'hu',
DUTCH: 'nl',
NORWEGIAN: 'no',
POLISH: 'pl',
BRAZILIAN_PORTUGUESE: 'pt-BR',
ROMANIA_ROMANIAN: 'ro',
FINNISH: 'fi',
SWEDISH: 'sv-SE',
VIETNAMESE: 'vi',
TURKISH: 'tr',
CZECH: 'cs',
GREEK: 'el',
BULGARIAN: 'bg',
RUSSIAN: 'ru',
UKRAINIAN: 'uk',
HINDI: 'hi',
THAI: 'th',
CHINA_CHINESE: 'zh-CN',
JAPANESE: 'ja',
TAIWAN_CHINESE: 'zh-TW',
KOREAN: 'ko',
};
class ClientUserSettingManager extends CachedManager { class ClientUserSettingManager extends CachedManager {
constructor(client, iterable) { constructor(client, iterable) {
super(client); super(client);
@ -48,19 +17,43 @@ class ClientUserSettingManager extends CachedManager {
// Language // Language
this.locale = null; this.locale = null;
// Setting => ACTIVITY SETTINGS => Activity Status => Display current activity as a status message // Setting => ACTIVITY SETTINGS => Activity Status => Display current activity as a status message
this.showCurrentGame = null; this.activityDisplay = null;
//
this.disableDMfromServer = new Collection();
// Allow direct messages from server members
this.DMfromServerMode = null;
//
this.displayImage = null;
//
this.linkedImageDisplay = null;
// Setting => APP SETTINGS => Accessibility => Automatically play GIFs when Discord is focused. // Setting => APP SETTINGS => Accessibility => Automatically play GIFs when Discord is focused.
this.autoplayGIF = null; this.autoplayGIF = null;
// Show embeds and preview website links pasted into chat
this.previewLink = null;
// Setting => APP SETTINGS => Accessibility => Play Animated Emojis
this.animatedEmojis = null;
// Setting => APP SETTINGS => Accessibility => Text-to-speech => Allow playback
this.allowTTS = null;
// Setting => APP SETTINGS => Appearance => Message Display => Compact Mode [OK] // Setting => APP SETTINGS => Appearance => Message Display => Compact Mode [OK]
this.compactMode = null; this.compactMode = null;
// Setting => APP SETTINGS => Text & Images => Emoji => Convert Emoticons // Setting => APP SETTINGS => Text & Images => Emoji => Convert Emoticons
this.convertEmoticons = null; this.convertEmoticons = null;
// Setting => APP SETTINGS => Accessibility => Text-to-speech => Allow playback // SAFE DIRECT MESSAGING
this.allowTTS = null; this.DMScanLevel = null;
// Setting => APP SETTINGS => Appearance => Theme [OK] // Setting => APP SETTINGS => Appearance => Theme [OK]
this.theme = ''; this.theme = '';
// Setting => APP SETTINGS => Accessibility => Play Animated Emojis //
this.animatedEmojis = null; this.developerMode = null;
//
this.afkTimeout = null;
//
this.stickerAnimationMode = null;
// WHO CAN ADD YOU AS A FRIEND ?
this.addFriendFrom = {
all: null,
mutual_friends: null,
mutual_guilds: null,
};
// Setting => APP SETTINGS => Text & Images => Emoji => Show emoji reactions // Setting => APP SETTINGS => Text & Images => Emoji => Show emoji reactions
this.showEmojiReactions = null; this.showEmojiReactions = null;
// Custom Stauts [It's not working now] // Custom Stauts [It's not working now]
@ -72,33 +65,58 @@ class ClientUserSettingManager extends CachedManager {
/** /**
* *
* @param {Object} data Raw Data to patch * @param {Object} data Raw Data to patch
* @extends https://github.com/Merubokkusu/Discord-S.C.U.M/blob/master/discum/user/user.py
* @private * @private
*/ */
_patch(data) { _patch(data) {
this.rawSetting = data; this.rawSetting = data;
if ('locale' in data) { if ('locale' in data) {
this.locale = data.locale; this.locale = localeObject[data.locale];
} }
if ('show_current_game' in data) { if ('show_current_game' in data) {
this.showCurrentGame = data.show_current_game; this.activityDisplay = data.show_current_game;
}
if ('default_guilds_restricted' in data) {
this.DMfromServerMode = data.default_guilds_restricted;
}
if ('inline_attachment_media' in data) {
this.displayImage = data.inline_attachment_media;
}
if ('inline_embed_media' in data) {
this.linkedImageDisplay = data.inline_embed_media;
} }
if ('gif_auto_play' in data) { if ('gif_auto_play' in data) {
this.autoplayGIF = data.gif_auto_play; this.autoplayGIF = data.gif_auto_play;
} }
if ('render_embeds' in data) {
this.previewLink = data.render_embeds;
}
if ('animate_emoji' in data) {
this.animatedEmojis = data.animate_emoji;
}
if ('enable_tts_command' in data) {
this.allowTTS = data.enable_tts_command;
}
if ('message_display_compact' in data) { if ('message_display_compact' in data) {
this.compactMode = data.message_display_compact; this.compactMode = data.message_display_compact;
} }
if ('convert_emoticons' in data) { if ('convert_emoticons' in data) {
this.convertEmoticons = data.convert_emoticons; this.convertEmoticons = data.convert_emoticons;
} }
if ('enable_tts_command' in data) { if ('explicit_content_filter' in data) {
this.allowTTS = data.enable_tts_command; this.DMScanLevel = DMScanLevel[data.explicit_content_filter];
} }
if ('theme' in data) { if ('theme' in data) {
this.theme = data.theme; this.theme = data.theme;
} }
if ('animate_emoji' in data) { if ('developer_mode' in data) {
this.animatedEmojis = data.animate_emoji; this.developerMode = data.developer_mode;
}
if ('afk_timeout' in data) {
this.afkTimeout = data.afk_timeout * 1000; // second => milisecond
}
if ('animate_stickers' in data) {
this.stickerAnimationMode = stickerAnimationMode[data.animate_stickers];
} }
if ('render_reactions' in data) { if ('render_reactions' in data) {
this.showEmojiReactions = data.render_reactions; this.showEmojiReactions = data.render_reactions;
@ -107,6 +125,15 @@ class ClientUserSettingManager extends CachedManager {
this.customStatus = data.custom_status || {}; // Thanks PinkDuwc._#3443 reported this issue this.customStatus = data.custom_status || {}; // Thanks PinkDuwc._#3443 reported this issue
this.customStatus.status = data.status; this.customStatus.status = data.status;
} }
if ('friend_source_flags' in data) {
this.addFriendFrom = {
all: data.friend_source_flags.all || false,
mutual_friends:
data.friend_source_flags.all ? true : data.friend_source_flags.mutual_friends,
mutual_guilds:
data.friend_source_flags.all ? true : data.friend_source_flags.mutual_guilds,
};
}
if ('guild_folders' in data) { if ('guild_folders' in data) {
const data_ = data.guild_positions.map((guildId, i) => { const data_ = data.guild_positions.map((guildId, i) => {
// Find folder // Find folder
@ -126,6 +153,14 @@ class ClientUserSettingManager extends CachedManager {
}); });
this.guildMetadata = new Collection(data_); this.guildMetadata = new Collection(data_);
} }
if ('restricted_guilds' in data) {
data.restricted_guilds.map((guildId) => {
const guild = this.client.guilds.cache.get(guildId);
if (!guild) return;
guild.disableDM = true;
this.disableDMfromServer.set(guildId, true);
});
}
} }
async fetch() { async fetch() {
if (this.client.bot) throw new Error('INVALID_BOT_METHOD'); if (this.client.bot) throw new Error('INVALID_BOT_METHOD');
@ -286,8 +321,9 @@ class ClientUserSettingManager extends CachedManager {
const oldGuildFolderPosition = this.rawSetting.guild_folders.findIndex( const oldGuildFolderPosition = this.rawSetting.guild_folders.findIndex(
(value) => value.guild_ids.includes(guildId), (value) => value.guild_ids.includes(guildId),
); );
const newGuildFolderPosition = this.rawSetting.guild_folders.findIndex((value) => const newGuildFolderPosition = this.rawSetting.guild_folders.findIndex(
value.guild_ids.includes(this.rawSetting.guild_positions[newPosition]), (value) =>
value.guild_ids.includes(this.rawSetting.guild_positions[newPosition]),
); );
if (type == 2 || `${type}`.toUpperCase() == 'HOME') { if (type == 2 || `${type}`.toUpperCase() == 'HOME') {
// Delete GuildID from Folder and create new Folder // Delete GuildID from Folder and create new Folder

View File

@ -128,6 +128,8 @@ class Guild extends AnonymousGuild {
* @type {number} * @type {number}
*/ */
this.shardId = data.shardId; this.shardId = data.shardId;
this.disableDM = false;
} }
/** /**

View File

@ -103,6 +103,51 @@ const listUserAgent = [
"Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1" "Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1"
] ]
exports.DMScanLevel = {
0: 'NOT_SCAN',
1: 'NOT_FRIEND',
2: 'EVERYONE',
};
exports.stickerAnimationMode = {
0: 'ALWAYS',
1: 'INTERACTION',
2: 'NEVER',
};
exports.localeObject = {
da: 'DANISH',
de: 'GERMAN',
'en-GB': 'ENGLISH_UK',
'en-US': 'ENGLISH_US',
'es-ES': 'SPANISH',
fr: 'FRENCH',
hr: 'CROATIAN',
it: 'ITALIAN',
lt: 'LITHUANIAN',
hu: 'HUNGARIAN',
nl: 'DUTCH',
no: 'NORWEGIAN',
pl: 'POLISH',
'pt-BR': 'BRAZILIAN_PORTUGUESE',
ro: 'ROMANIA_ROMANIAN',
fi: 'FINNISH',
'sv-SE': 'SWEDISH',
vi: 'VIETNAMESE',
tr: 'TURKISH',
cs: 'CZECH',
el: 'GREEK',
bg: 'BULGARIAN',
ru: 'RUSSIAN',
uk: 'UKRAINIAN',
hi: 'HINDI',
th: 'THAI',
'zh-CN': 'CHINA_CHINESE',
ja: 'JAPANESE',
'zh-TW': 'TAIWAN_CHINESE',
ko: 'KOREAN',
};
exports.UserAgent = listUserAgent[Math.floor(Math.random() * listUserAgent.length)]; exports.UserAgent = listUserAgent[Math.floor(Math.random() * listUserAgent.length)];
exports.WSCodes = { exports.WSCodes = {

View File

@ -132,76 +132,91 @@ class Options extends null {
*/ */
static createDefault() { static createDefault() {
return { return {
jsonTransformer: (object) => JSONBig.stringify(object), jsonTransformer: (object) => JSONBig.stringify(object),
checkUpdate: true, checkUpdate: true,
readyStatus: false, readyStatus: false,
waitGuildTimeout: 15_000, waitGuildTimeout: 15_000,
shardCount: 1, shardCount: 1,
makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings), makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings),
messageCacheLifetime: 0, messageCacheLifetime: 0,
messageSweepInterval: 0, messageSweepInterval: 0,
invalidRequestWarningInterval: 0, invalidRequestWarningInterval: 0,
intents: 65535, intents: 65535,
partials: [ partials: [
'USER', 'USER',
'CHANNEL', 'CHANNEL',
'GUILD_MEMBER', 'GUILD_MEMBER',
'MESSAGE', 'MESSAGE',
'REACTION', 'REACTION',
'GUILD_SCHEDULED_EVENT', 'GUILD_SCHEDULED_EVENT',
], // Enable the partials ], // Enable the partials
restWsBridgeTimeout: 5_000, restWsBridgeTimeout: 5_000,
restRequestTimeout: 15_000, restRequestTimeout: 15_000,
restGlobalRateLimit: 0, restGlobalRateLimit: 0,
retryLimit: 1, retryLimit: 1,
restTimeOffset: 500, restTimeOffset: 500,
restSweepInterval: 60, restSweepInterval: 60,
failIfNotExists: false, failIfNotExists: false,
userAgentSuffix: [], userAgentSuffix: [],
presence: {}, presence: {},
sweepers: {}, sweepers: {},
ws: { ws: {
large_threshold: 50, large_threshold: 50,
compress: false, compress: false,
properties: { properties: {
//$os: 'iPhone14,5', //$os: 'iPhone14,5',
//$browser: 'Discord iOS', //$browser: 'Discord iOS',
//$device: 'iPhone14,5 OS 15.2', //$device: 'iPhone14,5 OS 15.2',
$os: 'Windows 11', $os: 'Windows',
$browser: 'Chrome', $browser: 'Discord Client',
$device: 'ASUS ROG Phone 5', $device: 'ASUS ROG Phone 5',
}, },
version: 9, version: 9,
}, },
http: { http: {
headers: { headers: {
Accept: '*/*', Accept: '*/*',
// 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9', 'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'no-cache', 'Cache-Control': 'no-cache',
// 'Content-Type': 'application/json', Pragma: 'no-cache',
Pragma: 'no-cache', Referer: 'https://discord.com/channels/@me',
Referer: 'https://discord.com/channels/@me', 'Sec-Ch-Ua': '" Not A;Brand";v="99" "',
'Sec-Ch-Ua': '" Not A;Brand";v="99" "', 'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"iOS"',
'Sec-Ch-Ua-Platform': '"iOS"', 'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Site': 'same-origin', 'X-Debug-Options': 'bugReporterEnabled',
'X-Debug-Options': 'bugReporterEnabled', // https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66#issuecomment-1009171667
'X-Discord-Locale': 'en-US', 'x-super-properties': `${Buffer.from(
Origin: 'https://discord.com', JSONBig.stringify({
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36', os: 'Windows',
}, browser: 'Discord Client',
agent: {}, release_channel: 'stable',
version: 9, client_version: '1.0.9004',
api: 'https://discord.com/api', os_version: '10.0.22000',
cdn: 'https://cdn.discordapp.com', os_arch: 'x64',
invite: 'https://discord.gg', system_locale: 'en-US',
template: 'https://discord.new', client_build_number: 122087,
scheduledEvent: 'https://discord.com/events', client_event_source: null,
}, }),
}; 'ascii',
).toString('base64')}`,
'X-Discord-Locale': 'en-US',
Origin: 'https://discord.com',
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9004 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36',
},
agent: {},
version: 9,
api: 'https://discord.com/api',
cdn: 'https://cdn.discordapp.com',
invite: 'https://discord.gg',
template: 'https://discord.new',
scheduledEvent: 'https://discord.com/events',
},
};
} }
/** /**

45
typings/enums.d.ts vendored
View File

@ -10,6 +10,51 @@ export const enum ActivityTypes {
COMPETING = 5, COMPETING = 5,
} }
export const enum DMScanLevel {
NOT_SCAN = 0,
NOT_FRIEND = 1,
EVERYONE = 2,
}
export const enum stickerAnimationMode {
ALWAYS = 0,
INTERACTION = 1,
NEVER = 2,
}
export const enum localeSetting {
DANISH = 'da',
GERMAN = 'de',
ENGLISH_UK = 'en-GB',
ENGLISH_US = 'en-US',
SPANISH = 'es-ES',
FRENCH = 'fr',
CROATIAN = 'hr',
ITALIAN = 'it',
LITHUANIAN = 'lt',
HUNGARIAN = 'hu',
DUTCH = 'nl',
NORWEGIAN = 'no',
POLISH = 'pl',
BRAZILIAN_PORTUGUESE = 'pt-BR',
ROMANIA_ROMANIAN = 'ro',
FINNISH = 'fi',
SWEDISH = 'sv-SE',
VIETNAMESE = 'vi',
TURKISH = 'tr',
CZECH = 'cs',
GREEK = 'el',
BULGARIAN = 'bg',
RUSSIAN = 'ru',
UKRAINIAN = 'uk',
HINDI = 'hi',
THAI = 'th',
CHINA_CHINESE = 'zh-CN',
JAPANESE = 'ja',
TAIWAN_CHINESE = 'zh-TW',
KOREAN = 'ko',
}
export const enum ApplicationCommandTypes { export const enum ApplicationCommandTypes {
CHAT_INPUT = 1, CHAT_INPUT = 1,
USER = 2, USER = 2,

3
typings/index.d.ts vendored
View File

@ -941,6 +941,7 @@ export class Guild extends AnonymousGuild {
public premiumProgressBarEnabled: boolean; public premiumProgressBarEnabled: boolean;
public premiumTier: PremiumTier; public premiumTier: PremiumTier;
public presences: PresenceManager; public presences: PresenceManager;
public readonly disableDM: boolean;
public readonly publicUpdatesChannel: TextChannel | null; public readonly publicUpdatesChannel: TextChannel | null;
public publicUpdatesChannelId: Snowflake | null; public publicUpdatesChannelId: Snowflake | null;
public roles: RoleManager; public roles: RoleManager;
@ -3067,7 +3068,7 @@ export class ClientUserSettingManager extends CachedManager<Snowflake, null> {
public fetch(): Promise<ClientUserSetting>; public fetch(): Promise<ClientUserSetting>;
public setDisplayCompactMode(value?: boolean): Promise<ClientUserSetting>; public setDisplayCompactMode(value?: boolean): Promise<ClientUserSetting>;
public setTheme(value?: 'dark' | 'light'): Promise<ClientUserSetting>; public setTheme(value?: 'dark' | 'light'): Promise<ClientUserSetting>;
public setLocale(value: LocaleStrings): Promise<ClientUserSetting>; public setLocale(value: localeSetting): Promise<ClientUserSetting>;
} }
export class GuildApplicationCommandManager extends ApplicationCommandManager<ApplicationCommand, {}, Guild> { export class GuildApplicationCommandManager extends ApplicationCommandManager<ApplicationCommand, {}, Guild> {