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] Bot can't start if a guild has no channels #54

Closed Santtiago2121 closed 3 years ago

Santtiago2121 commented 3 years ago

Summary

The bot cant start if a guild has 0 channels

Reproduction Steps

How did you make it happen?
  1. Trying to start the bot with an account who has a guild with 0 channels
  2. Bug found: IndexError

Code

Relevant code that shows the bug.
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
        print('hello')
bot.run('user token')

Expected Results

Normally run

Actual Results

What is currently happening?

The bot cant run

System Info

- Python v3.8.5-final
- discord.py v1.8.1-final
- aiohttp v3.6.2
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!

Exception

websocket connection is closing.
Traceback (most recent call last):
  File "genessir.py", line 190, in <module>
    runSelfbot()
  File "bot.py", line 188, in runSelfbot
    bot.run("mytoken")
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 755, in run
    return future.result()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 734, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 698, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 599, in connect
    await self.ws.poll_event()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\gateway.py", line 555, 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 505, in received_message
    func(data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\state.py", line 481, in parse_ready
    self._add_guild_from_data(guild_data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\state.py", line 377, in _add_guild_from_data
    guild = Guild(data=guild, state=self)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\guild.py", line 190, in __init__
    self._from_data(data)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\guild.py", line 326, in _from_data
    self._fetch_members(guild)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\guild.py", line 353, in _fetch_members
    channel = self.channels[0]
IndexError: list index out of range
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x03EBCA00>
Traceback (most recent call last):
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Bengali\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

image

dolfies commented 3 years ago

I expected this to eventually show up. It's because of the quick hack I had used to get events mostly working. Will be fixed in the next release.