Skip to content

Instantly share code, notes, and snippets.

@MattIPv4
Last active February 22, 2018 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattIPv4/6ce18631cbbdb6a71772f9da983fa0cd to your computer and use it in GitHub Desktop.
Save MattIPv4/6ce18631cbbdb6a71772f9da983fa0cd to your computer and use it in GitHub Desktop.
"""
========================
Testing Part 1
========================
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
[...]
self.loop.create_task(self.status_loop())
async def status_loop(self):
await self.wait_until_ready()
while not self.is_closed():
try:
channel = self.get_channel(self.config.support_auto)
await self.change_presence(game=discord.Game(type=3, name="#{}".format(channel or "Not loaded")), status=discord.Status.online)
except Exception as e:
print(e)
continue
await asyncio.sleep(120)
"""
When the bot first boots, this results in the status being set to #Not loaded.
On the next loop of status_loop (120s later) however it finds the channel fine and works.
This same issue was also tested in the same bot, in the on_ready as shown below.
This on_ready prints None yet if the same print is later eval'ed it finds the channel fine.
The channel id in self.config.support_auto is an integer snowflake of a channel known to exist in the one guild this bot is in.
This is shown true by the fact both the later loops of status and the eval'ing finding the channel fine.
"""
async def on_ready(self):
print(self.get_channel(self.config.support_auto))
"""
========================
Testing Part 2
========================
"""
async def on_ready(self):
try: print(self.get_guild(self.config.guild))
except Exception as e: print(e)
try: print([f.id for f in self.guilds])
except Exception as e: print(e)
try: print([self.get_guild(f.id) for f in self.guilds])
except Exception as e: print(e)
try: print(self.config.guild in [f.id for f in self.guilds])
except Exception as e: print(e)
try: print(len(self.get_guild(self.config.guild).text_channels))
except Exception as e: print(e)
try: print(self.get_channel(self.config.support_auto))
except Exception as e: print(e)
"""
Results in:
"""
__str__ returned non-string (type NoneType)
[231471142685245440]
[<Guild id=231471142685245440 name=None chunked=False>]
True
0
None
"""
What this suggests to me, imo, is that d.py has the guild id but absolutely nothing else.
The guild has 48 text channels, not 0.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment