From 07e4e4113c09a92d9d2cd6419743b56f3426938b Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 21 Feb 2020 02:41:39 -0800 Subject: [PATCH] Post stats every 30m --- discordbot/titanembeds/bot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/discordbot/titanembeds/bot.py b/discordbot/titanembeds/bot.py index f5e9cb5..6b6003b 100644 --- a/discordbot/titanembeds/bot.py +++ b/discordbot/titanembeds/bot.py @@ -78,7 +78,7 @@ class Titan(discord.AutoShardedClient): self.discordBotsOrg = DiscordBotsOrg(self.user.id, config.get("discord-bots-org-token", None)) self.botsDiscordPw = BotsDiscordPw(self.user.id, config.get("bots-discord-pw-token", None)) - await self.postStats() + self.loop.create_task(self.auto_post_stats()) async def on_message(self, message): await self.socketio.on_message(message) @@ -278,6 +278,11 @@ class Titan(discord.AutoShardedClient): if msg.id == msg_id: return True return False + + async def auto_post_stats(self): + while not self.is_closed(): + await self.postStats() + await asyncio.sleep(1800) async def postStats(self): count = len(self.guilds)