3838 Tuple ,
3939 Union ,
4040 overload ,
41- Literal ,
4241)
4342
4443from . import abc , utils
8079from .monetization import Entitlement
8180from .onboarding import Onboarding
8281from .permissions import PermissionOverwrite
83- from .role import Role
82+ from .role import Role , RoleColours
8483from .scheduled_events import ScheduledEvent , ScheduledEventLocation
8584from .stage_instance import StageInstance
8685from .sticker import GuildSticker
@@ -2981,6 +2980,8 @@ async def create_role(
29812980 name : str = ...,
29822981 permissions : Permissions = ...,
29832982 colour : Colour | int = ...,
2983+ colours : RoleColours = ...,
2984+ holographic : bool = ...,
29842985 hoist : bool = ...,
29852986 mentionable : bool = ...,
29862987 icon : bytes | None = MISSING ,
@@ -2995,6 +2996,8 @@ async def create_role(
29952996 name : str = ...,
29962997 permissions : Permissions = ...,
29972998 color : Colour | int = ...,
2999+ colors : RoleColours = ...,
3000+ holographic : bool = ...,
29983001 hoist : bool = ...,
29993002 mentionable : bool = ...,
30003003 icon : bytes | None = ...,
@@ -3008,6 +3011,9 @@ async def create_role(
30083011 permissions : Permissions = MISSING ,
30093012 color : Colour | int = MISSING ,
30103013 colour : Colour | int = MISSING ,
3014+ colors : RoleColours = MISSING ,
3015+ colours : RoleColours = MISSING ,
3016+ holographic : bool = MISSING ,
30113017 hoist : bool = MISSING ,
30123018 mentionable : bool = MISSING ,
30133019 reason : str | None = None ,
@@ -3071,11 +3077,30 @@ async def create_role(
30713077 else :
30723078 fields ["permissions" ] = "0"
30733079
3074- actual_colour = colour or color or Colour .default ()
3080+ actual_colour = colour if colour not in (MISSING , None ) else color
3081+
30753082 if isinstance (actual_colour , int ):
3076- fields ["color" ] = actual_colour
3083+ actual_colour = Colour (actual_colour )
3084+
3085+ if actual_colour not in (MISSING , None ):
3086+ utils .warn_deprecated ("colour" , "colours" , "2.7" )
3087+ actual_colours = RoleColours (primary = actual_colour )
3088+ elif holographic :
3089+ actual_colours = RoleColours .holographic ()
3090+ else :
3091+ actual_colours = colours or colors or RoleColours .default ()
3092+
3093+ if isinstance (actual_colours , RoleColours ):
3094+ if "ENHANCED_ROLE_COLORS" not in self .features :
3095+ actual_colours .secondary = None
3096+ actual_colours .tertiary = None
3097+ fields ["colors" ] = actual_colours ._to_dict ()
30773098 else :
3078- fields ["color" ] = actual_colour .value
3099+ raise InvalidArgument (
3100+ "colours parameter must be of type RoleColours, not {0.__class__.__name__}" .format (
3101+ actual_colours
3102+ )
3103+ )
30793104
30803105 if hoist is not MISSING :
30813106 fields ["hoist" ] = hoist
0 commit comments