Role
Represents a Discord role in a guild.Attributes
The ID for the role.
The name of the role.
The guild the role belongs to.
The position of the role. This number is usually positive. The bottom role has a position of 0.
Returns the role’s permissions.
The role’s colours. Aliased to
colors.Indicates if the role will be displayed separately from other members.
Indicates if the role is managed by the guild. This is true if any of
Role.is_integration(), Role.is_premium_subscriber(), Role.is_bot_managed() or Role.is_guild_connections_role() is True.Indicates if the role can be mentioned by users.
The role tags associated with this role.
Returns the role’s icon asset, if available.
The role’s unicode emoji. Only available to guilds that contain
ROLE_ICONS in Guild.features.Returns the role’s creation time in UTC.
Returns a string that allows you to mention a role.
Returns all the members with this role.
Methods
is_default()
is_default()
Checks if the role is the default role (@everyone).Returns:
bool - True if this is the @everyone role.Example:is_bot_managed()
is_bot_managed()
Whether the role is associated with a bot.Returns:
bool - True if the role is managed by a bot.Example:is_premium_subscriber()
is_premium_subscriber()
is_integration()
is_integration()
Whether the guild manages the role through some form of integrations such as Twitch or through guild subscriptions.Returns:
bool - True if the role is an integration role.is_assignable()
is_assignable()
Whether the role is able to be assigned or removed by the bot. This checks whether all of the following conditions are true:
- The role is not the guild’s default role
- The role is not managed
- The bot has the
manage_rolespermission - The bot’s top role is above this role
bool - True if the role can be assigned.Example:async edit(**options)
async edit(**options)
Edits the role.Returns:
You must have the
manage_roles permission to use this.The new role name to change to.
The new permissions to change to.
The new colours to change to.
Indicates if the role should be shown separately in the member list.
Indicates if the role should be mentionable by others.
The new role’s position. This must be below your top role’s position, or it will fail.
A bytes-like object representing the icon. Only PNG/JPEG/WebP is supported. Could be None to denote removal of the icon.
The role’s unicode emoji.
The reason for editing this role. Shows up on the audit log.
Role - The newly edited role.Example:async delete(reason=None)
async delete(reason=None)
Deletes the role.Example:
You must have the
manage_roles permission to use this.The reason for deleting this role. Shows up on the audit log.
RoleTags
Represents tags on a role. A role tag is a piece of extra information attached to a managed role that gives it context for the reason the role is managed.Attributes
The bot’s user ID that manages this role.
The integration ID that manages the role.
The subscription SKU and listing ID of the role.
Methods
is_bot_managed()
is_bot_managed()
Whether the role is associated with a bot.Returns:
boolis_premium_subscriber()
is_premium_subscriber()
is_integration()
is_integration()
Whether the guild manages the role through some form of integrations such as Twitch or through guild subscriptions.Returns:
boolis_available_for_purchase()
is_available_for_purchase()
Whether the role is available for purchase.Returns:
bool - True if the role is available for purchase, and False if it is not available for purchase or if the role is not linked to a guild subscription.is_guild_connections_role()
is_guild_connections_role()
Whether the role is a guild connections role.Returns:
boolRoleColours
Represents a role’s gradient colours.Attributes
The primary colour of the role.
The secondary colour of the role.
The tertiary colour of the role. At the moment, only 16761760 is allowed.
Whether the role is holographic. Currently roles are holographic when colours are set to 11127295, 16759788, and 16761760.
Class Methods
RoleColours.default()
RoleColours.default()
Returns a default
RoleColours object with no colours set.Returns: RoleColoursExample:RoleColours.holographic()
RoleColours.holographic()
Returns a Returns:
RoleColours that makes the role look holographic.Currently holographic roles are only supported with colours 11127295, 16759788, and 16761760.
RoleColoursExample: