diff --git a/payphone/cogs/mods/cog.py b/payphone/cogs/mods/cog.py index 02727ee..54121ed 100644 --- a/payphone/cogs/mods/cog.py +++ b/payphone/cogs/mods/cog.py @@ -2,14 +2,13 @@ from typing import Awaitable from datetime import datetime, timezone, timedelta -import sys import asyncio import discord from discord import errors from discord.ext import commands -from tortoise import transactions, expressions +from tortoise import transactions, expressions, functions from procs import flush_messages @@ -339,6 +338,19 @@ class Mods(base.Cog): - ``: The amount of seconds to wait between iterations. Defaults to 5. """ + async def count_banned_users() -> int: + return ( + await models.Ban.filter( + expressions.Q( + expires_at=None, + expires_at__gt=datetime.now(timezone.utc), + join_type="OR", + ) + ) + .annotate(unique_users_count=functions.Count("user_id", distinct=True)) + .values("unique_users_count") + )[0]["unique_users_count"] + stats = [ ( "On-call Channels", @@ -372,6 +384,10 @@ class Mods(base.Cog): ) ).count(), ), + ( + "Banned Users", + count_banned_users, + ), ("Reports", lambda: models.Report.all().count()), ( "On-review Reports",