Message#
Manager#
- class MessageManager(state: ConnectionState, cache: CacheStorage)#
Bases:
BaseManagerManager used to fetch
Messageobjects.- get(message_id: int) Message | None#
Attempts to fetch a
Messagefrom the internal cache of the bot.
- async fetch(channel_id: int, message_id: int) Message#
Attempts to fetch a
Messagefrom the Discord API.- Parameters:
message_id (
int) – The ID of the message to fetch.- Raises:
NotFound – Could not find a message with that ID.
Forbidden – You are not allowed to fetch that message.
HTTPException – A HTTP error occurred.
- async get_or_fetch(channel_id: int, message_id: int) Message#
A coroutine function that attempts to fetch a
Messagefrom internal cache and if not present, fetches it from Discord.- Parameters:
message_id (
int) – The message_id of the message to fetch.- Raises:
NotFound – Could not find a message with that ID.
Forbidden – You are not allowed to fetch that message.
HTTPException – A HTTP error occurred.
- async fetch_channel_messages(channel_id: int, *, around: int = _MISSING, limit: int = _MISSING) list[Message]#
- async fetch_channel_messages(channel_id: int, *, before: int = _MISSING, limit: int = _MISSING) list[Message]
- async fetch_channel_messages(channel_id: int, *, after: int = _MISSING, limit: int = _MISSING) list[Message]
Fetches the messages in a channel based on the parameters.
On a Guild Channel,
VIEW_CHANNEL(as well asCONNECTfor a voice channel) are needed for fetching messages.Returns an empty array if missing
READ_MESSAGE_HISTORY.Note
The before, after, and around parameters are mutually exclusive, only one may be passed at a time.
- Parameters:
channel_id (
int) – The ID of the channel to fetch messages from.around (
int, optional) – To fetch messages around this message ID.before (
int, optional) – To fetch messages before this message ID.after (
int, optional) – To fetch messages after this message ID.limit (
int, optional) – Max number of messages to return. Can be 1-100. Defaults to 50.
- Raises:
NotFound – Could not find a message with that ID.
Forbidden – You are not allowed to fetch those messages.
HTTPException – A HTTP error occurred.
- async create(channel_id: int, *, content: str = <mizuki._utils.Missing object>, tts: bool = <mizuki._utils.Missing object>, embeds: list[Embed] = <mizuki._utils.Missing object>, allowed_mentions: AllowedMentions = <mizuki._utils.Missing object>, message_reference: MessageReference = <mizuki._utils.Missing object>, files: list[File] = <mizuki._utils.Missing object>, sticker_ids: list[int] = <mizuki._utils.Missing object>, flags: MessageFlags = <mizuki._utils.Missing object>) Message#
Creates a new message in the specified channel.
Note
At least one of,
content,embeds,sticker_ids,filesmust be provided. For forwarding, onlymessage_referencemust be provided.- Parameters:
channel_id (
int) – The ID of the Channel to send message to.content (
str) – The content of the message.tts (
bool) – Whether TTS is enabled for the message.embeds (list[
Embed]) – The list of embeds to send along the message.allowed_mentions (
AllowedMentions) – The AllowedMentions object that dictates whether user, role or everyone pings are enabled.files (list[
File]) – The files to upload with the message.message_reference (
MessageReference) – The reference message for the new message, if anysticker_ids (list[
int]) – The Guild Stickers to send with the message. Max 3.flags (
MessageFlags) – The MessageFlags of the new message.
- Raises:
NotFound – The channel you tried to send to doesn’t exist.
Forbidden – You are not allowed to send the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async reply(channel_id: int, message_id: int, *, content: str = <mizuki._utils.Missing object>, tts: bool = <mizuki._utils.Missing object>, embeds: list[Embed] = <mizuki._utils.Missing object>, allowed_mentions: AllowedMentions = <mizuki._utils.Missing object>, files: list[File] = <mizuki._utils.Missing object>, sticker_ids: list[int] = <mizuki._utils.Missing object>, flags: MessageFlags = <mizuki._utils.Missing object>) Message#
Creates a new reply to a message in the specified channel.
Note
At least one of,
content,embeds,sticker_ids,filesmust be provided.- Parameters:
channel_id (
int) – The ID of the Channel to send reply to.message_id (
int) – The ID of the Message to reply to.content (
str) – The content of the message.tts (
bool) – Whether TTS is enabled for the message.embeds (list[
Embed]) – The list of embeds to send along the message.allowed_mentions (
AllowedMentions) – The AllowedMentions object that dictates whether user, role or everyone pings are enabled.files (list[
File]) – The files to upload with the message.sticker_ids (list[
int]) – The Guild Stickers to send with the message. Max 3.flags (
MessageFlags) – The MessageFlags of the new message.
- Raises:
NotFound – The channel you tried to send to doesn’t exist or the message you replied to doesn’t exist.
Forbidden – You are not allowed to send the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async forward(target_channel_id: int, *, message_id: int, channel_id: int, guild_id: int = <mizuki._utils.Missing object>) Message#
Forwards a message to a channel.
- Parameters:
- Raises:
NotFound – The channel you tried to send to doesn’t exist or the message you tried to forward doesn’t exist.
Forbidden – You are not allowed to send the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async crosspost(channel_id: int, message_id: int) Message#
Crossposts a message from an Announcement Channel to all following channels.
This requires
SEND_MESSAGESfor your own messages, andMANAGE_MESSAGESwhen crossposting messages sent by others.- Parameters:
- Raises:
NotFound – The channel you tried to crosspost from doesn’t exist or the message you tried to crosspost doesn’t exist.
Forbidden – You are not allowed to crosspost the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async react(*, channel_id: int, message_id: int, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str) None#
Adds a reaction to a message.
Requires
READ_MESSAGE_HISTORY. Also requiresADD_REACTIONSif no one has reacted with this emoji.- Parameters:
- Raises:
NotFound – The message you tried to react to or the emoji you tried to react with wasn’t found.
Forbidden – You are not allowed to react/see the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async remove_reaction(*, channel_id: int, message_id: int, user_id: int = <mizuki._utils.Missing object>, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str) None#
Removes your reaction from a message.
- Parameters:
channel_id (
int) – The ID of the channel the target message is in.message_id (
int) – The ID of the target message.user_id (
int, optional) – The ID of the target user. Defaults to the client user.emoji_id (
int, optional) – The ID of the custom emoji. Omit when reacting with a unicode emoji.emoji_name (
str) – The unicode emoji or the name of the custom emoji.
- Raises:
NotFound – The message you tried to remove reaction from or the emoji you tried to remove reaction of wasn’t found.
Forbidden – You are not allowed to remove reaction/see the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async fetch_reactions(*, channel_id: int, message_id: int, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str, type: ReactionType = <mizuki._utils.Missing object>, after: int = <mizuki._utils.Missing object>, limit: int = <mizuki._utils.Missing object>) list[User]#
Fetch a list of users that reacted with this emoji.
- Parameters:
channel_id (
int) – The ID of the channel containing the target message.message_id (
int) – The ID of the target message.emoji_id (
int, optional) – The ID of the custom emoji. Omit when reacting with a unicode emoji.emoji_name (
str) – The unicode emoji or the name of the custom emoji.type (
ReactionType, optional) – The type of the reaction to fetch. Defaults to fetchesNORMAL.after (
int, optional) – To fetch the list starting after the specified user ID.limit (
int, optional) – The max number of users to retrieve. Can be 1-100. Defaults to 25.
- Raises:
NotFound – The message you tried to fetch reactions of could not be found.
Forbidden – You are not allowed to fetch the message.
HTTPException – A HTTP error occurred.
- async delete_emoji_reactions(*, channel_id: int, message_id: int, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str) None#
Removes all reactions of a specified emoji from a message. This method requires
MANAGE_MESSAGES.- Parameters:
- Raises:
NotFound – The message you tried to do this action on or the emoji does not exist.
Forbidden – You are not allowed to fetch the message. Or you are missing the permissions to do this action.
HTTPException – A HTTP error occurred.
- async remove_all_reactions(*, channel_id: int, message_id: int) None#
Removes all reactions from a message. This method requires
MANAGE_MESSAGES.- Parameters:
- Raises:
NotFound – The message you tried to do this action on does not exist.
Forbidden – You are not allowed to fetch the message. Or you are missing the permissions to do this action.
HTTPException – A HTTP error occurred.
- async edit(*, channel_id: int, message_id: int, content: str | None = <mizuki._utils.Missing object>, embeds: list[Embed] = <mizuki._utils.Missing object>, flags: MessageFlags = <mizuki._utils.Missing object>, allowed_mentions: AllowedMentions | None = <mizuki._utils.Missing object>, files: list[File] = <mizuki._utils.Missing object>, override_files: bool = True) Message#
Edits a message sent by you.
- Parameters:
channel_id (
int|None) – The ID of the channel the target message is in. PassNoneto clear content.message_id (
int) – The ID of the target message.content (
str) – The content of the message.embeds (list[
Embed]) – The embeds of the message.flags (
MessageFlags) – The flags of the message.allowed_mentions (
AllowedMentions|None) – The AllowedMentions object that dictates whether user, role or everyone pings are enabled. PassNoneto set this back to default.files (list[
File]) – The files to upload to the message.override_files (
bool) – Whether to override or append the files to the message. Description is ignored when this is set toFalse
- Raises:
NotFound – The message you tried to edit was not found.
Forbidden – You are not allowed to edit that message.
HTTPException – A HTTP error occurred.
- async delete(*, channel_id: int, message_id: int) None#
Deletes a message from a channel.
This method requires
MANAGE_MESSAGESif deleting a message from someone else.- Parameters:
- Raises:
NotFound – The message you tried to delete does not exist.
Forbidden – You are not allowed to delete that message.
HTTPException – A HTTP error occurred.
- async bulk_delete(*, channel_id: int, message_ids: list[int]) None#
Bulk deletes messages from a channel.
This method requires
MANAGE_MESSAGES.- Parameters:
- Raises:
NotFound – The channel you tried to bulk delete from does not exist.
Forbidden – You do not have the required permission to bulk delete.
HTTPException – A HTTP error occurred.
Message#
- class Attachment(data: AttachmentPayload, *, state: ConnectionState)#
Bases:
object- id#
- filename#
- title#
- description#
- content_type#
- size#
- url#
- proxy_url#
- height#
- width#
- placeholder#
- placeholder_version#
- ephemeral#
- duration_secs#
- waveform#
- flags#
- clip_participants#
- clip_created_at#
- application#
- class MessageReference(data: MessageReferencePayload)#
Bases:
object- type#
- message_id#
- channel_id#
- guild_id#
- fail_if_not_exists#
- class PartialMessage(data: PartialMessagePayload, *, state: ConnectionState)#
Bases:
object- content#
- embeds#
- attachments#
- timestamp#
- edited_timestamp#
- flags#
- mentions#
- mention_roles#
- type#
- class MessageSnapshot(data: MessageSnapshotPayload, *, state: ConnectionState)#
Bases:
object- message#
- class MessageInteractionMetadata(data: MessageInteractionMetadataPayload, *, state: ConnectionState)#
Bases:
object- id#
- type#
- user#
- authorizing_integration_owners#
- original_response_message_id#
- target_user#
- target_message_id#
- class RoleSubscriptionData(data: RoleSubscriptionDataPayload)#
Bases:
object- role_subscription_listing_id#
- tier_name#
- total_months_subscribed#
- is_renewal#
- class Poll(data: PollPayload)#
Bases:
object- question#
- answers#
- expiry#
- allow_multiselect#
- layout_type#
- results#
Bases:
object
- class Message(data: MessagePayload, *, state: ConnectionState)#
Bases:
PartialMessage- id#
- channel_id#
- author#
- tts#
- mention_everyone#
- mention_channels#
- reactions#
- nonce#
- pinned#
- webhook_id#
- activity#
- application#
- application_id#
- message_reference#
- message_snapshots#
- referenced_message#
- interaction_metadata#
- thread#
- components#
- sticker_items#
- position#
- role_subscription_data#
- poll#
- async reply(content: str = <mizuki._utils.Missing object>, *, tts: bool = <mizuki._utils.Missing object>, embeds: list[Embed] = <mizuki._utils.Missing object>, allowed_mentions: AllowedMentions = <mizuki._utils.Missing object>, files: list[File] = <mizuki._utils.Missing object>, sticker_ids: list[int] = <mizuki._utils.Missing object>, flags: MessageFlags = <mizuki._utils.Missing object>) Message#
Creates a new reply to a message in the specified channel.
Note
At least one of,
content,embeds,sticker_ids,filesmust be provided.- Parameters:
content (
str) – The content of the message.tts (
bool) – Whether TTS is enabled for the message.embeds (list[
Embed]) – The list of embeds to send along the message.allowed_mentions (
AllowedMentions) – The AllowedMentions object that dictates whether user, role or everyone pings are enabled.files (list[
File]) – The files to upload with the message.sticker_ids (list[
int]) – The Guild Stickers to send with the message. Max 3.flags (
MessageFlags) – The MessageFlags of the new message.
- Raises:
NotFound – The channel you tried to send to doesn’t exist or the message you replied to doesn’t exist.
Forbidden – You are not allowed to send the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async forward(target_channel_id: int) Message#
Forwards a message to a channel.
- Parameters:
target_channel_id (
int) – The ID of the target Channel.- Raises:
NotFound – The channel you tried to send to doesn’t exist or the message you tried to forward doesn’t exist.
Forbidden – You are not allowed to send the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async crosspost() Message#
Crossposts a message from an Announcement Channel to all following channels.
This requires
SEND_MESSAGESfor your own messages, andMANAGE_MESSAGESwhen crossposting messages sent by others.- Raises:
NotFound – The channel you tried to crosspost from doesn’t exist or the message you tried to crosspost doesn’t exist.
Forbidden – You are not allowed to crosspost the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async react(*, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str) None#
Adds a reaction to a message.
Requires
READ_MESSAGE_HISTORY. Also requiresADD_REACTIONSif no one has reacted with this emoji.- Parameters:
- Raises:
NotFound – The message you tried to react to or the emoji you tried to react with wasn’t found.
Forbidden – You are not allowed to react/see the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async remove_reaction(*, user_id: int = <mizuki._utils.Missing object>, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str) None#
Removes your reaction from a message.
- Parameters:
- Raises:
NotFound – The message you tried to remove reaction from or the emoji you tried to remove reaction of wasn’t found.
Forbidden – You are not allowed to remove reaction/see the message. You may be missing a specific permission.
HTTPException – A HTTP error occurred.
- async remove_all_reactions() None#
Removes all reactions from a message. This method requires
MANAGE_MESSAGES.- Raises:
NotFound – The message you tried to do this action on does not exist.
Forbidden – You are not allowed to fetch the message. Or you are missing the permissions to do this action.
HTTPException – A HTTP error occurred.
- async fetch_reactions(*, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str, type: ReactionType = <mizuki._utils.Missing object>, after: int = <mizuki._utils.Missing object>, limit: int = <mizuki._utils.Missing object>) list[User]#
Fetch a list of users that reacted with this emoji.
- Parameters:
emoji_id (
int, optional) – The ID of the custom emoji. Omit when reacting with a unicode emoji.emoji_name (
str) – The unicode emoji or the name of the custom emoji.type (
ReactionType, optional) – The type of the reaction to fetch. Defaults to fetchesNORMAL.after (
int, optional) – To fetch the list starting after the specified user ID.limit (
int, optional) – The max number of users to retrieve. Can be 1-100. Defaults to 25.
- Raises:
NotFound – The message you tried to fetch reactions of could not be found.
Forbidden – You are not allowed to fetch the message.
HTTPException – A HTTP error occurred.
- async edit(content: str | None = <mizuki._utils.Missing object>, *, embeds: list[Embed] = <mizuki._utils.Missing object>, flags: MessageFlags = <mizuki._utils.Missing object>, allowed_mentions: AllowedMentions | None = <mizuki._utils.Missing object>, files: list[File] = <mizuki._utils.Missing object>, override_files: bool = True) Message#
Edits a message sent by you.
- Parameters:
content (
str) – The content of the message.embeds (list[
Embed]) – The embeds of the message.flags (
MessageFlags) – The flags of the message.allowed_mentions (
AllowedMentions|None) – The AllowedMentions object that dictates whether user, role or everyone pings are enabled. PassNoneto set this back to default.files (list[
File]) – The files to upload to the message.override_files (
bool) – Whether to override or append the files to the message. Description is ignored when this is set toFalse
- Raises:
NotFound – The message you tried to edit was not found.
Forbidden – You are not allowed to edit that message.
HTTPException – A HTTP error occurred.
- async delete() None#
Deletes a message from a channel.
This method requires
MANAGE_MESSAGESif deleting a message from someone else.- Raises:
NotFound – The message you tried to delete does not exist.
Forbidden – You are not allowed to delete that message.
HTTPException – A HTTP error occurred.
- attachments#
- content#
- edited_timestamp#
- embeds#
- flags#
- mention_roles#
- mentions#
- timestamp#
- type#
Enums#
- class MessageType(*values)#
- DEFAULT = 0#
- RECIPIENT_ADD = 1#
- RECIPIENT_REMOVE = 2#
- CALL = 3#
- CHANNEL_NAME_CHANGE = 4#
- CHANNEL_ICON_CHANGE = 5#
- CHANNEL_PINNED_MESSAGE = 6#
- USER_JOIN = 7#
- GUILD_BOOST = 8#
- GUILD_BOOST_TIER_1 = 9#
- GUILD_BOOST_TIER_2 = 10#
- GUILD_BOOST_TIER_3 = 11#
- CHANNEL_FOLLOW_ADD = 12#
- GUILD_DISCOVERY_DISQUALIFIED = 14#
- GUILD_DISCOVERY_REQUALIFIED = 15#
- GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = 16#
- GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = 17#
- THREAD_CREATED = 18#
- REPLY = 19#
- CHAT_INPUT_COMMAND = 20#
- THREAD_STARTER_MESSAGE = 21#
- GUILD_INVITE_REMINDER = 22#
- CONTEXT_MENU_COMMAND = 23#
- AUTO_MODERATION_ACTION = 24#
- ROLE_SUBSCRIPTION_PURCHASE = 25#
- INTERACTION_PREMIUM_UPSELL = 26#
- STAGE_START = 27#
- STAGE_END = 28#
- STAGE_SPEAKER = 29#
- STAGE_TOPIC = 31#
- GUILD_APPLICATION_PREMIUM_SUBSCRIPTION = 32#
- GUILD_INCIDENT_ALERT_MODE_ENABLED = 36#
- GUILD_INCIDENT_ALERT_MODE_DISABLED = 37#
- GUILD_INCIDENT_REPORT_RAID = 38#
- GUILD_INCIDENT_REPORT_FALSE_ALARM = 39#
- PURCHASE_NOTIFICATION = 44#
- POLL_RESULT = 46#