This commit is contained in:
2025-11-26 19:34:08 +05:00
commit 1dd4394e4b
11 changed files with 926 additions and 0 deletions

38
c/tasks.py Normal file
View File

@@ -0,0 +1,38 @@
import discord
from discord.ext import commands, tasks
from datetime import datetime
class Tasks(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.last_member = None
self.update_status.start()
global timestamp
timestamp = datetime.now()
print(f"start time {timestamp}")
@tasks.loop(seconds=60)
async def update_status(self):
dt = datetime.today()
delta = dt - timestamp
sec = delta.total_seconds()
minutes = int(sec) // 60
hours = int(sec) // 3600
days = int(sec) // 86400
if minutes >= 60:
minutes = (int(sec) - (hours * 3600)) // 60
if hours >= 24:
hours = (int(sec) - (days * 86400)) // 60 // 60
total = f"d:{days} h:{hours} m:{minutes}"
try:
await self.bot.status_up(total)
except:
print("can't set discord status")
@commands.Cog.listener()
async def on_ready(self):
print('Tasks cog has been loaded')
async def setup(bot):
await bot.add_cog(Tasks(bot))