feat(bot): ✨ Add past bans to p.user.
This commit is contained in:
+17
-11
@@ -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(
|
||||
[
|
||||
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
|
||||
]
|
||||
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(
|
||||
[
|
||||
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
|
||||
]
|
||||
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.*",
|
||||
),
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user