Role Models#

class interactions.api.models.role.Role(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing a role.

Variables:
  • id (Snowflake) – Role ID

  • name (str) – Role name

  • color (int) – Role color in integer representation

  • hoist (bool) – A status denoting if this role is hoisted

  • icon (Optional[str]) – Role icon hash, if any.

  • unicode_emoji (Optional[str]) – Role unicode emoji

  • position (int) – Role position

  • permissions (Permissions) – Role permissions as a bit set

  • managed (bool) – A status denoting if this role is managed by an integration

  • mentionable (bool) – A status denoting if this role is mentionable

  • tags (Optional[RoleTags]) – The tags this role has

property mention: str#

New in version 4.1.0.

Returns a string that allows you to mention the given role.

Returns:

The string of the mentioned role.

Return type:

str

property created_at: datetime#

New in version 4.4.0.

Returns when the role was created.

async delete(guild_id, reason=None)[source]#

New in version 4.0.2.

Deletes the role from the guild.

Parameters:
  • guild_id (int) – The id of the guild to delete the role from

  • reason (Optional[str]) – The reason for the deletion

async modify(guild_id, name=<interactions.MISSING>, permissions=<interactions.MISSING>, color=<interactions.MISSING>, hoist=<interactions.MISSING>, icon=<interactions.MISSING>, unicode_emoji=<interactions.MISSING>, mentionable=<interactions.MISSING>, reason=None)[source]#

New in version 4.0.2.

Edits the role in a guild.

Parameters:
  • guild_id (int) – The id of the guild to edit the role on

  • name (Optional[str]) – The name of the role, defaults to the current value of the role

  • color (Optional[int]) – RGB color value as integer, defaults to the current value of the role

  • permissions (Optional[Union[Permissions, int]]) – Bitwise value of the enabled/disabled permissions, defaults to the current value of the role

  • hoist (Optional[bool]) – Whether the role should be displayed separately in the sidebar, defaults to the current value of the role

  • icon (Optional[Image]) – The role’s icon image (if the guild has the ROLE_ICONS feature), defaults to the current value of the role

  • unicode_emoji (Optional[str]) – The role’s unicode emoji as a standard emoji (if the guild has the ROLE_ICONS feature), defaults to the current value of the role

  • mentionable (Optional[bool]) – Whether the role should be mentionable, defaults to the current value of the role

  • reason (Optional[str]) – The reason why the role is edited, default None

Returns:

The modified role object

Return type:

Role

async modify_position(guild_id, position, reason=None)[source]#

New in version 4.0.2.

Modifies the position of a role in the guild.

Parameters:
  • guild_id (int) – The id of the guild to modify the role position on

  • position (int) – The new position of the role

  • reason (Optional[str]) – The reason for the modifying

Returns:

List of guild roles with updated hierarchy

Return type:

List[Role]

class interactions.api.models.role.RoleTags(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the tags of a role.

Note

With the premium_subscriber and available_for_purchase attributes currently, if the attribute is present and “null” it’s true, and if the attribute is not present it’s false.

Variables:
  • bot_id (Optional[Snowflake]) – The id of the bot this role belongs to

  • integration_id (Optional[Snowflake]) – The id of the integration this role belongs to

  • premium_subscriber (Optional[bool]) – Whether if this is the guild’s booster role.

  • subscription_listing_id (Optional[Snowflake]) – The id of this role’s subscription sku and listing, if any.

  • available_for_purchase (Optional[bool]) – Whether this role is available for purchase.