Better user error messages for errors by youtubedl

This commit is contained in:
ekzyis 2022-04-15 01:03:36 +02:00
parent bbbb39bf3d
commit e9e6e07a83
1 changed files with 11 additions and 2 deletions

View File

@ -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<error>\w+Error): ?(ERROR: ?)?(?P<message>.*): ?Traceback", message):
description = f"{match.group('error')}: {match.group('message')}"
super().__init__(
title=f"Error: {message}",
title=title,
description=description,
color=discord.Color.red()
)