feat(bot): ✨ Add banned users stat to p.stats.
This commit is contained in:
@@ -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):
|
||||
- `<wait>`: 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",
|
||||
|
||||
Reference in New Issue
Block a user