7979from .monetization import Entitlement
8080from .onboarding import Onboarding
8181from .permissions import PermissionOverwrite
82- from .role import Role
82+ from .role import Role , RoleColours
8383from .scheduled_events import ScheduledEvent , ScheduledEventLocation
8484from .stage_instance import StageInstance
8585from .sticker import GuildSticker
@@ -2916,6 +2916,8 @@ async def create_role(
29162916 name : str = ...,
29172917 permissions : Permissions = ...,
29182918 colour : Colour | int = ...,
2919+ colours : RoleColours = ...,
2920+ holographic : bool = ...,
29192921 hoist : bool = ...,
29202922 mentionable : bool = ...,
29212923 icon : bytes | None = MISSING ,
@@ -2930,6 +2932,8 @@ async def create_role(
29302932 name : str = ...,
29312933 permissions : Permissions = ...,
29322934 color : Colour | int = ...,
2935+ colors : RoleColours = ...,
2936+ holographic : bool = ...,
29332937 hoist : bool = ...,
29342938 mentionable : bool = ...,
29352939 icon : bytes | None = ...,
@@ -2943,6 +2947,9 @@ async def create_role(
29432947 permissions : Permissions = MISSING ,
29442948 color : Colour | int = MISSING ,
29452949 colour : Colour | int = MISSING ,
2950+ colors : RoleColours = MISSING ,
2951+ colours : RoleColours = MISSING ,
2952+ holographic : bool = MISSING ,
29462953 hoist : bool = MISSING ,
29472954 mentionable : bool = MISSING ,
29482955 reason : str | None = None ,
@@ -3006,11 +3013,30 @@ async def create_role(
30063013 else :
30073014 fields ["permissions" ] = "0"
30083015
3009- actual_colour = colour or color or Colour .default ()
3016+ actual_colour = colour if colour not in (MISSING , None ) else color
3017+
30103018 if isinstance (actual_colour , int ):
3011- fields ["color" ] = actual_colour
3019+ actual_colour = Colour (actual_colour )
3020+
3021+ if actual_colour not in (MISSING , None ):
3022+ utils .warn_deprecated ("colour" , "colours" , "2.7" )
3023+ actual_colours = RoleColours (primary = actual_colour )
3024+ elif holographic :
3025+ actual_colours = RoleColours .holographic ()
3026+ else :
3027+ actual_colours = colours or colors or RoleColours .default ()
3028+
3029+ if isinstance (actual_colours , RoleColours ):
3030+ if "ENHANCED_ROLE_COLORS" not in self .features :
3031+ actual_colours .secondary = None
3032+ actual_colours .tertiary = None
3033+ fields ["colors" ] = actual_colours ._to_dict ()
30123034 else :
3013- fields ["color" ] = actual_colour .value
3035+ raise InvalidArgument (
3036+ "colours parameter must be of type RoleColours, not {0.__class__.__name__}" .format (
3037+ actual_colours
3038+ )
3039+ )
30143040
30153041 if hoist is not MISSING :
30163042 fields ["hoist" ] = hoist
0 commit comments