Browse Source

Fix: throw exception when color is used together with colors parameters

pull/10214/head
makerze 1 month ago
parent
commit
4d058136fc
  1. 11
      discord/guild.py
  2. 11
      discord/role.py

11
discord/guild.py

@ -3727,6 +3727,17 @@ class Guild(Hashable):
else:
fields['color'] = actual_colour.value
solid_color_used = color is not MISSING or colour is not MISSING
colors_used = (
primary_color is not MISSING or
secondary_color is not MISSING or
tertiary_color is not MISSING
)
if solid_color_used and colors_used:
raise TypeError(
"You must choose either only solid color (color/colour) or colors (primary_color/secondary_color/tertiary_color), not both."
)
colors_payload: Dict[str, Any]= {}
if primary_color is not MISSING:
if primary_color is None:

11
discord/role.py

@ -551,6 +551,17 @@ class Role(Hashable):
if mentionable is not MISSING:
payload['mentionable'] = mentionable
solid_color_used = color is not MISSING or colour is not MISSING
colors_used = (
primary_color is not MISSING or
secondary_color is not MISSING or
tertiary_color is not MISSING
)
if solid_color_used and colors_used:
raise TypeError(
"You must choose either only solid color (color/colour) or colors (primary_color/secondary_color/tertiary_color), not both."
)
colors_payload: Dict[str, Any] = {}
if primary_color is not MISSING:
if primary_color is None:

Loading…
Cancel
Save