discord.py-self icon indicating copy to clipboard operation
discord.py-self copied to clipboard

API error

Open OriBM opened this issue 1 year ago • 1 comments

Summary

Info API Down

Reproduction Steps

Just started out, used the most basic option possible, straight from the doc page.

Code

import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print(f'Logged on as {self.user}!')

    async def on_message(self, message):
        print(f'Message from {message.author}: {message.content}')

client = MyClient()
client.run('token')

Expected Results

should have connected to discord

Actual Results

2024-04-12 00:34:10 INFO discord.client Logging in using static token. 2024-04-12 00:34:27 WARNING discord.utils Info API down. Falling back to manual fetching... Traceback (most recent call last): File "/root/selfbot/selfbot.py", line 73, in bot.run('bot token, removed it for obvious reasons.') File "/root/selfbot/bot-env/lib/python3.10/site-packages/discord/client.py", line 938, in run asyncio.run(runner()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/root/selfbot/bot-env/lib/python3.10/site-packages/discord/client.py", line 927, in runner await self.start(token, reconnect=reconnect) File "/root/selfbot/bot-env/lib/python3.10/site-packages/discord/client.py", line 857, in start await self.login(token) File "/root/selfbot/bot-env/lib/python3.10/site-packages/discord/client.py", line 698, in login data = await state.http.static_login(token.strip()) File "/root/selfbot/bot-env/lib/python3.10/site-packages/discord/http.py", line 991, in static_login await self.startup() File "/root/selfbot/bot-env/lib/python3.10/site-packages/discord/http.py", line 562, in startup self.super_properties, self.encoded_super_properties = sp, _ = await utils._get_info(session) File "/root/selfbot/bot-env/lib/python3.10/site-packages/discord/utils.py", line 1446, in _get_info bn = await _get_build_number(session) File "/root/selfbot/bot-env/lib/python3.10/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

System Information

  • Python v3.10.12-final
  • discord.py-self v2.0.0-final
  • aiohttp v3.9.4
  • system info: Linux 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shared the entire traceback.
  • [X] I am using a user token (and it isn't visible in the code).

Additional Information

No response

OriBM avatar Apr 11 '24 21:04 OriBM

I was able to fix the problem in the v2.0 release by editing the build URL and build index to match the updated files from discord.

utils.py line 1474 build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+\.[a-z0-9]+)\.js').findall(login_page)[-2] + '.js'

line 1477 build_index = build_file.find('buildNumber') + 26

It returned the correct build number (284187 currently) and then I could log in.

Soggy-Pancake avatar Apr 12 '24 21:04 Soggy-Pancake

I was able to fix the problem in the v2.0 release by editing the build URL and build index to match the updated files from discord.

utils.py line 1474 build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+\.[a-z0-9]+)\.js').findall(login_page)[-2] + '.js'

line 1477 build_index = build_file.find('buildNumber') + 26

It returned the correct build number (284187 currently) and then I could log in.

I too am having a similar issue however this fix did not work for me assuming the build number has changed since, hopefully a more permanent solution is established soon.

omnituensaeternum avatar Apr 23 '24 01:04 omnituensaeternum

The version available on PyPI (Python Package Index) is outdated. You can install the latest version directly from GitHub using this command:

pip install git+https://github.com/dolfies/discord.py-self.git

syntaxsurge avatar Apr 26 '24 20:04 syntaxsurge

Fixed the fallback! The API is back up too. Sorry for the wait guys.

dolfies avatar May 15 '24 01:05 dolfies