From 811b7b9a7cb22fd47c07f07f427b18ffb5702229 Mon Sep 17 00:00:00 2001 From: Louis Chauvet Date: Sat, 25 Apr 2020 01:02:34 +0200 Subject: [PATCH] Add color config --- __init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index 807a126..92dad92 100644 --- a/__init__.py +++ b/__init__.py @@ -12,9 +12,12 @@ class Logging(BasePython): self.config.register("error_channels", factory(c_t.List, factory(c_t.discord_types.Channel, client))) self.config.register("info_channels", factory(c_t.List, factory(c_t.discord_types.Channel, client))) self.config.register("warning_channels", factory(c_t.List, factory(c_t.discord_types.Channel, client))) + self.config.register("error_color", factory(c_t.Color)) + self.config.register("info_color", factory(c_t.Color)) + self.config.register("warning_color", factory(c_t.Color)) self.config.load() - async def send_splited_embed(self, content, channels, title): + async def send_splited_embed(self, content, channels, title, color): h = hex(abs(hash(content))) content = content.splitlines(keepends=True) contents = [] @@ -32,7 +35,7 @@ class Logging(BasePython): embeds = [] for i, content in enumerate(contents_list): embed = discord.Embed(title=f"{title.title()} - {h[2:8]} - {i + 1}/{len(contents_list)}", - description=f"```py\n{content}\n```") + description=f"```py\n{content}\n```", color=color) embed.set_footer(text=h[2:]) embeds.append(embed) for channel in channels: @@ -45,15 +48,15 @@ class Logging(BasePython): async def on_log_info(self, info, *args, **kwargs): channels = self.config["info_channels"] - await self.send_splited_embed(info, channels, "info") + await self.send_splited_embed(info, channels, "info", self.config["info_color"]) async def on_log_error(self, error, *args, **kwargs): channels = self.config["error_channels"] - await self.send_splited_embed(error, channels, "error") + await self.send_splited_embed(error, channels, "error", self.config["error_color"]) async def on_log_warning(self, warning, *args, **kwargs): channels = self.config["warning_channels"] - await self.send_splited_embed(warning, channels, "warning") + await self.send_splited_embed(warning, channels, "warning", self.config["warning_color"]) __main_class__ = Logging