Skip to content

MessageBuilder

Note

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


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

Note

Flags are ignored if editing an existing message.

components: Optional[list[ActionRowPart | ContainerPart]] = 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[EmbedPart]] = 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.

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:

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss


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.

MessageFlagParams

Bases: TypedDict

Parameters for setting message flags. See MessageFlags.

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


MessageReference dataclass

Bases: DataModel

Represents the Message Reference object.

message_id: int instance-attribute

ID of the originating message.

channel_id: int instance-attribute

Channel ID of the originating message.

Note

Optional for default type, but REQUIRED for forwards.

type: int = MessageReferenceTypes.DEFAULT class-attribute instance-attribute

Type of reference. Defaults to DEFAULT. See MessageReferenceTypes.

to_dict

Recursively turns the dataclass into a dictionary and drops empty fields.

Returns:

  • dict

    serialized dataclasss

MessageReferenceTypes

Constants associated with how reference data is populated.

DEFAULT = 0 class-attribute instance-attribute

Standard reference used by replies.

FORWARD = 1 class-attribute instance-attribute

Reference used to point to a message at a point in time.


Attachment dataclass

Bases: DataModel

Represents an attachment.

id: int = field(init=False, default=None) class-attribute instance-attribute

ID of the attachment (internally set).

path: str instance-attribute

Relative path to the file.

description: str instance-attribute

Description of the file.

to_dict