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:
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:
- 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.
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.
- async get_channel()[source]#
New in version 4.0.2.
Gets the channel where the message was sent.
- Return type:
- async get_guild()[source]#
New in version 4.0.2.
Gets the guild where the message was sent.
- Return type:
- 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:
- 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:
- 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:
- 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:
- async remove_all_reactions_of(emoji)[source]#
New in version 4.2.0.
Removes all reactions of one emoji of the message.
- async remove_own_reaction_of(emoji)[source]#
New in version 4.2.0.
Removes the own reaction of an emoji of the message.
- async remove_reaction_from(emoji, user)[source]#
New in version 4.2.0.
Removes another reaction of an emoji of the message.
- 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
- async classmethod get_from_url(url, client)[source]#
New in version 4.1.0.
Gets a Message based from its url.
- 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:
- 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.
- 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.
- 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.
- 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
- 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
- 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
- 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
- set_author(name, url=None, icon_url=None, proxy_icon_url=None)[source]#
New in version 4.2.0.
Sets the embed’s author
New in version 4.2.0.
Sets the embed’s footer
- set_image(url, proxy_url=None, height=None, width=None)[source]#
New in version 4.2.0.
Sets the embed’s image
- set_video(url, proxy_url=None, height=None, width=None)[source]#
New in version 4.2.0.
Sets the embed’s video
- 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", )
- class interactions.api.models.message.EmbedProvider(kwargs_dict=None, /, **other_kwargs)[source]#
A class object representing the provider of an embed.
- 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, )
- 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, )
- class interactions.api.models.message.Attachment(kwargs_dict=None, /, **other_kwargs)[source]#
A class object representing an attachment in a message.
Note
height
andwidth
have values based off ofcontent_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.
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", )
- class interactions.api.models.message.ReactionObject(kwargs_dict=None, /, **other_kwargs)[source]#
The reaction object.
- class interactions.api.models.message.PartialSticker(kwargs_dict=None, /, **other_kwargs)[source]#
Partial object for a Sticker.
- Variables:
- 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.