feat(shard): ✨ Show warns in the p.bs command.
This commit is contained in:
@@ -191,18 +191,34 @@ class Admin(base.Cog):
|
||||
|
||||
user_id = user if isinstance(user, int) else user.id if user else ctx.author.id
|
||||
|
||||
user: models.User | None = await models.User.get_or_none(id=user_id)
|
||||
|
||||
if user is None:
|
||||
return await ctx.send("❌ User not found.")
|
||||
|
||||
bans = (
|
||||
await models.Ban.filter(user_id=user_id)
|
||||
.prefetch_related("report", "created_by", "expired_by")
|
||||
.order_by("-created_at")
|
||||
)
|
||||
warns = (
|
||||
await models.Warn.filter(user_id=user_id)
|
||||
.prefetch_related("report", "created_by")
|
||||
.order_by("-created_at")
|
||||
)
|
||||
|
||||
if not bans:
|
||||
await ctx.send(f"<@!{user_id}> has no bans.")
|
||||
if not bans and not warns:
|
||||
if user.bans_count or user.warns_count:
|
||||
await ctx.send(
|
||||
"<@!{user_id}> has no bans nor warns registered in the database, but they"
|
||||
f" have been banned `{user.bans_count}` times and warned `{user.warns_count}`."
|
||||
)
|
||||
return
|
||||
|
||||
await pages.Paginator(
|
||||
[
|
||||
await ctx.send(f"<@!{user_id}> has no bans nor warns.")
|
||||
return
|
||||
|
||||
ban_embeds = [
|
||||
(
|
||||
discord.Embed(
|
||||
color=constants.MODERATOR_COLOR,
|
||||
@@ -267,7 +283,59 @@ class Admin(base.Cog):
|
||||
)
|
||||
)
|
||||
for ban in bans
|
||||
]
|
||||
|
||||
warn_embeds = [
|
||||
(
|
||||
discord.Embed(
|
||||
color=constants.MASK_COLOR,
|
||||
title=f"Warn #{warn.id}",
|
||||
description=formatting.trim(warn.report.message_content, 500),
|
||||
author=discord.EmbedAuthor(
|
||||
name=warn.report.user_name,
|
||||
icon_url=warn.report.user_avatar_url,
|
||||
),
|
||||
fields=[
|
||||
discord.EmbedField(
|
||||
name="User Avatar",
|
||||
value=f"[Click to open avatar URL](<{warn.report.user_avatar_url}>)",
|
||||
),
|
||||
]
|
||||
+ (
|
||||
[
|
||||
discord.EmbedField(
|
||||
name="Replying To",
|
||||
value=f'"{formatting.trim(warn.report.reply_message_content)}" by {warn.report.reply_user_name}',
|
||||
)
|
||||
]
|
||||
if warn.report.reply_message_content
|
||||
else []
|
||||
),
|
||||
thumbnail=warn.report.user_avatar_url,
|
||||
footer=discord.EmbedFooter(
|
||||
text=f"Warned by {(await self.bot.get_or_fetch_user(warn.created_by.id)).display_name}"
|
||||
),
|
||||
)
|
||||
if warn.report
|
||||
else discord.Embed(
|
||||
color=constants.MASK_COLOR,
|
||||
title=f"Warn #{warn.id}",
|
||||
description=f"The user was warned manually by <@!{warn.created_by.id}> <t:{int(warn.created_at.timestamp())}:R>.",
|
||||
fields=[
|
||||
discord.EmbedField(
|
||||
name="Reason", value=warn.reason or "No reason provided."
|
||||
)
|
||||
],
|
||||
footer=discord.EmbedFooter(
|
||||
text=f"Warned by {(await self.bot.get_or_fetch_user(warn.created_by.id)).display_name}"
|
||||
),
|
||||
)
|
||||
)
|
||||
for warn in warns
|
||||
]
|
||||
|
||||
await pages.Paginator(
|
||||
ban_embeds + warn_embeds,
|
||||
author_check=True,
|
||||
).send(ctx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user