Thank you everyone for releasing discord.py version 1.4 (final), you are amazing. However, with this new version, I am enable to close the discord connection with my bot. Here is a minimal reproducible example:
File: main.py
import discord, asyncio
from discord.ext import commands
bot = commands.Bot("!")
if __name__ == "__main__":
bot.load_extension("cogs.owner")
bot.run(TOKEN)
File: cogs/owner.py
import discord, asyncio
from discord.ext import commands
class Owner(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
@commands.is_owner()
async def shutdown(self, ctx):
await self.bot.close()
def setup(bot):
bot.add_cog(Owner(bot))
Now when I run the shutdown command, the whole program just freezes (it doesn't terminate) and the fans on my computer start to spin faster. The bot still appears online but is not responding. This is weird, as everything worked alright before the update.
I think it might be beneficial if you could get the logs for this. (make sure to remove any identifiable info)
https://discordpy.readthedocs.io/en/latest/logging.html
@Gobot1234 I have used it in DEBUG mode (using my discord.log file), and I found something very weird. After executing the command, I found this line: :DEBUG:discord.gateway: Received WSMessage(type=<WSMsgType.CLOSING: 256>, data=None, extra=None). Then, it was followed by the line: :DEBUG:discord.gateway: Received WSMessage(type=<WSMsgType.CLOSED: 257>, data=None, extra=None) being repeated over 7,000 times.
I couldn't reproduce this locally but I believe that https://github.com/Rapptz/discord.py/commit/5dd8e372e4a5aa3749d85f8fd2f7eb4d779512cb should fix it.
git clone https://github.com/Rapptz/discord.py
cd discord.py
python3 -m pip install -U .[voice]
If the program terminates then that's the extent of what I can do.
Most helpful comment
@Gobot1234 I have used it in
DEBUGmode (using mydiscord.logfile), and I found something very weird. After executing the command, I found this line::DEBUG:discord.gateway: Received WSMessage(type=<WSMsgType.CLOSING: 256>, data=None, extra=None). Then, it was followed by the line::DEBUG:discord.gateway: Received WSMessage(type=<WSMsgType.CLOSED: 257>, data=None, extra=None)being repeated over 7,000 times.