dolfies / discord.py-self

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

[BUG] KeyError: 'guild_id' | Sometimes the bot can't run due this error #74

Closed Santtiago2121 closed 3 years ago

Santtiago2121 commented 3 years ago

Summary

Sometimes the bot can't start

Reproduction Steps

Trying to start the bot

Code

Relevant code that shows the bug.
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='.')

bot.run('my_token')

Expected Results

Normal start

Actual Results

Sometimes the bot can't start due to this error, and takes a lot to load the event on_ready

System Info

C:\Users\Bengali\Desktop\Genessir X\selfbot>python -m discord --version
- Python v3.8.5-final
- discord.py-self v1.9.0-final
- aiohttp v3.6.2
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!

Additional Information


  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 631, in run
    return future.result()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 610, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 574, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 477, in connect
    await self.ws.poll_event()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\gateway.py", line 547, in poll_event
    await self.received_message(msg.data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\gateway.py", line 497, in received_message
    func(data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\state.py", line 497, in parse_message_create
    guild_id = int(data['guild_id'])
KeyError: 'guild_id'
dolfies commented 3 years ago

Duplicate of #72 and fixed in 1.9.1.

As for the slow on_ready, that's because of the new guild subscribing feature. You can disable it by passing a disabled GuildSubscriptionOptions when constructing a Client (or bot) class.