From 4297eed5916822e65d0f3240dfbd2c0ebe4b263a Mon Sep 17 00:00:00 2001 From: iDutchy Date: Thu, 1 Oct 2020 22:41:02 +0000 Subject: [PATCH] hmm --- discord/client.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/discord/client.py b/discord/client.py index 034ca522..e88e662f 100644 --- a/discord/client.py +++ b/discord/client.py @@ -246,6 +246,8 @@ class Client: if HEX.match(str(col)): self.embed_color = str(hex(col)) os.environ['DEFAULT_EMBED_COLOR'] = str(hex(col)) + else: + raise TypeError('The hex value passed could not be converted to a color') except: raise TypeError('embed_color must be an instance of discord.Colour or a valid 0x****** hex value.') @@ -276,6 +278,40 @@ class Client: # internals + def set_embed_color(self, new_color): + """Set a new default embed color. + + This will raise a TypeError if an improper format was passed. + + Parameters + ----------- + name: Union[:class:`.Colour`, :class:`int`] + The new color you want to set as default embed color. + Pass either an instance of discord.Color or a valid + 0x****** HEX value. + + Returns + -------- + :class:`.Colour` + The new color that has been set as default embed color. + """ + if isinstance(new_color, (Color, Colour)): + self.embed_color = str(hex(new_color)) + os.environ['DEFAULT_EMBED_COLOR'] = str(hex(new_color)) + return new_color + else: + try: + HEX = re.compile(r'^(#)[A-Fa-f0-9]{6}$') + col = Color(new_color) + if HEX.match(str(col)): + self.embed_color = str(hex(col)) + os.environ['DEFAULT_EMBED_COLOR'] = str(hex(col)) + return col + else: + raise TypeError('The hex value passed could not be converted to a color') + except: + raise TypeError('embed_color must be an instance of discord.Colour or a valid 0x****** hex value.') + def _get_websocket(self, guild_id=None, *, shard_id=None): return self.ws