dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
718 stars 165 forks source link

IndexError: list index out of range on login(latest version) #619

Closed TutlaMC closed 11 months ago

TutlaMC commented 11 months ago

Summary

When logging in normally in latest version without any code causes a crash

Reproduction Steps

How to create the bug: Step 1: Have python 3.12 and discord.py-self Step 2: Put this code and run it:

class Client(discord.Client):
    async def on_ready(self):
        print("ready")
token = ''
client = Client()
client.run(token)```

### Code

```python
PS C:\Users\Admin\OneDrive\Desktop\Tutla\Tutla6lient\modules> & C:/Users/Admin/AppData/Local/Programs/Python/Python312/python.exe c:/Users/Admin/OneDrive/Desktop/Tutla/Tutla6lient/modules/ez.py
2023-12-02 17:41:32 INFO     discord.client Logging in using static token.
2023-12-02 17:41:41 WARNING  discord.utils Info API down. Falling back to manual fetching...
Traceback (most recent call last):
  File "c:\Users\Admin\OneDrive\Desktop\Tutla\Tutla6lient\modules\ez.py", line 16, in <module>
    client.run(token)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 938, in run
    asyncio.run(runner())
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 927, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 857, in start
    await self.login(token)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\client.py", line 698, in login
    data = await state.http.static_login(token.strip())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\http.py", line 
991, in static_login
    await self.startup()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\http.py", line 
562, in startup
    self.super_properties, self.encoded_super_properties = sp, _ = await utils._get_info(session)       
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^       
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\utils.py", line 1446, in _get_info
    bn = await _get_build_number(session)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\utils.py", line 1474, in _get_build_number
    build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+)\.js').findall(login_page)[-2] + '.js'
                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

Expected Results

"Ready" on the log

Actual Results

IndexError: list index out of range

System Information

Checklist

Additional Information

No response

JrXen commented 11 months ago

+1

TutlaMC commented 11 months ago

I downgraded it to 3.9 and i got 2 errors: 2023-12-02 18:45:12 INFO discord.client Logging in using static token. 2023-12-02 18:45:24 WARNING discord.utils Info API down. Falling back to manual fetching... Traceback (most recent call last): File "c:\Users\Admin\OneDrive\Desktop\Tutla\Tutla6lient\modules\err.py", line 425, in <module> client.run(token) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 938, in run asyncio.run(runner()) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 927, in runner await self.start(token, reconnect=reconnect) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 857, in start await self.login(token) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 698, in login data = await state.http.static_login(token.strip()) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 991, in static_login await self.startup() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 562, in startup self.super_properties, self.encoded_super_properties = sp, _ = await utils._get_info(session) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\utils.py", line 1446, in _get_info bn = await _get_build_number(session) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\utils.py", line 1482, in _get_build_number return default_build_number NameError: name 'default_build_number' is not defined Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001F3ADC46E50> Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon self._check_closed() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001F3ADC46E50> Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon self._check_closed() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001F3ADC46E50> Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__ self.close() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon self._check_closed() File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed

khoi1908vn commented 11 months ago

+1 got the same exception on startup

[2023-12-02 21:59:39] [discord.client] [INFO] Logging in using static token.
[2023-12-02 21:59:46] [discord.utils] [WARNING] Info API down. Falling back to manual fetching...
Exception in thread Thread-1 (_bot):
Traceback (most recent call last):
  File "%localappdata%\onefile_2984_133460027777193644\threading.py", line 1038, in _bootstrap_inner
  File "%localappdata%\onefile_2984_133460027777193644\threading.py", line 975, in run
  File "%localappdata%\onefile_2984_133460027777193644\bot.py", line 622, in _bot
  File "%localappdata%\onefile_2984_133460027777193644\discord\client.py", line 1059, in run
  File "%localappdata%\onefile_2984_133460027777193644\asyncio\runners.py", line 190, in run
  File "%localappdata%\onefile_2984_133460027777193644\asyncio\runners.py", line 118, in run
  File "%localappdata%\onefile_2984_133460027777193644\asyncio\base_events.py", line 653, in run_until_complete
  File "%localappdata%\onefile_2984_133460027777193644\discord\client.py", line 1048, in runner
  File "%localappdata%\onefile_2984_133460027777193644\discord\client.py", line 978, in start
  File "%localappdata%\onefile_2984_133460027777193644\discord\client.py", line 820, in login
  File "%localappdata%\onefile_2984_133460027777193644\discord\http.py", line 1054, in static_login
  File "%localappdata%\onefile_2984_133460027777193644\discord\http.py", line 698, in request
  File "%localappdata%\onefile_2984_133460027777193644\discord\http.py", line 634, in startup
  File "%localappdata%\onefile_2984_133460027777193644\discord\utils.py", line 1451, in _get_info
  File "%localappdata%\onefile_2984_133460027777193644\discord\utils.py", line 1480, in _get_build_number
IndexError: list index out of range
Zectxr commented 11 months ago

+1

requiredtruth commented 11 months ago

this fix is a single DOT . They change the login page stuff.

File: (site-packages) discord/utils.py

LINE: 1480 BEFORE: build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+).js').findall(login_page)[-2] + '.js' AFTER: build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9.]+).js').findall(login_page)[-2] + '.js'

I didnt have time to wait... your welcome <3

dolfies commented 11 months ago

Should be fixed now. Really sorry about this, I just haven't had time to bring the API back up or look at issues/PRs at all :( I'll try to bring the API back up as soon as I can.

headlined commented 11 months ago

I'm still confused? I read @requiredtruth's response, but I'm lost on how to get login_page, am I missing something?