From b2f03cb54b85021de770591aa9fe1db2ff60cbce Mon Sep 17 00:00:00 2001 From: Hipstercat Date: Mon, 31 Aug 2020 20:06:55 +0200 Subject: [PATCH] verbose --- cogs/wynncraft/wynncraftcog.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cogs/wynncraft/wynncraftcog.py b/cogs/wynncraft/wynncraftcog.py index ee9bbc5..d4e0c7a 100644 --- a/cogs/wynncraft/wynncraftcog.py +++ b/cogs/wynncraft/wynncraftcog.py @@ -55,12 +55,16 @@ class WynncraftCog(commands.Cog): await self.bot.wait_until_ready() last_status = {} while self is self.bot.get_cog("WynncraftCog"): + print("Looping guilds") async for guild in self.bot.fetch_guilds(limit=150): guild_id = guild.id + print("Loop id %s" % guild_id) try: channel_id = await self.config.guild(guild).channel() if channel_id: + print("Channel set") for tracked in await self.config.guild(guild).tracked(): + print("calling API for player %s" % tracked) r = requests.get("https://api.wynncraft.com/v2/player/%s/stats" % tracked).json() for cl in r["data"][0]["classes"]: if guild_id not in last_status: @@ -75,8 +79,12 @@ class WynncraftCog(commands.Cog): if cl["professions"]["combat"]["level"] > last_status[guild_id][tracked][cl["name"]]["professions"]["combat"]["level"]: channel = self.bot.get_channel(channel_id) await channel.send(":high_brightness: %s a level up au niveau %s! GG!" % (tracked, cl["professions"]["combat"]["level"])) + else: + print("Player %s had last level %s and current %s" % (tracked, last_status[guild_id][tracked][cl["name"]]["professions"]["combat"]["level"], cl["professions"]["combat"]["level"])) last_status[guild_id][tracked][cl["name"]] = cl + else: + print("Guild has no channel set") except: traceback.print_exc() await asyncio.sleep(30)