Skip to content

Commit

Permalink
Merge pull request dolfies#1 from pc111c/patch-1
Browse files Browse the repository at this point in the history
Update utils.py
  • Loading branch information
pc111c authored Dec 1, 2023
2 parents 4076a3b + 877eb07 commit d740474
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,11 +1477,13 @@ async def _get_build_number(session: ClientSession) -> int: # Thank you Discord
try:
login_page_request = await session.get('https://discord.com/login', timeout=7)
login_page = await login_page_request.text()
build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+)\.js').findall(login_page)[-2] + '.js'
build_request = await session.get(build_url, timeout=7)
build_file = await build_request.text()
build_find = re.findall(r'Build Number:\D+"(\d+)"', build_file)
return int(build_find[0]) if build_find else default_build_number
for asset in re.compile(r'(\w+\.[a-z0-9]+)\.js').findall(login_page)[-1:]:
build_url = 'https://discord.com/assets/' + asset + '.js'
build_request = await session.get(build_url, timeout=7)
build_file = await build_request.text()
build_find = re.findall(r'Build Number:\D+"(\d+)"', build_file)
if build_find:
return int(build_find[0]) if build_find else default_build_number
except asyncio.TimeoutError:
_log.critical('Could not fetch client build number. Falling back to hardcoded value...')
return default_build_number
Expand Down

0 comments on commit d740474

Please sign in to comment.