Moved rpc loop to bot.py

This commit is contained in:
2021-10-31 12:05:27 +01:00
parent fc7da80b29
commit ba51aba4e9
2 changed files with 14 additions and 12 deletions
+14 -1
View File
@@ -1,6 +1,6 @@
import discord import discord
from discord.colour import Color from discord.colour import Color
from discord.ext import commands from discord.ext import commands, tasks
import sys import sys
import json import json
from typing import Any, Dict, List, Sequence 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 voice_states=True, guild_messages=True, guilds=True, messages=True
) )
self.rpc_is_help_message = True
self.update_status.start()
self.config = config self.config = config
self.initial_cog_names: List[str] = self.config.get("cogs", []) self.initial_cog_names: List[str] = self.config.get("cogs", [])
self.colors: Dict[str, Color] = self.process_colours(config.get("colors", [])) 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)) colour_dict[name] = Color(int(color, 16))
return colour_dict 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__": if __name__ == "__main__":
try: try:
-11
View File
@@ -13,17 +13,6 @@ from utils.paginator import HelpPaginator
class InformationCog(commands.Cog, name="Information"): class InformationCog(commands.Cog, name="Information"):
def __init__(self, bot: commands.Bot): def __init__(self, bot: commands.Bot):
self.bot = 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.cooldown(rate=1, per=5, type=commands.BucketType.user)
@commands.command(description="PONG!", aliases=["pong"]) @commands.command(description="PONG!", aliases=["pong"])