[Mod] Send ban reason on Temp Bans (#4837)

* [Mod] Send ban reason on Temp Bans

* If none

* Locale friendly

* Fixes for black style

* Use double line break to distinguish between reason header

* Check settings

* Black

* Reduce the number of config calls

* remove additional config call

* fixes

* style

* We're already in `if reason` so this is always True

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Kreus Amredes 2021-09-02 18:07:07 +01:00 committed by GitHub
parent f628093208
commit 4e2e4bfe6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -620,12 +620,14 @@ class KickBanMixin(MixinMeta):
await ctx.send(_("I cannot do that due to Discord hierarchy rules."))
return
guild_data = await self.config.guild(guild).all()
if duration is None:
duration = timedelta(seconds=await self.config.guild(guild).default_tempban_duration())
duration = timedelta(seconds=guild_data["default_tempban_duration"])
unban_time = datetime.now(timezone.utc) + duration
if days is None:
days = await self.config.guild(guild).default_days()
days = guild_data["default_days"]
if not (0 <= days <= 7):
await ctx.send(_("Invalid days. Must be between 0 and 7."))
@ -643,8 +645,10 @@ class KickBanMixin(MixinMeta):
msg = _("You have been temporarily banned from {server_name} until {date}.").format(
server_name=guild.name, date=unban_time.strftime("%m-%d-%Y %H:%M:%S")
)
if guild_data["dm_on_kickban"] and reason:
msg += _("\n\n**Reason:** {reason}").format(reason=reason)
if invite:
msg += _(" Here is an invite for when your ban expires: {invite_link}").format(
msg += _("\n\nHere is an invite for when your ban expires: {invite_link}").format(
invite_link=invite
)
await member.send(msg)