Skip to content

MessageBuilder

Note

The following classes come from the discord.parts.message module.


MessageBuilder dataclass

Bases: DataModel

Describes expected params when editing/creating a message.

content: Optional[str] = None class-attribute instance-attribute

Message text content.

flags: Optional[int] = 0 class-attribute instance-attribute

Message flags. See MessageFlags for details.

components: Optional[list[ActionRow | Container]] = field(default_factory=list) class-attribute instance-attribute

Components to be attached to this message.

attachments: Optional[list[_Attachment]] = field(default_factory=list) class-attribute instance-attribute

Attachments to be attached to this message.

embeds: Optional[list[EmbedBuilder]] = field(default_factory=list) class-attribute instance-attribute

Embeds to be attached to this message.

message_reference: Optional[_MessageReference] = None class-attribute instance-attribute

Message reference if reply.

add_row

Add an action row to this message.

Parameters:

Returns:

add_container

Add a container to this message.

Parameters:

  • container (Container) –

    the Container object.

  • has_container_boarder (bool, default: False ) –

    If message should be contained in an Embed-like container. Defaults to False.

Returns:

add_embed

Add an embed to this message.

Parameters:

Returns:

add_attachment

Add an attachment to this message

Parameters:

  • file_path (str) –

    full qualifying path to file

  • description (str, default: None ) –

    file descriptor. Defaults to None.

Returns:

set_flags

Set this message's flags using MessageFlagParams.

Parameters:

  • flags (Unpack[MessageFlagParams], default: {} ) –

    message flags to set. (set respective flag to True to toggle.)

Raises:

  • ValueError

    invalid flag

Returns:


MessageFlagParams

Bases: TypedDict

Parameters for setting message flags.

crossposted: bool instance-attribute

is_crosspost: bool instance-attribute

suppress_embeds: bool instance-attribute

ephemeral: bool instance-attribute

loading: bool instance-attribute

is_components_v2: bool instance-attribute

Note

Each parameter maps directly to a constant in MessageFlags.


MessageFlags

Flags that can be applied to a message.

CROSSPOSTED = 1 << 0 class-attribute instance-attribute

Message has been published.

IS_CROSSPOST = 1 << 1 class-attribute instance-attribute

Message originated from another channel.

SUPPRESS_EMBEDS = 1 << 2 class-attribute instance-attribute

Hide embeds (if any).

EPHEMERAL = 1 << 6 class-attribute instance-attribute

Only visible to the invoking user.

LOADING = 1 << 7 class-attribute instance-attribute

Thinking response.

IS_COMPONENTS_V2 = 1 << 15 class-attribute instance-attribute

This message includes Discord's V2 Components.