Stop putting text about invite when invite isn't sent in tempban message (#3991)

This commit is contained in:
jack1142 2020-07-06 19:57:16 +02:00 committed by GitHub
parent 12bce6a560
commit 4dd0fb97fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -448,16 +448,14 @@ class KickBanMixin(MixinMeta):
with contextlib.suppress(discord.HTTPException): with contextlib.suppress(discord.HTTPException):
# We don't want blocked DMs preventing us from banning # We don't want blocked DMs preventing us from banning
await user.send( 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")
"You have been temporarily banned from {server_name} until {date}. "
"Here is an invite for when your ban expires: {invite_link}"
).format(
server_name=guild.name,
date=unban_time.strftime("%m-%d-%Y %H:%M:%S"),
invite_link=invite,
) )
if invite:
msg += _(" Here is an invite for when your ban expires: {invite_link}").format(
invite_link=invite
) )
await user.send(msg)
try: try:
await guild.ban(user, reason=reason, delete_message_days=days) await guild.ban(user, reason=reason, delete_message_days=days)
except discord.Forbidden: except discord.Forbidden: