Escape ANSI escape sequences

This commit is contained in:
ekzyis 2022-04-15 01:01:33 +02:00
parent 9970fab505
commit d2d1356521
1 changed files with 5 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import logging import logging
import re
from discord.ext import commands from discord.ext import commands
@ -27,8 +28,11 @@ class ErrorHandler(commands.Cog):
else: else:
message = "Oh no! Something went wrong while running the command!" 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) 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) await ctx.send(embed=embed)