From e9e6e07a835b8a6f9ce2fb6c8167744257de1405 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 15 Apr 2022 01:03:36 +0200 Subject: [PATCH] Better user error messages for errors by youtubedl --- src/message.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/message.py b/src/message.py index a505b4e..61908e7 100644 --- a/src/message.py +++ b/src/message.py @@ -1,3 +1,5 @@ +import re + import discord @@ -14,9 +16,16 @@ class BotMessage(discord.Embed): class ErrorMessage(BotMessage): - def __init__(self, message): + def __init__(self, message, *, command_name: str = None): + title = message + if command_name: + title = f'Error during command "{command_name}"' + description = None + if match := re.search(r"(?P\w+Error): ?(ERROR: ?)?(?P.*): ?Traceback", message): + description = f"{match.group('error')}: {match.group('message')}" super().__init__( - title=f"Error: {message}", + title=title, + description=description, color=discord.Color.red() )