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(
|
bans = await models.Ban.filter(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
)
|
).order_by("-created_at")
|
||||||
|
|
||||||
ongoing_bans = [
|
ongoing_bans = [
|
||||||
ban
|
ban
|
||||||
@@ -476,21 +476,27 @@ class Mods(base.Cog):
|
|||||||
fields=[
|
fields=[
|
||||||
discord.EmbedField(
|
discord.EmbedField(
|
||||||
name="Ongoing Bans",
|
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
|
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.*",
|
or "*No ongoing bans.*",
|
||||||
),
|
),
|
||||||
discord.EmbedField(
|
discord.EmbedField(
|
||||||
name="Past Bans",
|
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
|
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.*",
|
or "*No expired bans.*",
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ def trim(text: str, length: int = 100) -> str:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if len(text) > length:
|
if len(text) > length:
|
||||||
return text[:length] + "..."
|
return text[:length - 3] + "..."
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user