Message

Manager

class MessageManager(client: HTTPClient, cache: CacheStorage)

Bases: BaseManager

Manager used to fetch Message objects.

get(message_id: int) Message | None

Attempts to fetch a Message from the internal cache of the bot.

Parameters:

message_id (int) – The ID of the message to fetch.

Returns:

  • Message – The Message received from the cache.

  • None – Could not find the Message object in the internal cache.

async fetch(channel_id: int, message_id: int) Message

Attempts to fetch a Message from 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 Message from 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 as CONNECT for 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>, 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 must be provided. For forwarding, only message_reference must 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.

  • message_reference (MessageReference) – The reference message for the new message, if any

  • 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.

  • 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>, 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 must 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.

  • 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:
  • target_channel_id (int) – The ID of the target Channel.

  • message_id (int) – The ID to the message to forward.

  • channel_id (int) – The ID of the source Channel.

  • guild_id (int, optional) – The ID of the source Guild.

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_MESSAGES for your own messages, and MANAGE_MESSAGES when crossposting messages sent by others.

Parameters:
  • channel_id (int) – The ID of the announcement channel.

  • message_id (int) – The ID of the message to crosspost.

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 requires ADD_REACTIONS if no one has reacted with this emoji.

Parameters:
  • channel_id (int) – The ID of the channel the target message is in.

  • 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.

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, 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.

  • 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 remove_user_reaction(user_id: int, *, channel_id: int, message_id: int, emoji_id: int = <mizuki._utils.Missing object>, emoji_name: str) None

Removes a specific user’s reaction from a message.

Parameters:
  • user_id (int) – The ID of the user to delete reaction of.

  • channel_id (int) – The ID of the channel the target message is in.

  • 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.

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 get_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 fetches NORMAL.

  • 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:
  • 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.

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 delete_all_reactions(*, channel_id: int, message_id: int) None

Removes all reactions from a message. This method requires MANAGE_MESSAGES.

Parameters:
  • channel_id (int) – The ID of the channel containing the target message.

  • message_id (int) – The ID of the target message.

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>) Message

Edits a message sent by you.

Parameters:
  • channel_id (int | None) – The ID of the channel the target message is in. Pass None to 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. Pass None to set this back to default.

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_MESSAGES if deleting a message from someone else.

Parameters:
  • channel_id (int) – The ID of the channel to delete the message from.

  • message_id (int) – The ID of the message to delete.

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:
  • channel_id (int) – The ID of the channel to delete the message from.

  • message_ids (list[int]) – The list of ID of the messages to delete. Minimum and maximum length of list required are 2 and 100 respectively.

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)

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
classmethod new(*, type: MessageReferenceType = MessageReferenceType.DEFAULT, message_id: int, channel_id: int = <mizuki._utils.Missing object>, guild_id: int = <mizuki._utils.Missing object>, fail_if_not_exists: bool = True) Self
class MessageActivity(data: MessageActivityPayload)

Bases: object

type
party_id
class PartialMessage(data: PartialMessagePayload)

Bases: object

content
embeds
attachments
timestamp
edited_timestamp
flags
mentions
mention_roles
type
class MessageSnapshot(data: MessageSnapshotPayload)

Bases: object

message
class MessageInteractionMetadata(data: MessageInteractionMetadataPayload)

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 PollMedia(data: PollMediaPayload)

Bases: object

text
emoji
class PollAnswer(data: PollAnswerPayload)

Bases: object

answer_id
poll_media
class PollAnswerCount(data: PollAnswerCountPayload)

Bases: object

id
count
me_voted
class PollResult(data: PollResultPayload)

Bases: object

is_finalized
answer_counts
class Poll(data: PollPayload)

Bases: object

question
answers
expiry
allow_multiselect
layout_type
results
class SharedClientTheme(data: SharedClientThemePayload)

Bases: object

colors
gradient_angle
base_mix
base_theme
class AllowedMentions(data: AllowedMentionsPayload)

Bases: object

parse
classmethod new(*, roles: bool = True, users: bool = True, everyone: bool = True) Self
class Message(data: MessagePayload)

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
shared_client_theme
attachments
content
edited_timestamp
embeds
flags
mention_roles
mentions
timestamp
type

Enums

class MessageReferenceType(*values)
DEFAULT = 0
FORWARD = 1
class MessageActivityType(*values)
JOIN = 1
SPECTATE = 2
LISTEN = 3
JOIN_REQUEST = 5
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
class BaseThemeType(*values)
UNSET = 0
DARK = 1
LIGHT = 2
DARKER = 3
MIDNIGHT = 4
class ReactionType(*values)
NORMAL = 0
BURST = 1