From 70f1fef3c2141b3d3d050ac3fad0acd4721c6660 Mon Sep 17 00:00:00 2001 From: Benjamin O'Brien Date: Sat, 22 Aug 2020 22:49:06 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Final=201.3=20Patch=20?= =?UTF-8?q?=F0=9F=A9=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/prism.py | 18 ++++++++---------- commands/misc/profile.py | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/assets/prism.py b/assets/prism.py index 78c1d04..66a37bf 100644 --- a/assets/prism.py +++ b/assets/prism.py @@ -108,11 +108,15 @@ async def error_handler(ctx, error): return await ctx.send(embed = Tools.error(f"You need the {str(error).split('sing ')[1].split(' per')[0]} permission(s) to use this command.")) - elif "Forbidden: 403 Forbidden" in str(error): + elif isinstance(error, commands.CommandNotFound): + + return + + elif "403" in str(error): try: - return await ctx.send(embed = Tools.error("I'm either missing permission(s) or that user is higher than me.")) + return await ctx.send(embed = Tools.error("Missing permission(s).")) except: @@ -120,7 +124,7 @@ async def error_handler(ctx, error): elif "NoSuchUser" in str(error): - return + return await ctx.send(embed = Tools.error("Couldn't find that user.")) await ctx.send(embed = discord.Embed(title = "Unexpected Error", description = "The command you just used generated an unexpected error.\nPrism has sent an automatic bug report about this problem.\n\nIn the meantime, try some of our other commands. :)", color = 0xFF0000)) @@ -414,10 +418,6 @@ def bought(name, amount): async def getClosestUser(ctx, user, return_member = False): - if ctx.author.id == user.id: - - user = ctx.author.id - user = str(user) matcher = StringMatcher() @@ -464,9 +464,7 @@ async def getClosestUser(ctx, user, return_member = False): if not matches: - await ctx.send(embed = Tools.error("Couldn't find that user.")) - - raise AttributeError("NoSuchUser") + raise ValueError("NoSuchUser") id = int(max(matches.items(), key = itemgetter(1))[0]) diff --git a/commands/misc/profile.py b/commands/misc/profile.py index 683513d..cf86219 100644 --- a/commands/misc/profile.py +++ b/commands/misc/profile.py @@ -20,7 +20,7 @@ async def profile(self, ctx, user = None): db = loads(open("db/users", "r").read()) - user = Tools.getClosestUser(ctx, user if user else ctx.author) + user = await Tools.getClosestUser(ctx, user if user else ctx.author) if not str(user.id) in db: