v1.0.0 #15

Merged
profitroll merged 53 commits from dev into main 2025-05-06 21:34:32 +03:00
2 changed files with 48 additions and 1 deletions
Showing only changes of commit 6b143d8a2d - Show all commits

47
cogs/cog_utility.py Normal file
View File

@@ -0,0 +1,47 @@
from logging import Logger
from discord import Activity, ActivityType, Cog
from discord.ext import commands
from classes.pycord_bot import PycordBot
from modules.utils import get_logger
logger: Logger = get_logger(__name__)
class CogUtility(Cog):
def __init__(self, bot: PycordBot):
self.bot: PycordBot = bot
@commands.Cog.listener()
async def on_ready(self) -> None:
"""Listener for the event when bot connects to Discord and becomes "ready"."""
logger.info("Logged in as %s", self.bot.user)
activity_enabled: bool = self.bot.config["bot"]["status"]["enabled"]
activity_type: str = self.bot.config["bot"]["status"]["activity_type"]
activity_message: str = self.bot.config["bot"]["status"]["activity_text"]
if not activity_enabled:
return
if activity_type == "playing":
await self.bot.change_presence(activity=Activity(type=ActivityType.playing, name=activity_message))
elif activity_type == "watching":
await self.bot.change_presence(activity=Activity(type=ActivityType.watching, name=activity_message))
elif activity_type == "listening":
await self.bot.change_presence(activity=Activity(type=ActivityType.listening, name=activity_message))
elif activity_type == "streaming":
await self.bot.change_presence(activity=Activity(type=ActivityType.streaming, name=activity_message))
elif activity_type == "competing":
await self.bot.change_presence(activity=Activity(type=ActivityType.competing, name=activity_message))
elif activity_type == "custom":
await self.bot.change_presence(activity=Activity(type=ActivityType.custom, name=activity_message))
else:
return
logger.info("Set activity type to %s with message %s", activity_type, activity_message)
def setup(bot: PycordBot) -> None:
bot.add_cog(CogUtility(bot))

View File

@@ -12,7 +12,7 @@
"timezone": "UTC",
"status": {
"enabled": true,
"activity_type": 0,
"activity_type": "playing",
"activity_text": "The Game Of Life"
}
},