bugfixes regarding logging, api and db working; small fixes in all of the cogs; moved all the configurable information to the config.py

This commit is contained in:
2026-03-09 01:56:07 +05:00
parent 417c5daa60
commit 4ace3b6611
12 changed files with 513 additions and 651 deletions

View File

@@ -1,46 +1,47 @@
import discord
from discord.ext import commands
import datetime
def pluralize(n: int, one: str, few: str, many: str) -> str:
if 11 <= n % 100 <= 14:
return f"{n} {many}"
r = n % 10
if r == 1:
return f"{n} {one}"
if 2 <= r <= 4:
return f"{n} {few}"
return f"{n} {many}"
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)
self.start_time = discord.utils.utcnow()
@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 = "бот работает уже: "
delta = discord.utils.utcnow() - self.start_time
seconds = int(delta.total_seconds())
minutes, secs = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
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)
if days:
parts.append(pluralize(days, "день", "дня", "дней"))
if hours:
parts.append(pluralize(hours, "час", "часа", "часов"))
if minutes:
parts.append(pluralize(minutes, "минуту", "минуты", "минут"))
if secs or not parts:
parts.append(pluralize(secs, "секунду", "секунды", "секунд"))
embed = discord.Embed(
description="бот работает уже: " + " ".join(parts),
color=discord.Color.green()
)
await ctx.send(embed=embed)
async def setup(bot):
await bot.add_cog(UptimeSimple(bot))