API Reference¶
The following section outlines the API of stoat.py.
Note
This module uses the Python logging module to log diagnostic and errors in an output independent way. If the logging module is not configured, these logs will not be output anywhere. See Setting Up Logging for more information on how to set up and use the logging module with stoat.py.
Documents¶
EventHandler¶
- def after_connect
- def before_connect
- def handle_raw
State¶
- def get_channel
- def get_server
- def get_user
- def provide_cache_context
- class stoat.State(*, cache=None, provide_cache_context_in=None, shard=None)[source]¶
Represents a manager for all stoat.py objects.
- provide_cache_context_in¶
The methods/properties that do provide cache context.
- Type:
List[
ProvideCacheContextIn]
- property my_id[source]¶
Returns the currently logged in user’s ID, or empty string if unavailable.
- Type:
- property saved_notes[source]¶
The Saved Notes channel.
- Type:
Optional[
SavedMessagesChannel]
- get_channel(channel_id, /)[source]¶
PartialMessageable: Returns the partial messageable for provided ID.
- get_server(server_id, /)[source]¶
BaseServer: Returns the base server for provided ID.
CDNClient¶
- class stoat.CDNClient(*, base=None, adapter=None, state, user_agent=None)[source]¶
Represents a HTTP client sending HTTP requests to the Stoat Autumn API.
- await preview(tag, id)[source]¶
This function is a coroutine.
Preview an asset. Only applicable for images.
Tag¶
- class stoat.Tag¶
An alias to
typing.Literalwith available CDN tags.
Resource¶
- async upload
Upload¶
- cls Upload.attachment
- cls Upload.avatar
- cls Upload.background
- cls Upload.banner
- cls Upload.emoji
- cls Upload.icon
- async upload
- class stoat.Upload(content, *, tag=None, filename)[source]¶
Represents a file upload.
This inherits from
Resource.
Content¶
- class stoat.Content¶
An union of types that can be resolved into content.
The following classes are included in this union:
ResolvableResource¶
- class stoat.ResolvableResource¶
An union of types that can be resolved into resource.
The following classes are included in this union:
- await stoat.resolve_resource(state, resolvable, /, *, tag)[source]¶
Resolve a resource.
- Parameters:
state (
State) – The state.resolvable (
ResolvableResource) – The object that should be resolved.
- Returns:
The uploaded file ID.
- Return type:
Parser¶
- def parse_apple_music_embed_special
- def parse_asset
- def parse_asset_metadata
- def parse_auth_event
- def parse_authenticated_event
- def parse_ban
- def parse_bandcamp_embed_special
- def parse_bans
- def parse_bot
- def parse_bot_oauth2
- def parse_bot_user_metadata
- def parse_bots
- def parse_bulk_message_delete_event
- def parse_category
- def parse_channel
- def parse_channel_ack_event
- def parse_channel_create_event
- def parse_channel_delete_event
- def parse_channel_group_join_event
- def parse_channel_group_leave_event
- def parse_channel_start_typing_event
- def parse_channel_stop_typing_event
- def parse_channel_unread
- def parse_channel_update_event
- def parse_channel_voice_state
- def parse_created_report
- def parse_detached_emoji
- def parse_direct_message_channel
- def parse_disabled_response_login
- def parse_discoverable_bot
- def parse_discoverable_bot_search_result
- def parse_discoverable_bots_page
- def parse_discoverable_server
- def parse_discoverable_server_search_result
- def parse_discoverable_servers_page
- def parse_discoverable_theme
- def parse_discoverable_theme_search_result
- def parse_discoverable_themes_page
- def parse_display_user
- def parse_embed
- def parse_embed_special
- def parse_emoji
- def parse_emoji_create_event
- def parse_emoji_delete_event
- def parse_gif_embed_special
- def parse_group_channel
- def parse_group_invite
- def parse_group_public_invite
- def parse_image_embed
- def parse_instance
- def parse_instance_build
- def parse_instance_captcha_feature
- def parse_instance_features_config
- def parse_instance_generic_feature
- def parse_instance_livekit_voice_node
- def parse_instance_voice_feature
- def parse_invite
- def parse_lightspeed_embed_special
- def parse_logout_event
- def parse_member
- def parse_member_list
- def parse_members_with_users
- def parse_message
- def parse_message_append_event
- def parse_message_call_started_system_event
- def parse_message_channel_description_changed_system_event
- def parse_message_channel_icon_changed_system_event
- def parse_message_channel_ownership_changed_system_event
- def parse_message_channel_renamed_system_event
- def parse_message_delete_event
- def parse_message_event
- def parse_message_interactions
- def parse_message_masquerade
- def parse_message_message_pinned_system_event
- def parse_message_message_unpinned_system_event
- def parse_message_react_event
- def parse_message_remove_reaction_event
- def parse_message_reported_content
- def parse_message_start_edting
- def parse_message_stop_edting
- def parse_message_system_event
- def parse_message_text_system_event
- def parse_message_unreact_event
- def parse_message_update_event
- def parse_message_user_added_system_event
- def parse_message_user_banned_system_event
- def parse_message_user_joined_system_event
- def parse_message_user_kicked_system_event
- def parse_message_user_left_system_event
- def parse_message_user_remove_system_event
- def parse_message_webhook
- def parse_messages
- def parse_mfa_response_login
- def parse_mfa_ticket
- def parse_multi_factor_status
- def parse_mutuals
- def parse_none_embed
- def parse_none_embed_special
- def parse_oauth2_access_token
- def parse_oauth2_authorization
- def parse_oauth2_scope_reasoning
- def parse_own_user
- def parse_partial_account
- def parse_partial_session
- def parse_partial_user_profile
- def parse_permission_override
- def parse_permission_override_field
- def parse_policy_change
- def parse_possible_oauth2_authorization
- def parse_public_bot
- def parse_public_invite
- def parse_ready_event
- def parse_rejected_report
- def parse_relationship
- def parse_report
- def parse_report_create_event
- def parse_reported_content
- def parse_resolved_report
- def parse_response_login
- def parse_response_webhook
- def parse_role
- def parse_saved_messages_channel
- def parse_server
- def parse_server_create_event
- def parse_server_delete_event
- def parse_server_emoji
- def parse_server_invite
- def parse_server_member_join_event
- def parse_server_member_leave_event
- def parse_server_member_update_event
- def parse_server_public_invite
- def parse_server_reported_content
- def parse_server_role_delete_event
- def parse_server_role_ranks_update_event
- def parse_server_role_update_event
- def parse_server_update_event
- def parse_session
- def parse_soundcloud_embed_special
- def parse_spotify_embed_special
- def parse_streamable_embed_special
- def parse_system_message_channels
- def parse_text_channel
- def parse_text_embed
- def parse_twitch_embed_special
- def parse_unknown_public_invite
- def parse_user
- def parse_user_move_voice_channel_event
- def parse_user_platform_wipe_event
- def parse_user_profile
- def parse_user_relationship_event
- def parse_user_reported_content
- def parse_user_settings
- def parse_user_settings_update_event
- def parse_user_status
- def parse_user_status_edit
- def parse_user_update_event
- def parse_user_voice_state
- def parse_user_voice_state_update_event
- def parse_video_embed
- def parse_voice_channel
- def parse_voice_channel_join_event
- def parse_voice_channel_leave_event
- def parse_voice_channel_move_event
- def parse_voice_information
- def parse_webhook
- def parse_webhook_create_event
- def parse_webhook_delete_event
- def parse_webhook_update_event
- def parse_webpush_subscription
- def parse_website_embed
- def parse_youtube_embed_special
- class stoat.Parser(*, state)[source]¶
An factory that produces wrapper objects from raw data.
- parse_apple_music_embed_special(payload, /)[source]¶
Parses an Apple Music embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The Apple Music embed special content payload to parse.- Returns:
The parsed Apple Music embed special content object.
- Return type:
- parse_asset_metadata(d, /)[source]¶
Parses an asset metadata object.
- Parameters:
payload (Dict[
str, Any]) – The asset metadata payload to parse.- Returns:
The parsed asset metadata object.
- Return type:
- parse_asset(d, /)[source]¶
Parses an asset object.
- Parameters:
payload (Dict[
str, Any]) – The asset payload to parse.- Returns:
The parsed asset object.
- Return type:
- parse_auth_event(shard, payload, /)[source]¶
Parses an Auth event.
- Parameters:
- Returns:
The parsed authifier event object.
- Return type:
- parse_authenticated_event(shard, payload, /)[source]¶
Parses an Authenticated event.
- Parameters:
- Returns:
The parsed authenticated event object.
- Return type:
- parse_ban(payload, users, /)[source]¶
Parses a ban object.
- Parameters:
payload (Dict[
str, Any]) – The ban payload to parse.users (Dict[
str,DisplayUser]) – The users associated with the ban.
- Returns:
The parsed ban object.
- Return type:
- parse_bandcamp_embed_special(payload, /)[source]¶
Parses a Bandcamp embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The Bandcamp embed special content payload to parse.- Returns:
The parsed Bandcamp embed special content object.
- Return type:
- parse_bot_user_metadata(payload, /)[source]¶
Parses a bot user metadata.
- Parameters:
payload (Dict[
str, Any]) – The bot payload to parse.user (raw.User) – The user associated with the bot.
- Returns:
The parsed bot user metadata object.
- Return type:
- parse_bulk_message_delete_event(shard, payload, /)[source]¶
Parses a BulkMessageDelete event.
- Parameters:
- Returns:
The parsed message bulk delete event object.
- Return type:
- parse_channel_ack_event(shard, payload, /)[source]¶
Parses a ChannelAck event.
- Parameters:
- Returns:
The parsed message ack event object.
- Return type:
- parse_channel_create_event(shard, payload, /)[source]¶
Parses a ChannelCreate event.
- Parameters:
- Returns:
The parsed channel create event object.
- Return type:
- parse_channel_delete_event(shard, payload, /)[source]¶
Parses a ChannelDelete event.
- Parameters:
- Returns:
The parsed channel delete event object.
- Return type:
- parse_channel_group_join_event(shard, payload, /)[source]¶
Parses a ChannelGroupJoin event.
- Parameters:
- Returns:
The parsed group recipient add event object.
- Return type:
- parse_channel_group_leave_event(shard, payload, /)[source]¶
Parses a ChannelGroupLeave event.
- Parameters:
- Returns:
The parsed group recipient remove event object.
- Return type:
- parse_channel_start_typing_event(shard, payload, /)[source]¶
Parses a ChannelStartTyping event.
- Parameters:
- Returns:
The parsed channel typing start event object.
- Return type:
- parse_channel_stop_typing_event(shard, payload, /)[source]¶
Parses a ChannelStopTyping event.
- Parameters:
- Returns:
The parsed channel typing stop event object.
- Return type:
- parse_channel_update_event(shard, payload, /)[source]¶
Parses a ChannelUpdate event.
- Parameters:
- Returns:
The parsed channel update event object.
- Return type:
- parse_channel_voice_state(payload, /)[source]¶
Parses a channel voice state container object.
- Parameters:
payload (Dict[
str, Any]) – The channel voice state container payload to parse.- Returns:
The parsed channel voice state container object.
- Return type:
- parse_created_report(payload, /)[source]¶
Parses a created report object.
- Parameters:
payload (Dict[
str, Any]) – The created report payload to parse.- Returns:
The parsed created report object.
- Return type:
CreatedReport
- parse_detached_emoji(payload, /)[source]¶
Parses a detached emoji object.
- Parameters:
payload (Dict[
str, Any]) – The detached emoji payload to parse.- Returns:
The parsed detached emoji object.
- Return type:
- parse_disabled_response_login(payload, /)[source]¶
Parses a “Account Disabled” login response object.
- Parameters:
payload (Dict[
str, Any]) – The login response payload to parse.- Returns:
The parsed “Account Disabled” login response object.
- Return type:
- parse_discoverable_bot(payload, /)[source]¶
Parses a discoverable bot object.
- Parameters:
payload (Dict[
str, Any]) – The discoverable bot payload to parse.- Returns:
The parsed bot object.
- Return type:
- parse_discoverable_bot_search_result(payload, /)[source]¶
Parses a bot search results object.
- Parameters:
payload (Dict[
str, Any]) – The bot search results payload to parse.- Returns:
The parsed bot search results object.
- Return type:
- parse_discoverable_bots_page(payload, /)[source]¶
Parses a discoverable bots page object.
- Parameters:
payload (Dict[
str, Any]) – The discoverable bots page payload to parse.- Returns:
The parsed discoverable bots page object.
- Return type:
- parse_discoverable_server(payload, /)[source]¶
Parses a discoverable server object.
- Parameters:
payload (Dict[
str, Any]) – The discoverable server payload to parse.- Returns:
The parsed server object.
- Return type:
- parse_discoverable_servers_page(payload, /)[source]¶
Parses a discoverable servers page object.
- Parameters:
payload (Dict[
str, Any]) – The discoverable servers page payload to parse.- Returns:
The parsed discoverable servers page object.
- Return type:
- parse_discoverable_server_search_result(payload, /)[source]¶
Parses a server search results object.
- Parameters:
payload (Dict[
str, Any]) – The server search results payload to parse.- Returns:
The parsed server search results object.
- Return type:
- parse_discoverable_theme(payload, /)[source]¶
Parses a discoverable theme object.
- Parameters:
payload (Dict[
str, Any]) – The discoverable theme payload to parse.- Returns:
The parsed theme object.
- Return type:
- parse_discoverable_theme_search_result(payload, /)[source]¶
Parses a theme search results object.
- Parameters:
payload (Dict[
str, Any]) – The theme search results payload to parse.- Returns:
The parsed theme search results object.
- Return type:
- parse_discoverable_themes_page(payload, /)[source]¶
Parses a discoverable themes page object.
- Parameters:
payload (Dict[
str, Any]) – The discoverable themes page payload to parse.- Returns:
The parsed discoverable themes page object.
- Return type:
- parse_display_user(payload, /)[source]¶
Parses a display user object.
- Parameters:
payload (Dict[
str, Any]) – The display user payload to parse.- Returns:
The parsed user object.
- Return type:
- parse_embed_special(payload, /)[source]¶
Parses an embed special remote content object.
- Parameters:
payload (Dict[
str, Any]) – The embed special remote content payload to parse.- Returns:
The parsed embed special remote content object.
- Return type:
- parse_emoji_delete_event(shard, payload, /)[source]¶
Parses an EmojiDelete event.
- Parameters:
- Returns:
The parsed server emoji delete event object.
- Return type:
- parse_gif_embed_special(_, /)[source]¶
Parses a GIF embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The GIF embed special content payload to parse.- Returns:
The parsed GIF embed special content object.
- Return type:
- parse_group_channel(payload, recipients, /)[source]¶
Parses a group channel object.
- Parameters:
- Returns:
The parsed group channel object.
- Return type:
- parse_group_invite(payload, /)[source]¶
Parses a group invite object.
- Parameters:
payload (Dict[
str, Any]) – The group invite payload to parse.- Returns:
The parsed group invite object.
- Return type:
- parse_group_public_invite(payload, /)[source]¶
Parses a group public invite object.
- Parameters:
payload (Dict[
str, Any]) – The group public invite payload to parse.- Returns:
The parsed group public invite object.
- Return type:
- parse_image_embed(payload, /)[source]¶
Parses an image embed object.
- Parameters:
payload (Dict[
str, Any]) – The image embed payload to parse.- Returns:
The parsed image embed object.
- Return type:
- parse_instance_build(payload, /)[source]¶
Parses an instance build object.
- Parameters:
payload (Dict[
str, Any]) – The instance build payload to parse.- Returns:
The parsed instance build object.
- Return type:
- parse_instance_captcha_feature(payload, /)[source]¶
Parses an instance CAPTCHA feature object.
- Parameters:
payload (Dict[
str, Any]) – The instance CAPTCHA feature payload to parse.- Returns:
The parsed instance CAPTCHA feature object.
- Return type:
- parse_instance_features_config(payload, /)[source]¶
Parses an instance features config object.
- Parameters:
payload (Dict[
str, Any]) – The instance features config payload to parse.- Returns:
The parsed instance features config object.
- Return type:
- parse_instance_generic_feature(payload, /)[source]¶
Parses an instance generic feature object.
- Parameters:
payload (Dict[
str, Any]) – The instance generic feature payload to parse.- Returns:
The parsed instance generic feature object.
- Return type:
- parse_instance_voice_feature(payload, livekit, /)[source]¶
Parses an instance voice feature object.
- Parameters:
payload (Dict[
str, Any]) – The instance voice feature payload to parse.- Returns:
The parsed instance voice feature object.
- Return type:
- parse_instance_livekit_voice_node(payload, /)[source]¶
Parses an instance voice node object.
- Parameters:
payload (Dict[
str, Any]) – The instance voice node payload to parse.- Returns:
The parsed instance voice node object.
- Return type:
InstanceLivekitVoiceNode
- parse_lightspeed_embed_special(payload, /)[source]¶
Parses a Lightspeed.tv embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The Lightspeed.tv embed special content payload to parse.- Returns:
The parsed Lightspeed.tv embed special content object.
- Return type:
- parse_logout_event(shard, payload, /)[source]¶
Parses a Logout event.
- Parameters:
- Returns:
The parsed logout event object.
- Return type:
- parse_member_list(payload, /)[source]¶
Parses a member list object.
- Parameters:
payload (Dict[
str, Any]) – The member list payload to parse.- Returns:
The parsed member list object.
- Return type:
- parse_message(payload, members={}, users={}, cls=<class 'stoat.message.Message'>, /)[source]¶
Parses a message object.
- Parameters:
payload (Dict[
str, Any]) – The message payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populatingMessage.author.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingMessage.author.cls (Type[
Message]) – The message class to use when constructing final object. The constructor of provided class must be compatible with default one.
- Returns:
The parsed message object.
- Return type:
- parse_message_append_event(shard, payload, /)[source]¶
Parses a MessageAppend event.
- Parameters:
- Returns:
The parsed message append event object.
- Return type:
- parse_message_call_started_system_event(payload, members={}, users={}, /)[source]¶
Parses a “Call Started” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forStatelessCallStartedSystemEvent.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessCallStartedSystemEvent.by.
- Returns:
The parsed “Call Started” message system event object.
- Return type:
- parse_message_channel_description_changed_system_event(payload, members={}, users={}, /)[source]¶
Parses a “Channel Description Changed” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forStatelessChannelDescriptionChangedSystemEvent.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessChannelDescriptionChangedSystemEvent.by.
- Returns:
The parsed “Channel Description Changed” message system event object.
- Return type:
- parse_message_channel_icon_changed_system_event(payload, members={}, users={}, /)[source]¶
Parses a “Channel Icon Changed” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forStatelessChannelIconChangedSystemEvent.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessChannelIconChangedSystemEvent.by.
- Returns:
The parsed “Channel Icon Changed” message system event object.
- Return type:
- parse_message_channel_renamed_system_event(payload, members={}, users={}, /)[source]¶
Parses a “Channel Renamed” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forStatelessChannelRenamedSystemEvent.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessChannelRenamedSystemEvent.by.
- Returns:
The parsed “Channel Renamed” message system event object.
- Return type:
- parse_message_channel_ownership_changed_system_event(payload, members={}, users={}, /)[source]¶
Parses a “Channel Ownership Changed” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forStatelessChannelOwnershipChangedSystemEvent.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessChannelOwnershipChangedSystemEvent.from_andStatelessChannelOwnershipChangedSystemEvent.to.
- Returns:
The parsed “Channel Ownership Changed” message system event object.
- Return type:
- parse_message_delete_event(shard, payload, /)[source]¶
Parses a MessageDelete event.
- Parameters:
- Returns:
The parsed message delete event object.
- Return type:
- parse_message_event(shard, payload, /)[source]¶
Parses a Message event.
- Parameters:
- Returns:
The parsed message create event object.
- Return type:
- parse_message_interactions(payload, /)[source]¶
Parses a message interactions object.
- Parameters:
payload (Dict[
str, Any]) – The message interactions payload to parse.- Returns:
The parsed message interactions object.
- Return type:
- parse_message_masquerade(payload, /)[source]¶
Parses a message masquerade object.
- Parameters:
payload (Dict[
str, Any]) – The message masquerade payload to parse.- Returns:
The parsed message masquerade object.
- Return type:
- parse_message_message_pinned_system_event(payload, members={}, users={}, /)[source]¶
Parses a “Message Pinned” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populatingStatelessMessagePinnedSystemEvent.by.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessMessagePinnedSystemEvent.by.
- Returns:
The parsed “Message Pinned” message system event object.
- Return type:
- parse_message_message_unpinned_system_event(payload, members={}, users={}, /)[source]¶
Parses a “Message Unpinned” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populatingStatelessMessageUnpinnedSystemEvent.by.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessMessageUnpinnedSystemEvent.by.
- Returns:
The parsed “Message Unpinned” message system event object.
- Return type:
- parse_message_react_event(shard, payload, /)[source]¶
Parses a MessageReact event.
- Parameters:
- Returns:
The parsed message react event object.
- Return type:
- parse_message_remove_reaction_event(shard, payload, /)[source]¶
Parses a MessageRemoveReaction event.
- Parameters:
- Returns:
The parsed message clear reaction event object.
- Return type:
- parse_message_reported_content(payload, /)[source]¶
Parses a message reported content object.
- Parameters:
payload (Dict[
str, Any]) – The message reported content payload to parse.- Returns:
The parsed message reported content object.
- Return type:
MessageReportedContent
- parse_message_start_edting(shard, payload, /)[source]¶
Parses a message start editing event.
- Parameters:
- Returns:
The parsed message start editing event object.
- Return type:
- parse_message_stop_edting(shard, payload, /)[source]¶
Parses a message stop editing event.
- Parameters:
- Returns:
The parsed message stop editing event object.
- Return type:
- parse_message_system_event(payload, members, users, /)[source]¶
Parses a message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populating various user-related attributes.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populating various user-related attributes.
- Returns:
The parsed message system event object.
- Return type:
- parse_message_text_system_event(payload, members={}, users={}, /)[source]¶
Parses a text message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forTextSystemEvent.users (Dict[
str,User]) – Should be empty forTextSystemEvent.
- Returns:
The parsed text message system event object.
- Return type:
- parse_message_unreact_event(shard, payload, /)[source]¶
Parses a MessageUnreact event.
- Parameters:
- Returns:
The parsed message unreact event object.
- Return type:
- parse_message_update_event(shard, payload, /)[source]¶
Parses a MessageUpdate event.
- Parameters:
- Returns:
The parsed message update event object.
- Return type:
- parse_message_user_added_system_event(payload, members={}, users={}, /)[source]¶
Parses a “User Added” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forStatelessUserAddedSystemEvent.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessUserAddedSystemEvent.userandStatelessUserAddedSystemEvent.by.
- Returns:
The parsed “User Added” message system event object.
- Return type:
- parse_message_user_banned_system_event(payload, members={}, users={}, /)[source]¶
Parses a “User Banned” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populatingStatelessUserBannedSystemEvent.user.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessUserBannedSystemEvent.user.
- Returns:
The parsed “User Banned” message system event object.
- Return type:
- parse_message_user_joined_system_event(payload, members={}, users={}, /)[source]¶
Parses a “User Joined” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populatingStatelessUserJoinedSystemEvent.user.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessUserJoinedSystemEvent.user.
- Returns:
The parsed “User Joined” message system event object.
- Return type:
- parse_message_user_kicked_system_event(payload, members={}, users={}, /)[source]¶
Parses a “User Kicked” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populatingStatelessUserKickedSystemEvent.user.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessUserKickedSystemEvent.user.
- Returns:
The parsed “User Kicked” message system event object.
- Return type:
- parse_message_user_left_system_event(payload, members={}, users={}, /)[source]¶
Parses a “User Left” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – The mapping of user IDs to member objects. Required for trying populatingStatelessUserLeftSystemEvent.user.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessUserLeftSystemEvent.user.
- Returns:
The parsed “User Left” message system event object.
- Return type:
- parse_message_user_remove_system_event(payload, members={}, users={}, /)[source]¶
Parses a “User Removed” message system event object.
- Parameters:
payload (Dict[
str, Any]) – The message system event payload to parse.members (Dict[
str,Member]) – Should be empty forStatelessUserRemovedSystemEvent.users (Dict[
str,User]) – The mapping of user IDs to user objects. Required for trying populatingStatelessUserRemovedSystemEvent.userandStatelessUserRemovedSystemEvent.by.
- Returns:
The parsed “User Removed” message system event object.
- Return type:
- parse_message_webhook(payload, /)[source]¶
Parses a message webhook object.
- Parameters:
payload (Dict[
str, Any]) – The message webhook payload to parse.- Returns:
The parsed message webhook object.
- Return type:
- parse_mfa_response_login(payload, friendly_name, /)[source]¶
Parses a “MFA required” login response object.
- Parameters:
- Returns:
The parsed “MFA required” login response object.
- Return type:
- parse_none_embed_special(_, /)[source]¶
Parses an empty embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The empty embed special content payload to parse.- Returns:
The parsed empty embed special content object.
- Return type:
- parse_oauth2_access_token(payload, /)[source]¶
Parses an OAuth2 access token object.
Added in version 1.2.
- Parameters:
payload (Dict[
str, Any]) – The OAuth2 access token payload to parse.- Returns:
The parsed OAuth2 access token.
- Return type:
- parse_oauth2_authorization(payload, /)[source]¶
Parses an OAuth2 authorization object.
Added in version 1.2.
- Parameters:
payload (Dict[
str, Any]) – The OAuth2 authorization payload to parse.- Returns:
The parsed OAuth2 authorization.
- Return type:
OAuth2Authorization
- parse_oauth2_scope_reasoning(payload, /)[source]¶
Parses an OAuth2 scope reasoning object.
Added in version 1.2.
- Parameters:
payload (Dict[
str, Any]) – The OAuth2 scope reasoning payload to parse.- Returns:
The parsed OAuth2 scope reasoning.
- Return type:
- parse_partial_account(payload, /)[source]¶
Parses a partial account object.
- Parameters:
payload (Dict[
str, Any]) – The partial account payload to parse.- Returns:
The parsed partial account object.
- Return type:
- parse_partial_session(payload, /)[source]¶
Parses a partial session object.
- Parameters:
payload (Dict[
str, Any]) – The partial session payload to parse.- Returns:
The parsed partial session object.
- Return type:
- parse_partial_user_profile(payload, clear, /)[source]¶
Parses a partial user profile object.
- Parameters:
payload (Dict[
str, Any]) – The partial user profile payload to parse.clear (List[raw.FieldsUser]) – The fields that were cleared.
- Returns:
The parsed partial user profile object.
- Return type:
- parse_permission_override(payload, /)[source]¶
Parses a permission override object.
- Parameters:
payload (Dict[
str, Any]) – The permission override payload to parse.- Returns:
The parsed permission override object.
- Return type:
- parse_permission_override_field(payload, /)[source]¶
Parses a permission override field object.
- Parameters:
payload (Dict[
str, Any]) – The permission override field payload to parse.- Returns:
The parsed permission override object.
- Return type:
- parse_policy_change(payload, /)[source]¶
Parses a policy change object.
- Parameters:
payload (Dict[
str, Any]) – The policy change payload to parse.- Returns:
The parsed policy change object.
- Return type:
- parse_possible_oauth2_authorization(payload, /)[source]¶
Parses a possible OAuth2 authorization object.
Added in version 1.2.
- Parameters:
payload (Dict[
str, Any]) – The possible OAuth2 authorization payload to parse.- Returns:
The parsed possible OAuth2 authorization.
- Return type:
- parse_public_invite(payload, /)[source]¶
Parses a public invite object.
- Parameters:
payload (Dict[
str, Any]) – The public invite payload to parse.- Returns:
The parsed public invite object.
- Return type:
- parse_ready_event(shard, payload, /)[source]¶
Parses a Ready event.
- Parameters:
- Returns:
The parsed ready event object.
- Return type:
- parse_rejected_report(payload, /)[source]¶
Parses a rejected report object.
- Parameters:
payload (Dict[
str, Any]) – The rejected report payload to parse.- Returns:
The parsed rejected report object.
- Return type:
RejectedReport
- parse_relationship(payload, /)[source]¶
Parses a relationship object.
- Parameters:
payload (Dict[
str, Any]) – The relationship payload to parse.- Returns:
The parsed relationship object.
- Return type:
- parse_report(payload, /)[source]¶
Parses a report object.
- Parameters:
payload (Dict[
str, Any]) – The report payload to parse.- Returns:
The parsed report object.
- Return type:
Report
- parse_report_create_event(shard, payload, /)[source]¶
Parses a ReportCreate event.
- Parameters:
- Returns:
The parsed report create event object.
- Return type:
- parse_reported_content(payload, /)[source]¶
Parses a reported content object.
- Parameters:
payload (Dict[
str, Any]) – The reported content payload to parse.- Returns:
The parsed reported content object.
- Return type:
ReportedContent
- parse_resolved_report(payload, /)[source]¶
Parses a resolved report object.
- Parameters:
payload (Dict[
str, Any]) – The resolved report payload to parse.- Returns:
The parsed resolved report object.
- Return type:
ResolvedReport
- parse_response_login(payload, friendly_name, /)[source]¶
Parses a login response object.
- Parameters:
- Returns:
The parsed login response object.
- Return type:
- parse_saved_messages_channel(payload, /)[source]¶
Parses a saved messages channel object.
- Parameters:
payload (Dict[
str, Any]) – The saved messages channel payload to parse.- Returns:
The parsed saved messages channel object.
- Return type:
- parse_server_create_event(shard, payload, joined_at, /)[source]¶
Parses a server create event.
- Parameters:
- Returns:
The parsed server create event object.
- Return type:
- parse_server_delete_event(shard, payload, /)[source]¶
Parses a server delete event.
- Parameters:
- Returns:
The parsed server delete event object.
- Return type:
- parse_server_emoji(payload, /)[source]¶
Parses a server emoji object.
- Parameters:
payload (Dict[
str, Any]) – The server emoji payload to parse.- Returns:
The parsed server emoji object.
- Return type:
- parse_server_invite(payload, /)[source]¶
Parses a server private invite object.
- Parameters:
payload (Dict[
str, Any]) – The server private invite payload to parse.- Returns:
The parsed server private invite object.
- Return type:
ServerPrivateInvite
- parse_server_member_join_event(shard, payload, joined_at, /)[source]¶
Parses a server member join event.
- Parameters:
- Returns:
The parsed server member join event object.
- Return type:
- parse_server_member_leave_event(shard, payload, /)[source]¶
Parses a server member remove event.
- Parameters:
- Returns:
The parsed server member remove event object.
- Return type:
- parse_server_member_update_event(shard, payload, /)[source]¶
Parses a server member update event.
- Parameters:
- Returns:
The parsed server member update event object.
- Return type:
- parse_server_public_invite(payload, /)[source]¶
Parses a server public invite object.
- Parameters:
payload (Dict[
str, Any]) – The server public invite payload to parse.- Returns:
The parsed server public invite object.
- Return type:
- parse_server_reported_content(payload, /)[source]¶
Parses a server reported content object.
- Parameters:
payload (Dict[
str, Any]) – The server reported content payload to parse.- Returns:
The parsed server reported content object.
- Return type:
ServerReportedContent
- parse_server_role_delete_event(shard, payload, /)[source]¶
Parses a ServerRoleDelete event.
- Parameters:
- Returns:
The parsed server role delete event object.
- Return type:
- parse_server_role_ranks_update_event(shard, payload, /)[source]¶
Parses a ServerRoleRanksUpdate event.
- Parameters:
- Returns:
The parsed server role ranks update event object.
- Return type:
- parse_server_role_update_event(shard, payload, /)[source]¶
Parses a ServerRoleUpdate event.
- Parameters:
- Returns:
The parsed server role create/update event object.
- Return type:
- parse_server_update_event(shard, payload, /)[source]¶
Parses a ServerUpdate event.
- Parameters:
- Returns:
The parsed server update event object.
- Return type:
- parse_soundcloud_embed_special(_, /)[source]¶
Parses a Soundcloud embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The Soundcloud embed special content payload to parse.- Returns:
The parsed Soundcloud embed special content object.
- Return type:
- parse_spotify_embed_special(payload, /)[source]¶
Parses a Spotify embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The Spotify embed special content payload to parse.- Returns:
The parsed Spotify embed special content object.
- Return type:
- parse_streamable_embed_special(payload, /)[source]¶
Parses a Streamable embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The Streamable embed special content payload to parse.- Returns:
The parsed Streamable embed special content object.
- Return type:
- parse_system_message_channels(payload, /)[source]¶
Parses a system message channels object.
- Parameters:
payload (Dict[
str, Any]) – The system message channels payload to parse.- Returns:
The parsed system message channels object.
- Return type:
- parse_text_channel(payload, /)[source]¶
Parses a text channel object.
- Parameters:
payload (Dict[
str, Any]) – The text channel payload to parse.- Returns:
The parsed text channel object.
- Return type:
- parse_twitch_embed_special(payload, /)[source]¶
Parses a Twitch embed special content object.
- Parameters:
payload (Dict[
str, Any]) – The Twitch embed special content payload to parse.- Returns:
The parsed Twitch embed special content object.
- Return type:
- parse_unknown_public_invite(payload, /)[source]¶
Parses an unknown public invite object.
- Parameters:
payload (Dict[
str, Any]) – The unknown public invite payload to parse.- Returns:
The parsed unknown public invite object.
- Return type:
- parse_user_move_voice_channel_event(shard, payload, /)[source]¶
Parses an UserMoveVoiceChannel event.
- Parameters:
- Returns:
The parsed user move voice channel event object.
- Return type:
- parse_user_platform_wipe_event(shard, payload, /)[source]¶
Parses an UserPlatformWipe event.
- Parameters:
- Returns:
The parsed user platform wipe event object.
- Return type:
- parse_user_profile(payload, /)[source]¶
Parses an user profile object.
- Parameters:
payload (Dict[
str, Any]) – The user profile payload to parse.- Returns:
The parsed user profile object.
- Return type:
- parse_user_relationship_event(shard, payload, /)[source]¶
Parses an UserRelationship event.
- Parameters:
- Returns:
The parsed user relationship event object.
- Return type:
- parse_user_reported_content(payload, /)[source]¶
Parses an user reported content object.
- Parameters:
payload (Dict[
str, Any]) – The user reported content payload to parse.- Returns:
The parsed user reported content object.
- Return type:
UserReportedContent
- parse_user_settings(payload, partial, /)[source]¶
Parses a nuser settings object.
- Parameters:
- Returns:
The parsed user settings object.
- Return type:
- parse_user_settings_update_event(shard, payload, /)[source]¶
Parses an UserSettingsUpdate event.
- Parameters:
- Returns:
The parsed user settings update event object.
- Return type:
- parse_user_status(payload, /)[source]¶
Parses an user status object.
- Parameters:
payload (Dict[
str, Any]) – The user status payload to parse.- Returns:
The parsed user status object.
- Return type:
- parse_user_status_edit(payload, clear, /)[source]¶
Parses an user status edit object.
- Parameters:
payload (Dict[
str, Any]) – The user status payload to parse.clear (List[raw.FieldsUser]) – The fields that were cleared.
- Returns:
The parsed user status edit object.
- Return type:
- parse_user_update_event(shard, payload, /)[source]¶
Parses an UserUpdate event.
- Parameters:
- Returns:
The parsed user update event object.
- Return type:
- parse_user_voice_state(payload, /)[source]¶
Parses an user voice state object.
- Parameters:
payload (Dict[
str, Any]) – The user voice state payload to parse.- Returns:
The parsed user voice state object.
- Return type:
- parse_user_voice_state_update_event(shard, payload, /)[source]¶
Parses an user voice state update event.
- Parameters:
payload (Dict[
str, Any]) – The event payload to parse.- Returns:
The parsed user voice state update object.
- Return type:
- parse_video_embed(payload, /)[source]¶
Parses a video embed object.
- Parameters:
payload (Dict[
str, Any]) – The video embed payload to parse.- Returns:
The parsed video embed object.
- Return type:
- parse_voice_channel(payload, /)[source]¶
Parses a voice channel object.
Deprecated since version 0.7.0: The method was deprecated in favour of
parse_text_channel()and usingTextChannel.voiceinstead.- Parameters:
payload (Dict[
str, Any]) – The voice channel payload to parse.- Returns:
The parsed voice channel object.
- Return type:
- parse_voice_channel_join_event(shard, payload, /)[source]¶
Parses a voice channel join event.
- Parameters:
- Returns:
The parsed voice channel join event object.
- Return type:
- parse_voice_channel_leave_event(shard, payload, /)[source]¶
Parses a voice channel leave event.
- Parameters:
- Returns:
The parsed voice channel leave event object.
- Return type:
- parse_voice_channel_move_event(shard, payload, /)[source]¶
Parses a voice channel move event.
- Parameters:
- Returns:
The parsed voice channel move event object.
- Return type:
- parse_voice_information(payload, /)[source]¶
Parses a channel voice metadata object.
- Parameters:
payload (Dict[
str, Any]) – The channel voice metadata payload to parse.- Returns:
The parsed channel voice metadata object.
- Return type:
- parse_webhook_create_event(shard, payload, /)[source]¶
Parses a WebhookCreate event.
- Parameters:
- Returns:
The parsed webhook create event object.
- Return type:
- parse_webhook_update_event(shard, payload, /)[source]¶
Parses a WebhookUpdate event.
- Parameters:
- Returns:
The parsed webhook update event object.
- Return type:
- parse_webhook_delete_event(shard, payload, /)[source]¶
Parses a WebhookDelete event.
- Parameters:
- Returns:
The parsed webhook delete event object.
- Return type:
- parse_webpush_subscription(payload, /)[source]¶
Parses a WebPush subscription object.
- Parameters:
payload (Dict[
str, Any]) – The WebPush subscription payload to parse.- Returns:
The parsed WebPush subscription object.
- Return type:
- parse_website_embed(payload, /)[source]¶
Parses a website embed object.
- Parameters:
payload (Dict[
str, Any]) – The website embed payload to parse.- Returns:
The parsed website embed object.
- Return type:
Permissions Calculator¶
- stoat.calculate_saved_messages_channel_permissions(perspective_id, user_id, /)[source]¶
Calculates the permissions in
SavedMessagesChannelscope.- Parameters:
- Returns:
The calculated permissions.
- Return type:
- stoat.calculate_dm_channel_permissions(permissions, /)[source]¶
Calculates the permissions in
DMChannelscope.- Parameters:
permissions (
UserPermissions) – The user permissions.- Returns:
The calculated permissions.
- Return type:
- stoat.calculate_group_channel_permissions(perspective_id, /, *, group_owner_id, group_permissions, group_recipients)[source]¶
Calculates the permissions in
GroupChannelscope.- Parameters:
perspective_id (
str) – The ID of perspective user.group_owner_id (
str) – The ID of group owner (GroupChannel.owner_id).group_permissions (Optional[
Permissions]) – The default group permissions (GroupChannel.permissions).group_recipients (List[
str]) – The IDs of group recipients (GroupChannel.recipient_ids).
- Returns:
The calculated permissions.
- Return type:
- stoat.calculate_server_channel_permissions(initial_permissions, roles, *, default_permissions, role_permissions)[source]¶
Calculates the permissions in
BaseServerChannelscope.- Parameters:
initial_permissions (
str) – The initial permissions to use. Should beserver.permissions_for(member)for members andServer.default_permissionsfor users.roles (List[
Role]) – The member’s roles. Should be empty list if calculating forUser.default_permissions (
str) – The default channel permissions (BaseServerChannel.default_permissions).role_permissions (Dict[
str,Permissions]) – The permissions overrides for roles in the channel (BaseServerChannel.role_permissions).
- Returns:
The calculated permissions.
- Return type:
- stoat.calculate_server_permissions(target_roles, target_timeout, /, *, default_permissions, can_publish=True, can_receive=True, category=None)[source]¶
Calculates the permissions in
Serverscope.- Parameters:
target_roles (List[
Role]) – The target member’s roles. Should be empty list if calculating againstUser, orstoat.sort_member_roles(member.roles, server_roles=server.roles)if calculating against member.target_timeout (Optional[
datetime]) – The target timeout, if applicable (Member.timed_out_until).default_permissions (
Permissions) – The default channel permissions (Server.default_permissions).can_publish (
bool) – Whether the member can send voice data. Defaults toTrue.can_receive (
bool) – Whether the member can receive voice data. Defaults toTrue.category (Optional[
Category]) –The category to calculate permissions with.
Added in version 1.2.
- Returns:
The calculated permissions.
- Return type:
- stoat.calculate_user_permissions(user_id, user_relationship, user_bot, /, *, perspective_id, perspective_bot, perspective_privileged)[source]¶
Calculates the permissions between two users.
- Parameters:
user_id (
str) – The target ID.user_relationship (
RelationshipStatus) – The relationship between us and target user (User.relationship).user_bot (Optional[
BotUserMetadata]) – The bot information about the user (User.bot), if applicable.perspective_id (
str) – The ID of the current user.perspective_bot (Optional[
BotUserMetadata]) – The bot information about the current user (User.bot), if applicable.perspective_privileged (
bool) – Whether the current user is privileged (User.privileged).
- Returns:
The calculated permissions.
- Return type:
Utility Functions¶
- stoat.sort_member_roles(target_role_ids, /, *, safe=True, server_roles)[source]¶
Sorts the member roles.
- Parameters:
target_role_ids (List[
str]) – The IDs of roles to sort (Member.role_ids).safe (
bool) – Whether to raise exception or not if role is missing in cache.server_roles (Dict[
str,Role]) – The mapping of role IDs to role objects (Server.roles).
- Raises:
NoData – The role is not found in cache.
- Returns:
The sorted result, in ascending order.
- Return type:
List[
Role]
Abstract Base Classes¶
Messageable¶
- async acknowledge
- async begin_typing
- async end_typing
- async fetch_channel_id
- async fetch_message
- def get_channel_id
- def get_message
- async history
- async search
- async send
- def typing
- class stoat.abc.Messageable[source]¶
An ABC that allows derived instances to send messages.
The following classes implement this ABC:
- async with typing()[source]¶
Returns an asynchronous context manager that allows you to send a typing indicator in destination channel for an indefinite period of time.
- await fetch_channel_id(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves the channel’s ID.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The channel’s ID.
- Return type:
- await begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- await acknowledge(message=UNDEFINED, *, channel_http_overrides=None, http_overrides=None)[source]¶
This function is a coroutine.
Marks the destination channel as read.
You must have
view_channelto do this.Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Parameters:
message (ULIDOr[
BaseMessage]) – The message to mark as read.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.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.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- await fetch_message(message, /, *, channel_http_overrides=None, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a message.
- Parameters:
message (ULIDOr[
BaseMessage]) – The message to retrieve.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.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 view the channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:
- Returns:
The retrieved message.
- Return type:
- await history(*, channel_http_overrides=None, http_overrides=None, limit=None, before=None, after=None, sort=None, nearby=None, populate_users=None)[source]¶
This function is a coroutine.
Retrieve message history from destination channel.
You must have
read_message_historyto do this.- Parameters:
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.limit (Optional[
int]) –The maximum number of messages to get. Must be between 1 and 100. Defaults to 50.
If
nearbyis provided, then this is(limit + 2).before (Optional[ULIDOr[
BaseMessage]]) – The message before which messages should be fetched.after (Optional[ULIDOr[
BaseMessage]]) – The message after which messages should be fetched.sort (Optional[
MessageSort]) – The message sort direction. Defaults tolatestnearby (Optional[ULIDOr[
BaseMessage]]) –The message to search around.
Providing this parameter will discard
before,afterandsortparameters.It will also take half of limit rounded as the limits to each side. It also fetches the message specified.
populate_users (
bool) – Whether to populate user (and member, if server channel) objects.
- 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 read the message history.
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 messages retrieved.
- Return type:
List[
Message]
- await search(query=None, *, channel_http_overrides=None, http_overrides=None, pinned=None, limit=None, before=None, after=None, sort=None, populate_users=None)[source]¶
This function is a coroutine.
Searches for messages in destination channel.
For
queryandpinned, only one parameter can be provided, otherwise aHTTPExceptionwill be thrown withInvalidOperationtype.You must have
read_message_historyto do this.Note
This can only be used by non-bot accounts.
- Parameters:
query (Optional[
str]) – The full-text search query. See MongoDB documentation for more information.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.pinned (Optional[
bool]) – Whether to search for (un-)pinned messages or not.limit (Optional[
int]) –The maximum number of messages to get. Must be between 1 and 100. Defaults to 50.
If
nearbyis provided, then this is(limit + 2).before (Optional[ULIDOr[
BaseMessage]]) – The message before which messages should be fetched.after (Optional[ULIDOr[
BaseMessage]]) – The message after which messages should be fetched.sort (Optional[
MessageSort]) – The message sort direction. Defaults tolatestnearby (Optional[ULIDOr[
BaseMessage]]) –The message to search around.
Providing this parameter will discard
before,afterandsortparameters.It will also take half of limit rounded as the limits to each side. It also fetches the message specified.
populate_users (
bool) – Whether to populate user (and member, if server channel) objects.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationOne of
before,afterornearbyparameters were invalid IDs.InvalidOperationYou provided both
queryandpinnedparameters.IsBotThe current token belongs to bot account.
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 search messages.
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 messages matched.
- Return type:
List[
Message]
- await send(content=None, *, channel_http_overrides=None, http_overrides=None, nonce=None, attachments=None, replies=None, embeds=None, masquerade=None, interactions=None, silent=None, mention_everyone=None, mention_online=None)[source]¶
This function is a coroutine.
Sends a message to destination channel.
You must have
send_messagesto do this.If message mentions “@everyone” or “@online”, you must have
mention_everyoneto do that.If message mentions any roles, you must
mention_rolesto do that.Fires
MessageCreateEventand optionallyMessageAppendEvent, both for all users who can see destination channel.- Parameters:
content (Optional[
str]) – The message content.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nonce (Optional[
str]) – The message nonce.attachments (Optional[List[
ResolvableResource]]) –The attachments to send the message with.
You must have
upload_filesto provide this.replies (Optional[List[Union[
Reply, ULIDOr[BaseMessage]]]]) – The message replies.embeds (Optional[List[
SendableEmbed]]) –The embeds to send the message with.
You must have
send_embedsto provide this.masquerade (Optional[
MessageMasquerade]) –The message masquerade.
You must have
use_masqueradeto provide this.If
coloris provided,use_masqueradeis also required.interactions (Optional[
MessageInteractions]) –The message interactions.
silent (Optional[
bool]) – Whether to suppress notifications or not.mention_everyone (Optional[
bool]) –Whether to mention all users who can see the channel. This cannot be mixed with
mention_onlineparameter.Note
User accounts cannot set this to
True.mention_online (Optional[
bool]) –Whether to mention all users who are online and can see the channel. This cannot be mixed with
mention_everyoneparameter.Note
User accounts cannot set this to
True.
- Raises:
stoat.HTTPException– Possible values fortype:Value
Reason
EmptyMessageThe message was empty.
FailedValidationThe payload was invalid.
InvalidFlagValueBoth
mention_everyoneandmention_onlinewereTrue.InvalidOperationThe passed nonce was already used. One of
reactionselements was invalid.InvalidPropertyrestrict_reactionswasTruebutreactionswas empty.IsBotThe current token belongs to bot account.
IsNotBotThe current token belongs to user account.
PayloadTooLargeThe message was too large.
TooManyAttachmentsYou provided more attachments than allowed on this instance.
TooManyEmbedsYou provided more embeds than allowed on this instance.
TooManyRepliesYou were replying to more messages than was 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 send messages.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/file/reply was not found.
stoat.InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during message creation.
- Returns:
The message that was sent.
- Return type:
Connectable¶
- async connect
- async fetch_channel_id
- def get_channel_id
- async join_call
- class stoat.abc.Connectable[source]¶
An ABC that allows derived instances to connect to voice call.
The following classes implement this ABC:
- await fetch_channel_id(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves the channel’s ID.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The channel’s ID.
- Return type:
- await join_call(*, channel_http_overrides=None, http_overrides=None, node=UNDEFINED, force_disconnect=UNDEFINED, recipients=UNDEFINED)[source]¶
This function is a coroutine.
Asks the voice server for a token to join the call in destination channel.
You must have
connectto do this.For Livekit instances, fires
MessageCreateEventandVoiceChannelJoinEvent/VoiceChannelMoveEventfor all users who can see target channel.- Parameters:
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.node (UndefinedOr[Optional[
str]]) –The node’s name to use for starting a call.
If
NoneorUNDEFINED, the currently assigned channel node will be used.If channel has no node assigned, you should discover existing voice nodes via
query_node()(on official instances, you generally currently should useworldwide). Otherwise, this will throw anUnknownNodeerror.Added in version 1.2.
force_disconnect (UndefinedOr[Optional[
bool]]) –Whether to force disconnect any other existing voice connections. Useful for disconnecting on another device and joining on a new.
Added in version 1.2.
recipients (UndefinedOr[Optional[List[ULIDOr[
BaseUser]]]]) –A list of users which should be notified of the call starting. Only used when the user is the first one connected.
Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
AlreadyConnectedThe current user was already connected to this voice channel.
CannotJoinCallThe channel was type of
saved_messages(or if instance uses legacy voice server,text).InvalidOperationThe voice server is unavailable.
LivekitUnavailableThe voice server is unavailable. Only applicable to instances using Livekit.
NotConnectedThe current user was already connected to other voice channel.
NotAVoiceChannelThe channel was not a voice channel. Only applicable to instances using Livekit.
UnknownNodeThe server could not discover a voice node.
VosoUnavailableThe voice server is unavailable. Not applicable to instances using Livekit.
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 join a call.
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.
InternalErrorSomehow something went during retrieving token.
- Returns:
The token for authenticating with the voice server, and node WebSocket URL (can be empty if instance does not use Livekit).
- Return type:
- await connect(*, channel_http_overrides=None, http_overrides=None, node=None)[source]¶
Connects to a destination voice channel and returns a Room associated with destination.
- Parameters:
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.node (Optional[
str]) –The node’s name to use for starting a call.
If
None, the currently assigned channel node will be used.If channel has no node assigned, you should discover existing voice nodes via
query_node()(on official instances, you generally currently should useworldwide). Otherwise, this will throw anUnknownNodeerror.Added in version 1.2.
- Raises:
HTTPException– Possible values fortype:Value
Reason
AlreadyConnectedThe current user was already connected to this voice channel.
CannotJoinCallThe channel was type of
saved_messages(or if instance uses legacy voice server,text).InvalidOperationThe voice server is unavailable.
LivekitUnavailableThe voice server is unavailable. Only applicable to instances using Livekit.
NotConnectedThe current user was already connected to other voice channel.
NotAVoiceChannelThe channel was not a voice channel. Only applicable to instances using Livekit.
UnknownNodeThe server could not discover a voice node.
VosoUnavailableThe voice server is unavailable. Not applicable to instances using Livekit.
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 join a call.
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.
InternalErrorSomehow something went during retrieving token.
TypeError– If livekit dependency is not installed.
Models¶
UndefinedOr¶
- stoat.UNDEFINED¶
A type-sentinel to mark something as undefined. Used to distinguish missing parameter from explicit
Nonevalues.
StatelessAsset¶
- def attach_state
- def to_dict
- class stoat.StatelessAsset(*, id, filename, metadata, content_type, size, deleted, reported, message_id, user_id, server_id, object_id)[source]¶
Represents a stateless file on Stoat generated by Autumn.
For better user experience, prefer using
parent.foorather thanparent.internal_foo.- metadata¶
Parsed metadata of this file.
- Type:
Asset¶
- def attach_state
- async preview
- async read
- def to_dict
- def url
- class stoat.Asset(*, id, filename, metadata, content_type, size, deleted, reported, message_id, user_id, server_id, object_id, state, tag)[source]¶
Bases:
StatelessAssetRepresents an asset on Stoat.
This inherits from
StatelessAsset.- await preview()[source]¶
This function is a coroutine.
Preview an asset. Only applicable for images.
- Returns:
The preview in webp format.
- Return type:
- await read()[source]¶
This function is a coroutine.
Read asset contents.
- Returns:
The asset contents.
- Return type:
- metadata¶
Parsed metadata of this file.
- Type:
PermissionOverride¶
ReadState¶
- async edit
- def get_channel
- def to_dict
- class stoat.ReadState(*, state, channel_id, user_id, last_acked_id, mentioned_in)[source]¶
Represents the read state of a channel.
Note
An entity currently refers to message here. However this might change in future.
- last_acked_id¶
The last acknowledged entity’s ID. It may not point to an existing or valid entity.
- Type:
Optional[
str]
- await edit(*, last_acked_id=UNDEFINED, http_overrides=None)[source]¶
This function is a coroutine.
Edits the read state.
You must have
view_channelto do this.Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Parameters:
last_acked_id (UndefinedOr[Optional[ULIDOr[
BaseMessage]]]) – The new last acknowledged entity’s ID.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.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- Returns:
The newly updated read state.
- Return type:
InstanceCaptchaFeature¶
InstanceGenericFeature¶
InstanceVoiceFeature¶
- stoat.InstanceVoiceFeature¶
alias of
InstanceVosoVoiceFeature|InstanceLivekitVoiceFeature
InstanceFeaturesConfig¶
- class stoat.InstanceFeaturesConfig(*, captcha, email_verification, invite_only, autumn, january, voice)[source]¶
Represents how features are configured on this Stoat instance.
- captcha¶
The CAPTCHA configuration.
- Type:
- autumn¶
The configuration for Autumn (file server service).
- Type:
- january¶
The configuration for January (embed server service).
- Type:
- voice¶
The configuration for Vortex or Livekit (voice server service).
- Type:
InstanceBuild¶
- class stoat.InstanceBuild(*, commit_as_sha, committed_at, semver, origin_url, built_at)[source]¶
Represents information about instance build.
Warning
Some fields might be None, empty string or have
'<failed to generate>'value if they are unavailable. Never assume that they will be available.- commit_as_sha¶
'a52d610e6c152e7acc23cd017a7c67af46eace4c'.- Type:
- Type:
The commit hash. For example
- built_at¶
When the instance executables were built at. This is different from
committed_at.- Type:
Optional[
datetime]
Instance¶
PolicyChange¶
- class stoat.PolicyChange(*, created_at, effective_at, description, url)[source]¶
Represents a platform policy change.
To acknowledge the policy changes, call
HTTPClient.acknowledge_policy_changes().Added in version 1.2.
Exceptions¶
The following exceptions are thrown by the library.
- exception stoat.StoatException[source]¶
Bases:
ExceptionBase exception class for stoat.py
Ideally speaking, this could be caught to handle any exceptions raised from this library.
Changed in version 1.2: Renamed from
PyvoltExceptiontoStoatException.Deprecated since version 1.2: The
PyvoltExceptionalias is a deprecated alias.
- exception stoat.WebSocketConnectionFailure(*, status)[source]¶
Bases:
ExceptionSignal that WebSocket endpoint did not return “101 Switching Protocols” status code.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.HTTPException(response, data, /)[source]¶
Bases:
StoatExceptionException that’s raised when a HTTP request operation fails.
This inherits from
StoatException.- response¶
The response of the failed HTTP request.
- Type:
- error¶
The validation error details. Only applicable when
typeis'FailedValidation'.- Type:
Optional[
str]
- max¶
The maximum count of entities. Only applicable when
typeone of following values:'FileTooLarge''GroupTooLarge''TooManyAttachments''TooManyChannels''TooManyEmbeds''TooManyEmoji''TooManyPendingFriendRequests''TooManyReplies''TooManyRoles''TooManyServers'
- Type:
Optional[
int]
- permission¶
The permission required to perform request. Only applicable when
typeone of following values:'MissingPermission''MissingUserPermission'
- Type:
Optional[
str]
- operation¶
The database operation that failed. Only applicable when
typeis'DatabaseError'.- Type:
Optional[
str]
- collection¶
The collection’s name the operation was on. Not always available when
typeis'DatabaseError'.- Type:
Optional[
str]
- with_¶
The collection’s name the operation was on. Only applicable when
typeone of following values: -'IncorrectData'Not always available when
typeis'DatabaseError'.- Type:
Optional[
str]
- feature¶
The feature that was disabled. Only applicable when
typeis'FeatureDisabled'.Possible values:
'features.mass_mentions_enabled'
- Type:
Optional[
str]
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.NoEffect(data, /)[source]¶
Bases:
StoatExceptionHTTP exception that corresponds to HTTP 200 status code.
This exists because Stoat API returns 200 with error body for some reason.
This inherits from
StoatException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.Unauthorized(response, data, /)[source]¶
Bases:
HTTPExceptionHTTP exception that corresponds to HTTP 401 status code.
This inherits from
HTTPException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.Forbidden(response, data, /)[source]¶
Bases:
HTTPExceptionHTTP exception that corresponds to HTTP 403 status code.
This inherits from
HTTPException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.NotFound(response, data, /)[source]¶
Bases:
HTTPExceptionHTTP exception that corresponds to HTTP 404 status code.
This inherits from
HTTPException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.Conflict(response, data, /)[source]¶
Bases:
HTTPExceptionHTTP exception that corresponds to HTTP 409 status code.
This inherits from
HTTPException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.Ratelimited(response, data, /)[source]¶
Bases:
HTTPExceptionHTTP exception that corresponds to HTTP 429 status code.
This inherits from
HTTPException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.InternalServerError(response, data, /)[source]¶
Bases:
HTTPExceptionHTTP exception that corresponds to HTTP 5xx status code.
This inherits from
HTTPException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.BadGateway(response, data, /)[source]¶
Bases:
HTTPExceptionHTTP exception that corresponds to HTTP 502 status code.
This inherits from
HTTPException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.ShardError[source]¶
Bases:
StoatExceptionException that’s raised when any shard-related error happens.
This inherits from
StoatException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.ShardClosedError[source]¶
Bases:
ShardErrorException that’s raised when shard was already closed.
This inherits from
ShardError.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.AuthenticationError(payload, /)[source]¶
Bases:
ShardErrorException that’s raised when WebSocket authentication fails.
This inherits from
ShardError.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.ConnectError(tries, errors, /)[source]¶
Bases:
ShardErrorException that’s raised when the library fails to connect to Stoat WebSocket.
This inherits from
ShardError.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.DiscoverError(response, status, data, /)[source]¶
Bases:
StoatExceptionException that’s raised when a HTTP request operation fails.
This inherits from
StoatException.- response¶
The response of the failed HTTP request.
- Type:
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.InvalidData(reason, /)[source]¶
Bases:
StoatExceptionException that’s raised when the library encounters unknown or invalid data from Stoat.
This inherits from
StoatException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception stoat.NoData(what, type)[source]¶
Bases:
StoatExceptionException that’s raised when the library did not found data requested from cache.
This is different from
NotFound, and inherits fromStoatException.- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.