From 5989f123e857f10871c1fb073d82151f8647bea6 Mon Sep 17 00:00:00 2001 From: 0x5c <0x5c.dev@gmail.com> Date: Fri, 4 Oct 2019 14:17:45 -0400 Subject: [PATCH] Added task to refresh the activity - It's like `chron`, but in discord! --- main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index a2abfc5..df9e6f8 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ qrm, a bot for Discord from types import SimpleNamespace import discord -import discord.ext.commands as commands +from discord.ext import commands, tasks import info @@ -48,14 +48,28 @@ bot = commands.Bot(command_prefix=opt.prefix, description=info.description, help async def on_ready(): print(f"Logged in as: {bot.user} - {bot.user.id}") print("------") + + +# --- Tasks --- + +@tasks.loop(minutes=5) +async def _ensure_activity(): await bot.change_presence(activity=discord.Game(name="with lids on 7.200")) +@_ensure_activity.before_loop +async def _before_ensure_activity(): + await bot.wait_until_ready() + + # --- Run --- bot.add_cog(GlobalSettings(bot)) bot.load_extension("cogs.infocog") +_ensure_activity.start() + + try: bot.run(keys.discord_token)