mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 22: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
|
import discord
|
||||||
|
from discord import ActivityType
|
||||||
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 +20,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", []))
|
||||||
@@ -73,6 +77,20 @@ 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=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__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -14,17 +14,6 @@ from utils.paginator import HelpPaginator
|
|||||||
class InformationCog(commands.Cog, name="Information"):
|
class InformationCog(commands.Cog, name="Information"):
|
||||||
def __init__(self, bot: ChristmasBot):
|
def __init__(self, bot: ChristmasBot):
|
||||||
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"])
|
||||||
|
|||||||
Reference in New Issue
Block a user