From ba51aba4e92fd520227e10edc70299209228a5c6 Mon Sep 17 00:00:00 2001 From: strNophix Date: Sun, 31 Oct 2021 12:05:27 +0100 Subject: [PATCH] Moved rpc loop to bot.py --- bot.py | 15 ++++++++++++++- cogs/information.py | 11 ----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bot.py b/bot.py index 3b0a779..bbae001 100644 --- a/bot.py +++ b/bot.py @@ -1,6 +1,6 @@ import discord from discord.colour import Color -from discord.ext import commands +from discord.ext import commands, tasks import sys import json from typing import Any, Dict, List, Sequence @@ -19,6 +19,9 @@ class ChristmasBot(commands.Bot): voice_states=True, guild_messages=True, guilds=True, messages=True ) + self.rpc_is_help_message = True + self.update_status.start() + self.config = config self.initial_cog_names: List[str] = self.config.get("cogs", []) self.colors: Dict[str, Color] = self.process_colours(config.get("colors", [])) @@ -69,6 +72,16 @@ class ChristmasBot(commands.Bot): colour_dict[name] = Color(int(color, 16)) return colour_dict + @tasks.loop(seconds=20) + async def update_status(self): + await self.wait_until_ready() + title = "ck!connect | ck!help" + if self.rpc_is_help_message: + title = "Tfoe broer" + self.rpc_is_help_message = not self.rpc_is_help_message + + await self.change_presence(activity=discord.Game(title)) + if __name__ == "__main__": try: diff --git a/cogs/information.py b/cogs/information.py index 1d45160..e8336f3 100644 --- a/cogs/information.py +++ b/cogs/information.py @@ -13,17 +13,6 @@ from utils.paginator import HelpPaginator class InformationCog(commands.Cog, name="Information"): def __init__(self, bot: commands.Bot): self.bot = bot - self.is_help_msg = True - self.update_status.start() - - @tasks.loop(seconds=30.0) - async def update_status(self): - await self.bot.wait_until_ready() - title = "ck!connect | ck!help" - if self.is_help_msg: - title = "Tfoe broer" - self.is_help_msg = not self.is_help_msg - await self.bot.change_presence(activity=discord.Game(title)) @commands.cooldown(rate=1, per=5, type=commands.BucketType.user) @commands.command(description="PONG!", aliases=["pong"])