Roles¶
The following section documents everything related to roles.
Models¶
BaseRole¶
- async delete
- async edit
- def get_server
- async set_permissions
- class stoat.BaseRole(*, state, id, server_id)[source]¶
Represents a base role in Stoat server.
This inherits from
Base.- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the role.
You must have
manage_rolesto do this.Fires
ServerRoleDeleteEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of role you’re trying to delete.
MissingPermissionYou do not have the proper permissions to delete role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, name=UNDEFINED, color=UNDEFINED, hoist=UNDEFINED, rank=UNDEFINED)[source]¶
This function is a coroutine.
Edits the role.
You must have
manage_rolesto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new role name. Must be between 1 and 32 characters long.color (UndefinedOr[Optional[
str]]) – The new role color. Must be a valid CSS color.hoist (UndefinedOr[
bool]) – Whether this role should be displayed separately.rank (UndefinedOr[
int]) –The new ranking position. The smaller value is, the more role takes priority.
Deprecated since version 1.2: Use
bulk_edit_role_ranks()instead.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedOne of these:
Rank of your top role is higher than rank of role you’re trying to edit.
Rank of your top role is higher than rank you’re trying to set for this role.
MissingPermissionYou do not have the proper permissions to edit role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated role.
- Return type:
- await set_permissions(*, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for this role.
You must have
manage_permissionsto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow.deny (
Permissions) – The permissions to deny.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
NotElevatedRank of your top role is higher than rank of role you’re trying to set override for.
MissingPermissionYou do not have the proper permissions to edit permissions for this role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated server with new permissions.
- Return type:
PartialRole¶
- async delete
- async edit
- def get_server
- def into_full
- async set_permissions
- class stoat.PartialRole(*, state, id, server_id, name, permissions, color, hoist, rank)[source]¶
Represents a partial role for the server.
Unmodified fields will have
UNDEFINEDvalue.This inherits from
BaseRole.- permissions¶
The new role’s permissions.
- Type:
UndefinedOr[
PermissionOverride]
- into_full()[source]¶
Optional[
Role]: Tries transform this partial role into full object. This is useful when caching role.
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the role.
You must have
manage_rolesto do this.Fires
ServerRoleDeleteEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of role you’re trying to delete.
MissingPermissionYou do not have the proper permissions to delete role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, name=UNDEFINED, color=UNDEFINED, hoist=UNDEFINED, rank=UNDEFINED)[source]¶
This function is a coroutine.
Edits the role.
You must have
manage_rolesto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new role name. Must be between 1 and 32 characters long.color (UndefinedOr[Optional[
str]]) – The new role color. Must be a valid CSS color.hoist (UndefinedOr[
bool]) – Whether this role should be displayed separately.rank (UndefinedOr[
int]) –The new ranking position. The smaller value is, the more role takes priority.
Deprecated since version 1.2: Use
bulk_edit_role_ranks()instead.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedOne of these:
Rank of your top role is higher than rank of role you’re trying to edit.
Rank of your top role is higher than rank you’re trying to set for this role.
MissingPermissionYou do not have the proper permissions to edit role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated role.
- Return type:
- await set_permissions(*, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for this role.
You must have
manage_permissionsto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow.deny (
Permissions) – The permissions to deny.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
NotElevatedRank of your top role is higher than rank of role you’re trying to set override for.
MissingPermissionYou do not have the proper permissions to edit permissions for this role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated server with new permissions.
- Return type:
Role¶
- async delete
- async edit
- def get_server
- def locally_update
- async set_permissions
- def to_dict
- class stoat.Role(*, state, id, server_id, name, permissions, color, hoist, rank)[source]¶
Represents a role in Stoat server.
This inherits from
BaseRole.- permissions¶
Permissions available to this role.
- Type:
- locally_update(data, /)[source]¶
Locally updates role with provided data.
Warning
This is called by library internally to keep cache up to date.
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the role.
You must have
manage_rolesto do this.Fires
ServerRoleDeleteEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of role you’re trying to delete.
MissingPermissionYou do not have the proper permissions to delete role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, name=UNDEFINED, color=UNDEFINED, hoist=UNDEFINED, rank=UNDEFINED)[source]¶
This function is a coroutine.
Edits the role.
You must have
manage_rolesto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new role name. Must be between 1 and 32 characters long.color (UndefinedOr[Optional[
str]]) – The new role color. Must be a valid CSS color.hoist (UndefinedOr[
bool]) – Whether this role should be displayed separately.rank (UndefinedOr[
int]) –The new ranking position. The smaller value is, the more role takes priority.
Deprecated since version 1.2: Use
bulk_edit_role_ranks()instead.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedOne of these:
Rank of your top role is higher than rank of role you’re trying to edit.
Rank of your top role is higher than rank you’re trying to set for this role.
MissingPermissionYou do not have the proper permissions to edit role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated role.
- Return type:
- await set_permissions(*, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for this role.
You must have
manage_permissionsto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow.deny (
Permissions) – The permissions to deny.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
NotElevatedRank of your top role is higher than rank of role you’re trying to set override for.
MissingPermissionYou do not have the proper permissions to edit permissions for this role.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated server with new permissions.
- Return type: