From 0496e288c2b227306bec2b7efaf3873c28ae3c46 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Sat, 24 Jul 2021 21:19:39 -0600 Subject: [PATCH] Fix outright failure to send DM on ban --- jarvis/__init__.py | 13 +++---------- jarvis/cogs/admin.py | 8 ++++---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 2c7c601..1578d1e 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -14,15 +14,8 @@ from psutil import Process from jarvis import logo, utils from jarvis.config import get_config from jarvis.db import DBManager -from jarvis.db.types import ( - Autopurge, - Autoreact, - Ban, - Lock, - Mute, - Setting, - Warning, -) +from jarvis.db.types import (Autopurge, Autoreact, Ban, Lock, Mute, Setting, + Warning) from jarvis.utils import build_embed from jarvis.utils.field import Field @@ -44,7 +37,7 @@ jarvis = commands.Bot( ) slash = SlashCommand(jarvis, sync_commands=True, sync_on_cog_reload=True) jarvis_self = Process() -__version__ = "1.5.6" +__version__ = "1.5.7" db = DBManager(get_config().mongo).mongo diff --git a/jarvis/cogs/admin.py b/jarvis/cogs/admin.py index 6afd169..86946b9 100644 --- a/jarvis/cogs/admin.py +++ b/jarvis/cogs/admin.py @@ -136,16 +136,16 @@ class AdminCog(commands.Cog): if mtype == "temp": user_message += f"\nDuration: {duration} hours" + try: + await user.send(user_message) + except Exception: + send_failed = True try: await ctx.guild.ban(user, reason=reason) except Exception as e: await ctx.send(f"Failed to ban user:\n```\n{e}\n```", hidden=True) return send_failed = False - try: - await user.send(user_message) - except Exception: - send_failed = True if mtype == "soft": await ctx.guild.unban(user, reason="Ban was softban")