Files
muzovkantv2/cogs/uptime.py
perforat 5f00de56b9 upload from local
upload muzovkantv2 from local storage
2026-03-08 14:35:33 +05:00

46 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import discord
from discord.ext import commands
import datetime
class UptimeSimple(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.start_time = None
@commands.Cog.listener()
async def on_ready(self):
if self.start_time is None:
self.start_time = datetime.datetime.now(datetime.timezone.utc)
@commands.command(name="uptime")
async def uptime(self, ctx):
if self.start_time is None:
await ctx.send("ебать у тебя тайминги кнш")
return
current_time = datetime.datetime.now(datetime.timezone.utc)
uptime = current_time - self.start_time
seconds = int(uptime.total_seconds())
days = seconds // 86400
hours = (seconds % 86400) // 3600
minutes = (seconds % 3600) // 60
secs = seconds % 60
result = "бот работает уже: "
parts = []
if days > 0:
parts.append(f"{days} дня")
if hours > 0:
parts.append(f"{hours} часа")
if minutes > 0:
parts.append(f"{minutes} минут")
if secs > 0 or not parts:
parts.append(f"{secs} секунд")
result += " ".join(parts)
await ctx.send(result)
async def setup(bot):
await bot.add_cog(UptimeSimple(bot))