diff --git a/DOCUMENT.md b/DOCUMENT.md index 60cbacc..648ce64 100644 --- a/DOCUMENT.md +++ b/DOCUMENT.md @@ -13,10 +13,17 @@ const client = new Client({ version: 10 }, 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 diff --git a/src/managers/ClientUserSettingManager.js b/src/managers/ClientUserSettingManager.js index e19f99a..08dc09f 100644 --- a/src/managers/ClientUserSettingManager.js +++ b/src/managers/ClientUserSettingManager.js @@ -4,42 +4,11 @@ const CachedManager = require('./CachedManager'); const { default: Collection } = require('@discordjs/collection'); const { Error, TypeError } = require('../errors/DJSError'); const { remove } = require('lodash'); +const { localeObject, DMScanLevel, stickerAnimationMode } = require('../util/Constants') /** * Manages API methods for users and stores their cache. * @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 { constructor(client, iterable) { super(client); @@ -48,19 +17,43 @@ class ClientUserSettingManager extends CachedManager { // Language this.locale = null; // 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. 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] this.compactMode = null; // Setting => APP SETTINGS => Text & Images => Emoji => Convert Emoticons this.convertEmoticons = null; - // Setting => APP SETTINGS => Accessibility => Text-to-speech => Allow playback - this.allowTTS = null; + // SAFE DIRECT MESSAGING + this.DMScanLevel = null; // Setting => APP SETTINGS => Appearance => Theme [OK] 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 this.showEmojiReactions = null; // Custom Stauts [It's not working now] @@ -72,33 +65,58 @@ class ClientUserSettingManager extends CachedManager { /** * * @param {Object} data Raw Data to patch + * @extends https://github.com/Merubokkusu/Discord-S.C.U.M/blob/master/discum/user/user.py * @private */ _patch(data) { this.rawSetting = data; if ('locale' in data) { - this.locale = data.locale; + this.locale = localeObject[data.locale]; } 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) { 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) { this.compactMode = data.message_display_compact; } if ('convert_emoticons' in data) { this.convertEmoticons = data.convert_emoticons; } - if ('enable_tts_command' in data) { - this.allowTTS = data.enable_tts_command; + if ('explicit_content_filter' in data) { + this.DMScanLevel = DMScanLevel[data.explicit_content_filter]; } if ('theme' in data) { this.theme = data.theme; } - if ('animate_emoji' in data) { - this.animatedEmojis = data.animate_emoji; + if ('developer_mode' in data) { + 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) { 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.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) { const data_ = data.guild_positions.map((guildId, i) => { // Find folder @@ -126,6 +153,14 @@ class ClientUserSettingManager extends CachedManager { }); 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() { 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( (value) => value.guild_ids.includes(guildId), ); - const newGuildFolderPosition = this.rawSetting.guild_folders.findIndex((value) => - value.guild_ids.includes(this.rawSetting.guild_positions[newPosition]), + const newGuildFolderPosition = this.rawSetting.guild_folders.findIndex( + (value) => + value.guild_ids.includes(this.rawSetting.guild_positions[newPosition]), ); if (type == 2 || `${type}`.toUpperCase() == 'HOME') { // Delete GuildID from Folder and create new Folder diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 5ff0a2e..1626d10 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -128,6 +128,8 @@ class Guild extends AnonymousGuild { * @type {number} */ this.shardId = data.shardId; + + this.disableDM = false; } /** diff --git a/src/util/Constants.js b/src/util/Constants.js index 8397e34..cecf8f5 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -103,6 +103,51 @@ const listUserAgent = [ "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.WSCodes = { diff --git a/src/util/Options.js b/src/util/Options.js index 18ae24b..2b24a03 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -132,76 +132,91 @@ class Options extends null { */ static createDefault() { return { - jsonTransformer: (object) => JSONBig.stringify(object), - checkUpdate: true, - readyStatus: false, - waitGuildTimeout: 15_000, - shardCount: 1, - makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings), - messageCacheLifetime: 0, - messageSweepInterval: 0, - invalidRequestWarningInterval: 0, - intents: 65535, - partials: [ - 'USER', - 'CHANNEL', - 'GUILD_MEMBER', - 'MESSAGE', - 'REACTION', - 'GUILD_SCHEDULED_EVENT', - ], // Enable the partials - restWsBridgeTimeout: 5_000, - restRequestTimeout: 15_000, - restGlobalRateLimit: 0, - retryLimit: 1, - restTimeOffset: 500, - restSweepInterval: 60, - failIfNotExists: false, - userAgentSuffix: [], - presence: {}, - sweepers: {}, - ws: { - large_threshold: 50, - compress: false, - properties: { - //$os: 'iPhone14,5', - //$browser: 'Discord iOS', - //$device: 'iPhone14,5 OS 15.2', - $os: 'Windows 11', - $browser: 'Chrome', - $device: 'ASUS ROG Phone 5', - }, - version: 9, - }, - http: { - headers: { - Accept: '*/*', - // 'Accept-Encoding': 'gzip, deflate, br', - 'Accept-Language': 'en-US,en;q=0.9', - 'Cache-Control': 'no-cache', - // 'Content-Type': 'application/json', - Pragma: 'no-cache', - Referer: 'https://discord.com/channels/@me', - 'Sec-Ch-Ua': '" Not A;Brand";v="99" "', - 'Sec-Ch-Ua-Mobile': '?0', - 'Sec-Ch-Ua-Platform': '"iOS"', - 'Sec-Fetch-Dest': 'empty', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Site': 'same-origin', - 'X-Debug-Options': 'bugReporterEnabled', - 'X-Discord-Locale': 'en-US', - Origin: 'https://discord.com', - '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', - }, - 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', - }, - }; + jsonTransformer: (object) => JSONBig.stringify(object), + checkUpdate: true, + readyStatus: false, + waitGuildTimeout: 15_000, + shardCount: 1, + makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings), + messageCacheLifetime: 0, + messageSweepInterval: 0, + invalidRequestWarningInterval: 0, + intents: 65535, + partials: [ + 'USER', + 'CHANNEL', + 'GUILD_MEMBER', + 'MESSAGE', + 'REACTION', + 'GUILD_SCHEDULED_EVENT', + ], // Enable the partials + restWsBridgeTimeout: 5_000, + restRequestTimeout: 15_000, + restGlobalRateLimit: 0, + retryLimit: 1, + restTimeOffset: 500, + restSweepInterval: 60, + failIfNotExists: false, + userAgentSuffix: [], + presence: {}, + sweepers: {}, + ws: { + large_threshold: 50, + compress: false, + properties: { + //$os: 'iPhone14,5', + //$browser: 'Discord iOS', + //$device: 'iPhone14,5 OS 15.2', + $os: 'Windows', + $browser: 'Discord Client', + $device: 'ASUS ROG Phone 5', + }, + version: 9, + }, + http: { + headers: { + Accept: '*/*', + 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'en-US,en;q=0.9', + 'Cache-Control': 'no-cache', + Pragma: 'no-cache', + Referer: 'https://discord.com/channels/@me', + 'Sec-Ch-Ua': '" Not A;Brand";v="99" "', + 'Sec-Ch-Ua-Mobile': '?0', + 'Sec-Ch-Ua-Platform': '"iOS"', + 'Sec-Fetch-Dest': 'empty', + 'Sec-Fetch-Mode': 'cors', + 'Sec-Fetch-Site': 'same-origin', + 'X-Debug-Options': 'bugReporterEnabled', + // https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66#issuecomment-1009171667 + 'x-super-properties': `${Buffer.from( + JSONBig.stringify({ + os: 'Windows', + browser: 'Discord Client', + release_channel: 'stable', + client_version: '1.0.9004', + os_version: '10.0.22000', + os_arch: 'x64', + system_locale: 'en-US', + client_build_number: 122087, + 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', + }, + }; } /** diff --git a/typings/enums.d.ts b/typings/enums.d.ts index e23a307..ed971d8 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -10,6 +10,51 @@ export const enum ActivityTypes { 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 { CHAT_INPUT = 1, USER = 2, diff --git a/typings/index.d.ts b/typings/index.d.ts index 0c32160..7bcadc2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -941,6 +941,7 @@ export class Guild extends AnonymousGuild { public premiumProgressBarEnabled: boolean; public premiumTier: PremiumTier; public presences: PresenceManager; + public readonly disableDM: boolean; public readonly publicUpdatesChannel: TextChannel | null; public publicUpdatesChannelId: Snowflake | null; public roles: RoleManager; @@ -3067,7 +3068,7 @@ export class ClientUserSettingManager extends CachedManager { public fetch(): Promise; public setDisplayCompactMode(value?: boolean): Promise; public setTheme(value?: 'dark' | 'light'): Promise; - public setLocale(value: LocaleStrings): Promise; + public setLocale(value: localeSetting): Promise; } export class GuildApplicationCommandManager extends ApplicationCommandManager {