Add color config
This commit is contained in:
parent
ed56e5ee3a
commit
811b7b9a7c
13
__init__.py
13
__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
|
||||
|
Loading…
Reference in New Issue
Block a user