dolfies / discord.py-self

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

API error #681

Closed OriBM closed 1 month ago

OriBM commented 2 months ago

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_superproperties = 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

Checklist

Additional Information

No response

Soggy-Pancake commented 2 months ago

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.

omnituensaeternum commented 2 months ago

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.

syntaxsurge commented 2 months ago

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
dolfies commented 1 month ago

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