Server Members¶
The following section documents everything related to server members.
Models¶
BaseMember¶
- async acknowledge
- async ban
- async begin_typing
- async connect
- async edit
- async end_typing
- def eq
- 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
- def get_server
- def get_user
- async history
- def is_sentinel
- async join_call
- async kick
- async mutual_friend_ids
- async mutual_server_ids
- async mutuals
- def ne
- async open_dm
- async remove_friend
- async report
- async search
- async send
- async timeout
- def typing
- async unblock
- class stoat.BaseMember(*, state, server_id, internal_user)[source]¶
Represents a Stoat base member to a
Server.This inherits from
ConnectableandMessageable.- property internal_avatar[source]¶
The stateless avatar of the member user.
- Type:
Optional[
StatelessAsset]
- property status[source]¶
The current member user’s status.
- Type:
Optional[
UserStatus]
- 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 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 fetch_message(message, /, *, channel_http_overrides=None, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves a message.
- Parameters:
message (ULIDOr[
BaseMessage]) – The message to retrieve.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:
- Returns:
The retrieved message.
- Return type:
- await history(*, channel_http_overrides=None, http_overrides=None, limit=None, before=None, after=None, sort=None, nearby=None, populate_users=None)[source]¶
This function is a coroutine.
Retrieve message history from destination channel.
You must have
read_message_historyto do this.- Parameters:
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.limit (Optional[
int]) –The maximum number of messages to get. Must be between 1 and 100. Defaults to 50.
If
nearbyis provided, then this is(limit + 2).before (Optional[ULIDOr[
BaseMessage]]) – The message before which messages should be fetched.after (Optional[ULIDOr[
BaseMessage]]) – The message after which messages should be fetched.sort (Optional[
MessageSort]) – The message sort direction. Defaults tolatestnearby (Optional[ULIDOr[
BaseMessage]]) –The message to search around.
Providing this parameter will discard
before,afterandsortparameters.It will also take half of limit rounded as the limits to each side. It also fetches the message specified.
populate_users (
bool) – Whether to populate user (and member, if server channel) objects.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to read the message history.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The messages retrieved.
- Return type:
List[
Message]
- await 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 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.
- property bot[source]¶
The information about the bot.
- Type:
Optional[
BotUserMetadata]
- property tag[source]¶
The tag of the member user.
Assuming that
Member.nameis'kotlin.Unit'andMmeber.discriminatoris'3510', example output would be'kotlin.Unit#3510'.- Type:
- await ban(*, http_overrides=None, reason=None)[source]¶
This function is a coroutine.
Bans an user from the server.
You must have
ban_membersto do this.May fire
ServerMemberRemoveEventfor banned user and all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.reason (Optional[
str]) – The ban reason. Can be only up to 1024 characters long.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to ban yourself.
FailedValidationThe payload was invalid.
InvalidOperationYou tried to ban server owner.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created ban.
- Return type:
- await 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 edit(*, http_overrides=None, nick=UNDEFINED, avatar=UNDEFINED, roles=UNDEFINED, timeout=UNDEFINED, can_publish=UNDEFINED, can_receive=UNDEFINED, voice=UNDEFINED)[source]¶
This function is a coroutine.
Edits the member.
Fires
ServerMemberUpdateEventfor all server members, and optionally fires multiple/singleServerChannelCreateEvent/ChannelDeleteEventevents for target member ifrolesparameter is provided.For Livekit instances:
If
voiceparameter is provided, firesVoiceChannelMoveEvent/VoiceChannelLeaveEventif specified asNone, otherwiseVoiceChannelLeaveEventis fired. The specified events are fired for all users who can see voice channel the member is currently in.If any of
roles,can_publishorcan_receiveparameters is provided, may fireUserVoiceStateUpdateEventfor all users who can see voice channel the member is currently in.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nick (UndefinedOr[Optional[
str]]) –The member’s new nick. Use
Noneto remove the nickname.To provide this, you must have
manage_nicknamesif changing other member’s nick. Otherwise,change_nicknameis required instead.avatar (UndefinedOr[Optional[
ResolvableResource]]) –The member’s new avatar. Use
Noneto remove the avatar.You can only change your own server avatar.
You must have
change_avatarto provide this.roles (UndefinedOr[Optional[List[ULIDOr[
BaseRole]]]]) –The member’s new list of roles. This replaces the roles.
You must have
assign_rolesto provide this.timeout (UndefinedOr[Optional[Union[
datetime,timedelta,float,int]]]) –The duration/date the member’s timeout should expire, or
Noneto remove the timeout.This must be a timezone-aware datetime object. Consider using
stoat.utils.utcnow().If the member has
timeout_members, this will throw aNonElevatederror.You must have
timeout_membersto provide this.can_publish (UndefinedOr[Optional[
bool]]) –Whether the member should send voice data.
You must have
mute_membersto provide this.can_receive (UndefinedOr[Optional[
bool]]) –Whether the member should receive voice data.
You must have
deafen_membersto provide this.voice (UndefinedOr[Optional[ULIDOr[Union[
TextChannel,VoiceChannel]]]]) –The voice channel to move the member to.
You must have
move_membersto provide this.Changed in version 1.3: Members can be kicked from the current voice channel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotTimeoutYourselfYou tried to time out yourself.
LivekitUnavailableThe voice server is unavailable. Only applicable to instances using Livekit.
NotAVoiceChannelThe channel passed in
voiceparameter was not voice-like channel. Only applicable to instances using Livekit.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
IsElevatedThe member has
timeout_members, and as such cannot be timed out.MissingPermissionYou do not have the proper permissions to edit this member.
NotElevatedRanking of one of roles you tried to add is lower than ranking of your top role.
NotFound– Possible values fortype:Value
Reason
InvalidRoleOne of provided roles passed in
rolesparameter was not found.NotFoundThe server/member was not found.
UnknownChannelThe channel passed in
voiceparameter was not found.InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during editing member.
- Returns:
The newly updated member.
- Return type:
- await kick(*, http_overrides=None)[source]¶
This function is a coroutine.
Kicks the member from the server.
Fires
ServerMemberRemoveEventfor kicked user and all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to kick yourself.
InvalidOperationYou tried to kick server owner.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await 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 timeout(length, *, http_overrides=None)[source]¶
This function is a coroutine.
Timeouts the member.
If the member has
timeout_members, this will throw aNonElevatederror.You must have
timeout_membersto do this.Fires
ServerMemberUpdateEventfor all server members.- Parameters:
length (UndefinedOr[Optional[Union[
datetime,timedelta,float,int]]]) –The duration/date the member’s timeout should expire, or
Noneto remove the timeout.This must be a timezone-aware datetime object. Consider using
stoat.utils.utcnow().http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotTimeoutYourselfYou tried to time out yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
IsElevatedThe member has
timeout_members, and as such cannot be timed out.MissingPermissionYou do not have the proper permissions to edit this member.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/member was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during editing member.
- Returns:
The newly updated member.
- Return type:
- 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:
PartialMember¶
- avatar
- badges
- bot
- bot_owner
- can_publish
- can_receive
- default_avatar_url
- discriminator
- display_name
- dm_channel
- dm_channel_id
- flags
- id
- internal_avatar
- internal_server_avatar
- internal_user
- mention
- messages
- name
- nick
- online
- pm
- pm_id
- privileged
- raw_badges
- raw_flags
- relationship
- role_ids
- server_avatar
- server_id
- state
- status
- tag
- timed_out_until
- user
- async acknowledge
- async ban
- async begin_typing
- async connect
- async edit
- async end_typing
- def eq
- 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
- def get_server
- def get_user
- async history
- def is_sentinel
- async join_call
- async kick
- async mutual_friend_ids
- async mutual_server_ids
- async mutuals
- def ne
- async open_dm
- async remove_friend
- async report
- async search
- async send
- async timeout
- def typing
- async unblock
- class stoat.PartialMember(*, state, server_id, internal_user, nick, internal_server_avatar, role_ids, timed_out_until, can_publish, can_receive)[source]¶
Represents a partial Stoat member to a
Server.Unmodified fields will have
UNDEFINEDvalue.This inherits from
BaseMember.- 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 ban(*, http_overrides=None, reason=None)[source]¶
This function is a coroutine.
Bans an user from the server.
You must have
ban_membersto do this.May fire
ServerMemberRemoveEventfor banned user and all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.reason (Optional[
str]) – The ban reason. Can be only up to 1024 characters long.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to ban yourself.
FailedValidationThe payload was invalid.
InvalidOperationYou tried to ban server owner.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created ban.
- Return type:
- await begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- property bot[source]¶
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.
- await edit(*, http_overrides=None, nick=UNDEFINED, avatar=UNDEFINED, roles=UNDEFINED, timeout=UNDEFINED, can_publish=UNDEFINED, can_receive=UNDEFINED, voice=UNDEFINED)[source]¶
This function is a coroutine.
Edits the member.
Fires
ServerMemberUpdateEventfor all server members, and optionally fires multiple/singleServerChannelCreateEvent/ChannelDeleteEventevents for target member ifrolesparameter is provided.For Livekit instances:
If
voiceparameter is provided, firesVoiceChannelMoveEvent/VoiceChannelLeaveEventif specified asNone, otherwiseVoiceChannelLeaveEventis fired. The specified events are fired for all users who can see voice channel the member is currently in.If any of
roles,can_publishorcan_receiveparameters is provided, may fireUserVoiceStateUpdateEventfor all users who can see voice channel the member is currently in.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nick (UndefinedOr[Optional[
str]]) –The member’s new nick. Use
Noneto remove the nickname.To provide this, you must have
manage_nicknamesif changing other member’s nick. Otherwise,change_nicknameis required instead.avatar (UndefinedOr[Optional[
ResolvableResource]]) –The member’s new avatar. Use
Noneto remove the avatar.You can only change your own server avatar.
You must have
change_avatarto provide this.roles (UndefinedOr[Optional[List[ULIDOr[
BaseRole]]]]) –The member’s new list of roles. This replaces the roles.
You must have
assign_rolesto provide this.timeout (UndefinedOr[Optional[Union[
datetime,timedelta,float,int]]]) –The duration/date the member’s timeout should expire, or
Noneto remove the timeout.This must be a timezone-aware datetime object. Consider using
stoat.utils.utcnow().If the member has
timeout_members, this will throw aNonElevatederror.You must have
timeout_membersto provide this.can_publish (UndefinedOr[Optional[
bool]]) –Whether the member should send voice data.
You must have
mute_membersto provide this.can_receive (UndefinedOr[Optional[
bool]]) –Whether the member should receive voice data.
You must have
deafen_membersto provide this.voice (UndefinedOr[Optional[ULIDOr[Union[
TextChannel,VoiceChannel]]]]) –The voice channel to move the member to.
You must have
move_membersto provide this.Changed in version 1.3: Members can be kicked from the current voice channel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotTimeoutYourselfYou tried to time out yourself.
LivekitUnavailableThe voice server is unavailable. Only applicable to instances using Livekit.
NotAVoiceChannelThe channel passed in
voiceparameter was not voice-like channel. Only applicable to instances using Livekit.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
IsElevatedThe member has
timeout_members, and as such cannot be timed out.MissingPermissionYou do not have the proper permissions to edit this member.
NotElevatedRanking of one of roles you tried to add is lower than ranking of your top role.
NotFound– Possible values fortype:Value
Reason
InvalidRoleOne of provided roles passed in
rolesparameter was not found.NotFoundThe server/member was not found.
UnknownChannelThe channel passed in
voiceparameter was not found.InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during editing member.
- Returns:
The newly updated member.
- 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]
- property internal_avatar[source]¶
The stateless avatar of the member 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 kick(*, http_overrides=None)[source]¶
This function is a coroutine.
Kicks the member from the server.
Fires
ServerMemberRemoveEventfor kicked user and all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to kick yourself.
InvalidOperationYou tried to kick server owner.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await 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:
- property status[source]¶
The current member user’s status.
- Type:
Optional[
UserStatus]
- property tag[source]¶
The tag of the member user.
Assuming that
Member.nameis'kotlin.Unit'andMmeber.discriminatoris'3510', example output would be'kotlin.Unit#3510'.- Type:
- await timeout(length, *, http_overrides=None)[source]¶
This function is a coroutine.
Timeouts the member.
If the member has
timeout_members, this will throw aNonElevatederror.You must have
timeout_membersto do this.Fires
ServerMemberUpdateEventfor all server members.- Parameters:
length (UndefinedOr[Optional[Union[
datetime,timedelta,float,int]]]) –The duration/date the member’s timeout should expire, or
Noneto remove the timeout.This must be a timezone-aware datetime object. Consider using
stoat.utils.utcnow().http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotTimeoutYourselfYou tried to time out yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
IsElevatedThe member has
timeout_members, and as such cannot be timed out.MissingPermissionYou do not have the proper permissions to edit this member.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/member was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during editing member.
- Returns:
The newly updated member.
- 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:
- internal_server_avatar¶
The new member’s avatar.
- Type:
UndefinedOr[Optional[
StatelessAsset]]
Member¶
- avatar
- badges
- bot
- bot_owner
- can_publish
- can_receive
- default_avatar_url
- discriminator
- display_name
- dm_channel
- dm_channel_id
- flags
- id
- internal_avatar
- internal_server_avatar
- internal_user
- joined_at
- mention
- messages
- name
- nick
- online
- pm
- pm_id
- privileged
- raw_badges
- raw_flags
- relationship
- role_ids
- roles
- server_avatar
- server_id
- server_permissions
- state
- status
- tag
- timed_out_until
- top_role
- user
- async acknowledge
- async ban
- async begin_typing
- async connect
- async edit
- async end_typing
- def eq
- 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
- def get_server
- def get_user
- async history
- def is_sentinel
- async join_call
- async kick
- def locally_update
- async mutual_friend_ids
- async mutual_server_ids
- async mutuals
- def ne
- async open_dm
- async remove_friend
- async report
- async search
- async send
- async timeout
- def to_dict
- def typing
- async unblock
- class stoat.Member(*, state, server_id, internal_user, joined_at, nick, internal_server_avatar, role_ids, timed_out_until, can_publish, can_receive)[source]¶
Represents a Stoat member to a
Server.This inherits from
BaseMember.- 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 ban(*, http_overrides=None, reason=None)[source]¶
This function is a coroutine.
Bans an user from the server.
You must have
ban_membersto do this.May fire
ServerMemberRemoveEventfor banned user and all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.reason (Optional[
str]) – The ban reason. Can be only up to 1024 characters long.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to ban yourself.
FailedValidationThe payload was invalid.
InvalidOperationYou tried to ban server owner.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created ban.
- Return type:
- await begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- property bot[source]¶
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.
- await edit(*, http_overrides=None, nick=UNDEFINED, avatar=UNDEFINED, roles=UNDEFINED, timeout=UNDEFINED, can_publish=UNDEFINED, can_receive=UNDEFINED, voice=UNDEFINED)[source]¶
This function is a coroutine.
Edits the member.
Fires
ServerMemberUpdateEventfor all server members, and optionally fires multiple/singleServerChannelCreateEvent/ChannelDeleteEventevents for target member ifrolesparameter is provided.For Livekit instances:
If
voiceparameter is provided, firesVoiceChannelMoveEvent/VoiceChannelLeaveEventif specified asNone, otherwiseVoiceChannelLeaveEventis fired. The specified events are fired for all users who can see voice channel the member is currently in.If any of
roles,can_publishorcan_receiveparameters is provided, may fireUserVoiceStateUpdateEventfor all users who can see voice channel the member is currently in.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nick (UndefinedOr[Optional[
str]]) –The member’s new nick. Use
Noneto remove the nickname.To provide this, you must have
manage_nicknamesif changing other member’s nick. Otherwise,change_nicknameis required instead.avatar (UndefinedOr[Optional[
ResolvableResource]]) –The member’s new avatar. Use
Noneto remove the avatar.You can only change your own server avatar.
You must have
change_avatarto provide this.roles (UndefinedOr[Optional[List[ULIDOr[
BaseRole]]]]) –The member’s new list of roles. This replaces the roles.
You must have
assign_rolesto provide this.timeout (UndefinedOr[Optional[Union[
datetime,timedelta,float,int]]]) –The duration/date the member’s timeout should expire, or
Noneto remove the timeout.This must be a timezone-aware datetime object. Consider using
stoat.utils.utcnow().If the member has
timeout_members, this will throw aNonElevatederror.You must have
timeout_membersto provide this.can_publish (UndefinedOr[Optional[
bool]]) –Whether the member should send voice data.
You must have
mute_membersto provide this.can_receive (UndefinedOr[Optional[
bool]]) –Whether the member should receive voice data.
You must have
deafen_membersto provide this.voice (UndefinedOr[Optional[ULIDOr[Union[
TextChannel,VoiceChannel]]]]) –The voice channel to move the member to.
You must have
move_membersto provide this.Changed in version 1.3: Members can be kicked from the current voice channel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotTimeoutYourselfYou tried to time out yourself.
LivekitUnavailableThe voice server is unavailable. Only applicable to instances using Livekit.
NotAVoiceChannelThe channel passed in
voiceparameter was not voice-like channel. Only applicable to instances using Livekit.Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
IsElevatedThe member has
timeout_members, and as such cannot be timed out.MissingPermissionYou do not have the proper permissions to edit this member.
NotElevatedRanking of one of roles you tried to add is lower than ranking of your top role.
NotFound– Possible values fortype:Value
Reason
InvalidRoleOne of provided roles passed in
rolesparameter was not found.NotFoundThe server/member was not found.
UnknownChannelThe channel passed in
voiceparameter was not found.InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during editing member.
- Returns:
The newly updated member.
- 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]
- property internal_avatar[source]¶
The stateless avatar of the member 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 kick(*, http_overrides=None)[source]¶
This function is a coroutine.
Kicks the member from the server.
Fires
ServerMemberRemoveEventfor kicked user and all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotRemoveYourselfYou tried to kick yourself.
InvalidOperationYou tried to kick server owner.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
NotElevatedRank of your top role is higher than rank of top role of user you’re trying to ban.
MissingPermissionYou do not have the proper permissions to ban members.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/user was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await 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:
- property status[source]¶
The current member user’s status.
- Type:
Optional[
UserStatus]
- property tag[source]¶
The tag of the member user.
Assuming that
Member.nameis'kotlin.Unit'andMmeber.discriminatoris'3510', example output would be'kotlin.Unit#3510'.- Type:
- await timeout(length, *, http_overrides=None)[source]¶
This function is a coroutine.
Timeouts the member.
If the member has
timeout_members, this will throw aNonElevatederror.You must have
timeout_membersto do this.Fires
ServerMemberUpdateEventfor all server members.- Parameters:
length (UndefinedOr[Optional[Union[
datetime,timedelta,float,int]]]) –The duration/date the member’s timeout should expire, or
Noneto remove the timeout.This must be a timezone-aware datetime object. Consider using
stoat.utils.utcnow().http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotTimeoutYourselfYou tried to time out yourself.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
IsElevatedThe member has
timeout_members, and as such cannot be timed out.MissingPermissionYou do not have the proper permissions to edit this member.
NotFound– Possible values fortype:Value
Reason
NotFoundThe server/member was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during editing member.
- Returns:
The newly updated member.
- 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:
- internal_server_avatar¶
The member’s avatar on server.
- Type:
Optional[
StatelessAsset]
- locally_update(data, /)[source]¶
Locally updates member with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialMember) – The data to update member with.