From d2d135652166030f34416eff618a4a5127a723b2 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 15 Apr 2022 01:01:33 +0200 Subject: [PATCH] Escape ANSI escape sequences --- src/error.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/error.py b/src/error.py index 7bca386..17249e8 100644 --- a/src/error.py +++ b/src/error.py @@ -1,4 +1,5 @@ import logging +import re from discord.ext import commands @@ -27,8 +28,11 @@ class ErrorHandler(commands.Cog): else: message = "Oh no! Something went wrong while running the command!" + ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') + message = ansi_escape.sub("", message) + self.logger.error('Error during command "%s": %s', command_name, message) - embed = ErrorMessage(message) + embed = ErrorMessage(message, command_name=command_name) await ctx.send(embed=embed)