Browse Source

Set X-Discord-Locale header based on user settings

pull/10109/head
dolfies 2 years ago
parent
commit
7167014a6e
  1. 1
      discord/client.py
  2. 7
      discord/http.py

1
discord/client.py

@ -260,6 +260,7 @@ class Client:
http_trace=http_trace,
captcha_handler=captcha_handler,
max_ratelimit_timeout=max_ratelimit_timeout,
locale=lambda: self._connection.locale,
)
self._handlers: Dict[str, Callable[..., None]] = {

7
discord/http.py

@ -31,6 +31,7 @@ import ssl
import string
from typing import (
Any,
Callable,
ClassVar,
Coroutine,
Dict,
@ -573,6 +574,7 @@ class HTTPClient:
http_trace: Optional[aiohttp.TraceConfig] = None,
captcha_handler: Optional[CaptchaHandler] = None,
max_ratelimit_timeout: Optional[float] = None,
locale: Callable[[], str] = lambda: 'en-US',
) -> None:
self.loop: asyncio.AbstractEventLoop = loop
self.connector: aiohttp.BaseConnector = connector or MISSING
@ -595,6 +597,7 @@ class HTTPClient:
self.use_clock: bool = not unsync_clock
self.captcha_handler: Optional[CaptchaHandler] = captcha_handler
self.max_ratelimit_timeout: Optional[float] = max(30.0, max_ratelimit_timeout) if max_ratelimit_timeout else None
self.get_locale: Callable[[], str] = locale
self.super_properties: Dict[str, Any] = {}
self.encoded_super_properties: str = MISSING
@ -713,7 +716,7 @@ class HTTPClient:
'Origin': 'https://discord.com',
'Pragma': 'no-cache',
'Referer': 'https://discord.com/channels/@me',
'Sec-CH-UA': '"Google Chrome";v="{0}", "Chromium";v="{0}", ";Not A Brand";v="99"'.format(
'Sec-CH-UA': '"Google Chrome";v="{0}", "Chromium";v="{0}", ";Not-A.Brand";v="24"'.format(
self.browser_version.split('.')[0]
),
'Sec-CH-UA-Mobile': '?0',
@ -722,7 +725,7 @@ class HTTPClient:
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': self.user_agent,
'X-Discord-Locale': 'en-US',
'X-Discord-Locale': self.get_locale(),
'X-Debug-Options': 'bugReporterEnabled',
'X-Super-Properties': self.encoded_super_properties,
}

Loading…
Cancel
Save