Users¶
The following section documents everything related to users. Users are generally considered base entity on Stoat.
Models¶
UserStatus¶
- def locally_update
- def to_dict
UserStatusEdit¶
StatelessUserProfile¶
- def attach_state
- class stoat.StatelessUserProfile(*, content, internal_background)[source]¶
Represents Stoat
User's stateless profile.- internal_background¶
The stateless background visible on user’s profile.
- Type:
Optional[
StatelessAsset]
- attach_state(state, user_id, /)[source]¶
UserProfile: Attach a state to user profile.
UserProfile¶
- class stoat.UserProfile(*, content, internal_background, state, user_id)[source]¶
Represents Stoat
User's profile.This inherits from
StatelessUserProfile.
PartialUserProfile¶
- class stoat.PartialUserProfile(*, state, content, internal_background)[source]¶
Represents partial user’s profile.
- internal_background¶
The new stateless background visible on user’s profile.
- Type:
Undefined[Optional[
StatelessAsset]]
UserProfileEdit¶
- async to_dict
- class stoat.UserProfileEdit(content=UNDEFINED, *, background=UNDEFINED)[source]¶
Partially represents user’s profile.
- background¶
The background to use on user’s profile.
- Type:
UndefinedOr[Optional[
ResolvableResource]]
Relationship¶
Mutuals¶
BaseUser¶
- async accept_friend_request
- async block
- async deny_friend_request
- async edit
- async fetch
- async fetch_channel_id
- async fetch_default_avatar
- async fetch_flags
- async fetch_profile
- def get_channel_id
- def is_sentinel
- async mutual_friend_ids
- async mutual_server_ids
- async mutuals
- async open_dm
- async remove_friend
- async report
- async unblock
- class stoat.BaseUser(*, state, id)[source]¶
Represents an user on Stoat.
This inherits from
Base,ConnectableandMessageable.- await accept_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Accept another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you accepted friend request from.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
IsBotEither the current user or user you tried to accept friend request from are bot accounts.
TooManyPendingFriendRequestsYou sent too many outgoing friend requests.
NoEffect– You tried to accept friend request from yourself.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BlockedOtherThe user you tried to accept friend request from have blocked you.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyFriendsYou’re already friends with user you tried to accept friend request from.
AlreadySentRequestYou already sent friend request to this user.
BlockedYou have blocked the user you tried to accept friend request from.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you accepted friend request from.
- Return type:
- await block(*, http_overrides=None)[source]¶
This function is a coroutine.
Blocks an user.
Fires
UserRelationshipUpdateEventfor the current user and blocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you already had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The blocked user.
- Return type:
- await deny_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Denies another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you denide friend request from.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you denied friend request from.
- Return type:
- await edit(*, http_overrides=None, display_name=UNDEFINED, avatar=UNDEFINED, status=UNDEFINED, profile=UNDEFINED, badges=UNDEFINED, flags=UNDEFINED)[source]¶
This function is a coroutine.
Edits the user.
Fires
UserUpdateEventfor all users who are subscribed to target user.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.display_name (UndefinedOr[Optional[
str]]) – The new display name. Must be between 2 and 32 characters and not contain zero width space, newline or carriage return characters.avatar (UndefinedOr[Optional[
ResolvableResource]]) – The new avatar. Could beNoneto remove avatar.status (UndefinedOr[
UserStatusEdit]) – The new user status.profile (UndefinedOr[
UserProfileEdit]) – The new user profile data. This is applied as a partial.badges (UndefinedOr[
UserBadges]) – The new user badges. You must be privileged user to provide this.flags (UndefinedOr[
UserFlags]) – The new user flags. You must be privileged user to provide this.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotPrivilegedYou tried to edit fields that require you to be privileged, or tried to edit bot you do not own.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated user.
- Return type:
- await fetch(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve user’s information.
You must have
accessto 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
MissingUserPermissionYou do not have the proper permissions to view access user data.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user.
- Return type:
- 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 fetch_default_avatar(*, http_overrides=None)[source]¶
This function is a coroutine.
Return a default user avatar based on the given ID.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The image in PNG format.
- Return type:
- await fetch_flags(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves flags for user.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The retrieved flags.
- Return type:
- await fetch_profile(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve profile of an user.
You must have
view_profileto 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
MissingUserPermissionYou do not have the proper permissions to view user profile.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user profile.
- Return type:
- await mutual_friend_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friend user IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual friend user IDs.
- Return type:
List[
str]
- await mutual_server_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual server IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual server IDs.
- Return type:
List[
str]
- await mutuals(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friends and servers with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutuals.
- Return type:
- await open_dm(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve a DM (or create if it doesn’t exist) with another user.
If target is current user, a
SavedMessagesChannelis always returned.You must have
send_messagesto do this.May fire
PrivateChannelCreateEventfor the current user and user you opened DM with.- 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 user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to open DM with this user.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The private channel.
- Return type:
Union[
SavedMessagesChannel,DMChannel]
- await remove_friend(*, http_overrides=None)[source]¶
This function is a coroutine.
Removes the user from friend list.
Fires
UserRelationshipUpdateEventfor the current user and user you removed from friend list.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you removed from friend list.
- Return type:
- await report(reason, *, http_overrides=None, additional_context=None, message_context=None)[source]¶
This function is a coroutine.
Report the user to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Note
This can only be used by non-bot accounts.
- Parameters:
reason (
UserReportReason) – The reason for reporting user.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.message_context (Optional[ULIDOr[
BaseMessage]]) –The message context.
Internally, 15 messages around provided message will be snapshotted for context. All attachments of provided message are snapshotted as well.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report yourself.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await unblock(*, http_overrides=None)[source]¶
This function is a coroutine.
Unblocks an user.
Fires
UserRelationshipUpdateEventfor the current user and unblocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you didn’t had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during unblocking user.
- Returns:
The unblocked user.
- Return type:
DisplayUser¶
- async accept_friend_request
- async acknowledge
- async begin_typing
- async block
- async connect
- async deny_friend_request
- async edit
- async end_typing
- async fetch
- async fetch_channel_id
- async fetch_default_avatar
- async fetch_flags
- async fetch_message
- async fetch_profile
- def get_channel_id
- def get_message
- async history
- def is_sentinel
- async join_call
- async mutual_friend_ids
- async mutual_server_ids
- async mutuals
- async open_dm
- async remove_friend
- async report
- async search
- async send
- async send_friend_request
- def typing
- async unblock
- class stoat.DisplayUser(*, state, id, name, discriminator, internal_avatar)[source]¶
Represents an user on Stoat that can be easily displayed in UI.
This inherits from
BaseUser.- internal_avatar¶
The stateless avatar of the user.
- Type:
Optional[
StatelessAsset]
- property display_avatar_url[source]¶
The URL to user’s avatar, or their default avatar if they have none set.
- Type:
- property tag[source]¶
The tag of the user.
Assuming that
User.nameis'kotlin.Unit'andUser.discriminatoris'3510', example output would be'kotlin.Unit#3510'.- Type:
- await send_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Sends a friend request to this user.
Fires
UserRelationshipUpdateEventfor the current user and user you sent friend request to.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
InvalidPropertyYou did not provide a discriminator.
IsBotEither the current user or user you tried to accept friend request from are bot accounts.
TooManyPendingFriendRequestsYou sent too many outgoing friend requests.
NoEffect– You tried to accept friend request from yourself.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BlockedOtherThe user you tried to send friend request to have blocked you.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyFriendsYou’re already friends with user you tried to send friend request to.
AlreadySentRequestYou already sent friend request to this user.
BlockedYou have blocked the user you tried to send friend request to.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you sent friend request to.
- Return type:
- await accept_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Accept another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you accepted friend request from.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
IsBotEither the current user or user you tried to accept friend request from are bot accounts.
TooManyPendingFriendRequestsYou sent too many outgoing friend requests.
NoEffect– You tried to accept friend request from yourself.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BlockedOtherThe user you tried to accept friend request from have blocked you.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyFriendsYou’re already friends with user you tried to accept friend request from.
AlreadySentRequestYou already sent friend request to this user.
BlockedYou have blocked the user you tried to accept friend request from.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you accepted friend request from.
- Return type:
- 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 begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- await block(*, http_overrides=None)[source]¶
This function is a coroutine.
Blocks an user.
Fires
UserRelationshipUpdateEventfor the current user and blocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you already had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The blocked user.
- 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.
- await deny_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Denies another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you denide friend request from.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you denied friend request from.
- Return type:
- await edit(*, http_overrides=None, display_name=UNDEFINED, avatar=UNDEFINED, status=UNDEFINED, profile=UNDEFINED, badges=UNDEFINED, flags=UNDEFINED)[source]¶
This function is a coroutine.
Edits the user.
Fires
UserUpdateEventfor all users who are subscribed to target user.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.display_name (UndefinedOr[Optional[
str]]) – The new display name. Must be between 2 and 32 characters and not contain zero width space, newline or carriage return characters.avatar (UndefinedOr[Optional[
ResolvableResource]]) – The new avatar. Could beNoneto remove avatar.status (UndefinedOr[
UserStatusEdit]) – The new user status.profile (UndefinedOr[
UserProfileEdit]) – The new user profile data. This is applied as a partial.badges (UndefinedOr[
UserBadges]) – The new user badges. You must be privileged user to provide this.flags (UndefinedOr[
UserFlags]) – The new user flags. You must be privileged user to provide this.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotPrivilegedYou tried to edit fields that require you to be privileged, or tried to edit bot you do not own.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated user.
- Return type:
- await fetch(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve user’s information.
You must have
accessto 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
MissingUserPermissionYou do not have the proper permissions to view access user data.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user.
- Return type:
- 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 fetch_default_avatar(*, http_overrides=None)[source]¶
This function is a coroutine.
Return a default user avatar based on the given ID.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The image in PNG format.
- Return type:
- await fetch_flags(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves flags for user.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The retrieved flags.
- Return type:
- 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 fetch_profile(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve profile of an user.
You must have
view_profileto 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
MissingUserPermissionYou do not have the proper permissions to view user profile.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user profile.
- 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 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 mutual_friend_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friend user IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual friend user IDs.
- Return type:
List[
str]
- await mutual_server_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual server IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual server IDs.
- Return type:
List[
str]
- await mutuals(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friends and servers with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutuals.
- Return type:
- await open_dm(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve a DM (or create if it doesn’t exist) with another user.
If target is current user, a
SavedMessagesChannelis always returned.You must have
send_messagesto do this.May fire
PrivateChannelCreateEventfor the current user and user you opened DM with.- 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 user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to open DM with this user.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The private channel.
- Return type:
Union[
SavedMessagesChannel,DMChannel]
- await remove_friend(*, http_overrides=None)[source]¶
This function is a coroutine.
Removes the user from friend list.
Fires
UserRelationshipUpdateEventfor the current user and user you removed from friend list.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you removed from friend list.
- Return type:
- await report(reason, *, http_overrides=None, additional_context=None, message_context=None)[source]¶
This function is a coroutine.
Report the user to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Note
This can only be used by non-bot accounts.
- Parameters:
reason (
UserReportReason) – The reason for reporting user.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.message_context (Optional[ULIDOr[
BaseMessage]]) –The message context.
Internally, 15 messages around provided message will be snapshotted for context. All attachments of provided message are snapshotted as well.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report yourself.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- 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:
- 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 unblock(*, http_overrides=None)[source]¶
This function is a coroutine.
Unblocks an user.
Fires
UserRelationshipUpdateEventfor the current user and unblocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you didn’t had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during unblocking user.
- Returns:
The unblocked user.
- Return type:
BotUserMetadata¶
PartialUser¶
- async accept_friend_request
- async acknowledge
- async begin_typing
- async block
- async connect
- async deny_friend_request
- async edit
- async end_typing
- async fetch
- async fetch_channel_id
- async fetch_default_avatar
- async fetch_flags
- async fetch_message
- async fetch_profile
- def get_channel_id
- def get_message
- async history
- def is_sentinel
- async join_call
- async mutual_friend_ids
- async mutual_server_ids
- async mutuals
- async open_dm
- async remove_friend
- async report
- async search
- async send
- def typing
- async unblock
- class stoat.PartialUser(*, state, id, name, discriminator, display_name, internal_avatar, raw_badges, status, raw_flags, bot, online)[source]¶
Represents a partial user on Stoat.
This inherits from
BaseUser.- internal_avatar¶
The new user’s stateless avatar.
- Type:
UndefinedOr[Optional[
StatelessAsset]]
- status¶
The new user’s status.
- Type:
UndefinedOr[
UserStatusEdit]
- bot¶
The information about the bot.
- Type:
UndefinedOr[
BotUserMetadata]
- property badges[source]¶
The new user’s badges.
- Type:
UndefinedOr[
UserBadges]
- await accept_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Accept another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you accepted friend request from.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
IsBotEither the current user or user you tried to accept friend request from are bot accounts.
TooManyPendingFriendRequestsYou sent too many outgoing friend requests.
NoEffect– You tried to accept friend request from yourself.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BlockedOtherThe user you tried to accept friend request from have blocked you.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyFriendsYou’re already friends with user you tried to accept friend request from.
AlreadySentRequestYou already sent friend request to this user.
BlockedYou have blocked the user you tried to accept friend request from.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you accepted friend request from.
- Return type:
- 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 begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- await block(*, http_overrides=None)[source]¶
This function is a coroutine.
Blocks an user.
Fires
UserRelationshipUpdateEventfor the current user and blocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you already had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The blocked user.
- 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.
- await deny_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Denies another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you denide friend request from.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you denied friend request from.
- Return type:
- await edit(*, http_overrides=None, display_name=UNDEFINED, avatar=UNDEFINED, status=UNDEFINED, profile=UNDEFINED, badges=UNDEFINED, flags=UNDEFINED)[source]¶
This function is a coroutine.
Edits the user.
Fires
UserUpdateEventfor all users who are subscribed to target user.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.display_name (UndefinedOr[Optional[
str]]) – The new display name. Must be between 2 and 32 characters and not contain zero width space, newline or carriage return characters.avatar (UndefinedOr[Optional[
ResolvableResource]]) – The new avatar. Could beNoneto remove avatar.status (UndefinedOr[
UserStatusEdit]) – The new user status.profile (UndefinedOr[
UserProfileEdit]) – The new user profile data. This is applied as a partial.badges (UndefinedOr[
UserBadges]) – The new user badges. You must be privileged user to provide this.flags (UndefinedOr[
UserFlags]) – The new user flags. You must be privileged user to provide this.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotPrivilegedYou tried to edit fields that require you to be privileged, or tried to edit bot you do not own.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated user.
- Return type:
- await fetch(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve user’s information.
You must have
accessto 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
MissingUserPermissionYou do not have the proper permissions to view access user data.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user.
- Return type:
- 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 fetch_default_avatar(*, http_overrides=None)[source]¶
This function is a coroutine.
Return a default user avatar based on the given ID.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The image in PNG format.
- Return type:
- await fetch_flags(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves flags for user.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The retrieved flags.
- Return type:
- 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 fetch_profile(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve profile of an user.
You must have
view_profileto 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
MissingUserPermissionYou do not have the proper permissions to view user profile.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user profile.
- 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 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 mutual_friend_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friend user IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual friend user IDs.
- Return type:
List[
str]
- await mutual_server_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual server IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual server IDs.
- Return type:
List[
str]
- await mutuals(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friends and servers with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutuals.
- Return type:
- await open_dm(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve a DM (or create if it doesn’t exist) with another user.
If target is current user, a
SavedMessagesChannelis always returned.You must have
send_messagesto do this.May fire
PrivateChannelCreateEventfor the current user and user you opened DM with.- 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 user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to open DM with this user.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The private channel.
- Return type:
Union[
SavedMessagesChannel,DMChannel]
- await remove_friend(*, http_overrides=None)[source]¶
This function is a coroutine.
Removes the user from friend list.
Fires
UserRelationshipUpdateEventfor the current user and user you removed from friend list.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you removed from friend list.
- Return type:
- await report(reason, *, http_overrides=None, additional_context=None, message_context=None)[source]¶
This function is a coroutine.
Report the user to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Note
This can only be used by non-bot accounts.
- Parameters:
reason (
UserReportReason) – The reason for reporting user.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.message_context (Optional[ULIDOr[
BaseMessage]]) –The message context.
Internally, 15 messages around provided message will be snapshotted for context. All attachments of provided message are snapshotted as well.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report yourself.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- 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:
- 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 unblock(*, http_overrides=None)[source]¶
This function is a coroutine.
Unblocks an user.
Fires
UserRelationshipUpdateEventfor the current user and unblocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you didn’t had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during unblocking user.
- Returns:
The unblocked user.
- Return type:
User¶
- async accept_friend_request
- async acknowledge
- async begin_typing
- async block
- async connect
- async deny_friend_request
- async edit
- async end_typing
- async fetch
- async fetch_channel_id
- async fetch_default_avatar
- async fetch_flags
- async fetch_message
- async fetch_profile
- def get_bot_owner
- def get_channel_id
- def get_message
- async history
- def is_active_supporter
- def is_banned
- def is_deleted
- def is_developer
- def is_early_adopter
- def is_founder
- def is_paw
- def is_platform_moderator
- def is_relevant_joke_1
- def is_relevant_joke_2
- def is_responsible_disclosure
- def is_sentinel
- def is_spammer
- def is_supporter
- def is_suspended
- def is_translator
- async join_call
- def locally_update
- async mutual_friend_ids
- async mutual_server_ids
- async mutuals
- async open_dm
- async remove_friend
- async report
- async search
- async send
- async send_friend_request
- def to_dict
- def typing
- async unblock
- class stoat.User(*, state, id, name, discriminator, internal_avatar, display_name, raw_badges, status, raw_flags, privileged, bot, relationship, online)[source]¶
Represents an user on Stoat.
This inherits from
DisplayUser.- status¶
The current user’s status.
- Type:
Optional[
UserStatus]
- bot¶
The information about the bot.
- Type:
Optional[
BotUserMetadata]
- relationship¶
The current user’s relationship with this user.
- Type:
- locally_update(data, /)[source]¶
Locally updates user with provided data.
Warning
This is called by library internally to keep cache up to date.
- await accept_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Accept another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you accepted friend request from.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
IsBotEither the current user or user you tried to accept friend request from are bot accounts.
TooManyPendingFriendRequestsYou sent too many outgoing friend requests.
NoEffect– You tried to accept friend request from yourself.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BlockedOtherThe user you tried to accept friend request from have blocked you.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyFriendsYou’re already friends with user you tried to accept friend request from.
AlreadySentRequestYou already sent friend request to this user.
BlockedYou have blocked the user you tried to accept friend request from.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you accepted friend request from.
- Return type:
- 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 begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- await block(*, http_overrides=None)[source]¶
This function is a coroutine.
Blocks an user.
Fires
UserRelationshipUpdateEventfor the current user and blocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you already had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The blocked user.
- 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.
- await deny_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Denies another user’s friend request.
Fires
UserRelationshipUpdateEventfor the current user and user you denide friend request from.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you denied friend request from.
- Return type:
- property display_avatar_url[source]¶
The URL to user’s avatar, or their default avatar if they have none set.
- Type:
- await edit(*, http_overrides=None, display_name=UNDEFINED, avatar=UNDEFINED, status=UNDEFINED, profile=UNDEFINED, badges=UNDEFINED, flags=UNDEFINED)[source]¶
This function is a coroutine.
Edits the user.
Fires
UserUpdateEventfor all users who are subscribed to target user.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.display_name (UndefinedOr[Optional[
str]]) – The new display name. Must be between 2 and 32 characters and not contain zero width space, newline or carriage return characters.avatar (UndefinedOr[Optional[
ResolvableResource]]) – The new avatar. Could beNoneto remove avatar.status (UndefinedOr[
UserStatusEdit]) – The new user status.profile (UndefinedOr[
UserProfileEdit]) – The new user profile data. This is applied as a partial.badges (UndefinedOr[
UserBadges]) – The new user badges. You must be privileged user to provide this.flags (UndefinedOr[
UserFlags]) – The new user flags. You must be privileged user to provide this.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotPrivilegedYou tried to edit fields that require you to be privileged, or tried to edit bot you do not own.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated user.
- Return type:
- await fetch(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve user’s information.
You must have
accessto 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
MissingUserPermissionYou do not have the proper permissions to view access user data.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user.
- Return type:
- 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 fetch_default_avatar(*, http_overrides=None)[source]¶
This function is a coroutine.
Return a default user avatar based on the given ID.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The image in PNG format.
- Return type:
- await fetch_flags(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves flags for user.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The retrieved flags.
- Return type:
- 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 fetch_profile(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve profile of an user.
You must have
view_profileto 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
MissingUserPermissionYou do not have the proper permissions to view user profile.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user profile.
- 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]
- internal_avatar¶
The stateless avatar of the user.
- Type:
Optional[
StatelessAsset]
- 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 mutual_friend_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friend user IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual friend user IDs.
- Return type:
List[
str]
- await mutual_server_ids(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual server IDs with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutual server IDs.
- Return type:
List[
str]
- await mutuals(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a list of mutual friends and servers with another user.
You must have
view_profileto do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationYou tried to retrieve mutuals with yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to view user profile.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The found mutuals.
- Return type:
- await open_dm(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve a DM (or create if it doesn’t exist) with another user.
If target is current user, a
SavedMessagesChannelis always returned.You must have
send_messagesto do this.May fire
PrivateChannelCreateEventfor the current user and user you opened DM with.- 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 user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to open DM with this user.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The private channel.
- Return type:
Union[
SavedMessagesChannel,DMChannel]
- await remove_friend(*, http_overrides=None)[source]¶
This function is a coroutine.
Removes the user from friend list.
Fires
UserRelationshipUpdateEventfor the current user and user you removed from friend list.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
IsBotEither the current user or user you tried to deny friend request from are bot accounts.
NoEffect– You tried to deny friend request from user you had no friend request sent from/to.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you removed from friend list.
- Return type:
- await report(reason, *, http_overrides=None, additional_context=None, message_context=None)[source]¶
This function is a coroutine.
Report the user to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Note
This can only be used by non-bot accounts.
- Parameters:
reason (
UserReportReason) – The reason for reporting user.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.message_context (Optional[ULIDOr[
BaseMessage]]) –The message context.
Internally, 15 messages around provided message will be snapshotted for context. All attachments of provided message are snapshotted as well.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report yourself.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- 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:
- await send_friend_request(*, http_overrides=None)[source]¶
This function is a coroutine.
Sends a friend request to this user.
Fires
UserRelationshipUpdateEventfor the current user and user you sent friend request to.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
InvalidPropertyYou did not provide a discriminator.
IsBotEither the current user or user you tried to accept friend request from are bot accounts.
TooManyPendingFriendRequestsYou sent too many outgoing friend requests.
NoEffect– You tried to accept friend request from yourself.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
BlockedOtherThe user you tried to send friend request to have blocked you.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyFriendsYou’re already friends with user you tried to send friend request to.
AlreadySentRequestYou already sent friend request to this user.
BlockedYou have blocked the user you tried to send friend request to.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The user you sent friend request to.
- Return type:
- property tag[source]¶
The tag of the user.
Assuming that
User.nameis'kotlin.Unit'andUser.discriminatoris'3510', example output would be'kotlin.Unit#3510'.- Type:
- 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 unblock(*, http_overrides=None)[source]¶
This function is a coroutine.
Unblocks an user.
Fires
UserRelationshipUpdateEventfor the current user and unblocked user.Note
This is not supposed to be used by bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
NoEffect– You tried to block yourself or someone that you didn’t had blocked.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during unblocking user.
- Returns:
The unblocked user.
- Return type:
- is_responsible_disclosure()[source]¶
bool: Whether this user responsibly disclosed a security issue.
- is_early_adopter()[source]¶
bool: Whether this user have joined Stoat as one of the first 1000 users in 2021.
- is_relevant_joke_1()[source]¶
bool: Whether this user have given funny joke (Called “sus”, displayed as Amogus in Revite).
OwnUser¶
- async acknowledge
- async begin_typing
- async connect
- async edit
- async end_typing
- async fetch
- async fetch_channel_id
- async fetch_default_avatar
- async fetch_flags
- async fetch_message
- async fetch_profile
- def get_bot_owner
- def get_channel_id
- def get_message
- async history
- def is_active_supporter
- def is_banned
- def is_deleted
- def is_developer
- def is_early_adopter
- def is_founder
- def is_paw
- def is_platform_moderator
- def is_relevant_joke_1
- def is_relevant_joke_2
- def is_responsible_disclosure
- def is_sentinel
- def is_spammer
- def is_supporter
- def is_suspended
- def is_translator
- async join_call
- def locally_update
- async open_dm
- async search
- async send
- def to_dict
- def typing
- class stoat.OwnUser(*, state, id, name, discriminator, internal_avatar, display_name, raw_badges, status, raw_flags, privileged, bot, relationship, online, relations)[source]¶
Represents a current user on Stoat.
This inherits from
User.- 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 begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- bot¶
The information about the bot.
- Type:
Optional[
BotUserMetadata]
- 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.
- property display_avatar_url[source]¶
The URL to user’s avatar, or their default avatar if they have none set.
- Type:
- await fetch(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve user’s information.
You must have
accessto 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
MissingUserPermissionYou do not have the proper permissions to view access user data.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user.
- Return type:
- 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 fetch_default_avatar(*, http_overrides=None)[source]¶
This function is a coroutine.
Return a default user avatar based on the given ID.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The image in PNG format.
- Return type:
- await fetch_flags(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves flags for user.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Returns:
The retrieved flags.
- Return type:
- 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 fetch_profile(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve profile of an user.
You must have
view_profileto 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
MissingUserPermissionYou do not have the proper permissions to view user profile.
NotFound– Possible values fortype:Value
Reason
NotFoundThe user was not found.
- Returns:
The retrieved user profile.
- 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]
- internal_avatar¶
The stateless avatar of the user.
- Type:
Optional[
StatelessAsset]
- is_early_adopter()[source]¶
bool: Whether this user have joined Stoat as one of the first 1000 users in 2021.
- is_relevant_joke_1()[source]¶
bool: Whether this user have given funny joke (Called “sus”, displayed as Amogus in Revite).
- is_relevant_joke_2()[source]¶
bool: Whether this user have given other funny joke (Called as “It’s Morbin Time” in Revite).
- is_responsible_disclosure()[source]¶
bool: Whether this user responsibly disclosed a security issue.
- 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:
- locally_update(data, /)[source]¶
Locally updates user with provided data.
Warning
This is called by library internally to keep cache up to date.
- await open_dm(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieve a DM (or create if it doesn’t exist) with another user.
If target is current user, a
SavedMessagesChannelis always returned.You must have
send_messagesto do this.May fire
PrivateChannelCreateEventfor the current user and user you opened DM with.- 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 user was not found.
Forbidden– Possible values fortype:Value
Reason
MissingUserPermissionYou do not have the proper permissions to open DM with this user.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The private channel.
- Return type:
Union[
SavedMessagesChannel,DMChannel]
- relationship¶
The current user’s relationship with this user.
- Type:
- 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:
- status¶
The current user’s status.
- Type:
Optional[
UserStatus]
- property tag[source]¶
The tag of the user.
Assuming that
User.nameis'kotlin.Unit'andUser.discriminatoris'3510', example output would be'kotlin.Unit#3510'.- Type:
- typing()[source]¶
Returns an asynchronous context manager that allows you to send a typing indicator in destination channel for an indefinite period of time.
- relations¶
The dictionary of relationships with other users.
- Type:
Dict[
str,Relationship]
- await edit(*, http_overrides=None, display_name=UNDEFINED, avatar=UNDEFINED, status=UNDEFINED, profile=UNDEFINED, badges=UNDEFINED, flags=UNDEFINED)[source]¶
This function is a coroutine.
Edits the current user.
Fires
UserUpdateEventfor all users who are subscribed to you.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.display_name (UndefinedOr[Optional[
str]]) – The new display name. Must be between 2 and 32 characters and not contain zero width space, newline or carriage return characters.avatar (UndefinedOr[Optional[
ResolvableResource]]) – The new avatar. Could beNoneto remove avatar.status (UndefinedOr[
UserStatusEdit]) – The new user status.profile (UndefinedOr[
UserProfileEdit]) – The new user profile data. This is applied as a partial.badges (UndefinedOr[
UserBadges]) – The new user badges. You must be privileged user to provide this.flags (UndefinedOr[
UserFlags]) – The new user flags. You must be privileged user to provide this.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotPrivilegedYou tried to edit fields that require you to be privileged.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated authenticated user.
- Return type:
UserVoiceState¶
- def locally_update