Better user error messages for errors by youtubedl
This commit is contained in:
parent
bbbb39bf3d
commit
e9e6e07a83
|
@ -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()
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue