Role¶
discord_http.role module¶
- class discord_http.role.PartialRole(*, state: DiscordAPI, id: int, guild_id: int)[source]¶
Bases:
PartialBase
- async add_role(user_id: int, *, reason: str | None = None) None [source]¶
Add the role to someone
- Parameters:
user_id (int) – The user ID to add the role to
reason (Optional[str]) – The reason for adding the role
- async delete(*, reason: str | None = None) None [source]¶
Delete the role
- Parameters:
reason (Optional[str]) – The reason for deleting the role
- async edit(*, name: str | None = <MISSING>, colour: ~discord_http.colour.Colour | int | None = <MISSING>, hoist: bool | None = <MISSING>, mentionable: bool | None = <MISSING>, positions: int | None = <MISSING>, permissions: Permissions | None = <MISSING>, unicode_emoji: str | None = <MISSING>, icon: ~discord_http.file.File | bytes | None = <MISSING>, reason: str | None = None) Role [source]¶
Edit the role
- Parameters:
name (Optional[str]) – The new name of the role
colour (Optional[Union[Colour, int]]) – The new colour of the role
hoist (Optional[bool]) – Whether the role should be displayed separately in the sidebar
mentionable (Optional[bool]) – Whether the role should be mentionable
unicode_emoji (Optional[str]) – The new unicode emoji of the role
positions (Optional[int]) – The new position of the role
permissions (Optional[Permissions]) – The new permissions for the role
icon (Optional[File]) – The new icon of the role
reason (Union[str]) – The reason for editing the role
- Returns:
The edited role and its data
- Return type:
Union[Role, PartialRole]
- 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: PartialGuild¶
Returns the guild this role is in
- Type:
PartialGuild
- property mention: str¶
Returns a string that mentions the role
- Type:
str
- class discord_http.role.Role(*, state: DiscordAPI, guild: PartialGuild | Guild, data: dict)[source]¶
Bases:
PartialRole
bool: Returns whether the role is a premium subscriber