From ee58f2d36c96fecd6128e2b70ec8171b8e914492 Mon Sep 17 00:00:00 2001 From: privacy lulz <80280930+slyberries@users.noreply.github.com> Date: Wed, 1 Sep 2021 19:47:18 +0000 Subject: [PATCH] Add different base support --- discord/embeds.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/discord/embeds.py b/discord/embeds.py index 25f05aef..c118aadc 100644 --- a/discord/embeds.py +++ b/discord/embeds.py @@ -315,13 +315,28 @@ class Embed: return getattr(self, '_colour', EmptyEmbed) @colour.setter - def colour(self, value: Union[int, Colour, _EmptyEmbed]): # type: ignore + def colour(self, value: Union[int, Colour, _EmptyEmbed, str], base:int=None): # type: ignore + """ + Set colour + ============ + + value `Union[int, Colour, _EmptyEmbed, str]`: + + value of the colour. If you want to use different number systems such as hexidecimal or binary, use Colour.from_base or set it as a string in that system + + base `int` (optional): + + if value is a string without a prefix(0x, 0b), set base here + """ + if isinstance(value, (Colour, _EmptyEmbed)): self._colour = value elif isinstance(value, int): self._colour = Colour(value=value) + elif isinstance(value, str): + self._colour = int(value, base=base) else: - raise TypeError(f'Expected discord.Colour, int, or Embed.Empty but received {value.__class__.__name__} instead.') + raise TypeError(f'Expected discord.Colour, int, str, or Embed.Empty but received {value.__class__.__name__} instead.') color = colour