Closed civiltox closed 10 months ago
i've tried installing brotli and updating aiohttp, both fail
Have same issue from today morning. specs: windows 11 python 3.11 discord.py-self - 2.0.0
I retraced the action that the utils.py
is performing to pull the build number and Discord may have changed the content of the .js
file its scraping it from. Here is the relevant snippet that the code is currently pulling which is the source of the error:
DEV_NOTICE_STAGING:"Staging {buildNumber}",NOTIF_CENTER_V2_VIEW_SUMMARY
Looking at the code itself on line 1474:
async def _get_build_number(session: ClientSession) -> int: # Thank you Discord-S.C.U.M
"""Fetches client build number"""
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_index = build_file.find('buildNumber') + 24
return int(build_file[build_index : build_index + 6])
except asyncio.TimeoutError:
_log.critical('Could not fetch client build number. Falling back to hardcoded value...')
return 9999
The exception handler is only catching asyncio.TimeoutError
which means when the integer conversion fails, the whole thing fails.
Using the same .js
file that is being evaluated, I found this line of code:
log("[BUILD INFO] Release Channel: ".concat(L,", Build Number: ").concat("244358",", Version Hash: ").concat("c189fc12370cb266be57cc968e278e86f7030f9b")),t.default.setTags({appContext:l.CURRENT_APP_CONTEXT}),S.default.initBasic(),N.default.init(),I.FocusRingManager.init(),O.init(),(0,R.cleanupTempFiles)()},599417:function(e,_,E){"use strict";E.r(_),E.d(_,{default:function(){return r}});var t=E("872717"),o=E("49111"),n=E("782340");class r extends t.default.V8APIError
The number 244358
does align with what Discord is telling me the build number is (and that number appears multiple times in that file near the text "Build Number"), so there are probably two fixes to be made, here:
build_index = build_file.find('Build Number') + 25
Same error here
Same error here too
Same
same error, since this morning
iv had my bot open for days, so its working. but when I restarted my computer. i got the same issue too. and 2 other people ik got it too.
FIX: for util.py
I did not send a pull request, anyone who are interested can do this
async def _get_build_number(session: ClientSession) -> int:
"""Fetches client build number"""
try:
login_page_request = await session.get('https://discord.com/login', timeout=7)
login_page = await login_page_request.text()
# Find all potential JavaScript files that could contain the build number
js_files = re.findall(r'assets/([a-z0-9]+)\.js', login_page)
# Check each JavaScript file for the build number
for js_file in js_files:
build_url = f'https://discord.com/assets/{js_file}.js'
build_request = await session.get(build_url, timeout=7)
build_file = await build_request.text()
# Look for 'buildNumber' in the JS file
build_index = build_file.find('buildNumber') + len('buildNumber') + 2 # Adjusting the offset to after "buildNumber":
# Try to extract a six-digit number, assuming that the build number is 6 digits
possible_build_number = build_file[build_index: build_index + 6]
# If we find a number, return it
if possible_build_number.isdigit():
return int(possible_build_number)
# If no build number is found in any file, fall back to the hardcoded value
_log.critical('Could not fetch client build number. Falling back to hardcoded value...')
return 244594
except asyncio.TimeoutError as e:
_log.critical(f'Could not fetch client build number due to timeout: {e}')
return 244594
same
I'm using discord.py-self 2.0.0, Python 3.11.5 and it's working for me somehow. Had problems yesterday when the Auth/API was down but since then worked perfectly again.
Having the same issue
async def _get_build_number(session: ClientSession) -> int: """Fetches client build number""" try: login_page_request = await session.get('https://discord.com/login', timeout=7) login_page = await login_page_request.text()
Find all potential JavaScript files that could contain the build number
js_files = re.findall(r'assets/([a-z0-9]+)\.js', login_page) # Check each JavaScript file for the build number for js_file in js_files: build_url = f'https://discord.com/assets/{js_file}.js' build_request = await session.get(build_url, timeout=7) build_file = await build_request.text() # Look for 'buildNumber' in the JS file build_index = build_file.find('buildNumber') + len('buildNumber') + 2 # Adjusting the offset to after "buildNumber": # Try to extract a six-digit number, assuming that the build number is 6 digits possible_build_number = build_file[build_index: build_index + 6] # If we find a number, return it if possible_build_number.isdigit(): return int(possible_build_number) # If no build number is found in any file, fall back to the hardcoded value _log.critical('Could not fetch client build number. Falling back to hardcoded value...') return 244594 except asyncio.TimeoutError as e: _log.critical(f'Could not fetch client build number due to timeout: {e}') return 244594
thanks! solved the issue for me.
FIX: for util.py
I did not send a pull request, anyone who are interested can do this
async def _get_build_number(session: ClientSession) -> int: """Fetches client build number""" try: login_page_request = await session.get('https://discord.com/login', timeout=7) login_page = await login_page_request.text() # Find all potential JavaScript files that could contain the build number js_files = re.findall(r'assets/([a-z0-9]+)\.js', login_page) # Check each JavaScript file for the build number for js_file in js_files: build_url = f'https://discord.com/assets/{js_file}.js' build_request = await session.get(build_url, timeout=7) build_file = await build_request.text() # Look for 'buildNumber' in the JS file build_index = build_file.find('buildNumber') + len('buildNumber') + 2 # Adjusting the offset to after "buildNumber": # Try to extract a six-digit number, assuming that the build number is 6 digits possible_build_number = build_file[build_index: build_index + 6] # If we find a number, return it if possible_build_number.isdigit(): return int(possible_build_number) # If no build number is found in any file, fall back to the hardcoded value _log.critical('Could not fetch client build number. Falling back to hardcoded value...') return 244594 except asyncio.TimeoutError as e: _log.critical(f'Could not fetch client build number due to timeout: {e}') return 244594
god!
Fixed in #596
Fixed in #596
Also add it to "Releases" and to "PyPi" so to those who install via PIP can use it, I am sure 99% people install via PIP
Fixed in #596
Also add it to "Releases" and to PyPi so to those who install with PIP can use it, I am 99% people install via PIP
SAME
Yeah, it's been quite a while since a release has been made...
Can you please help me how to fix this problem like the author, I don't understand it
FIX: for util.py
I did not send a pull request, anyone who are interested can do this
async def _get_build_number(session: ClientSession) -> int: """Fetches client build number""" try: login_page_request = await session.get('https://discord.com/login', timeout=7) login_page = await login_page_request.text() # Find all potential JavaScript files that could contain the build number js_files = re.findall(r'assets/([a-z0-9]+)\.js', login_page) # Check each JavaScript file for the build number for js_file in js_files: build_url = f'https://discord.com/assets/{js_file}.js' build_request = await session.get(build_url, timeout=7) build_file = await build_request.text() # Look for 'buildNumber' in the JS file build_index = build_file.find('buildNumber') + len('buildNumber') + 2 # Adjusting the offset to after "buildNumber": # Try to extract a six-digit number, assuming that the build number is 6 digits possible_build_number = build_file[build_index: build_index + 6] # If we find a number, return it if possible_build_number.isdigit(): return int(possible_build_number) # If no build number is found in any file, fall back to the hardcoded value _log.critical('Could not fetch client build number. Falling back to hardcoded value...') return 244594 except asyncio.TimeoutError as e: _log.critical(f'Could not fetch client build number due to timeout: {e}') return 244594
how how do I do that?
where should I insert it
where should I insert it
Just install the development version here is guide: https://github.com/dolfies/discord.py-self#installing
To install the development version, do the following:
$ git clone https://github.com/dolfies/discord.py-self
$ cd discord.py-self
$ python3 -m pip install -U .
where should I insert it
Just install the development version here is guide: https://github.com/dolfies/discord.py-self#installing
To install the development version, do the following:
$ git clone https://github.com/dolfies/discord.py-self $ cd discord.py-self $ python3 -m pip install -U .
Thanks so much. This worked!
Has this bug been fixed? I encountered the same problem。and I have cloned the developer version, but it doesn't work。Maybe my network connection is not up to this address, I need someone help🙏🏻
Summary
Info API Down
Reproduction Steps
opening main.py
Code
Expected Results
its meant to work
Actual Results
its failing idk what else to put here
System Information
Checklist
Additional Information
No response