mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 19:57:48 +00:00
Merge pull request #2 from strNophix/change-presence-loop
Change presence loop
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import discord
|
||||
from discord import ActivityType
|
||||
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 +20,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", []))
|
||||
@@ -73,6 +77,20 @@ class ChristmasBot(commands.Bot):
|
||||
colour_dict[name] = Color(int(color, 16))
|
||||
return colour_dict
|
||||
|
||||
@tasks.loop(seconds=30)
|
||||
async def update_status(self):
|
||||
await self.wait_until_ready()
|
||||
|
||||
bot_prefix = self.config["prefixes"][0]
|
||||
if self.rpc_is_help_message:
|
||||
title = f"for {bot_prefix}connect | {bot_prefix}help"
|
||||
activity = discord.Activity(name=title, type=ActivityType.watching)
|
||||
else:
|
||||
activity = discord.Activity(name="Some song", type=ActivityType.playing)
|
||||
|
||||
self.rpc_is_help_message = not self.rpc_is_help_message
|
||||
await self.change_presence(activity=activity)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user