diff --git a/cogs/BotInformation.py b/cogs/BotInformation.py index 0c02086..484805d 100644 --- a/cogs/BotInformation.py +++ b/cogs/BotInformation.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- - -from discord.ext import commands +import discord +from discord.ext import commands, tasks from discord.ext.commands import Context import datetime import time @@ -10,6 +10,7 @@ class BotInformation(commands.Cog): def __init__(self, bot: commands.Bot): self.bot: commands.Bot = bot self.start_time: float = time.time() + self.presence_task.start() @commands.command('info') async def get_info(self, ctx: Context): @@ -31,6 +32,15 @@ Invite link: https://discord.com/oauth2/authorize?client_id={self.bot.user.id}&s uptime_str = datetime.timedelta(seconds=int(uptime)) await ctx.send(f"Application is up for {str(uptime_str)}") + @tasks.loop(seconds=120) + async def presence_task(self) -> None: + presence = discord.Game(f"{len(self.bot.guilds)} guilds | @{self.bot.user.name} help") + await self.bot.change_presence(activity=presence) + + @presence_task.before_loop + async def presence_task_wait_ready(self): + await self.bot.wait_until_ready() + async def setup(bot): await bot.add_cog(BotInformation(bot))