Fix outright failure to send DM on ban

This commit is contained in:
Zeva Rose 2021-07-24 21:19:39 -06:00
parent 1f552d7d32
commit 0496e288c2
2 changed files with 7 additions and 14 deletions

View file

@ -14,15 +14,8 @@ from psutil import Process
from jarvis import logo, utils from jarvis import logo, utils
from jarvis.config import get_config from jarvis.config import get_config
from jarvis.db import DBManager from jarvis.db import DBManager
from jarvis.db.types import ( from jarvis.db.types import (Autopurge, Autoreact, Ban, Lock, Mute, Setting,
Autopurge, Warning)
Autoreact,
Ban,
Lock,
Mute,
Setting,
Warning,
)
from jarvis.utils import build_embed from jarvis.utils import build_embed
from jarvis.utils.field import Field from jarvis.utils.field import Field
@ -44,7 +37,7 @@ jarvis = commands.Bot(
) )
slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True) slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True)
jarvis_self = Process() jarvis_self = Process()
__version__ = "1.5.6" __version__ = "1.5.7"
db = DBManager(get_config().mongo).mongo db = DBManager(get_config().mongo).mongo

View file

@ -136,16 +136,16 @@ class AdminCog(commands.Cog):
if mtype == "temp": if mtype == "temp":
user_message += f"\nDuration: {duration} hours" user_message += f"\nDuration: {duration} hours"
try:
await user.send(user_message)
except Exception:
send_failed = True
try: try:
await ctx.guild.ban(user, reason=reason) await ctx.guild.ban(user, reason=reason)
except Exception as e: except Exception as e:
await ctx.send(f"Failed to ban user:\n```\n{e}\n```", hidden=True) await ctx.send(f"Failed to ban user:\n```\n{e}\n```", hidden=True)
return return
send_failed = False send_failed = False
try:
await user.send(user_message)
except Exception:
send_failed = True
if mtype == "soft": if mtype == "soft":
await ctx.guild.unban(user, reason="Ban was softban") await ctx.guild.unban(user, reason="Ban was softban")