Channels¶
The following section documents everything related to channels.
Models¶
BaseChannel¶
- async close
- async edit
- def message
- def permissions_for
- class stoat.BaseChannel(*, state, id)[source]¶
Represents channel on Stoat.
This inherits from
Base.- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
- await close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- Return type:
PartialChannel¶
- async close
- async edit
- def message
- def permissions_for
- class stoat.PartialChannel(*, state, id, name, owner_id, description, internal_icon, nsfw, active, raw_permissions, role_permissions, default_permissions, last_message_id, category_id, voice)[source]¶
Represents a partial channel on Stoat.
This inherits from
BaseChannel.- name¶
The new channel name, if applicable. Only for
GroupChannelandBaseServerChannel’s.- Type:
UndefinedOr[
str]
- owner_id¶
The ID of new group owner, if applicable. Only for
GroupChannel.- Type:
UndefinedOr[
str]
- description¶
The new channel’s description, if applicable. Only for
GroupChannelandBaseServerChannel’s.- Type:
UndefinedOr[Optional[
str]]
- internal_icon¶
The new channel’s stateless icon, if applicable. Only for
GroupChannelandBaseServerChannel’s.- Type:
UndefinedOr[Optional[
StatelessAsset]]
- nsfw¶
Whether the channel have been marked as NSFW, if applicable. Only for
GroupChannelandBaseServerChannel’s.- Type:
UndefinedOr[
bool]
- active¶
Whether the DM channel is active now, if applicable. Only for
DMChannel’s.- Type:
UndefinedOr[
bool]
- raw_permissions¶
The new channel’s permissions raw value, if applicable. Only for
GroupChannel’s.- Type:
UndefinedOr[
int]
- role_permissions¶
The new channel’s permission overrides for roles, if applicable. Only for
BaseServerChannel’s.- Type:
UndefinedOr[Dict[
str,PermissionOverride]]
- default_permissions¶
The new channel’s permission overrides for everyone, if applicable. Only for
BaseServerChannel’s.- Type:
UndefinedOr[Optional[
PermissionOverride]]
- voice¶
The new voice-specific metadata for this channel.
Added in version 1.2.
- Type:
UndefinedOr[
ChannelVoiceMetadata]
- property icon[source]¶
The new channel’s icon, if applicable. Only for
GroupChannelandBaseServerChannel's.- Type:
UndefinedOr[Optional[
Asset]]
- property permissions[source]¶
The new channel’s permissions, if applicable. Only for
GroupChannel's.- Type:
UndefinedOr[
Permissions]
- await close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- Return type:
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
SavedMessagesChannel¶
- async acknowledge
- async begin_typing
- async close
- async edit
- async end_typing
- async fetch_channel_id
- async fetch_message
- def get_channel_id
- def get_me
- def get_message
- async history
- def locally_update
- def message
- def permissions_for
- async search
- async send
- def to_dict
- def typing
- class stoat.SavedMessagesChannel(*, state, id, user_id)[source]¶
Represents a personal “Saved Notes” channel which allows users to save messages.
This inherits from
BaseChannelandMessageable.- locally_update(data, /)[source]¶
Locally updates channel with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialChannel) – The data to update channel with.
- property type[source]¶
The channel’s type.
- Type:
Literal[
ChannelType.saved_messages]
- permissions_for(target, /)[source]¶
Calculate permissions for given member.
- 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 close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- 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_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]
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
- 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:
DMChannel¶
- async acknowledge
- async begin_typing
- async close
- async connect
- async edit
- async end_typing
- async fetch_channel_id
- async fetch_message
- def get_channel_id
- def get_initiator
- def get_last_message
- def get_me
- def get_message
- def get_read_state
- def get_recipient
- def get_recipients
- async history
- async join_call
- def locally_update
- def message
- def permissions_for
- async search
- async send
- def to_dict
- def typing
- class stoat.DMChannel(*, state, id, active, recipient_ids, last_message_id)[source]¶
Represents a private channel between two users.
This inherits from
BaseChannel,ConnectableandMessageable.- get_read_state(*, default_acked_message_id=None, create_if_not_exists=True)[source]¶
Optional[
ReadState]: Returns the channel’s read state.
- property type[source]¶
The channel’s type.
- Type:
Literal[
ChannelType.private]
- locally_update(data, /)[source]¶
Locally updates channel with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialChannel) – The data to update channel with.
- permissions_for(target, /)[source]¶
Calculate permissions for given user.
- await acknowledge(message=UNDEFINED, *, channel_http_overrides=None, http_overrides=None)[source]¶
This function is a coroutine.
Marks the destination channel as read.
You must have
view_channelto do this.Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Parameters:
message (ULIDOr[
BaseMessage]) – The message to mark as read.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- await begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- await close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- 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, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- 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_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:
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
- 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:
GroupChannel¶
- async acknowledge
- async add
- async add_bot
- async begin_typing
- async close
- async connect
- async create_invite
- async create_webhook
- async edit
- async end_typing
- async fetch_channel_id
- async fetch_message
- async fetch_recipients
- def get_channel_id
- def get_last_message
- def get_me
- def get_message
- def get_owner
- def get_read_state
- async history
- async join_call
- async leave
- def locally_update
- def message
- def permissions_for
- async search
- async send
- async set_default_permissions
- def to_dict
- def typing
- class stoat.GroupChannel(*, state, id, name, owner_id, description, internal_recipients, internal_icon, last_message_id, raw_permissions, nsfw)[source]¶
Represesnts a Stoat group channel between 1 or more participants.
This inherits from
BaseChannel,ConnectableandMessageable.- internal_icon¶
The stateless group icon.
- Type:
Optional[
StatelessAsset]
- raw_permissions¶
The permissions assigned to members of this group.
Note
This attribute does not apply to the owner of the group.
- Type:
Optional[
int]
- get_read_state(*, default_acked_message_id=None, create_if_not_exists=True)[source]¶
Optional[
ReadState]: Returns the channel’s read state.
- locally_update(data, /)[source]¶
Locally updates channel with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialChannel) – The data to update channel with.
- property permissions[source]¶
The permissions assigned to members of this group.
Note
This attribute does not apply to the owner of the group.
- Type:
Optional[
Permissions]
- property type[source]¶
The channel’s type.
- Type:
Literal[
ChannelType.group]
- await add(user, *, http_overrides=None)[source]¶
This function is a coroutine.
Adds another user to the group.
You must have
create_invitesto do this.Fires
PrivateChannelCreateEventfor added recipient, andGroupRecipientAddEventfor rest of group recipients.Note
This can only be used by non-bot accounts.
- Parameters:
user (ULIDOr[
BaseUser]) – The user to add.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
GroupTooLargeThe group exceeded maximum count of recipients.
MissingPermissionYou do not have the proper permissions to add the recipient.
NotFriendsYou’re not friends with the user you want to add.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel or user were not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInGroupThe user is already in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await add_bot(bot, *, http_overrides=None)[source]¶
This function is a coroutine.
Invites a bot to a group.
You must have
create_invitesto do this.Fires
PrivateChannelCreateEventfor bot,GroupRecipientAddEventandMessageCreateEventfor all group recipients.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Forbidden– Possible values fortype:Value
Reason
BotIsPrivateYou do not own the bot to add it.
GroupTooLargeThe group exceeded maximum count of recipients.
MissingPermissionYou do not have the proper permissions to add bots.
NotFound– Possible values fortype:Value
Reason
NotFoundThe bot/group/server was not found.
Conflict– Possible values fortype:Value
Reason
AlreadyInGroupThe bot is already in group.
AlreadyInServerThe bot is already in server.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
TypeError– You specifiedserverandgroupparameters, or passed no parameters.
- await create_invite(*, http_overrides=None)[source]¶
This function is a coroutine.
Creates an invite to group channel.
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
InvalidOperationThe target channel is not group or server channel.
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 create invites in channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe target channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The invite that was created.
- Return type:
- await create_webhook(*, http_overrides=None, name, avatar=None)[source]¶
This function is a coroutine.
Creates a webhook which 3rd party platforms can use to send.
You must have
manage_webhookspermission to do this.Fires
WebhookCreateEventfor all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (
str) – The webhook name. Must be between 1 and 32 chars long.avatar (Optional[
ResolvableResource]) – The webhook avatar.
- Raises:
HTTPException– Possible values fortype:Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create a webhook.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/file was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created webhook.
- Return type:
- await fetch_recipients(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all recipients who are part of this group.
Added in version 1.2.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationThe target channel is not group.
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 group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe target channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The group recipients.
- Return type:
List[
User]
- await leave(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Leaves a group or closes a group.
You must have
view_channelto do this.Fires
PrivateChannelDeleteEventfor all group recipients (including group owner) if the current user is group owner, otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all group recipients.- Parameters:
permissions (
Permissions) – The new permissions.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this channel.
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 updated group with new permissions.
- Return type:
- permissions_for(target, /)[source]¶
Calculate permissions for given user.
- await acknowledge(message=UNDEFINED, *, channel_http_overrides=None, http_overrides=None)[source]¶
This function is a coroutine.
Marks the destination channel as read.
You must have
view_channelto do this.Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Parameters:
message (ULIDOr[
BaseMessage]) – The message to mark as read.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- await begin_typing(*, http_overrides=None)[source]¶
Begins typing in channel, until
end_typing()is called.
- await close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- 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, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- 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_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:
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
- 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:
UnknownPrivateChannel¶
- class stoat.UnknownPrivateChannel(*, state, id, payload)[source]¶
Represents a private channel that is not recognized by library yet.
This inherits from
BaseChannel.- property type[source]¶
The channel’s type.
- Type:
Literal[
ChannelType.unknown]
- await close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- Return type:
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
BaseServerChannel¶
- async close
- async create_invite
- async delete
- async edit
- async fetch_webhooks
- def get_category
- def get_me
- def get_server
- def locally_update
- def message
- def permissions_for
- async set_default_permissions
- async set_role_permissions
- class stoat.BaseServerChannel(*, state, id, server_id, name, description, internal_icon, default_permissions, role_permissions, category_id, nsfw)[source]¶
A base class for server channels.
This inherits from
BaseChannel.- internal_icon¶
The stateless custom channel icon.
- Type:
Optional[
StatelessAsset]
- default_permissions¶
Default permissions assigned to users in this channel.
- Type:
Optional[
PermissionOverride]
- role_permissions¶
The permissions assigned based on role to this channel.
- Type:
Dict[
str,PermissionOverride]
- await create_invite(*, http_overrides=None)[source]¶
This function is a coroutine.
Creates an invite to server channel.
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
InvalidOperationThe target channel is not group or server channel.
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 create invites in channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe target channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The invite that was created.
- Return type:
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a server channel.
You must have
view_channelandmanage_channelsto do this.For server channels,
ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view and/or delete the channel.
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.
- await fetch_webhooks(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all webhooks in a channel.
You must have
manage_webhookspermission to do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view webhooks that belong to this channel.
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 webhooks for this channel.
- Return type:
List[
Webhook]
- await set_role_permissions(role, *, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for the specified role in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventfor users who no longer can see target channel.- Parameters:
role (ULIDOr[
BaseRole]) – The role.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow for role in channel.deny (
Permissions) – The permissions to deny for role in channel.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
NotElevatedRank of your top role is higher than rank of role you’re trying to set override for.
MissingPermissionYou do not have the proper permissions to edit overrides for this channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated server channel with new permissions.
- Return type:
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventis fired for users who no longer can see target channel.- Parameters:
permissions (
PermissionOverride) – The new permissions.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this channel.
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 updated server channel with new permissions.
- Return type:
- locally_update(data, /)[source]¶
Locally updates channel with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialChannel) – The data to update channel with.
- permissions_for(target, /, *, safe=True, with_ownership=True, include_timeout=True)[source]¶
Calculate permissions for given user.
- Parameters:
- Raises:
NoData– The server or role is not found in cache.- Returns:
The calculated permissions.
- Return type:
- await close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- Return type:
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
ChannelVoiceMetadata¶
- class stoat.ChannelVoiceMetadata(max_users=0)[source]¶
Represents some voice-specific metadata for text channel.
- max_users¶
The maximium amount of users allowed in the voice channel at once.
Zero means an infinite amount of users can connect to voice channel.
- Type:
- Parameters:
max_users (
int) –The maximium amount of users allowed in the voice channel at once.
Zero means an infinite amount of users can connect to voice channel.
Must be greater than 1.
TextChannel¶
- async acknowledge
- async begin_typing
- async close
- async connect
- async create_invite
- async create_webhook
- async delete
- async edit
- async end_typing
- async fetch_channel_id
- async fetch_message
- async fetch_webhooks
- def get_category
- def get_channel_id
- def get_last_message
- def get_me
- def get_message
- def get_read_state
- def get_server
- async history
- async join_call
- def locally_update
- def message
- def permissions_for
- async search
- async send
- async set_default_permissions
- async set_role_permissions
- def to_dict
- def typing
- class stoat.TextChannel(*, state, id, server_id, name, description, internal_icon, default_permissions, role_permissions, category_id, nsfw, last_message_id, voice)[source]¶
Represents a text channel that belongs to a server on Stoat.
This inherits from
BaseServerChannel,ConnectableandMessageable.- voice¶
The voice’s metadata in the channel.
Added in version 1.2.
- Type:
Optional[
ChannelVoiceMetadata]
- 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 close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- 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 create_invite(*, http_overrides=None)[source]¶
This function is a coroutine.
Creates an invite to server channel.
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
InvalidOperationThe target channel is not group or server channel.
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 create invites in channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe target channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The invite that was created.
- Return type:
- default_permissions¶
Default permissions assigned to users in this channel.
- Type:
Optional[
PermissionOverride]
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a server channel.
You must have
view_channelandmanage_channelsto do this.For server channels,
ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- 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_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_webhooks(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all webhooks in a channel.
You must have
manage_webhookspermission to do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view webhooks that belong to this channel.
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 webhooks for this channel.
- Return type:
List[
Webhook]
- await history(*, channel_http_overrides=None, http_overrides=None, limit=None, before=None, after=None, sort=None, nearby=None, populate_users=None)[source]¶
This function is a coroutine.
Retrieve message history from destination channel.
You must have
read_message_historyto do this.- Parameters:
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.limit (Optional[
int]) –The maximum number of messages to get. Must be between 1 and 100. Defaults to 50.
If
nearbyis provided, then this is(limit + 2).before (Optional[ULIDOr[
BaseMessage]]) – The message before which messages should be fetched.after (Optional[ULIDOr[
BaseMessage]]) – The message after which messages should be fetched.sort (Optional[
MessageSort]) – The message sort direction. Defaults tolatestnearby (Optional[ULIDOr[
BaseMessage]]) –The message to search around.
Providing this parameter will discard
before,afterandsortparameters.It will also take half of limit rounded as the limits to each side. It also fetches the message specified.
populate_users (
bool) – Whether to populate user (and member, if server channel) objects.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to read the message history.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The messages retrieved.
- Return type:
List[
Message]
- internal_icon¶
The stateless custom channel icon.
- 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:
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
- permissions_for(target, /, *, safe=True, with_ownership=True, include_timeout=True)[source]¶
Calculate permissions for given user.
- Parameters:
- Raises:
NoData– The server or role is not found in cache.- Returns:
The calculated permissions.
- Return type:
- role_permissions¶
The permissions assigned based on role to this channel.
- Type:
Dict[
str,PermissionOverride]
- await search(query=None, *, channel_http_overrides=None, http_overrides=None, pinned=None, limit=None, before=None, after=None, sort=None, populate_users=None)[source]¶
This function is a coroutine.
Searches for messages in destination channel.
For
queryandpinned, only one parameter can be provided, otherwise aHTTPExceptionwill be thrown withInvalidOperationtype.You must have
read_message_historyto do this.Note
This can only be used by non-bot accounts.
- Parameters:
query (Optional[
str]) –The full-text search query. See MongoDB documentation for more information.
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.pinned (Optional[
bool]) – Whether to search for (un-)pinned messages or not.limit (Optional[
int]) –The maximum number of messages to get. Must be between 1 and 100. Defaults to 50.
If
nearbyis provided, then this is(limit + 2).before (Optional[ULIDOr[
BaseMessage]]) – The message before which messages should be fetched.after (Optional[ULIDOr[
BaseMessage]]) – The message after which messages should be fetched.sort (Optional[
MessageSort]) – The message sort direction. Defaults tolatestnearby (Optional[ULIDOr[
BaseMessage]]) –The message to search around.
Providing this parameter will discard
before,afterandsortparameters.It will also take half of limit rounded as the limits to each side. It also fetches the message specified.
populate_users (
bool) – Whether to populate user (and member, if server channel) objects.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationOne of
before,afterornearbyparameters were invalid IDs.InvalidOperationYou provided both
queryandpinnedparameters.IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to search messages.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The messages matched.
- Return type:
List[
Message]
- await send(content=None, *, channel_http_overrides=None, http_overrides=None, nonce=None, attachments=None, replies=None, embeds=None, masquerade=None, interactions=None, silent=None, mention_everyone=None, mention_online=None)[source]¶
This function is a coroutine.
Sends a message to destination channel.
You must have
send_messagesto do this.If message mentions “@everyone” or “@online”, you must have
mention_everyoneto do that.If message mentions any roles, you must
mention_rolesto do that.Fires
MessageCreateEventand optionallyMessageAppendEvent, both for all users who can see destination channel.- Parameters:
content (Optional[
str]) – The message content.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nonce (Optional[
str]) – The message nonce.attachments (Optional[List[
ResolvableResource]]) –The attachments to send the message with.
You must have
upload_filesto provide this.replies (Optional[List[Union[
Reply, ULIDOr[BaseMessage]]]]) – The message replies.embeds (Optional[List[
SendableEmbed]]) –The embeds to send the message with.
You must have
send_embedsto provide this.masquerade (Optional[
MessageMasquerade]) –The message masquerade.
You must have
use_masqueradeto provide this.If
coloris provided,use_masqueradeis also required.interactions (Optional[
MessageInteractions]) –The message interactions.
silent (Optional[
bool]) – Whether to suppress notifications or not.mention_everyone (Optional[
bool]) –Whether to mention all users who can see the channel. This cannot be mixed with
mention_onlineparameter.Note
User accounts cannot set this to
True.mention_online (Optional[
bool]) –Whether to mention all users who are online and can see the channel. This cannot be mixed with
mention_everyoneparameter.Note
User accounts cannot set this to
True.
- Raises:
stoat.HTTPException– Possible values fortype:Value
Reason
EmptyMessageThe message was empty.
FailedValidationThe payload was invalid.
InvalidFlagValueBoth
mention_everyoneandmention_onlinewereTrue.InvalidOperationThe passed nonce was already used. One of
reactionselements was invalid.InvalidPropertyrestrict_reactionswasTruebutreactionswas empty.IsBotThe current token belongs to bot account.
IsNotBotThe current token belongs to user account.
PayloadTooLargeThe message was too large.
TooManyAttachmentsYou provided more attachments than allowed on this instance.
TooManyEmbedsYou provided more embeds than allowed on this instance.
TooManyRepliesYou were replying to more messages than was allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to send messages.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/file/reply was not found.
stoat.InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during message creation.
- Returns:
The message that was sent.
- Return type:
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventis fired for users who no longer can see target channel.- Parameters:
permissions (
PermissionOverride) – The new permissions.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this channel.
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 updated server channel with new permissions.
- Return type:
- await set_role_permissions(role, *, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for the specified role in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventfor users who no longer can see target channel.- Parameters:
role (ULIDOr[
BaseRole]) – The role.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow for role in channel.deny (
Permissions) – The permissions to deny for role in channel.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
NotElevatedRank of your top role is higher than rank of role you’re trying to set override for.
MissingPermissionYou do not have the proper permissions to edit overrides for this channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated server channel with new permissions.
- 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.
- get_read_state(*, default_acked_message_id=None, create_if_not_exists=True)[source]¶
Optional[
ReadState]: Returns the channel’s read state.
- locally_update(data, /)[source]¶
Locally updates channel with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialChannel) – The data to update channel with.
- property type[source]¶
The channel’s type.
- Type:
Literal[
ChannelType.text]
- await create_webhook(*, http_overrides=None, name, avatar=None)[source]¶
This function is a coroutine.
Creates a webhook which 3rd party platforms can use to send.
You must have
manage_webhookspermission to do this.Fires
WebhookCreateEventfor all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (
str) – The webhook name. Must be between 1 and 32 chars long.avatar (Optional[
ResolvableResource]) – The webhook avatar.
- Raises:
HTTPException– Possible values fortype:Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to create a webhook.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/file was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The created webhook.
- Return type:
VoiceChannel¶
- async acknowledge
- async begin_typing
- async close
- async connect
- async create_invite
- async delete
- async edit
- async end_typing
- async fetch_channel_id
- async fetch_message
- async fetch_webhooks
- def get_category
- def get_channel_id
- def get_me
- def get_message
- def get_server
- async history
- async join_call
- def locally_update
- def message
- def permissions_for
- async search
- async send
- async set_default_permissions
- async set_role_permissions
- def to_dict
- def typing
- class stoat.VoiceChannel(*, state, id, server_id, name, description, internal_icon, default_permissions, role_permissions, category_id, nsfw)[source]¶
Represents a voice channel that belongs to a server on Stoat.
This inherits from
BaseServerChannel,ConnectableandMessageable.Deprecated since version 0.7.0: The voice channel type was deprecated in favour of
TextChannel.voice.- 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 close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- 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 create_invite(*, http_overrides=None)[source]¶
This function is a coroutine.
Creates an invite to server channel.
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
InvalidOperationThe target channel is not group or server channel.
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 create invites in channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe target channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The invite that was created.
- Return type:
- default_permissions¶
Default permissions assigned to users in this channel.
- Type:
Optional[
PermissionOverride]
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a server channel.
You must have
view_channelandmanage_channelsto do this.For server channels,
ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- 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_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_webhooks(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all webhooks in a channel.
You must have
manage_webhookspermission to do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view webhooks that belong to this channel.
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 webhooks for this channel.
- Return type:
List[
Webhook]
- await history(*, channel_http_overrides=None, http_overrides=None, limit=None, before=None, after=None, sort=None, nearby=None, populate_users=None)[source]¶
This function is a coroutine.
Retrieve message history from destination channel.
You must have
read_message_historyto do this.- Parameters:
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.limit (Optional[
int]) –The maximum number of messages to get. Must be between 1 and 100. Defaults to 50.
If
nearbyis provided, then this is(limit + 2).before (Optional[ULIDOr[
BaseMessage]]) – The message before which messages should be fetched.after (Optional[ULIDOr[
BaseMessage]]) – The message after which messages should be fetched.sort (Optional[
MessageSort]) – The message sort direction. Defaults tolatestnearby (Optional[ULIDOr[
BaseMessage]]) –The message to search around.
Providing this parameter will discard
before,afterandsortparameters.It will also take half of limit rounded as the limits to each side. It also fetches the message specified.
populate_users (
bool) – Whether to populate user (and member, if server channel) objects.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to read the message history.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The messages retrieved.
- Return type:
List[
Message]
- internal_icon¶
The stateless custom channel icon.
- 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:
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
- permissions_for(target, /, *, safe=True, with_ownership=True, include_timeout=True)[source]¶
Calculate permissions for given user.
- Parameters:
- Raises:
NoData– The server or role is not found in cache.- Returns:
The calculated permissions.
- Return type:
- role_permissions¶
The permissions assigned based on role to this channel.
- Type:
Dict[
str,PermissionOverride]
- await search(query=None, *, channel_http_overrides=None, http_overrides=None, pinned=None, limit=None, before=None, after=None, sort=None, populate_users=None)[source]¶
This function is a coroutine.
Searches for messages in destination channel.
For
queryandpinned, only one parameter can be provided, otherwise aHTTPExceptionwill be thrown withInvalidOperationtype.You must have
read_message_historyto do this.Note
This can only be used by non-bot accounts.
- Parameters:
query (Optional[
str]) –The full-text search query. See MongoDB documentation for more information.
channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.pinned (Optional[
bool]) – Whether to search for (un-)pinned messages or not.limit (Optional[
int]) –The maximum number of messages to get. Must be between 1 and 100. Defaults to 50.
If
nearbyis provided, then this is(limit + 2).before (Optional[ULIDOr[
BaseMessage]]) – The message before which messages should be fetched.after (Optional[ULIDOr[
BaseMessage]]) – The message after which messages should be fetched.sort (Optional[
MessageSort]) – The message sort direction. Defaults tolatestnearby (Optional[ULIDOr[
BaseMessage]]) –The message to search around.
Providing this parameter will discard
before,afterandsortparameters.It will also take half of limit rounded as the limits to each side. It also fetches the message specified.
populate_users (
bool) – Whether to populate user (and member, if server channel) objects.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationOne of
before,afterornearbyparameters were invalid IDs.InvalidOperationYou provided both
queryandpinnedparameters.IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to search messages.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The messages matched.
- Return type:
List[
Message]
- await send(content=None, *, channel_http_overrides=None, http_overrides=None, nonce=None, attachments=None, replies=None, embeds=None, masquerade=None, interactions=None, silent=None, mention_everyone=None, mention_online=None)[source]¶
This function is a coroutine.
Sends a message to destination channel.
You must have
send_messagesto do this.If message mentions “@everyone” or “@online”, you must have
mention_everyoneto do that.If message mentions any roles, you must
mention_rolesto do that.Fires
MessageCreateEventand optionallyMessageAppendEvent, both for all users who can see destination channel.- Parameters:
content (Optional[
str]) – The message content.channel_http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides for getting channel.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.nonce (Optional[
str]) – The message nonce.attachments (Optional[List[
ResolvableResource]]) –The attachments to send the message with.
You must have
upload_filesto provide this.replies (Optional[List[Union[
Reply, ULIDOr[BaseMessage]]]]) – The message replies.embeds (Optional[List[
SendableEmbed]]) –The embeds to send the message with.
You must have
send_embedsto provide this.masquerade (Optional[
MessageMasquerade]) –The message masquerade.
You must have
use_masqueradeto provide this.If
coloris provided,use_masqueradeis also required.interactions (Optional[
MessageInteractions]) –The message interactions.
silent (Optional[
bool]) – Whether to suppress notifications or not.mention_everyone (Optional[
bool]) –Whether to mention all users who can see the channel. This cannot be mixed with
mention_onlineparameter.Note
User accounts cannot set this to
True.mention_online (Optional[
bool]) –Whether to mention all users who are online and can see the channel. This cannot be mixed with
mention_everyoneparameter.Note
User accounts cannot set this to
True.
- Raises:
stoat.HTTPException– Possible values fortype:Value
Reason
EmptyMessageThe message was empty.
FailedValidationThe payload was invalid.
InvalidFlagValueBoth
mention_everyoneandmention_onlinewereTrue.InvalidOperationThe passed nonce was already used. One of
reactionselements was invalid.InvalidPropertyrestrict_reactionswasTruebutreactionswas empty.IsBotThe current token belongs to bot account.
IsNotBotThe current token belongs to user account.
PayloadTooLargeThe message was too large.
TooManyAttachmentsYou provided more attachments than allowed on this instance.
TooManyEmbedsYou provided more embeds than allowed on this instance.
TooManyRepliesYou were replying to more messages than was allowed on this instance.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to send messages.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/file/reply was not found.
stoat.InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
InternalErrorSomehow something went wrong during message creation.
- Returns:
The message that was sent.
- Return type:
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventis fired for users who no longer can see target channel.- Parameters:
permissions (
PermissionOverride) – The new permissions.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this channel.
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 updated server channel with new permissions.
- Return type:
- await set_role_permissions(role, *, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for the specified role in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventfor users who no longer can see target channel.- Parameters:
role (ULIDOr[
BaseRole]) – The role.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow for role in channel.deny (
Permissions) – The permissions to deny for role in channel.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
NotElevatedRank of your top role is higher than rank of role you’re trying to set override for.
MissingPermissionYou do not have the proper permissions to edit overrides for this channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated server channel with new permissions.
- 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.
- locally_update(data, /)[source]¶
Locally updates channel with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialChannel) – The data to update channel with.
- property type[source]¶
The channel’s type.
- Type:
Literal[
ChannelType.voice]
UnknownServerChannel¶
- async close
- async create_invite
- async delete
- async edit
- async fetch_webhooks
- def get_category
- def get_me
- def get_server
- def locally_update
- def message
- def permissions_for
- async set_default_permissions
- async set_role_permissions
- def to_dict
- class stoat.UnknownServerChannel(*, state, id, server_id, name, description, internal_icon, default_permissions, role_permissions, category_id, nsfw, payload)[source]¶
Represents a server channel that is not recognized by library yet.
This inherits from
BaseServerChannel.- await close(*, http_overrides=None, silent=None)[source]¶
This function is a coroutine.
Deletes a server channel, leaves a group or closes a group.
You must have
view_channelto do this. If target channel is server channel,manage_channelsis also required.For DMs, fires
ChannelUpdateEventfor the current user and DM recipient. For groups, if the current user is group owner, firesPrivateChannelDeleteEventfor all group recipients (including group owner), otherwisePrivateChannelDeleteEventis fired for the current user, andGroupRecipientRemoveEventis fired for rest of group recipients. For server channels,ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.silent (Optional[
bool]) – Whether to not send message when leaving.
- 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 and/or delete the channel.
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.
- await create_invite(*, http_overrides=None)[source]¶
This function is a coroutine.
Creates an invite to server channel.
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
InvalidOperationThe target channel is not group or server channel.
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 create invites in channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe target channel was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The invite that was created.
- Return type:
- default_permissions¶
Default permissions assigned to users in this channel.
- Type:
Optional[
PermissionOverride]
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes a server channel.
You must have
view_channelandmanage_channelsto do this.For server channels,
ServerChannelDeleteEventis fired for all users who could see target channel, andServerUpdateEventfor all server members.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view and/or delete the channel.
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.
- await edit(*, http_overrides=None, name=UNDEFINED, description=UNDEFINED, owner=UNDEFINED, icon=UNDEFINED, nsfw=UNDEFINED, archived=UNDEFINED, voice=UNDEFINED, default_permissions=UNDEFINED)[source]¶
This function is a coroutine.
Edits the channel.
You must have
manage_channelsto do this.Fires
ChannelUpdateEventfor all users who still can see target channel, optionallyServerChannelCreateEventfor all users who now can see target server channel, and optionallyChannelDeleteEventfor users who no longer can see target server channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.name (UndefinedOr[
str]) – The new channel name. Only applicable when target channel isGroupChannel, orServerChannel.description (UndefinedOr[Optional[
str]]) – The new channel description. Only applicable when target channel isGroupChannel, orServerChannel.owner (UndefinedOr[ULIDOr[
BaseUser]]) – The new channel owner. Only applicable when target channel isGroupChannel.icon (UndefinedOr[Optional[
ResolvableResource]]) – The new channel icon. Only applicable when target channel isGroupChannel, orServerChannel.nsfw (UndefinedOr[
bool]) – To mark the channel as NSFW or not. Only applicable when target channel isGroupChannel, orServerChannel.archived (UndefinedOr[
bool]) – To mark the channel as archived or not.voice (UndefinedOr[
ChannelVoiceMetadata]) –The new voice-specific metadata for this channel.
Added in version 1.2.
default_permissions (UndefinedOr[None]) – To remove default permissions or not. Only applicable when target channel is
GroupChannel, orServerChannel.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
InvalidOperationThe target channel was not group/text/voice channel.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to edit the channel.
NotOwnerYou do not own the group.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
NotInGroupThe new owner was not in group.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly updated channel.
- Return type:
- await fetch_webhooks(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves all webhooks in a channel.
You must have
manage_webhookspermission to do this.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view webhooks that belong to this channel.
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 webhooks for this channel.
- Return type:
List[
Webhook]
- internal_icon¶
The stateless custom channel icon.
- Type:
Optional[
StatelessAsset]
- locally_update(data, /)[source]¶
Locally updates channel with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialChannel) – The data to update channel with.
- message(message, /)[source]¶
BaseMessage: Returns a partial message with specified ID.
- permissions_for(target, /, *, safe=True, with_ownership=True, include_timeout=True)[source]¶
Calculate permissions for given user.
- Parameters:
- Raises:
NoData– The server or role is not found in cache.- Returns:
The calculated permissions.
- Return type:
- role_permissions¶
The permissions assigned based on role to this channel.
- Type:
Dict[
str,PermissionOverride]
- await set_default_permissions(permissions, *, http_overrides=None)[source]¶
This function is a coroutine.
Sets default permissions for everyone in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventis fired for users who no longer can see target channel.- Parameters:
permissions (
PermissionOverride) – The new permissions.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
MissingPermissionYou do not have the proper permissions to edit default permissions for this channel.
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 updated server channel with new permissions.
- Return type:
- await set_role_permissions(role, *, http_overrides=None, allow=<Permissions: 0>, deny=<Permissions: 0>)[source]¶
This function is a coroutine.
Sets permissions for the specified role in a channel.
You must have
manage_permissionsto do this.Fires
ChannelUpdateEventfor all users who still see target channel,ServerChannelCreateEventfor all users who now can see target channel, andChannelDeleteEventfor users who no longer can see target channel.- Parameters:
role (ULIDOr[
BaseRole]) – The role.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.allow (
Permissions) – The permissions to allow for role in channel.deny (
Permissions) – The permissions to deny for role in channel.
- Raises:
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotGiveMissingPermissionsYour new provided permissions contained permissions you didn’t have.
NotElevatedRank of your top role is higher than rank of role you’re trying to set override for.
MissingPermissionYou do not have the proper permissions to edit overrides for this channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/server/role was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The updated server channel with new permissions.
- Return type:
- property type[source]¶
The channel’s type.
- Type:
Literal[
ChannelType.unknown]
PrivateChannel¶
- class stoat.PrivateChannel¶
An union of all channels that do not belong to a server.
The following classes are included in this union:
ServerChannel¶
- class stoat.ServerChannel¶
An union of all channels that belong to a server.
The following classes are included in this union:
TextableChannel¶
- class stoat.TextableChannel¶
An union of all channels that can have messages in them.
The following classes are included in this union:
UnknownChannel¶
- class stoat.UnknownChannel¶
An union of all channels that are not recognized by library.
The following classes are included in this union:
Channel¶
- class stoat.Channel¶
An union of all channels.
Union types such as this exist to help determine which exact channel type has some field during development.
The following classes are included in this union:
ChannelVoiceStateContainer¶
- def locally_add
- def locally_remove
- class stoat.ChannelVoiceStateContainer(*, channel_id, participants, node)[source]¶
Represents voice state container for the channel.
- participants¶
The channel’s participants.
- Type:
Dict[
str,UserVoiceState]
- locally_add(state, /)[source]¶
Locally adds user’s voice state into this container.
- Parameters:
state (
UserVoiceState) – The state to add.
- locally_remove(user_id, /)[source]¶
Locally removes user’s voice state from this container.
- Parameters:
user_id (
str) – The user’s ID to remove state from.- Returns:
The removed user’s voice state.
- Return type:
Optional[
UserVoiceState]
PartialMessageable¶
- def get_channel_id
- def permissions_for
- class stoat.PartialMessageable(*, state, id)[source]¶
Represents a partial messageable to aid with working messageable channels when only a channel ID is present.