Message Models#

enum interactions.api.models.message.MessageType(value)[source]#

An enumerable object representing the types of messages.

Note

There is no official name for MessageType 25, however it does represent when someone subscribes to a server for the first time.

Member Type:

int

Valid values are as follows:

DEFAULT = <MessageType.DEFAULT: 0>#
RECIPIENT_ADD = <MessageType.RECIPIENT_ADD: 1>#
RECIPIENT_REMOVE = <MessageType.RECIPIENT_REMOVE: 2>#
CALL = <MessageType.CALL: 3>#
CHANNEL_NAME_CHANGE = <MessageType.CHANNEL_NAME_CHANGE: 4>#
CHANNEL_ICON_CHANGE = <MessageType.CHANNEL_ICON_CHANGE: 5>#
CHANNEL_PINNED_MESSAGE = <MessageType.CHANNEL_PINNED_MESSAGE: 6>#
GUILD_MEMBER_JOIN = <MessageType.GUILD_MEMBER_JOIN: 7>#
USER_PREMIUM_GUILD_SUBSCRIPTION = <MessageType.USER_PREMIUM_GUILD_SUBSCRIPTION: 8>#
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = <MessageType.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1: 9>#
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = <MessageType.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2: 10>#
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = <MessageType.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3: 11>#
CHANNEL_FOLLOW_ADD = <MessageType.CHANNEL_FOLLOW_ADD: 12>#
GUILD_DISCOVERY_DISQUALIFIED = <MessageType.GUILD_DISCOVERY_DISQUALIFIED: 14>#
GUILD_DISCOVERY_REQUALIFIED = <MessageType.GUILD_DISCOVERY_REQUALIFIED: 15>#
GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = <MessageType.GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING: 16>#
GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = <MessageType.GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING: 17>#
THREAD_CREATED = <MessageType.THREAD_CREATED: 18>#
REPLY = <MessageType.REPLY: 19>#
APPLICATION_COMMAND = <MessageType.APPLICATION_COMMAND: 20>#
THREAD_STARTER_MESSAGE = <MessageType.THREAD_STARTER_MESSAGE: 21>#
GUILD_INVITE_REMINDER = <MessageType.GUILD_INVITE_REMINDER: 22>#
CONTEXT_MENU_COMMAND = <MessageType.CONTEXT_MENU_COMMAND: 23>#
AUTO_MODERATION_ACTION = <MessageType.AUTO_MODERATION_ACTION: 24>#
ROLE_SUBSCRIPTION_PURCHASE = <MessageType.ROLE_SUBSCRIPTION_PURCHASE: 25>#

The Enum and its members also have the following methods:

static not_deletable()[source]#

New in version 4.4.0.

returns A list of message types which are not deletable

Return type:

List[int]

class interactions.api.models.message.Message(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing a message.

Variables:
  • id (Snowflake) – ID of the message.

  • channel_id (Snowflake) – ID of the channel the message was sent in

  • guild_id (Optional[Snowflake]) – ID of the guild the message was sent in, if it exists.

  • author (User) – The author of the message.

  • member (Optional[Member]) – The member object associated with the author, if any.

  • content (str) – Message contents.

  • timestamp (datetime) – Timestamp denoting when the message was sent.

  • edited_timestamp (Optional[datetime]) – Timestamp denoting when the message was edited, if any.

  • tts (bool) – Status dictating if this was a TTS message or not.

  • mention_everyone (bool) – Status dictating of this message mentions everyone

  • mentions (Optional[List[Union[Member, User]]]) – Array of user objects with an additional partial member field.

  • mention_roles (Optional[List[str]]) – Array of roles mentioned in this message

  • mention_channels (Optional[List[ChannelMention]]) – Channels mentioned in this message, if any.

  • attachments (List[Attachment]) – An array of attachments

  • embeds (List[Embed]) – An array of embeds

  • reactions (Optional[List[ReactionObject]]) – Reactions to the message.

  • nonce (Union[int, str]) – Used for message validation

  • pinned (bool) – Whether this message is pinned.

  • webhook_id (Optional[Snowflake]) – Webhook ID if the message is generated by a webhook.

  • type (MessageType) – Type of message

  • activity (Optional[MessageActivity]) – Message activity object that’s sent by Rich Presence

  • application (Optional[Application]) – Application object that’s sent by Rich Presence

  • message_reference (Optional[MessageReference]) – Data showing the source of a message (crosspost, channel follow, add, pin, or replied message)

  • flags (Optional[MessageFlags]) – Message flags

  • referenced_message (Optional[Message]) – The message associated with the message_reference.

  • interaction (Optional[MessageInteraction]) – Message interaction object, if the message is sent by an interaction.

  • thread (Optional[Channel]) – The thread that started from this message, if any, with a thread member object embedded.

  • components (Optional[List[ActionRow]]) – Array of Action Rows associated with this message, if any.

  • sticker_items (Optional[List[PartialSticker]]) – An array of message sticker item objects, if sent with them.

  • stickers (Optional[List[Sticker]]) – Array of sticker objects sent with the message if any. Deprecated.

  • position (Optional[int]) – The approximate position of the message in a thread.

property deletable: bool#

New in version 4.4.0.

Returns if the message can be deleted or not

property created_at: datetime#

New in version 4.4.0.

Returns when the message was created.

async get_channel()[source]#

New in version 4.0.2.

Gets the channel where the message was sent.

Return type:

Channel

async get_guild()[source]#

New in version 4.0.2.

Gets the guild where the message was sent.

Return type:

Guild

async delete(reason=None)[source]#

New in version 4.0.2.

Deletes the message.

Parameters:

reason (Optional[str]) – Optional reason to show up in the audit log. Defaults to None.

async edit(content=<interactions.MISSING>, *, tts=<interactions.MISSING>, files=<interactions.MISSING>, embeds=<interactions.MISSING>, suppress_embeds=<interactions.MISSING>, allowed_mentions=<interactions.MISSING>, message_reference=<interactions.MISSING>, attachments=<interactions.MISSING>, components=<interactions.MISSING>)[source]#

New in version 4.0.2.

This method edits a message. Only available for messages sent by the bot.

Parameters:
  • content (Optional[str]) – The contents of the message as a string or string-converted value.

  • tts (Optional[bool]) – Whether the message utilizes the text-to-speech Discord programme or not.

  • files (Optional[Union[File, List[File]]]) –

    New in version 4.2.0: A file or list of files to be attached to the message.

  • embeds (Optional[Union[Embed, List[Embed]]]) – An embed, or list of embeds for the message.

  • suppress_embeds (Optional[bool]) –

    New in version 4.3.0: Whether to suppress embeds in the message.

  • allowed_mentions (Optional[Union[AllowedMentions, dict]]) – The allowed mentions for the message.

  • attachments (Optional[List[Attachment]]) –

    New in version 4.3.0: The attachments to attach to the message. Needs to be uploaded to the CDN first

  • components (Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]]) – A component, or list of components for the message. If [] the components will be removed

Returns:

The edited message as an object.

Return type:

Message

async reply(content=<interactions.MISSING>, *, tts=<interactions.MISSING>, embeds=<interactions.MISSING>, files=<interactions.MISSING>, attachments=<interactions.MISSING>, allowed_mentions=<interactions.MISSING>, stickers=<interactions.MISSING>, components=<interactions.MISSING>)[source]#

New in version 4.0.2.

Sends a new message replying to the old.

Parameters:
  • content (Optional[str]) – The contents of the message as a string or string-converted value.

  • tts (Optional[bool]) – Whether the message utilizes the text-to-speech Discord programme or not.

  • attachments (Optional[List[Attachment]]) –

    New in version 4.3.0: The attachments to attach to the message. Needs to be uploaded to the CDN first

  • files (Optional[Union[File, List[File]]]) –

    New in version 4.2.0: A file or list of files to be attached to the message.

  • embeds (Optional[Union[Embed, List[Embed]]]) – An embed, or list of embeds for the message.

  • allowed_mentions (Optional[Union[AllowedMentions, dict]]) – The allowed mentions for the message.

  • components (Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]]) – A component, or list of components for the message.

  • stickers (Optional[List[Sticker]]) – A list of stickers to send with your message. You can send up to 3 stickers per message.

Returns:

The sent message as an object.

Return type:

Message

async pin()[source]#

New in version 4.0.2.

Pins the message to its channel

async unpin()[source]#

New in version 4.0.2.

Unpins the message from its channel

async publish()[source]#

New in version 4.0.2.

Publishes (API calls it crossposts) the message in its channel to any that is followed by.

Returns:

message object

Return type:

Message

async create_thread(name, auto_archive_duration=<interactions.MISSING>, invitable=<interactions.MISSING>, reason=None)[source]#

New in version 4.1.0.

Creates a thread from the message.

Parameters:
  • name (str) – The name of the thread

  • auto_archive_duration (Optional[int]) – duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080

  • invitable (Optional[bool]) – Boolean to display if the Thread is open to join or private.

  • reason (Optional[str]) – An optional reason for the audit log

Returns:

The created thread

Return type:

Channel

async create_reaction(emoji)[source]#

New in version 4.2.0.

Adds a reaction to the message.

Parameters:

emoji (Union[str, Emoji]) – The Emoji as object or formatted as name:id

async remove_all_reactions()[source]#

New in version 4.2.0.

Removes all reactions of the message.

async remove_all_reactions_of(emoji)[source]#

New in version 4.2.0.

Removes all reactions of one emoji of the message.

Parameters:

emoji (Union[str, Emoji]) – The Emoji as object or formatted as name:id

async remove_own_reaction_of(emoji)[source]#

New in version 4.2.0.

Removes the own reaction of an emoji of the message.

Parameters:

emoji (Union[str, Emoji]) – The Emoji as object or formatted as name:id

async remove_reaction_from(emoji, user)[source]#

New in version 4.2.0.

Removes another reaction of an emoji of the message.

Parameters:
  • emoji (Union[str, Emoji]) – The Emoji as object or formatted as name:id

  • user (Union[Member, user, int]) – The user or user_id to remove the reaction of

async get_users_from_reaction(emoji)[source]#

New in version 4.2.0.

Retrieves all users that reacted to the message with the given emoji

Parameters:

emoji (Union[str, Emoji]) – The Emoji as object or formatted as name:id

Returns:

A list of user objects

Return type:

List[User]

async classmethod get_from_url(url, client)[source]#

New in version 4.1.0.

Gets a Message based from its url.

Parameters:
  • url (str) – The full url of the message

  • client (HTTPClient) – The HTTPClient of your bot. Set client=bot._http

Returns:

The message the URL points to

Return type:

Message

property url: str#

New in version 4.2.0.

Returns the URL of the message.

Returns:

The URL of said message

Return type:

str

async disable_all_components()[source]#

New in version 4.3.2.

Sets all components to disabled on this message.

Returns:

The modified message.

Return type:

Message

class interactions.api.models.message.MessageReference(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the “referenced”/replied message.

Note

All of the attributes in this class are optionals because a message can potentially never be referenced.

Variables:
  • message_id (Optional[Snowflake]) – The ID of the referenced message.

  • channel_id (Optional[Snowflake]) – The channel ID of the referenced message.

  • guild_id (Optional[Snowflake]) – The guild ID of the referenced message.

  • fail_if_not_exists (Optional[bool]) – Whether the message reference exists.

class interactions.api.models.message.MessageActivity(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the activity state of a message.

Note

party_id is ambiguous – Discord poorly documented this. :)

We assume it’s for game rich presence invites? i.e. : Phasmophobia and Call of Duty.

Variables:
  • type (str) – The message activity type.

  • party_id (Optional[Snowflake]) – The party ID of the activity.

class interactions.api.models.message.MessageInteraction(kwargs_dict=None, /, **other_kwargs)[source]#

A class object that resembles the interaction used to generate the associated message.

Variables:
  • id (Snowflake) – ID of the interaction.

  • type (int) – Type of interaction.

  • name (str) – Name of the application command.

  • user (User) – The user who invoked the interaction.

class interactions.api.models.message.ChannelMention(kwargs_dict=None, /, **other_kwargs)[source]#

A class object that resembles the mention of a channel in a guild.

Variables:
  • id (Snowflake) – The ID of the channel.

  • guild_id (Snowflake) – The ID of the guild that contains the channel.

  • type (int) – The channel type.

  • name (str) – The name of the channel.

class interactions.api.models.message.Embed(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing an embed.

Note

The example provided below is for a very basic implementation of an embed. Embeds are more unique than what is being shown.

The structure for an embed:

interactions.Embed(
    title="Embed title",
    fields=[interactions.EmbedField(...)],
)
Variables:
  • title (Optional[str]) – Title of embed

  • type (Optional[str]) – Embed type, relevant by CDN file connected. This is only important to rendering.

  • description (Optional[str]) – Embed description

  • url (Optional[str]) – URL of embed

  • timestamp (Optional[datetime]) – Timestamp of embed content

  • color (Optional[int]) – Color code of embed

  • footer (Optional[EmbedFooter]) – Footer information

  • image (Optional[EmbedImageStruct]) – Image information

  • thumbnail (Optional[EmbedImageStruct]) – Thumbnail information

  • video (Optional[EmbedImageStruct]) – Video information

  • provider (Optional[EmbedProvider]) – Provider information

  • author (Optional[EmbedAuthor]) – Author information

  • fields (Optional[List[EmbedField]]) – A list of fields denoting field information

add_field(name, value, inline=False)[source]#

New in version 4.2.0.

Adds a field to the embed

Parameters:
  • name (str) – The name of the field

  • value (str) – The value of the field

  • inline (Optional[bool]) – if the field is in the same line as the previous one

clear_fields()[source]#

New in version 4.2.0.

Clears all the fields of the embed

insert_field_at(index, name, value, inline=False)[source]#

New in version 4.2.0.

Inserts a field in the embed at the specified index

Parameters:
  • index (int) – The field’s index to insert

  • name (str) – The name of the field

  • value (str) – The value of the field

  • inline (Optional[bool]) – if the field is in the same line as the previous one

set_field_at(index, name, value, inline=False)[source]#

New in version 4.2.0.

Overwrites the field in the embed at the specified index

Parameters:
  • index (int) – The field’s index to overwrite

  • name (str) – The name of the field

  • value (str) – The value of the field

  • inline (Optional[bool]) – if the field is in the same line as the previous one

remove_field(index)[source]#

New in version 4.2.0.

Remove field at the specified index

Parameters:

index (int) – The field’s index to remove

remove_author()[source]#

New in version 4.2.0.

Removes the embed’s author

set_author(name, url=None, icon_url=None, proxy_icon_url=None)[source]#

New in version 4.2.0.

Sets the embed’s author

Parameters:
  • name (str) – The name of the author

  • url (Optional[str]) – Url of author

  • icon_url (Optional[str]) – Url of author icon (only supports http(s) and attachments)

  • proxy_icon_url (Optional[str]) – A proxied url of author icon

New in version 4.2.0.

Sets the embed’s footer

Parameters:
  • text (str) – The text of the footer

  • icon_url (Optional[str]) – Url of footer icon (only supports http(s) and attachments)

  • proxy_icon_url (Optional[str]) – A proxied url of footer icon

set_image(url, proxy_url=None, height=None, width=None)[source]#

New in version 4.2.0.

Sets the embed’s image

Parameters:
  • url (str) – Url of the image

  • proxy_url (Optional[str]) – A proxied url of the image

  • height (Optional[int]) – The image’s height

  • width (Optional[int]) – The image’s width

set_video(url, proxy_url=None, height=None, width=None)[source]#

New in version 4.2.0.

Sets the embed’s video

Parameters:
  • url (str) – Url of the video

  • proxy_url (Optional[str]) – A proxied url of the video

  • height (Optional[int]) – The video’s height

  • width (Optional[int]) – The video’s width

set_thumbnail(url, proxy_url=None, height=None, width=None)[source]#

New in version 4.2.0.

Sets the embed’s thumbnail

Parameters:
  • url (str) – Url of the thumbnail

  • proxy_url (Optional[str]) – A proxied url of the thumbnail

  • height (Optional[int]) – The thumbnail’s height

  • width (Optional[int]) – The thumbnail’s width

class interactions.api.models.message.EmbedAuthor(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the author of an embed.

The structure of an embed author:

interactions.EmbedAuthor(
    name="fl0w#0001",
)
Variables:
  • name (str) – Name of author

  • url (Optional[str]) – URL of author

  • icon_url (Optional[str]) – URL of author icon

  • proxy_icon_url (Optional[str]) – Proxied URL of author icon

class interactions.api.models.message.EmbedProvider(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the provider of an embed.

Variables:
  • name (Optional[str]) – Name of provider

  • url (Optional[str]) – URL of provider

class interactions.api.models.message.EmbedImageStruct(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the structure of an image in an embed.

The structure of an embed image:

interactions.EmbedImageStruct(
    url="https://example.com/",
    height=300,
    width=250,
)
Variables:
  • url (str) – Source URL of the object.

  • proxy_url (Optional[str]) – Proxied url of the object.

  • height (Optional[int]) – Height of the object.

  • width (Optional[int]) – Width of the object.

class interactions.api.models.message.EmbedField(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the field of an embed.

The structure of an embed field:

interactions.EmbedField(
    name="field title",
    value="blah blah blah",
    inline=False,
)
Variables:
  • name (str) – Name of the field.

  • value (str) – Value of the field

  • inline (Optional[bool]) – A status denoting if the field should be displayed inline.

class interactions.api.models.message.Attachment(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing an attachment in a message.

Note

height and width have values based off of content_type, which requires it to be a media file with viewabiltity as a photo, animated photo, GIF and/or video.

If ephemeral is given, the attachments will automatically be removed after a set period of time. In the case of regular messages, they’re available as long as the message associated with the attachment exists.

Variables:
  • id (int) – The ID of the attachment.

  • filename (str) – The name of the attachment file.

  • description (Optional[str]) – The description of the file.

  • content_type (Optional[str]) – The type of attachment file.

  • size (int) – The size of the attachment file.

  • url (str) – The CDN URL of the attachment file.

  • proxy_url (str) – The proxied/cached CDN URL of the attachment file.

  • height (Optional[int]) – The height of the attachment file.

  • width (Optional[int]) – The width of the attachment file.

  • ephemeral (Optional[bool]) – Whether the attachment is ephemeral.

async download()[source]#

Downloads the attachment.

Returns:

The attachment’s bytes as BytesIO object

Return type:

BytesIO

class interactions.api.models.message.EmbedFooter(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing the footer of an embed.

The structure of an embed footer:

interactions.EmbedFooter(
    text="yo mama so short, she can fit in here",
)
Variables:
  • text (str) – Footer text

  • icon_url (Optional[str]) – URL of footer icon

  • proxy_icon_url (Optional[str]) – Proxied URL of footer icon

class interactions.api.models.message.ReactionObject(kwargs_dict=None, /, **other_kwargs)[source]#

The reaction object.

Variables:
  • count (int) – The amount of times this emoji has been used to react

  • me (bool) – A status denoting if the current user reacted using this emoji

  • emoji (Emoji) – Emoji information

class interactions.api.models.message.PartialSticker(kwargs_dict=None, /, **other_kwargs)[source]#

Partial object for a Sticker.

Variables:
  • id (Snowflake) – ID of the sticker

  • name (str) – Name of the sticker

  • format_type (int) – Type of sticker format

property created_at: datetime#

New in version 4.4.0.

Returns when the sticker was created.

class interactions.api.models.message.Sticker(kwargs_dict=None, /, **other_kwargs)[source]#

A class object representing a full sticker apart from a partial.

Variables:
  • id (Snowflake) – ID of the sticker

  • pack_id (Optional[Snowflake]) – ID of the pack the sticker is from.

  • name (str) – Name of the sticker

  • description (Optional[str]) – Description of the sticker

  • tags (str) – Autocomplete/suggestion tags for the sticker (max 200 characters)

  • asset (str) – Previously a sticker asset hash, now an empty string.

  • type (int) – Type of sticker

  • format_type (int) – Type of sticker format

  • available (Optional[bool]) – Status denoting if this sticker can be used. (Can be false via server boosting)

  • guild_id (Optional[Snowflake]) – Guild ID that owns the sticker.

  • user (Optional[User]) – The user that uploaded the sticker.

  • sort_value (Optional[int]) – The standard sticker’s sort order within its pack

class interactions.api.models.message.StickerPack(kwargs_dict=None, /, **other_kwargs)[source]#

A class objects representing a pack of stickers.

Variables:
  • id (Snowflake) – ID of the sticker pack.

  • stickers (List[Sticker]) – The stickers in the pack.

  • name (str) – The name of sticker pack.

  • sku_id (Snowflake) – ID of the pack’s SKU.

  • cover_sticker_id (Optional[Snowflake]) – ID of a sticker in the pack which is shown as the pack’s icon.

  • description (str) – The description of sticker pack.

  • banned_asset_id (Optional[Snowflake]) – ID of the sticker pack’s banner image.

property created_at: datetime#

New in version 4.4.0.

Returns when the sticker pack was created.