dolfies / discord.py-self

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

"discord.utils API" down Error #604

Closed pwsh7 closed 10 months ago

pwsh7 commented 10 months ago

Summary

discord.py-self Doesn't work.

Reproduction Steps

Code

import sys
sys.path.insert(0, 'discord.py-self')
sys.path.insert(0, 'discord.py-self-embed')

import discord
from discord.ext import commands
import json

with open('config.json', 'r') as file:
    config = json.load(file)

token = config['TOKEN']
prefix = config['PREFIX']

bot = commands.Bot(command_prefix=".", self_bot=True, help_command=None)

@bot.command()
async def ping(ctx):
    await ctx.send(f"Pong! {round(bot.latency * 1000 / 1000)}ms")

bot.run(token)

Expected Results

It should stay like nothing and when i type .ping to discord it should say "Pong! (ping)ms."

Actual Results

2023-11-13 19:36:19 INFO discord.client Logging in using static token. 2023-11-13 19:36:20 WARNING discord.utils Info API down. Falling back to manual fetching... Traceback (most recent call last): File "C:\ode\python\HALFBOT\main.py", line 21, in bot.run(token) File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 938, in run asyncio.run(runner()) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64qbz5n2kfra8p0\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1776.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 927, in runner await self.start(token, reconnect=reconnect) File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 857, in start await self.login(token) File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\client.py", line 698, in login data = await state.http.static_login(token.strip()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\http.py", line 991, in static_login await self.startup() File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\http.py", line 562, in startup self.super_properties, self.encoded_superproperties = sp, = await utils._get_info(session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\utils.py", line 1446, in _get_info bn = await _get_build_number(session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\asus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\utils.py", line 1478, in _get_build_number return int(build_file[build_index : build_index + 6]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'ERV2'

System Information

Checklist

Additional Information

No response

VerifyBot commented 10 months ago

I got this now too when just trying to run a simple bot (just has on_ready)

VerifyBot commented 10 months ago

I know it's not ideal but I added this to my bot's file for a quickfix:

...
import discord

async def fix_get_build(*args, **kw):
  return 244594
discord.utils._get_build_number = fix_get_build

...
VerifyBot commented 10 months ago

Apparently the library on pypi is outdated so running pip install git+https://github.com/dolfies/discord.py-self.git fixes it.

simoovara commented 10 months ago

Apparently the library on pypi is outdated so running pip install git+https://github.com/dolfies/discord.py-self.git fixes it.

This worked for me as well

pwsh7 commented 10 months ago

Apparently the library on pypi is outdated so running pip install git+https://github.com/dolfies/discord.py-self.git fixes it.

i did both, now it shows this:

2023-11-16 16:38:28 INFO     discord.client Logging in using static token.
2023-11-16 16:38:29 WARNING  discord.utils Info API down. Falling back to manual fetching...
2023-11-16 16:38:30 INFO     discord.http Found user agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36, build number 244594.
2023-11-16 16:38:33 INFO     discord.gateway Connected to Gateway (Session ID: fdac0a18bf515ce6938447479eb40c90).
2023-11-16 16:38:33 WARNING  discord.state Member list scraping failed for 1134536127928352859 (Failed to automatically choose channels; please specify them manually).
2023-11-16 16:38:33 WARNING  discord.gateway Gateway is ratelimited, waiting 56.91 seconds.
pwsh7 commented 10 months ago

Ok, i removed discord.py-self and did pip install git+https://github.com/dolfies/discord.py-self.git then added that

import discord

async def fix_get_build(*args, **kw):
  return 244594
discord.utils._get_build_number = fix_get_build

and now it %100 works.

dolfies commented 10 months ago

This has been fixed in the latest commit. API should be back soonish for old builds.