Extra security for not overriding bot.embed_color
This commit is contained in:
parent
e3bce1ba58
commit
9e0303cc53
@ -241,14 +241,12 @@ class Client:
|
|||||||
self.shard_count = options.get('shard_count')
|
self.shard_count = options.get('shard_count')
|
||||||
colour = options.get('embed_color')
|
colour = options.get('embed_color')
|
||||||
if isinstance(colour, (Color, Colour)):
|
if isinstance(colour, (Color, Colour)):
|
||||||
self.embed_color = str(hex(colour))
|
|
||||||
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(colour))
|
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(colour))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
HEX = re.compile(r'^(#)[A-Fa-f0-9]{6}$')
|
HEX = re.compile(r'^(#)[A-Fa-f0-9]{6}$')
|
||||||
col = Color(colour)
|
col = Color(colour)
|
||||||
if HEX.match(str(col)):
|
if HEX.match(str(col)):
|
||||||
self.embed_color = str(hex(col))
|
|
||||||
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(col))
|
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(col))
|
||||||
else:
|
else:
|
||||||
raise TypeError('The hex value passed could not be converted to a color')
|
raise TypeError('The hex value passed could not be converted to a color')
|
||||||
@ -282,6 +280,15 @@ class Client:
|
|||||||
|
|
||||||
# internals
|
# internals
|
||||||
|
|
||||||
|
@property
|
||||||
|
def embed_color(self):
|
||||||
|
"""Optional[:class:`.Colour`]: The default embed colour that is
|
||||||
|
being used for all embed if no colour is passed."""
|
||||||
|
col = os.getenv("DEFAULT_EMBED_COLOR")
|
||||||
|
if not col:
|
||||||
|
return None
|
||||||
|
return Colour(int(col, 16))
|
||||||
|
|
||||||
def set_embed_color(self, color):
|
def set_embed_color(self, color):
|
||||||
"""Set a new default embed color.
|
"""Set a new default embed color.
|
||||||
|
|
||||||
@ -299,16 +306,14 @@ class Client:
|
|||||||
:class:`.Colour`
|
:class:`.Colour`
|
||||||
The new color that has been set as default embed color.
|
The new color that has been set as default embed color.
|
||||||
"""
|
"""
|
||||||
if isinstance(new_color, (Color, Colour)):
|
if isinstance(color, (Color, Colour)):
|
||||||
self.embed_color = str(hex(new_color))
|
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(color))
|
||||||
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(new_color))
|
return color
|
||||||
return new_color
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
HEX = re.compile(r'^(#)[A-Fa-f0-9]{6}$')
|
HEX = re.compile(r'^(#)[A-Fa-f0-9]{6}$')
|
||||||
col = Color(new_color)
|
col = Color(color)
|
||||||
if HEX.match(str(col)):
|
if HEX.match(str(col)):
|
||||||
self.embed_color = str(hex(col))
|
|
||||||
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(col))
|
os.environ['DEFAULT_EMBED_COLOR'] = str(hex(col))
|
||||||
return col
|
return col
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user