Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.67k stars 3.74k forks source link

missing _member_count on non userbot #422

Closed ccubed closed 7 years ago

ccubed commented 7 years ago

My understanding is this is a userbot issue on large guilds, but it appears to have spread to token bots as well. I was using the dev version up to the following commit: a0f4ad36eb0e4c82162c1ee571543c13b9a74bfd

perhaps more chunking woes? I'm at 5 days uptime and I've updated to the latest dev version though I haven't restarted my bot yet in case you want me to run some debugs.

Dec 21 12:05:40 Vertinext python[9272]: Exception in callback AngelBot.update_stats()
Dec 21 12:05:40 Vertinext python[9272]: handle: <TimerHandle when=1357127.567972774 AngelBot.update_stats()>
Dec 21 12:05:40 Vertinext python[9272]: Traceback (most recent call last):
Dec 21 12:05:40 Vertinext python[9272]:   File "/usr/lib/python3.5/asyncio/events.py", line 125, in _run
Dec 21 12:05:40 Vertinext python[9272]:     self._callback(*self._args)
Dec 21 12:05:40 Vertinext python[9272]:   File "/home/gizmo/AngelBot/AngelBot.py", line 192, in update_stats
Dec 21 12:05:40 Vertinext python[9272]:     stats['users'] = sum(x.member_count for x in self.servers)
Dec 21 12:05:40 Vertinext python[9272]:   File "/home/gizmo/AngelBot/AngelBot.py", line 192, in <genexpr>
Dec 21 12:05:40 Vertinext python[9272]:     stats['users'] = sum(x.member_count for x in self.servers)
Dec 21 12:05:40 Vertinext python[9272]:   File "/usr/lib/python3.5/site-packages/discord/server.py", line 263, in member_count
Dec 21 12:05:40 Vertinext python[9272]:     return self._member_count
Dec 21 12:05:40 Vertinext python[9272]: AttributeError: _member_count

Edit: I'm silly and forgot the commit

ccubed commented 7 years ago

This is my mistake for assuming self.servers won't ever have unavailable guilds. The fix is checking for if not x.unavailable. Thanks Danny.