Servers¶
The following section documents everything related to servers.
Models¶
BaseServer¶
- async add_bot
- async ban
- async bulk_edit_role_ranks
- async create_category
- async create_channel
- async create_role
- async create_server_emoji
- async create_text_channel
- async create_voice_channel
- async delete
- async delete_category
- async edit
- async edit_category
- async fetch
- async fetch_bans
- async fetch_emojis
- async fetch_invites
- async fetch_member
- async fetch_member_list
- async fetch_members
- async fetch_role
- def get_emoji
- def get_member
- async join
- async kick
- async leave
- async mark_server_as_read
- async query_members_by_name
- async report
- async set_default_permissions
- async set_role_permissions
- async subscribe
- async unban
- class stoat.BaseServer(*, state, id)[source]¶
Represents a server on Stoat.
This inherits from
Base.- get_emoji(emoji_id, /)[source]¶
Retrieves a server emoji from cache.
- Parameters:
emoji_id (
str) – The emoji ID.- Returns:
The emoji or
Noneif not found.- Return type:
Optional[
ServerEmoji]
- property emojis[source]¶
Returns all emojis of this server.
- Type:
Mapping[
str,ServerEmoji]
- await add_bot(bot, *, http_overrides=None)[source]¶
This function is a coroutine.
Invites a bot to a server or group.
You must have
manage_serverto do this.For servers, fires
ServerCreateEventfor bot,ServerMemberJoinEventandMessageCreateEventfor all server members.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Forbidden– Possible values fortype:Value
Reason
BannedThe bot was banned in target server.
BotIsPrivateYou do not own the bot to add it.
MissingPermissionYou do not have the proper permissions to add bots.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot/server was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInServerThe bot is already in server.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await ban(user, *, http_overrides=None, reason=None)[source]¶
This function is a coroutine.
Bans an user from the server.
You must have
ban_membersto do this.May fire
ServerMemberRemoveEventfor banned user and all server members.- Parameters:
user (Union[
str,BaseUser,BaseMember]) – The user to ban from the server.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.reason (Optional[
str]) – The ban reason. Can be only up to 1024 characters long.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to ban yourself.
FailedValidationThe payload was invalid.
InvalidOperationYou tried to ban server owner.
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 top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created ban.
- Return type:
- await bulk_edit_role_ranks(ranks, *, http_overrides=None)[source]¶
This function is a coroutine.
Edits ranks of all roles in bulk.
You must have
manage_rolesto do this.Fires
ServerRoleRanksUpdateEventfor all server members.- Parameters:
ranks (List[ULIDOr[
BaseRole]]) –A list of roles that should be reordered, where their position in list represents their new rank.
For example, we have following roles:
Owner
Administrator
Moderator
Member
Passing
[member_role_id, moderator_role_id, administrator_role_id, owner_role_id]would result in following hierachy:Member has rank=3
Moderator has rank=2
Administrator has rank=1
Owner has rank=0
Must contain all roles.
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
InvalidOperationOne of server roles was not specified in
ranksparameter.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 roles you were trying to edit rank of.
MissingPermissionYou do not have the proper permissions to edit role ranks.
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 server with updated role ranks.
- Return type:
- await create_category(title, *, http_overrides=None, channels)[source]¶
This function is a coroutine.
Create a new category within server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
title (
str) – The category name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.channels (List[ULIDOr[
ServerChannel]]) – The channel’s IDs inside this category.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
Category– The category created in server.
- await create_channel(*, http_overrides=None, type=None, name, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new text or voice channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.type (Optional[
ChannelType]) – The channel type. Defaults toChannelType.textif not provided.name (
str) – The channel name. Must be between 1 and 32 characters.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await create_server_emoji(name, *, http_overrides=None, nsfw=None, image)[source]¶
This function is a coroutine.
Creates an emoji in server.
You must have
manage_customizationto do this.Fires
EmojiCreateEventfor all server members.Note
Prior to API v0.8.4, this could only be used by non-bot accounts.
- Parameters:
name (
str) – The emoji name. Must be between 1 and 32 chars long. Can only contain ASCII digits, underscore and lowercase letters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nsfw (Optional[
bool]) – Whether the emoji is NSFW or not. Defaults toFalse.image (
ResolvableResource) – The emoji data.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
IsBotThe current token belongs to bot account. Only applicable to instances running API whose version is lower than
v0.8.3.TooManyEmojiThe server has too many emojis than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create emojis in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/file was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created emoji.
- Return type:
- await create_text_channel(name, *, http_overrides=None, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new text channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
name (
str) – The channel name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await create_voice_channel(name, *, http_overrides=None, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new voice channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
name (
str) – The channel name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await create_role(*, http_overrides=None, name, rank=None)[source]¶
This function is a coroutine.
Creates a new server role.
You must have
manage_rolesto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (
str) – The role name. Must be between 1 and 32 characters long.rank (Optional[
int]) – The ranking position. The smaller value is, the more role takes priority.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
TooManyRolesThe server has too many roles than allowed on this instance.
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 create.
MissingPermissionYou do not have the proper permissions to create role in this server.
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 role created in server.
- Return type:
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a server if owner, or leaves otherwise.
Fires
ServerDeleteEvent(if owner) orServerMemberRemoveEventfor 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.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await delete_category(category, *, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a category in server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
category (ULIDOr[
Category]) – The category to delete.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to delete categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
UnknownCategoryThe category was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, mfa_ticket=None, name=UNDEFINED, description=UNDEFINED, icon=UNDEFINED, banner=UNDEFINED, categories=UNDEFINED, system_messages=UNDEFINED, flags=UNDEFINED, discoverable=UNDEFINED, analytics=UNDEFINED, owner=UNDEFINED)[source]¶
This function is a coroutine.
Edits the server.
To provide any of parameters below (except for
categories,discoverableandflags), you must havemanage_server.Fires
ServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.mfa_ticket (Optional[
str]) – The valid MFA ticket token. Must be provided ifowneris provided as well.name (UndefinedOr[
str]) – The new server name. Must be between 1 and 32 characters long.description (UndefinedOr[Optional[
str]]) – The new server description. Can be only up to 1024 characters.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new server icon.banner (UndefinedOr[Optional[
ResolvableResource]]) – The new server banner.categories (UndefinedOr[Optional[List[
Category]]]) –The new server categories structure.
You must have
manage_channels.Deprecated since version 1.2: Due to categories rework in API v0.8.5, this parameter will be ignored on newer API versions, and was deprecated in favor of these dedicated methods:
system_messsages (UndefinedOr[Optional[
SystemMessageChannels]]) – The new system message channels configuration.flags (UndefinedOr[
ServerFlags]) – The new server flags. You must be a privileged user to provide this.discoverable (UndefinedOr[
bool]) –Whether this server is public and should show up on Stoat Discover.
The new server flags. You must be a privileged user to provide this.
analytics (UndefinedOr[
bool]) –Whether analytics should be collected for this server. Must be enabled in order to show up on Stoat Discover.
owner (UndefinedOr[Union[
str,BaseUser,BaseMember]]) –The member to transfer ownership to.
You must own the server, or be a privileged user to provide this.
The target user must be not a bot.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationOne of these:
More than 2 categories had same channel.
You tried to transfer ownership to bot.
Unauthorized– Possible values fortype:Value
Reason
InvalidCredentialsThe provided MFA ticket was invalid.
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit server details.
NotOwnerYou provided
ownerparameter but you do not own the server or are not a privileged user.NotPrivilegedYou provided
discoverableorflagsparameters but you are not a privileged user.NotFound– Possible values fortype:Value
Reason
NotFoundOne of these:
The server was not found.
One of channels in one of provided categories was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated server.
- Return type:
- await edit_category(category, *, http_overrides=None, title=UNDEFINED, channels=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits a category in server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
category (ULIDOr[
Category]) – The category to edit.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.title (UndefinedOr[
str]) – The new category title.channels (UndefinedOr[List[ULIDOr[
ServerChannel]]]) – The channel’s IDs inside this category.default_permissions (UndefinedOr[None]) – To remove default permissions or not.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/ban was not found.
UnknownCategoryThe category was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated category.
- Return type:
- await fetch(*, http_overrides=None, populate_channels=None)[source]¶
This function is a coroutine.
Retrieves the server.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.populate_channels (Optional[
bool]) – Whether to populateServer.channels.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
- Returns:
The retrieved server.
- Return type:
- await fetch_bans(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all bans on the server.
You must have
ban_membersto do this.- 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
MissingPermissionYou do not have the proper permissions to retrieve all bans.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The ban entries.
- Return type:
List[
Ban]
- await fetch_emojis(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all custom
ServerEmoji’s that belong to the server.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved emojis.
- Return type:
List[
ServerEmoji]
- await fetch_invites(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all invites that belong to the server.
You must have
manage_serverto do this.- 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
MissingPermissionYou do not have the proper permissions to retrieve server invites.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved invites.
- Return type:
List[
ServerInvite]
- await fetch_member(member, *, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a member.
- Parameters:
member (Union[
str,BaseUser,BaseMember]) – The user to retrieve.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved member.
- Return type:
- await fetch_members(*, http_overrides=None, exclude_offline=None)[source]¶
This function is a coroutine.
Retrieves all server members.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.exclude_offline (Optional[
bool]) – Whether to exclude offline users.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved members.
- Return type:
List[
Member]
- await fetch_member_list(*, http_overrides=None, exclude_offline=None)[source]¶
This function is a coroutine.
Retrieves server member list.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.exclude_offline (Optional[
bool]) – Whether to exclude offline users.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The member list.
- Return type:
- await fetch_role(role, *, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a server role.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.role (ULIDOr[
BaseRole]) – The role to retrieve.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
- Returns:
The retrieved role.
- Return type:
- await join(*, http_overrides=None)[source]¶
This function is a coroutine.
Joins the server.
Fires
ServerCreateEventfor the current user,ServerMemberJoinEventand optionallyMessageCreateEvent, both for all server members.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
TooManyServersYou’re participating in too many servers.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BannedYou’re banned from server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe invite/channel/server was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInServerThe user is already in server.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The server you just joined.
- Return type:
- await kick(member, *, http_overrides=None)[source]¶
This function is a coroutine.
Kicks a member from the server.
Fires
ServerMemberRemoveEventfor kicked user and all server members.- Parameters:
member (Union[
str,BaseUser,BaseMember]) – The member to kick.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to kick yourself.
InvalidOperationYou tried to kick server owner.
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 top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await leave(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Leaves a server if not owner, or deletes otherwise.
Fires
ServerMemberRemoveEventorServerDeleteEvent(if owner) for all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to silently leave server or not.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await mark_server_as_read(*, http_overrides=None)[source]¶
This function is a coroutine.
Marks all channels in a server as read.
Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await query_members_by_name(query, *, http_overrides=None)[source]¶
This function is a coroutine.
Query members by a given name.
Warning
This API is not stable and may be removed in the future.
- Parameters:
query (
str) – The query to search members for.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The members matched.
- Return type:
List[
Member]
- await report(reason, *, http_overrides=None, additional_context=None)[source]¶
This function is a coroutine.
Report the server to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Note
This can only be used by non-bot accounts.
- Parameters:
reason (
ContentReportReason) – The reason for reporting.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.additional_context (Optional[
str]) – The additional context for moderation team. Can be only up to 1000 characters.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report your own server.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await set_role_permissions(role, *, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for the specified server role.
You must have
manage_permissionsto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
role (ULIDOr[
BaseRole]) – The role.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow for the specified role.deny (
Permissions) – The permissions to deny for the specified role.
- 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:
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a server.
You must have
manage_permissionsto do this.Fires
ServerUpdateEventfor all server members.- Parameters:
permissions (
Permissions) – The new permissions.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
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated server.
- Return type:
- await unban(user, *, http_overrides=None)[source]¶
This function is a coroutine.
Unbans an user from the server.
You must have
ban_membersto do this.- Parameters:
user (ULIDOr[
BaseUser]) – The user to unban from the server.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
MissingPermissionYou do not have the proper permissions to unban members.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
PartialServer¶
- async add_bot
- async ban
- async bulk_edit_role_ranks
- async create_category
- async create_channel
- async create_role
- async create_server_emoji
- async create_text_channel
- async create_voice_channel
- async delete
- async delete_category
- async edit
- async edit_category
- async fetch
- async fetch_bans
- async fetch_emojis
- async fetch_invites
- async fetch_member
- async fetch_member_list
- async fetch_members
- async fetch_role
- def get_emoji
- def get_member
- async join
- async kick
- async leave
- async mark_server_as_read
- async query_members_by_name
- async report
- async set_default_permissions
- async set_role_permissions
- async subscribe
- async unban
- class stoat.PartialServer(*, state, id, name, owner_id, description, channel_ids, internal_categories, system_messages, raw_default_permissions, internal_icon, internal_banner, raw_flags, discoverable, analytics)[source]¶
Represents a partial server on Stoat.
Unmodified fields will have
UNDEFINEDvalue.This inherits from
BaseServer.- internal_categories¶
The server’s categories now.
- system_messages¶
The new server’s system message assignments.
- Type:
UndefinedOr[Optional[
SystemMessageChannels]]
- raw_default_permissions¶
The raw value of new default permissions for everyone.
- Type:
UndefinedOr[
int]
- internal_icon¶
The new server’s icon, if any.
- Type:
UndefinedOr[Optional[
StatelessAsset]]
- internal_banner¶
The new server’s banner, if any.
- Type:
UndefinedOr[Optional[
StatelessAsset]]
- property categories[source]¶
The server’s categories now.
- Type:
UndefinedOr[Optional[List[
Category]]]
- property default_permissions[source]¶
The new default permissions for everyone.
- Type:
UndefinedOr[
Permissions]
- property flags[source]¶
The new server’s flags.
- Type:
UndefinedOr[
ServerFlags]
- await add_bot(bot, *, http_overrides=None)[source]¶
This function is a coroutine.
Invites a bot to a server or group.
You must have
manage_serverto do this.For servers, fires
ServerCreateEventfor bot,ServerMemberJoinEventandMessageCreateEventfor all server members.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Forbidden– Possible values fortype:Value
Reason
BannedThe bot was banned in target server.
BotIsPrivateYou do not own the bot to add it.
MissingPermissionYou do not have the proper permissions to add bots.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot/server was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInServerThe bot is already in server.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await ban(user, *, http_overrides=None, reason=None)[source]¶
This function is a coroutine.
Bans an user from the server.
You must have
ban_membersto do this.May fire
ServerMemberRemoveEventfor banned user and all server members.- Parameters:
user (Union[
str,BaseUser,BaseMember]) – The user to ban from the server.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.reason (Optional[
str]) – The ban reason. Can be only up to 1024 characters long.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to ban yourself.
FailedValidationThe payload was invalid.
InvalidOperationYou tried to ban server owner.
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 top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created ban.
- Return type:
- await bulk_edit_role_ranks(ranks, *, http_overrides=None)[source]¶
This function is a coroutine.
Edits ranks of all roles in bulk.
You must have
manage_rolesto do this.Fires
ServerRoleRanksUpdateEventfor all server members.- Parameters:
ranks (List[ULIDOr[
BaseRole]]) –A list of roles that should be reordered, where their position in list represents their new rank.
For example, we have following roles:
Owner
Administrator
Moderator
Member
Passing
[member_role_id, moderator_role_id, administrator_role_id, owner_role_id]would result in following hierachy:Member has rank=3
Moderator has rank=2
Administrator has rank=1
Owner has rank=0
Must contain all roles.
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
InvalidOperationOne of server roles was not specified in
ranksparameter.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 roles you were trying to edit rank of.
MissingPermissionYou do not have the proper permissions to edit role ranks.
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 server with updated role ranks.
- Return type:
- await create_category(title, *, http_overrides=None, channels)[source]¶
This function is a coroutine.
Create a new category within server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
title (
str) – The category name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.channels (List[ULIDOr[
ServerChannel]]) – The channel’s IDs inside this category.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
Category– The category created in server.
- await create_channel(*, http_overrides=None, type=None, name, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new text or voice channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.type (Optional[
ChannelType]) – The channel type. Defaults toChannelType.textif not provided.name (
str) – The channel name. Must be between 1 and 32 characters.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await create_role(*, http_overrides=None, name, rank=None)[source]¶
This function is a coroutine.
Creates a new server role.
You must have
manage_rolesto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (
str) – The role name. Must be between 1 and 32 characters long.rank (Optional[
int]) – The ranking position. The smaller value is, the more role takes priority.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
TooManyRolesThe server has too many roles than allowed on this instance.
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 create.
MissingPermissionYou do not have the proper permissions to create role in this server.
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 role created in server.
- Return type:
- await create_server_emoji(name, *, http_overrides=None, nsfw=None, image)[source]¶
This function is a coroutine.
Creates an emoji in server.
You must have
manage_customizationto do this.Fires
EmojiCreateEventfor all server members.Note
Prior to API v0.8.4, this could only be used by non-bot accounts.
- Parameters:
name (
str) – The emoji name. Must be between 1 and 32 chars long. Can only contain ASCII digits, underscore and lowercase letters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nsfw (Optional[
bool]) – Whether the emoji is NSFW or not. Defaults toFalse.image (
ResolvableResource) – The emoji data.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
IsBotThe current token belongs to bot account. Only applicable to instances running API whose version is lower than
v0.8.3.TooManyEmojiThe server has too many emojis than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create emojis in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/file was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created emoji.
- Return type:
- await create_text_channel(name, *, http_overrides=None, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new text channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
name (
str) – The channel name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await create_voice_channel(name, *, http_overrides=None, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new voice channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
name (
str) – The channel name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a server if owner, or leaves otherwise.
Fires
ServerDeleteEvent(if owner) orServerMemberRemoveEventfor 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.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await delete_category(category, *, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a category in server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
category (ULIDOr[
Category]) – The category to delete.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to delete categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
UnknownCategoryThe category was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, mfa_ticket=None, name=UNDEFINED, description=UNDEFINED, icon=UNDEFINED, banner=UNDEFINED, categories=UNDEFINED, system_messages=UNDEFINED, flags=UNDEFINED, discoverable=UNDEFINED, analytics=UNDEFINED, owner=UNDEFINED)[source]¶
This function is a coroutine.
Edits the server.
To provide any of parameters below (except for
categories,discoverableandflags), you must havemanage_server.Fires
ServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.mfa_ticket (Optional[
str]) – The valid MFA ticket token. Must be provided ifowneris provided as well.name (UndefinedOr[
str]) – The new server name. Must be between 1 and 32 characters long.description (UndefinedOr[Optional[
str]]) – The new server description. Can be only up to 1024 characters.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new server icon.banner (UndefinedOr[Optional[
ResolvableResource]]) – The new server banner.categories (UndefinedOr[Optional[List[
Category]]]) –The new server categories structure.
You must have
manage_channels.Deprecated since version 1.2: Due to categories rework in API v0.8.5, this parameter will be ignored on newer API versions, and was deprecated in favor of these dedicated methods:
system_messsages (UndefinedOr[Optional[
SystemMessageChannels]]) – The new system message channels configuration.flags (UndefinedOr[
ServerFlags]) – The new server flags. You must be a privileged user to provide this.discoverable (UndefinedOr[
bool]) –Whether this server is public and should show up on Stoat Discover.
The new server flags. You must be a privileged user to provide this.
analytics (UndefinedOr[
bool]) –Whether analytics should be collected for this server. Must be enabled in order to show up on Stoat Discover.
owner (UndefinedOr[Union[
str,BaseUser,BaseMember]]) –The member to transfer ownership to.
You must own the server, or be a privileged user to provide this.
The target user must be not a bot.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationOne of these:
More than 2 categories had same channel.
You tried to transfer ownership to bot.
Unauthorized– Possible values fortype:Value
Reason
InvalidCredentialsThe provided MFA ticket was invalid.
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit server details.
NotOwnerYou provided
ownerparameter but you do not own the server or are not a privileged user.NotPrivilegedYou provided
discoverableorflagsparameters but you are not a privileged user.NotFound– Possible values fortype:Value
Reason
NotFoundOne of these:
The server was not found.
One of channels in one of provided categories was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated server.
- Return type:
- await edit_category(category, *, http_overrides=None, title=UNDEFINED, channels=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits a category in server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
category (ULIDOr[
Category]) – The category to edit.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.title (UndefinedOr[
str]) – The new category title.channels (UndefinedOr[List[ULIDOr[
ServerChannel]]]) – The channel’s IDs inside this category.default_permissions (UndefinedOr[None]) – To remove default permissions or not.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/ban was not found.
UnknownCategoryThe category was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated category.
- Return type:
- property emojis[source]¶
Returns all emojis of this server.
- Type:
Mapping[
str,ServerEmoji]
- await fetch(*, http_overrides=None, populate_channels=None)[source]¶
This function is a coroutine.
Retrieves the server.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.populate_channels (Optional[
bool]) – Whether to populateServer.channels.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
- Returns:
The retrieved server.
- Return type:
- await fetch_bans(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all bans on the server.
You must have
ban_membersto do this.- 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
MissingPermissionYou do not have the proper permissions to retrieve all bans.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The ban entries.
- Return type:
List[
Ban]
- await fetch_emojis(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all custom
ServerEmoji’s that belong to the server.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved emojis.
- Return type:
List[
ServerEmoji]
- await fetch_invites(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all invites that belong to the server.
You must have
manage_serverto do this.- 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
MissingPermissionYou do not have the proper permissions to retrieve server invites.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved invites.
- Return type:
List[
ServerInvite]
- await fetch_member(member, *, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a member.
- Parameters:
member (Union[
str,BaseUser,BaseMember]) – The user to retrieve.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved member.
- Return type:
- await fetch_member_list(*, http_overrides=None, exclude_offline=None)[source]¶
This function is a coroutine.
Retrieves server member list.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.exclude_offline (Optional[
bool]) – Whether to exclude offline users.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The member list.
- Return type:
- await fetch_members(*, http_overrides=None, exclude_offline=None)[source]¶
This function is a coroutine.
Retrieves all server members.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.exclude_offline (Optional[
bool]) – Whether to exclude offline users.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved members.
- Return type:
List[
Member]
- await fetch_role(role, *, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a server role.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.role (ULIDOr[
BaseRole]) – The role to retrieve.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
- Returns:
The retrieved role.
- Return type:
- get_emoji(emoji_id, /)[source]¶
Retrieves a server emoji from cache.
- Parameters:
emoji_id (
str) – The emoji ID.- Returns:
The emoji or
Noneif not found.- Return type:
Optional[
ServerEmoji]
- await join(*, http_overrides=None)[source]¶
This function is a coroutine.
Joins the server.
Fires
ServerCreateEventfor the current user,ServerMemberJoinEventand optionallyMessageCreateEvent, both for all server members.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
TooManyServersYou’re participating in too many servers.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BannedYou’re banned from server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe invite/channel/server was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInServerThe user is already in server.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The server you just joined.
- Return type:
- await kick(member, *, http_overrides=None)[source]¶
This function is a coroutine.
Kicks a member from the server.
Fires
ServerMemberRemoveEventfor kicked user and all server members.- Parameters:
member (Union[
str,BaseUser,BaseMember]) – The member to kick.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to kick yourself.
InvalidOperationYou tried to kick server owner.
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 top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await leave(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Leaves a server if not owner, or deletes otherwise.
Fires
ServerMemberRemoveEventorServerDeleteEvent(if owner) for all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to silently leave server or not.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await mark_server_as_read(*, http_overrides=None)[source]¶
This function is a coroutine.
Marks all channels in a server as read.
Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await query_members_by_name(query, *, http_overrides=None)[source]¶
This function is a coroutine.
Query members by a given name.
Warning
This API is not stable and may be removed in the future.
- Parameters:
query (
str) – The query to search members for.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The members matched.
- Return type:
List[
Member]
- await report(reason, *, http_overrides=None, additional_context=None)[source]¶
This function is a coroutine.
Report the server to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Note
This can only be used by non-bot accounts.
- Parameters:
reason (
ContentReportReason) – The reason for reporting.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.additional_context (Optional[
str]) – The additional context for moderation team. Can be only up to 1000 characters.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report your own server.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a server.
You must have
manage_permissionsto do this.Fires
ServerUpdateEventfor all server members.- Parameters:
permissions (
Permissions) – The new permissions.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
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated server.
- Return type:
- await set_role_permissions(role, *, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for the specified server role.
You must have
manage_permissionsto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
role (ULIDOr[
BaseRole]) – The role.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow for the specified role.deny (
Permissions) – The permissions to deny for the specified role.
- 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:
- await unban(user, *, http_overrides=None)[source]¶
This function is a coroutine.
Unbans an user from the server.
You must have
ban_membersto do this.- Parameters:
user (ULIDOr[
BaseUser]) – The user to unban from the server.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
MissingPermissionYou do not have the proper permissions to unban members.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
Server¶
- analytics
- banner
- categories
- categories_as_mapping
- channel_ids
- channels
- default_permissions
- description
- discoverable
- emojis
- flags
- icon
- id
- internal_banner
- internal_categories
- internal_icon
- me
- members
- name
- nsfw
- owner
- owner_as_member
- owner_as_user
- owner_id
- raw_default_permissions
- raw_flags
- roles
- state
- system_messages
- async add_bot
- async ban
- async bulk_edit_role_ranks
- async create_category
- async create_channel
- async create_role
- async create_server_emoji
- async create_text_channel
- async create_voice_channel
- async delete
- async delete_category
- async edit
- async edit_category
- async fetch
- async fetch_bans
- async fetch_emojis
- async fetch_invites
- async fetch_member
- async fetch_member_list
- async fetch_members
- async fetch_role
- def get_category
- def get_channel
- def get_emoji
- def get_me
- def get_member
- def get_owner
- def get_owner_as_member
- def get_owner_as_user
- def is_official
- def is_verified
- async join
- async kick
- async leave
- def locally_update
- async mark_server_as_read
- def permissions_for
- def prepare_cached
- async query_members_by_name
- async report
- async set_default_permissions
- async set_role_permissions
- async subscribe
- def to_dict
- async unban
- def upsert_role
- class stoat.Server(*, state, id, owner_id, name, description, internal_channels, internal_categories, system_messages, roles, raw_default_permissions, internal_icon, internal_banner, raw_flags, nsfw, analytics, discoverable)[source]¶
Represents a server on Stoat.
This inherits from
BaseServer.- internal_categories¶
The server’s categories.
- system_messages¶
The configuration for sending system event messages.
- Type:
Optional[
SystemMessageChannels]
- internal_icon¶
The stateless server’s icon.
- Type:
Optional[
StatelessAsset]
- internal_banner¶
The stateless server’s banner.
- Type:
Optional[
StatelessAsset]
- get_channel(channel_id, /)[source]¶
Retrieves a server channel from cache.
- Parameters:
channel_id (
str) – The channel ID.- Returns:
The channel or
Noneif not found.- Return type:
Optional[
ServerChannel]
- property channels[source]¶
The channels within this server.
- Type:
List[
ServerChannel]
- locally_update(data, /)[source]¶
Locally updates server with provided data.
Warning
This is called by library internally to keep cache up to date. You likely want to use
BaseServer.edit()method instead.
- permissions_for(member, /, *, safe=True, with_ownership=True, include_timeout=True)[source]¶
Calculate permissions for given member.
- Parameters:
- Raises:
NoData – The role is not found in cache.
- Returns:
The calculated permissions.
- Return type:
- prepare_cached()[source]¶
List[
ServerChannel]: Prepares the server to be cached.
- to_dict(*, with_channels=False)[source]¶
dict: Convert server to raw data.- Parameters:
with_channels (
bool) – Whether to include channel objects instead of their IDs inchannelskey when serializing. Defaults toFalse.
- upsert_role(role, /)[source]¶
Locally upserts role into
Server.rolesmapping.Warning
This is called by library internally to keep cache up to date. You likely want to use
BaseServer.create_role()orBaseRole.edit()instead.- Parameters:
role (Union[
PartialRole,Role]) – The role to upsert.
- await add_bot(bot, *, http_overrides=None)[source]¶
This function is a coroutine.
Invites a bot to a server or group.
You must have
manage_serverto do this.For servers, fires
ServerCreateEventfor bot,ServerMemberJoinEventandMessageCreateEventfor all server members.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Forbidden– Possible values fortype:Value
Reason
BannedThe bot was banned in target server.
BotIsPrivateYou do not own the bot to add it.
MissingPermissionYou do not have the proper permissions to add bots.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot/server was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInServerThe bot is already in server.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await ban(user, *, http_overrides=None, reason=None)[source]¶
This function is a coroutine.
Bans an user from the server.
You must have
ban_membersto do this.May fire
ServerMemberRemoveEventfor banned user and all server members.- Parameters:
user (Union[
str,BaseUser,BaseMember]) – The user to ban from the server.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.reason (Optional[
str]) – The ban reason. Can be only up to 1024 characters long.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to ban yourself.
FailedValidationThe payload was invalid.
InvalidOperationYou tried to ban server owner.
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 top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created ban.
- Return type:
- await bulk_edit_role_ranks(ranks, *, http_overrides=None)[source]¶
This function is a coroutine.
Edits ranks of all roles in bulk.
You must have
manage_rolesto do this.Fires
ServerRoleRanksUpdateEventfor all server members.- Parameters:
ranks (List[ULIDOr[
BaseRole]]) –A list of roles that should be reordered, where their position in list represents their new rank.
For example, we have following roles:
Owner
Administrator
Moderator
Member
Passing
[member_role_id, moderator_role_id, administrator_role_id, owner_role_id]would result in following hierachy:Member has rank=3
Moderator has rank=2
Administrator has rank=1
Owner has rank=0
Must contain all roles.
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
InvalidOperationOne of server roles was not specified in
ranksparameter.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 roles you were trying to edit rank of.
MissingPermissionYou do not have the proper permissions to edit role ranks.
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 server with updated role ranks.
- Return type:
- await create_category(title, *, http_overrides=None, channels)[source]¶
This function is a coroutine.
Create a new category within server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
title (
str) – The category name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.channels (List[ULIDOr[
ServerChannel]]) – The channel’s IDs inside this category.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
Category– The category created in server.
- await create_channel(*, http_overrides=None, type=None, name, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new text or voice channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.type (Optional[
ChannelType]) – The channel type. Defaults toChannelType.textif not provided.name (
str) – The channel name. Must be between 1 and 32 characters.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await create_role(*, http_overrides=None, name, rank=None)[source]¶
This function is a coroutine.
Creates a new server role.
You must have
manage_rolesto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (
str) – The role name. Must be between 1 and 32 characters long.rank (Optional[
int]) – The ranking position. The smaller value is, the more role takes priority.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
TooManyRolesThe server has too many roles than allowed on this instance.
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 create.
MissingPermissionYou do not have the proper permissions to create role in this server.
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 role created in server.
- Return type:
- await create_server_emoji(name, *, http_overrides=None, nsfw=None, image)[source]¶
This function is a coroutine.
Creates an emoji in server.
You must have
manage_customizationto do this.Fires
EmojiCreateEventfor all server members.Note
Prior to API v0.8.4, this could only be used by non-bot accounts.
- Parameters:
name (
str) – The emoji name. Must be between 1 and 32 chars long. Can only contain ASCII digits, underscore and lowercase letters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nsfw (Optional[
bool]) – Whether the emoji is NSFW or not. Defaults toFalse.image (
ResolvableResource) – The emoji data.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
IsBotThe current token belongs to bot account. Only applicable to instances running API whose version is lower than
v0.8.3.TooManyEmojiThe server has too many emojis than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create emojis in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/file was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created emoji.
- Return type:
- await create_text_channel(name, *, http_overrides=None, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new text channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
name (
str) – The channel name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await create_voice_channel(name, *, http_overrides=None, description=None, nsfw=None, voice=None)[source]¶
This function is a coroutine.
Create a new voice channel within server.
You must have
manage_channelsto do this.Fires
ServerChannelCreateEventfor all server members.- Parameters:
name (
str) – The channel name. Must be between 1 and 32 characters.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.description (Optional[
str]) – The channel description. Can be only up to 1024 characters.nsfw (Optional[
bool]) – To mark channel as NSFW or not.voice (Optional[
ChannelVoiceMetadata]) –The voice-specific metadata for this channel.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyChannelsThe server has too many channels than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create channels in server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The channel created in server.
- Return type:
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a server if owner, or leaves otherwise.
Fires
ServerDeleteEvent(if owner) orServerMemberRemoveEventfor 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.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await delete_category(category, *, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a category in server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
category (ULIDOr[
Category]) – The category to delete.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to delete categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
UnknownCategoryThe category was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, mfa_ticket=None, name=UNDEFINED, description=UNDEFINED, icon=UNDEFINED, banner=UNDEFINED, categories=UNDEFINED, system_messages=UNDEFINED, flags=UNDEFINED, discoverable=UNDEFINED, analytics=UNDEFINED, owner=UNDEFINED)[source]¶
This function is a coroutine.
Edits the server.
To provide any of parameters below (except for
categories,discoverableandflags), you must havemanage_server.Fires
ServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.mfa_ticket (Optional[
str]) – The valid MFA ticket token. Must be provided ifowneris provided as well.name (UndefinedOr[
str]) – The new server name. Must be between 1 and 32 characters long.description (UndefinedOr[Optional[
str]]) – The new server description. Can be only up to 1024 characters.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new server icon.banner (UndefinedOr[Optional[
ResolvableResource]]) – The new server banner.categories (UndefinedOr[Optional[List[
Category]]]) –The new server categories structure.
You must have
manage_channels.Deprecated since version 1.2: Due to categories rework in API v0.8.5, this parameter will be ignored on newer API versions, and was deprecated in favor of these dedicated methods:
system_messsages (UndefinedOr[Optional[
SystemMessageChannels]]) – The new system message channels configuration.flags (UndefinedOr[
ServerFlags]) – The new server flags. You must be a privileged user to provide this.discoverable (UndefinedOr[
bool]) –Whether this server is public and should show up on Stoat Discover.
The new server flags. You must be a privileged user to provide this.
analytics (UndefinedOr[
bool]) –Whether analytics should be collected for this server. Must be enabled in order to show up on Stoat Discover.
owner (UndefinedOr[Union[
str,BaseUser,BaseMember]]) –The member to transfer ownership to.
You must own the server, or be a privileged user to provide this.
The target user must be not a bot.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationOne of these:
More than 2 categories had same channel.
You tried to transfer ownership to bot.
Unauthorized– Possible values fortype:Value
Reason
InvalidCredentialsThe provided MFA ticket was invalid.
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit server details.
NotOwnerYou provided
ownerparameter but you do not own the server or are not a privileged user.NotPrivilegedYou provided
discoverableorflagsparameters but you are not a privileged user.NotFound– Possible values fortype:Value
Reason
NotFoundOne of these:
The server was not found.
One of channels in one of provided categories was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated server.
- Return type:
- await edit_category(category, *, http_overrides=None, title=UNDEFINED, channels=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits a category in server.
You must have
manage_channelsto do this.Fires
ServerUpdateEventfor all server members.Added in version 1.2.
- Parameters:
category (ULIDOr[
Category]) – The category to edit.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.title (UndefinedOr[
str]) – The new category title.channels (UndefinedOr[List[ULIDOr[
ServerChannel]]]) – The channel’s IDs inside this category.default_permissions (UndefinedOr[None]) – To remove default permissions or not.
- Raises:
HTTPException– Possible values fortype:Value
Reason
TooManyCategoriesThe server has too many categories than allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit categories.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/ban was not found.
UnknownCategoryThe category was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated category.
- Return type:
- property emojis[source]¶
Returns all emojis of this server.
- Type:
Mapping[
str,ServerEmoji]
- await fetch(*, http_overrides=None, populate_channels=None)[source]¶
This function is a coroutine.
Retrieves the server.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.populate_channels (Optional[
bool]) – Whether to populateServer.channels.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
- Returns:
The retrieved server.
- Return type:
- await fetch_bans(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all bans on the server.
You must have
ban_membersto do this.- 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
MissingPermissionYou do not have the proper permissions to retrieve all bans.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The ban entries.
- Return type:
List[
Ban]
- await fetch_emojis(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all custom
ServerEmoji’s that belong to the server.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved emojis.
- Return type:
List[
ServerEmoji]
- await fetch_invites(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all invites that belong to the server.
You must have
manage_serverto do this.- 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
MissingPermissionYou do not have the proper permissions to retrieve server invites.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved invites.
- Return type:
List[
ServerInvite]
- await fetch_member(member, *, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a member.
- Parameters:
member (Union[
str,BaseUser,BaseMember]) – The user to retrieve.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved member.
- Return type:
- await fetch_member_list(*, http_overrides=None, exclude_offline=None)[source]¶
This function is a coroutine.
Retrieves server member list.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.exclude_offline (Optional[
bool]) – Whether to exclude offline users.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The member list.
- Return type:
- await fetch_members(*, http_overrides=None, exclude_offline=None)[source]¶
This function is a coroutine.
Retrieves all server members.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.exclude_offline (Optional[
bool]) – Whether to exclude offline users.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved members.
- Return type:
List[
Member]
- await fetch_role(role, *, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a server role.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.role (ULIDOr[
BaseRole]) – The role to retrieve.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/role was not found.
- Returns:
The retrieved role.
- Return type:
- get_emoji(emoji_id, /)[source]¶
Retrieves a server emoji from cache.
- Parameters:
emoji_id (
str) – The emoji ID.- Returns:
The emoji or
Noneif not found.- Return type:
Optional[
ServerEmoji]
- await join(*, http_overrides=None)[source]¶
This function is a coroutine.
Joins the server.
Fires
ServerCreateEventfor the current user,ServerMemberJoinEventand optionallyMessageCreateEvent, both for all server members.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
TooManyServersYou’re participating in too many servers.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BannedYou’re banned from server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe invite/channel/server was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInServerThe user is already in server.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The server you just joined.
- Return type:
- await kick(member, *, http_overrides=None)[source]¶
This function is a coroutine.
Kicks a member from the server.
Fires
ServerMemberRemoveEventfor kicked user and all server members.- Parameters:
member (Union[
str,BaseUser,BaseMember]) – The member to kick.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to kick yourself.
InvalidOperationYou tried to kick server owner.
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 top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await leave(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Leaves a server if not owner, or deletes otherwise.
Fires
ServerMemberRemoveEventorServerDeleteEvent(if owner) for all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to silently leave server or not.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await mark_server_as_read(*, http_overrides=None)[source]¶
This function is a coroutine.
Marks all channels in a server as read.
Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await query_members_by_name(query, *, http_overrides=None)[source]¶
This function is a coroutine.
Query members by a given name.
Warning
This API is not stable and may be removed in the future.
- Parameters:
query (
str) – The query to search members for.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The members matched.
- Return type:
List[
Member]
- await report(reason, *, http_overrides=None, additional_context=None)[source]¶
This function is a coroutine.
Report the server to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Note
This can only be used by non-bot accounts.
- Parameters:
reason (
ContentReportReason) – The reason for reporting.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.additional_context (Optional[
str]) – The additional context for moderation team. Can be only up to 1000 characters.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report your own server.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a server.
You must have
manage_permissionsto do this.Fires
ServerUpdateEventfor all server members.- Parameters:
permissions (
Permissions) – The new permissions.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
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this server.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated server.
- Return type:
- await set_role_permissions(role, *, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for the specified server role.
You must have
manage_permissionsto do this.Fires
RawServerRoleUpdateEventfor all server members.- Parameters:
role (ULIDOr[
BaseRole]) – The role.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow for the specified role.deny (
Permissions) – The permissions to deny for the specified role.
- 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:
- await unban(user, *, http_overrides=None)[source]¶
This function is a coroutine.
Unbans an user from the server.
You must have
ban_membersto do this.- Parameters:
user (ULIDOr[
BaseUser]) – The user to unban from the server.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
MissingPermissionYou do not have the proper permissions to unban members.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
Category¶
- def to_dict
- class stoat.Category(id, title, channels, *, default_permissions=None, role_permissions=None)[source]¶
Represents a category containing channels in Stoat server.
- Parameters:
id (
str) – The category’s ID. Must be between 1 and 32 characters long.title (
str) – The category’s title. Must be between 1 and 32 characters long.channels (List[
str]) – The channel’s IDs inside this category.default_permissions (Optional[
PermissionOverride]) –The default permissions in this category.
Added in version 1.2.
role_permissions (Optional[Dict[
str,PermissionOverride]]) –The role permissions in this category.
Added in version 1.2.
- default_permissions¶
The default permissions in this category.
Added in version 1.2.
- Type:
Optional[
PermissionOverride]
- role_permissions¶
The role permissions in this category.
Added in version 1.2.
- Type:
Dict[
str,PermissionOverride]
- def to_dict
Ban¶
- class stoat.Ban(*, server_id, user_id, reason, user)[source]¶
Represents a server ban on Stoat.
- user¶
The user that was banned.
- Type:
Optional[
DisplayUser]