Messages¶
The following section documents everything related to messages. Messages are core part of Stoat and they are way for users to communicate.
Models¶
BaseSystemEvent¶
TextSystemEvent¶
- def attach_state
- def to_dict
- class stoat.TextSystemEvent(*, content)[source]¶
A simple text system message.
This inherits from
BaseSystemEvent.- attach_state(message, /)[source]¶
TextSystemEventAttach a state to system event.- Parameters:
message (
Message) – The state to attach.
StatelessUserAddedSystemEvent¶
- def attach_state
- def get_by
- def get_user
- def to_dict
- class stoat.StatelessUserAddedSystemEvent(*, internal_user, internal_by)[source]¶
An user was added to a group.
This inherits from
BaseSystemEvent.- attach_state(message, /)[source]¶
UserAddedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
UserAddedSystemEvent¶
- def attach_state
- def get_by
- def get_user
- def to_dict
- class stoat.UserAddedSystemEvent(*, internal_user, internal_by, message)[source]¶
An user was added to a group.
This is a stateful version of
StatelessUserAddedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
UserAddedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
StatelessUserRemovedSystemEvent¶
- def attach_state
- def get_by
- def get_user
- def to_dict
- class stoat.StatelessUserRemovedSystemEvent(*, internal_user, internal_by)[source]¶
An user was removed from a group.
This inherits from
BaseSystemEvent.- internal_by¶
The ID of the user that removed this user, or full user instance.
- attach_state(message, /)[source]¶
UserRemovedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
UserRemovedSystemEvent¶
- def attach_state
- def get_by
- def get_user
- def to_dict
- class stoat.UserRemovedSystemEvent(*, internal_user, internal_by, message)[source]¶
An user was removed from a group.
This is a stateful version of
StatelessUserRemovedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
UserRemovedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_by¶
The ID of the user that removed this user, or full user instance.
StatelessUserJoinedSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.StatelessUserJoinedSystemEvent(*, internal_user)[source]¶
An user joined a server.
This inherits from
BaseSystemEvent.- internal_user¶
The ID of the user that joined this server, or full member/user instance.
- attach_state(message, /)[source]¶
UserJoinedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
UserJoinedSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.UserJoinedSystemEvent(*, internal_user, message)[source]¶
An user joined a server.
This is a stateful version of
StatelessUserJoinedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
UserJoinedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_user¶
The ID of the user that joined this server, or full member/user instance.
StatelessUserLeftSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.StatelessUserLeftSystemEvent(*, internal_user)[source]¶
An user left a group or server.
This inherits from
BaseSystemEvent.- internal_user¶
The ID of the user that left this group/server, or full member/user instance.
- attach_state(message, /)[source]¶
UserLeftSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
UserLeftSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.UserLeftSystemEvent(*, internal_user, message)[source]¶
An user left a group or server.
This is a stateful version of
StatelessUserLeftSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
UserLeftSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_user¶
The ID of the user that left this group/server, or full member/user instance.
StatelessUserKickedSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.StatelessUserKickedSystemEvent(*, internal_user)[source]¶
A member was kicked from a server.
This inherits from
BaseSystemEvent.- internal_user¶
The ID of the user that kicked from this server, or full member/user instance.
- attach_state(message, /)[source]¶
UserKickedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
UserKickedSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.UserKickedSystemEvent(*, internal_user, message)[source]¶
A member was kicked from a server.
This is a stateful version of
StatelessUserKickedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
UserKickedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_user¶
The ID of the user that kicked from this server, or full member/user instance.
StatelessUserBannedSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.StatelessUserBannedSystemEvent(*, internal_user)[source]¶
An user was banned from a server.
This inherits from
BaseSystemEvent.- internal_user¶
The ID of the user that was banned from this server, or full member/user instance.
- attach_state(message, /)[source]¶
UserBannedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
UserBannedSystemEvent¶
- def attach_state
- def get_user
- def get_user_as_member
- def get_user_as_user
- def to_dict
- class stoat.UserBannedSystemEvent(*, internal_user, message)[source]¶
An user was banned from a server.
This is a stateful version of
StatelessUserBannedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
UserBannedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_user¶
The ID of the user that was banned from this server, or full member/user instance.
StatelessChannelRenamedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.StatelessChannelRenamedSystemEvent(*, name, internal_by)[source]¶
An user renamed group.
This inherits from
BaseSystemEvent.- internal_by¶
The ID of the user that renamed this group, or full user instance.
- attach_state(message, /)[source]¶
ChannelRenamedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
ChannelRenamedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.ChannelRenamedSystemEvent(*, name, internal_by, message)[source]¶
An user renamed group.
This is a stateful version of
StatelessChannelRenamedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
ChannelRenamedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_by¶
The ID of the user that renamed this group, or full user instance.
StatelessChannelDescriptionChangedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.StatelessChannelDescriptionChangedSystemEvent(*, internal_by)[source]¶
An user changed group’s description.
This inherits from
BaseSystemEvent.- internal_by¶
The ID of the user that changed description of this group, or full user instance.
- attach_state(message, /)[source]¶
ChannelDescriptionChangedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
ChannelDescriptionChangedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.ChannelDescriptionChangedSystemEvent(*, internal_by, message)[source]¶
An user changed group’s description.
This is a stateful version of
StatelessChannelDescriptionChangedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
ChannelDescriptionChangedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_by¶
The ID of the user that changed description of this group, or full user instance.
StatelessChannelIconChangedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.StatelessChannelIconChangedSystemEvent(*, internal_by)[source]¶
An user changed group’s icon.
This inherits from
BaseSystemEvent.- internal_by¶
The ID of the user that changed icon of this group, or full user instance.
- attach_state(message, /)[source]¶
ChannelIconChangedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
ChannelIconChangedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.ChannelIconChangedSystemEvent(*, internal_by, message)[source]¶
An user changed group’s icon.
This is a stateful version of
StatelessChannelIconChangedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
ChannelIconChangedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_by¶
The ID of the user that changed icon of this group, or full user instance.
StatelessChannelOwnershipChangedSystemEvent¶
- def attach_state
- def get_from
- def get_to
- def to_dict
- class stoat.StatelessChannelOwnershipChangedSystemEvent(*, internal_from, internal_to)[source]¶
A group owner transferred ownership to someone else.
This inherits from
BaseSystemEvent.- internal_from¶
The ID of the user that was previous owner of this group, or full user instance.
- internal_to¶
The ID of the user that became owner of this group, or full user instance.
- attach_state(message, /)[source]¶
ChannelOwnershipChangedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
ChannelOwnershipChangedSystemEvent¶
- def attach_state
- def get_from
- def get_to
- def to_dict
- class stoat.ChannelOwnershipChangedSystemEvent(*, internal_from, internal_to, message)[source]¶
A group owner transferred ownership to someone else.
This is a stateful version of
StatelessChannelOwnershipChangedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
ChannelOwnershipChangedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_from¶
The ID of the user that was previous owner of this group, or full user instance.
- internal_to¶
The ID of the user that became owner of this group, or full user instance.
StatelessMessagePinnedSystemEvent¶
- def attach_state
- def get_by
- def get_by_as_member
- def get_by_as_user
- def to_dict
- class stoat.StatelessMessagePinnedSystemEvent(*, pinned_message_id, internal_by)[source]¶
A message was pinned.
This inherits from
BaseSystemEvent.- internal_by¶
The ID of the user that pinned a message, or full member/user instance.
- attach_state(message, /)[source]¶
MessagePinnedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
MessagePinnedSystemEvent¶
- def attach_state
- def get_by
- def get_by_as_member
- def get_by_as_user
- def get_pinned_message
- def to_dict
- class stoat.MessagePinnedSystemEvent(*, pinned_message_id, internal_by, message)[source]¶
A message was pinned.
This is a stateful version of
StatelessMessagePinnedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
MessagePinnedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_by¶
The ID of the user that pinned a message, or full member/user instance.
StatelessMessageUnpinnedSystemEvent¶
- def attach_state
- def get_by
- def get_by_as_member
- def get_by_as_user
- def to_dict
- class stoat.StatelessMessageUnpinnedSystemEvent(*, unpinned_message_id, internal_by)[source]¶
A message was unpinned.
This inherits from
BaseSystemEvent.- internal_by¶
The ID of the user that unpinned a message, or full member/user instance.
- attach_state(message, /)[source]¶
MessageUnpinnedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
MessageUnpinnedSystemEvent¶
- def attach_state
- def get_by
- def get_by_as_member
- def get_by_as_user
- def get_unpinned_message
- def to_dict
- class stoat.MessageUnpinnedSystemEvent(*, unpinned_message_id, internal_by, message)[source]¶
A message was unpinned.
This is a stateful version of
StatelessMessageUnpinnedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
MessageUnpinnedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
- internal_by¶
The ID of the user that unpinned a message, or full member/user instance.
StatelessCallStartedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.StatelessCallStartedSystemEvent(*, internal_by, finished_at)[source]¶
A call was just started in the channel.
This inherits from
BaseSystemEvent.- attach_state(message, /)[source]¶
CallStartedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
CallStartedSystemEvent¶
- def attach_state
- def get_by
- def to_dict
- class stoat.CallStartedSystemEvent(*, internal_by, finished_at, message)[source]¶
A call was just started in the channel.
This is a stateful version of
StatelessCallStartedSystemEvent, and inherits from it.- attach_state(message, /)[source]¶
CallStartedSystemEvent: Attach a state to system event.- Parameters:
message (
Message) – The state to attach.
StatelessSystemEvent¶
- class stoat.StatelessSystemEvent¶
An union of all stateless system events that message may hold.
The following classes are included in this union:
SystemEvent¶
- class stoat.SystemEvent¶
An union of all system events that message may hold.
The following classes are included in this union:
BaseMessage¶
- async ack
- async acknowledge
- async clear_reactions
- async delete
- async edit
- def editing
- async fetch
- def get_channel
- def get_server
- async pin
- async react
- async reply
- async report
- async unpin
- async unreact
- class stoat.BaseMessage(*, state, id, channel_id)[source]¶
Represents a message in channel on Stoat.
This inherits from
Base.- get_channel()[source]¶
Optional[
TextableChannel]: The channel this message was sent in.
- property channel[source]¶
The channel this message was sent in.
- Type:
Union[
TextableChannel,PartialMessageable]
- await ack(*, http_overrides=None)[source]¶
This function is a coroutine.
Marks this message as read.
This is an alias for
acknowledge().You must have
view_channelto do this.Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- await acknowledge(*, http_overrides=None)[source]¶
This function is a coroutine.
Marks this message as read.
You must have
view_channelto do this.There is an alias for this called
ack().Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- await clear_reactions(*, http_overrides=None)[source]¶
This function is a coroutine.
Removes all the reactions from the message.
You must have
manage_messagesto do this.Fires
MessageUpdateEventwith emptyreactionsfor all users who can see target channel.- 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 remove all the reactions.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel or message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the message in a channel.
You must have
manage_messagesto do this if message is not yours.Fires
MessageDeleteEventfor all users who can see target channel.- 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 delete the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel or message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, content=UNDEFINED, embeds=UNDEFINED)[source]¶
This function is a coroutine.
Edits the message.
Fires
MessageUpdateEventand optionallyMessageAppendEvent, both for all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.content (UndefinedOr[
str]) – The new content to replace the message with. Must be between 1 and 2000 characters long.embeds (UndefinedOr[List[
SendableEmbed]]) –The new embeds to replace the original with. Must be a maximum of 10. To remove all embeds
[]should be passed.You must have
send_embedsto provide this.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
PayloadTooLargeThe message was too large.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotEditMessageThe message you tried to edit isn’t yours.
MissingPermissionYou do not have the proper permissions to send messages.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message/file was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly edited message.
- Return type:
- editing()[source]¶
Editing: Returns an asynchronous context manager that allows you to send an editing indicator for a message in channel for an indefinite period of time.
- await fetch(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves the message.
- 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 the channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved message.
- Return type:
- await pin(*, http_overrides=None)[source]¶
This function is a coroutine.
Pins the message.
You must have
manage_messagesto do this, unless the channel isDMChannel.Fires
MessageUpdateEventandMessageCreateEvent, both for all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
AlreadyPinnedThe message was already pinned.
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 pin the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await react(emoji, *, http_overrides=None)[source]¶
This function is a coroutine.
React to this message.
You must have
reactto do this.Fires
MessageReactEventfor all users who can see target channel.- Parameters:
emoji (
ResolvableEmoji) – The emoji to react with.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationOne of these:
The message has too many reactions.
If
MessageInteractions.restrict_reactionsisTrue, then the emoji provided was not whitelisted.The provided emoji was invalid.
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 react.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message/custom emoji was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await reply(content=None, *, http_overrides=None, nonce=None, attachments=None, embeds=None, masquerade=None, interactions=None, silent=None, mention_everyone=None, mention_online=None, mention=True)[source]¶
This function is a coroutine.
Replies to this message.
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 target channel.- Parameters:
content (Optional[
str]) – The message content.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.masquearde (Optional[
MessageMasquerade]) –The message masquerade.
You must have
use_masqueradeto provide this.If
MessageMasquerade.coloris provided,manage_rolesis also required.interactions (Optional[
MessageInteractions]) –The message interactions.
If
MessageInteractions.reactionsis provided,reactis required.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.mention (
bool) – Whether to mention author of message you’re replying to.
- Raises:
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
MessageInteractions.reactionselements was invalid.InvalidPropertyMessageInteractions.restrict_reactionswasTruebutMessageInteractions.reactionswas 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.
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 report(reason, *, http_overrides=None, additional_context=None)[source]¶
This function is a coroutine.
Report the message to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Internally, 15 messages around provided message will be snapshotted for context. All attachments of provided message are snapshotted as well.
Note
This can only be used by non-bot accounts.
- Parameters:
reason (
ContentReportReason) – The reason for reporting.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.additional_context (Optional[
str]) – The additional context for moderation team. Can be only up to 1000 characters.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report your own message.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await unpin(*, http_overrides=None)[source]¶
This function is a coroutine.
Unpins the message.
You must have
manage_messagesto do this, unless the channel isDMChannel.Fires
MessageUpdateEventandMessageCreateEvent, both for all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
NotPinnedThe message was not pinned.
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 unpin the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await unreact(emoji, *, http_overrides=None, user=None, remove_all=None)[source]¶
This function is a coroutine.
Remove your own, someone else’s or all of a given reaction.
You must have
reactto do this.Fires
MessageClearReactionEventifremove_allisTrueorMessageUnreactEvent, for all users who can see target channel.- Parameters:
emoji (
ResolvableEmoji) – The emoji to remove.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.user (Optional[ULIDOr[
BaseUser]]) –The user to remove reactions from.
You must have
manage_messagesto provide this.remove_all (Optional[
bool]) –Whether to remove all reactions.
You must have
manage_messagesto provide this.
- 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 remove reaction.
NotFound– Possible values fortype:Value
Reason
NotFoundOne of these:
The channel was not found.
The message was not found.
The user provided did not react.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
PartialMessage¶
- class stoat.PartialMessage(*, state, id, channel_id, content, edited_at, internal_embeds, pinned, reactions)[source]¶
Represents partial message in channel on Stoat.
This inherits from
BaseMessage.- internal_embeds¶
The new message embeds.
- Type:
UndefinedOr[List[
StatelessEmbed]]
MessageAppendData¶
- class stoat.MessageAppendData(*, state, id, channel_id, internal_embeds)[source]¶
Appended data to message in channel on Stoat.
This inherits from
BaseMessage.- internal_embeds¶
The stateless embeds that were appended.
- Type:
UndefinedOr[List[
StatelessEmbed]]
Message¶
- attachments
- author
- author_as_member
- author_as_user
- author_id
- channel
- channel_id
- content
- edited_at
- embeds
- flags
- id
- interactions
- internal_attachments
- internal_author
- internal_embeds
- internal_system_event
- masquerade
- mention_ids
- mentions
- mentions_as_members
- mentions_as_users
- nonce
- pinned
- raw_flags
- reactions
- replies
- role_mention_ids
- role_mentions
- server
- state
- system_content
- system_event
- webhook
- async ack
- async acknowledge
- async clear_reactions
- async delete
- async edit
- def editing
- async fetch
- def get_author
- def get_author_as_member
- def get_author_as_user
- def get_channel
- def get_server
- def is_silent
- def locally_update
- async pin
- async react
- async reply
- async report
- def to_dict
- async unpin
- async unreact
- class stoat.Message(*, state, id, nonce, channel_id, internal_author, webhook, content, internal_system_event, internal_attachments, edited_at, internal_embeds, mention_ids, role_mention_ids, replies, reactions, interactions, masquerade, pinned, raw_flags)[source]¶
Represents a message in channel on Stoat.
This inherits from
BaseMessage.- await ack(*, http_overrides=None)[source]¶
This function is a coroutine.
Marks this message as read.
This is an alias for
acknowledge().You must have
view_channelto do this.Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- await acknowledge(*, http_overrides=None)[source]¶
This function is a coroutine.
Marks this message as read.
You must have
view_channelto do this.There is an alias for this called
ack().Fires
MessageAckEventfor the current user.Note
This can only be used by non-bot accounts.
- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
IsBotThe current token belongs to bot account.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
MissingPermissionYou do not have the proper permissions to view the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel was not found.
- property channel[source]¶
The channel this message was sent in.
- Type:
Union[
TextableChannel,PartialMessageable]
- await clear_reactions(*, http_overrides=None)[source]¶
This function is a coroutine.
Removes all the reactions from the message.
You must have
manage_messagesto do this.Fires
MessageUpdateEventwith emptyreactionsfor all users who can see target channel.- 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 remove all the reactions.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel or message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await delete(*, http_overrides=None)[source]¶
This function is a coroutine.
Deletes the message in a channel.
You must have
manage_messagesto do this if message is not yours.Fires
MessageDeleteEventfor all users who can see target channel.- 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 delete the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel or message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await edit(*, http_overrides=None, content=UNDEFINED, embeds=UNDEFINED)[source]¶
This function is a coroutine.
Edits the message.
Fires
MessageUpdateEventand optionallyMessageAppendEvent, both for all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.content (UndefinedOr[
str]) – The new content to replace the message with. Must be between 1 and 2000 characters long.embeds (UndefinedOr[List[
SendableEmbed]]) –The new embeds to replace the original with. Must be a maximum of 10. To remove all embeds
[]should be passed.You must have
send_embedsto provide this.
- Raises:
HTTPException– Possible values fortype:Value
Reason
FailedValidationThe payload was invalid.
PayloadTooLargeThe message was too large.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
Forbidden– Possible values fortype:Value
Reason
CannotEditMessageThe message you tried to edit isn’t yours.
MissingPermissionYou do not have the proper permissions to send messages.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message/file was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The newly edited message.
- Return type:
- editing()[source]¶
Editing: Returns an asynchronous context manager that allows you to send an editing indicator for a message in channel for an indefinite period of time.
- await fetch(*, http_overrides=None)[source]¶
This function is a coroutine.
Retrieves the message.
- 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 the channel.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- Returns:
The retrieved message.
- Return type:
- get_channel()[source]¶
Optional[
TextableChannel]: The channel this message was sent in.
- await pin(*, http_overrides=None)[source]¶
This function is a coroutine.
Pins the message.
You must have
manage_messagesto do this, unless the channel isDMChannel.Fires
MessageUpdateEventandMessageCreateEvent, both for all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
AlreadyPinnedThe message was already pinned.
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 pin the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await react(emoji, *, http_overrides=None)[source]¶
This function is a coroutine.
React to this message.
You must have
reactto do this.Fires
MessageReactEventfor all users who can see target channel.- Parameters:
emoji (
ResolvableEmoji) – The emoji to react with.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.
- Raises:
HTTPException– Possible values fortype:Value
Reason
InvalidOperationOne of these:
The message has too many reactions.
If
MessageInteractions.restrict_reactionsisTrue, then the emoji provided was not whitelisted.The provided emoji was invalid.
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 react.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message/custom emoji was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await reply(content=None, *, http_overrides=None, nonce=None, attachments=None, embeds=None, masquerade=None, interactions=None, silent=None, mention_everyone=None, mention_online=None, mention=True)[source]¶
This function is a coroutine.
Replies to this message.
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 target channel.- Parameters:
content (Optional[
str]) – The message content.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.masquearde (Optional[
MessageMasquerade]) –The message masquerade.
You must have
use_masqueradeto provide this.If
MessageMasquerade.coloris provided,manage_rolesis also required.interactions (Optional[
MessageInteractions]) –The message interactions.
If
MessageInteractions.reactionsis provided,reactis required.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.mention (
bool) – Whether to mention author of message you’re replying to.
- Raises:
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
MessageInteractions.reactionselements was invalid.InvalidPropertyMessageInteractions.restrict_reactionswasTruebutMessageInteractions.reactionswas 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.
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 report(reason, *, http_overrides=None, additional_context=None)[source]¶
This function is a coroutine.
Report the message to the instance moderation team.
Fires
ReportCreateEventinternally (but not fired over WebSocket).Internally, 15 messages around provided message will be snapshotted for context. All attachments of provided message are snapshotted as well.
Note
This can only be used by non-bot accounts.
- Parameters:
reason (
ContentReportReason) – The reason for reporting.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.additional_context (Optional[
str]) – The additional context for moderation team. Can be only up to 1000 characters.
- Raises:
HTTPException– Possible values fortype:Value
Reason
CannotReportYourselfYou tried to report your own message.
FailedValidationThe payload was invalid.
Unauthorized– Possible values fortype:Value
Reason
InvalidSessionThe current bot/user token is invalid.
NotFound– Possible values fortype:Value
Reason
NotFoundThe message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await unpin(*, http_overrides=None)[source]¶
This function is a coroutine.
Unpins the message.
You must have
manage_messagesto do this, unless the channel isDMChannel.Fires
MessageUpdateEventandMessageCreateEvent, both for all users who can see target channel.- Parameters:
http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.- Raises:
HTTPException– Possible values fortype:Value
Reason
NotPinnedThe message was not pinned.
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 unpin the message.
NotFound– Possible values fortype:Value
Reason
NotFoundThe channel/message was not found.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- await unreact(emoji, *, http_overrides=None, user=None, remove_all=None)[source]¶
This function is a coroutine.
Remove your own, someone else’s or all of a given reaction.
You must have
reactto do this.Fires
MessageClearReactionEventifremove_allisTrueorMessageUnreactEvent, for all users who can see target channel.- Parameters:
emoji (
ResolvableEmoji) – The emoji to remove.http_overrides (Optional[
HTTPOverrideOptions]) – The HTTP request overrides.user (Optional[ULIDOr[
BaseUser]]) –The user to remove reactions from.
You must have
manage_messagesto provide this.remove_all (Optional[
bool]) –Whether to remove all reactions.
You must have
manage_messagesto provide this.
- 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 remove reaction.
NotFound– Possible values fortype:Value
Reason
NotFoundOne of these:
The channel was not found.
The message was not found.
The user provided did not react.
InternalServerError– Possible values fortype:Value
Reason
Populated attributes
DatabaseErrorSomething went wrong during querying database.
- internal_author¶
The ID of the user (or webhook) that sent this message, or full member/user instance.
- webhook¶
The webhook that sent this message.
- Type:
Optional[
MessageWebhook]
- internal_system_event¶
The stateless system event information, occured in this message, if any.
- Type:
Optional[
StatelessSystemEvent]
- internal_attachments¶
The stateless attachments on this message.
- Type:
List[
StatelessAsset]
- internal_embeds¶
The attached stateless embeds to this message.
- Type:
List[
StatelessEmbed]
- interactions¶
The information about how this message should be interacted with.
- Type:
Optional[
MessageInteractions]
- masquerade¶
The name and / or avatar overrides for this message.
- Type:
Optional[
MessageMasquerade]
- locally_update(data, /)[source]¶
Locally updates message with provided data.
Warning
This is called by library internally to keep cache up to date.
- Parameters:
data (
PartialMessage) – The data to update message with.
- property system_event[source]¶
The system event information, occured in this message, if any.
- Type:
Optional[
SystemEvent]
Reply¶
- def to_dict
MessageMasquerade¶
- class stoat.MessageMasquerade(name=None, avatar=None, *, color=None)[source]¶
Represents overrides of name and/or avatar on message.
- name¶
The name to replace the display name on message with. Must be between 1 and 32 characters long.
- Type:
Optional[
str]
- color¶
The CSS color to replace display role color shown on message. This must be valid CSS color.
You (or webhook) must have
manage_rolespermission to set this attribute.- Type:
Optional[
str]
MessageInteractions¶
- def to_dict
- class stoat.MessageInteractions(reactions, restrict_reactions=False)[source]¶
Represents information how to guide interactions on the message.
- reactions¶
The reactions which should always appear and be distinct. Must be either emoji ID, or an unicode emoji.
- Type:
List[
str]