Mod cog: Option to show an extra field with custom content on the ban embed (#6593)

Co-authored-by: Michael Oliveira <34169552+Flame442@users.noreply.github.com>
This commit is contained in:
Myra
2025-08-10 23:54:51 +02:00
committed by GitHub
parent 2dbbb51208
commit 3fd23d4163
4 changed files with 206 additions and 11 deletions

View File

@@ -143,6 +143,8 @@ class KickBanMixin(MixinMeta):
toggle = await self.config.guild(guild).dm_on_kickban()
if toggle:
extra_embed = await self.config.guild(guild).ban_show_extra()
with contextlib.suppress(discord.HTTPException):
em = discord.Embed(
title=bold(_("You have been banned from {guild}.").format(guild=guild)),
@@ -153,6 +155,17 @@ class KickBanMixin(MixinMeta):
value=reason if reason is not None else _("No reason was given."),
inline=False,
)
if extra_embed:
extra_embed_title = await self.config.guild(guild).ban_extra_embed_title()
extra_embed_contents = await self.config.guild(
guild
).ban_extra_embed_contents()
em.add_field(
name=bold(extra_embed_title, escape_formatting=False),
value=extra_embed_contents,
inline=False,
)
await user.send(embed=em)
ban_type = "ban"
@@ -658,16 +671,38 @@ class KickBanMixin(MixinMeta):
with contextlib.suppress(discord.HTTPException):
# We don't want blocked DMs preventing us from banning
msg = _("You have been temporarily banned from {server_name} until {date}.").format(
server_name=guild.name, date=discord.utils.format_dt(unban_time)
extra_embed = await self.config.guild(guild).ban_show_extra()
em = discord.Embed(
title=bold(
_("You have been temporarily banned from {guild} until {date}.").format(
guild=guild, date=discord.utils.format_dt(unban_time)
)
),
color=await self.bot.get_embed_color(member),
)
em.add_field(
name=_("**Reason**"),
value=reason if reason is not None else _("No reason was given."),
inline=False,
)
if guild_data["dm_on_kickban"] and reason:
msg += _("\n\n**Reason:** {reason}").format(reason=reason)
if invite:
msg += _("\n\nHere is an invite for when your ban expires: {invite_link}").format(
invite_link=invite
em.add_field(
name=bold(_("Here is an invite for when your ban expires")),
value=invite,
inline=False,
)
await member.send(msg)
if extra_embed:
extra_embed_title = await self.config.guild(guild).ban_extra_embed_title()
extra_embed_contents = await self.config.guild(guild).ban_extra_embed_contents()
em.add_field(
name=bold(extra_embed_title, escape_formatting=False),
value=extra_embed_contents,
inline=False,
)
await member.send(embed=em)
audit_reason = get_audit_reason(author, reason, shorten=True)