Add different base support
This commit is contained in:
@@ -315,13 +315,28 @@ class Embed:
|
|||||||
return getattr(self, '_colour', EmptyEmbed)
|
return getattr(self, '_colour', EmptyEmbed)
|
||||||
|
|
||||||
@colour.setter
|
@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)):
|
if isinstance(value, (Colour, _EmptyEmbed)):
|
||||||
self._colour = value
|
self._colour = value
|
||||||
elif isinstance(value, int):
|
elif isinstance(value, int):
|
||||||
self._colour = Colour(value=value)
|
self._colour = Colour(value=value)
|
||||||
|
elif isinstance(value, str):
|
||||||
|
self._colour = int(value, base=base)
|
||||||
else:
|
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
|
color = colour
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user