Role

discord_http.role module

class discord_http.role.PartialRole(*, state, id, guild_id)

Bases: PartialBase

Parameters:
async add_role(user_id, *, reason=None) None

Add the role to someone.

Parameters:
  • user_id (Snowflake | int) – The user ID to add the role to

  • reason (str | None) – The reason for adding the role

Return type:

None

async delete(*, reason=None) None

Delete the role.

Parameters:

reason (str | None) – The reason for deleting the role

Return type:

None

async edit(*, name=<MISSING>, colour=<MISSING>, hoist=<MISSING>, mentionable=<MISSING>, positions=<MISSING>, permissions=<MISSING>, unicode_emoji=<MISSING>, icon=<MISSING>, reason=None) Role

Edit the role.

Parameters:
  • name (str | None) – The new name of the role

  • colour (Colour | int | None) – The new colour of the role

  • hoist (bool | None) – Whether the role should be displayed separately in the sidebar

  • mentionable (bool | None) – Whether the role should be mentionable

  • unicode_emoji (str | None) – The new unicode emoji of the role

  • positions (int | None) – The new position of the role

  • permissions (Permissions | None) – The new permissions for the role

  • icon (File | bytes | None) – The new icon of the role

  • reason (str | None) – The reason for editing the role

Return type:

Role

Returns:

The edited role and its data

Raises:

ValueError

  • If both unicode_emoji and icon are set - If there were no changes applied to the role - If position was changed, but Discord API returned invalid data

property guild: Guild | PartialGuild

Returns the guild this role is in.

property mention: str

Returns a string that mentions the role.

async remove_role(user_id, *, reason=None) None

Remove the role from someone.

Parameters:
  • user_id (Snowflake | int) – The user ID to remove the role from

  • reason (str | None) – The reason for removing the role

Return type:

None

class discord_http.role.Role(*, state, guild, data)

Bases: PartialRole

Parameters:
property display_icon: Asset | str | None

Returns the display icon of the role.

property icon: Asset | None

Returns the icon of the role if it’s custom.

is_available_for_purchase() bool

Returns whether the role is available for purchase.

Return type:

bool

is_bot_managed() bool

Returns whether the role is bot managed.

Return type:

bool

is_guild_connection() bool

Returns whether the role is a guild connection.

Return type:

bool

is_integration() bool

Returns whether the role is an integration.

Return type:

bool

is_premium_subscriber() bool

Returns whether the role is a premium subscriber.

Return type:

bool