feat(bot): ✨ Add past bans to p.user.

This commit is contained in:
Nyeki.py
2024-10-25 23:40:45 -03:00
parent 92f7790033
commit b0d5b8a5f7
2 changed files with 18 additions and 12 deletions
+9 -3
View File
@@ -451,7 +451,7 @@ class Mods(base.Cog):
bans = await models.Ban.filter(
user_id=user_id,
)
).order_by("-created_at")
ongoing_bans = [
ban
@@ -476,21 +476,27 @@ class Mods(base.Cog):
fields=[
discord.EmbedField(
name="Ongoing Bans",
value="\n".join(
value=fmt.trim(
"\n".join(
[
f"- `ID: {ban.id}`{f" (by <@{ban.banned_by_id}>)" if ban.banned_by_id else None}: {ban.reason if ban.reason else "*No reason*"}. Banned {f"until <t:{int(ban.expires_at.timestamp())}:R>" if ban.expires_at is not None else "permanently"}."
for ban in ongoing_bans
]
),
1024,
)
or "*No ongoing bans.*",
),
discord.EmbedField(
name="Past Bans",
value="\n".join(
value=fmt.trim(
"\n".join(
[
f"- `ID: {ban.id}`{f" (by <@{ban.banned_by_id}>)" if ban.banned_by_id else None}: {ban.reason if ban.reason else "*No reason*"}. {"Expired" if ban.unbanned_by_id is None else f"Unbanned by <@{ban.unbanned_by_id}>"} <t:{int(ban.expires_at.timestamp())}:R>."
for ban in expired_bans
]
),
1024,
)
or "*No expired bans.*",
),
+1 -1
View File
@@ -20,7 +20,7 @@ def trim(text: str, length: int = 100) -> str:
"""
if len(text) > length:
return text[:length] + "..."
return text[:length - 3] + "..."
return text