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] DMs break on_message #72

Closed destroyace closed 3 years ago

destroyace commented 3 years ago

Summary

It appears that sending/receiving a DM automatically crashes the selfbot.

Reproduction Steps

How did you make it happen?
  1. Receive or send a DM to another user
  2. Crashes

Code

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

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

@bot.command()
async def ping(ctx):
    await ctx.send("pong")

bot.run("MY_TOKEN")

Tested on two tokens just in case.

Expected Results

Nothing, the selfbot remains enabled.

Actual Results

The following error is sent (commands work):
Traceback (most recent call last):
  File "item.py", line 12, in <module>
    bot.run("MY_TOKEN")
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 631, in run
    return future.result()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 610, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 574, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 477, in connect
    await self.ws.poll_event()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 547, in poll_event        
    await self.received_message(msg.data)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 497, in received_message  
    func(data)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\state.py", line 497, in parse_message_create
    guild_id = int(data['guild_id'])
KeyError: 'guild_id'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001D0E7023820>
Traceback (most recent call last):
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
    self._check_closed()
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001D0E7023820>
Traceback (most recent call last):
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
  File "C:\Users\Ace\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
RuntimeError: Event loop is closed

System Info

Run python -m discord --version and paste the information below.
- Python v3.8.8-final
- discord.py-self v1.9.0-final
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19041

Checklist

Let's make sure this issue is valid!

Additional Information

> MY_TOKEN refers to an actual token.
dolfies commented 3 years ago

That's an... unfortunate bug.

Just fixed it in v1.9.1.