glyde/role
Guild roles.
Types
POST /guilds/{g}/roles. Every field is optional and Discord supplies
defaults: a role created without a name is called “new role”.
pub type CreateRole {
CreateRole(
name: option.Option(String),
permissions: option.Option(permissions.Permissions),
color: option.Option(RoleColorField),
hoist: option.Option(Bool),
badge: option.Option(RoleBadge),
mentionable: option.Option(Bool),
)
}
Constructors
-
CreateRole( name: option.Option(String), permissions: option.Option(permissions.Permissions), color: option.Option(RoleColorField), hoist: option.Option(Bool), badge: option.Option(RoleBadge), mentionable: option.Option(Bool), )Arguments
- name
-
Max 100 characters.
- hoist
-
Show the role’s members in their own section of the member list.
PATCH /guilds/{g}/roles/{r}. Only the badge accepts null, whatever the
reference page says, so only it takes a Field.
pub type EditRole {
EditRole(
name: option.Option(String),
permissions: option.Option(permissions.Permissions),
color: option.Option(RoleColorField),
hoist: option.Option(Bool),
badge: field.Field(RoleBadge),
mentionable: option.Option(Bool),
)
}
Constructors
-
EditRole( name: option.Option(String), permissions: option.Option(permissions.Permissions), color: option.Option(RoleColorField), hoist: option.Option(Bool), badge: field.Field(RoleBadge), mentionable: option.Option(Bool), )Arguments
- badge
-
Nullleaves the role with no icon and no emoji.
pub type Role {
Role(
id: id.Id(id.Role),
name: String,
colors: RoleColors,
hoist: Bool,
icon: option.Option(String),
unicode_emoji: option.Option(String),
position: Int,
permissions: permissions.Permissions,
managed: Bool,
mentionable: Bool,
tags: option.Option(RoleTags),
flags: flags.Flags(RoleFlag),
)
}
Constructors
-
Role( id: id.Id(id.Role), name: String, colors: RoleColors, hoist: Bool, icon: option.Option(String), unicode_emoji: option.Option(String), position: Int, permissions: permissions.Permissions, managed: Bool, mentionable: Bool, tags: option.Option(RoleTags), flags: flags.Flags(RoleFlag), )Arguments
- id
-
The @everyone role carries the guild’s own id.
- colors
-
The one colour field. Discord still sends the deprecated
color, and the decoder reads it only to fill this in whencolorsis missing, so there is no second number here to disagree with. - hoist
-
Listed separately in the member sidebar.
- icon
-
Absent without the ROLE_ICONS feature, null on a role with no icon.
- position
-
Ties are broken by id.
- permissions
-
Guild-wide. The
permissionson members and channels are not. - managed
-
Owned by an integration, so it cannot be assigned or deleted.
- tags
-
Absent on an ordinary role.
A role wears an icon or an emoji, never both. An edit setting either one writes an explicit null over the other, so the body says what it wants rather than leaning on Discord to clear the loser.
pub type RoleBadge {
RoleIcon(image.ImageData)
RoleEmoji(String)
}
Constructors
-
RoleIcon(image.ImageData)Needs the ROLE_ICONS guild feature.
-
RoleEmoji(String)
Discord takes the role’s colour two ways and reads only one of them, so stating it twice is a body that contradicts itself. One value, one key.
pub type RoleColorField {
LegacyColor(Int)
Colors(RoleColors)
}
Constructors
-
LegacyColor(Int)The deprecated
colorinteger, and still the only colour a guild without ENHANCED_ROLE_COLORS can set. -
Colors(RoleColors)The
colorsobject that supersedes it.
The three shapes Discord accepts. Anything else is a 400, so three
numbers that can disagree would be three ways to get one. Gradient and
Holographic need the ENHANCED_ROLE_COLORS feature.
pub type RoleColors {
Solid(primary: Int)
Gradient(primary: Int, secondary: Int)
Holographic
}
Constructors
-
Solid(primary: Int) -
Gradient(primary: Int, secondary: Int) -
HolographicDiscord accepts one holographic triple and no other, so this carries no numbers:
role_colors_to_jsonwrites them.
pub type RoleFlag {
InPrompt
}
Constructors
-
InPromptThe role can be picked in an onboarding prompt.
pub type RoleFlags =
flags.Flags(RoleFlag)
The three booleans are a present null for true and no key for false, so they are decoded by presence and not by value.
pub type RoleTags {
RoleTags(
bot_id: option.Option(id.Id(id.User)),
integration_id: option.Option(id.Id(id.Integration)),
subscription_listing_id: option.Option(
id.Id(id.SubscriptionListing),
),
premium_subscriber: Bool,
available_for_purchase: Bool,
guild_connections: Bool,
)
}
Constructors
-
RoleTags( bot_id: option.Option(id.Id(id.User)), integration_id: option.Option(id.Id(id.Integration)), subscription_listing_id: option.Option( id.Id(id.SubscriptionListing), ), premium_subscriber: Bool, available_for_purchase: Bool, guild_connections: Bool, )Arguments
- bot_id
-
Set on the managed role that belongs to a bot.
- premium_subscriber
-
The guild’s booster role.
Values
pub fn create_role() -> CreateRole
pub fn create_role_body(payload: CreateRole) -> body.Body
pub fn decoder() -> decode.Decoder(Role)
pub fn has_flag(
bits: flags.Flags(RoleFlag),
flag: RoleFlag,
) -> Bool
pub fn is_gradient(colors: RoleColors) -> Bool
pub fn role_colors_decoder() -> decode.Decoder(RoleColors)
pub fn role_colors_to_json(colors: RoleColors) -> json.Json
Every key, every time: a null clears a colour, and omitting the key keeps whatever the role already has.
pub fn role_tags_decoder() -> decode.Decoder(RoleTags)