Melisa Models Message#
Color#
Color#
- class Color[source]#
Bases:
objectRepresents a Discord colour. This class is similar to a (red, green, blue)
tuple.- value#
The raw integer colour value.
- Type:
int
- property b#
Returns the blue component of the colour.
- Type:
int
- classmethod from_hex_code(hex_code, /)[source]#
Convert the given hexadecimal color code to a Color.
The inputs may be of the following format (case insensitive): 1a2, #1a2, 0x1a2 (for web-safe colors), or 1a2b3c, #1a2b3c, 0x1a2b3c (for regular 3-byte color-codes).
- Parameters:
hex_code (
str) – A hexadecimal color code to parse. This may optionally start with a case insensitive 0x or #.- Returns:
A corresponding Color object.
- Return type:
- Raises:
ValueError – If
hex_codeis not a hexadecimal or is a invalid length.
- property g#
Returns the green component of the colour.
- Type:
int
- property r#
Returns the red component of the colour.
- Type:
int
Embed#
Embed#
- class Embed[source]#
Bases:
APIModelBaseRepresents an embed sent in with message within Discord.
- title#
Title of embed
- Type:
Optional[
str]
- description#
Description of embed
- Type:
Optional[
str]
- color#
Color code of the embed. If you really want to do something with a color, feel free to convert it to the
Color:color = Color(embed.color)
- Type:
Optional[
int]
- fields#
Fields information.
- Type:
Optional[List[
EmbedField]]
Footer information.
- Type:
Optional[
EmbedFooter]
- image#
Image information.
- Type:
Optional[
EmbedImage]
- provider#
Provider information.
- Type:
Optional[
EmbedProvider]
- thumbnail#
Thumbnail information.
- Type:
Optional[
EmbedThumbnail]
- timestamp#
Timestamp of embed content
- Type:
Optional[
Timestamp]
- url#
Url of embed
- Type:
Optional[
str]
- video#
Video information.
- Type:
Optional[
EmbedVideo]
- add_field(name, value, *, inline=False)[source]#
Adds a field to the embed object.
This function returns the class instance to allow for fluent-style chaining.
- Parameters:
name (
str) – The name of the field.value (
str) – The value of the field.inline (
bool) – Whether the field should be displayed inline.
- Returns:
This embed.
- Return type:
- edit_field(index, *, name=<UNDEFINED>, value=<UNDEFINED>, inline=<UNDEFINED>)[source]#
Edit an existing field on this embed.
- Parameters:
index (
int) – The index of the field to edit.name (Optional[
str]) – The name of the field.value (Optional[
str]) – The value of the field.inline (Optional[
bool]) – Whether the field should be displayed inline.
- Returns:
This embed.
- Return type:
- Raises:
IndexError – Raised if the index is greater than len(embed.fields) - 1 or less than -len(embed.fields)
- classmethod from_dict(data)[source]#
Generate a message from the given data.
- Parameters:
data (
dict) – The dictionary to convert into an unknown channel.
- remove_field(index)[source]#
Remove an existing field from this embed.
- Parameters:
index (
int) – The index of the embed field to remove.- Returns:
This embed.
- Return type:
- Raises:
IndexError – Raised if the index is greater than len(embed.fields) - 1 or less than -len(embed.fields)
- set_author(name, *, url=<UNDEFINED>, icon_url=<UNDEFINED>, proxy_icon_url=<UNDEFINED>)[source]#
Set the author for the embed.
- Parameters:
name (
str) – Name of authorurl (Optional[
str]) – Url of author icon (only supports http(s) and attachments)icon_url (Optional[
str]) – Url of authorproxy_icon_url (Optional[
str]) – A proxied url of author icon
- Returns:
Updated embed.
- Return type:
- set_color(color)[source]#
Sets color in the supported by discord format.
- Parameters:
color (Union[
Color,int]) – The datetime to set the timestamp to.- Returns:
The new embed object.
- Return type:
Sets the embed footer.
- Parameters:
text (
str) – Footer texticon_url (Optional[
str]) – Url of footer icon (only supports http(s) and attachments)proxy_icon_url (Optional[
str]) – A proxied url of footer icon
- Returns:
Updated embed.
- Return type:
- set_image(url, *, proxy_url=<UNDEFINED>)[source]#
Set the image for the embed.
- Parameters:
url (
str) – Source url of image (only supports http(s) and attachments)proxy_url (Optional[
str]) – A proxied url of the image
- Returns:
Updated embed.
- Return type:
- set_thumbnail(url, *, proxy_url=<UNDEFINED>)[source]#
Set the thumbnail for the embed.
- Parameters:
url (
str) – Source url of thumbnail (only supports http(s) and attachments)proxy_url (Optional[
str]) – A proxied url of the thumbnail
- Returns:
Updated embed.
- Return type:
EmbedType#
- class EmbedType[source]#
Bases:
EnumEmbed types are “loosely defined” and, for the most part, are not used by our clients for rendering. Embed attributes power what is rendered. Embed types should be considered deprecated and might be removed in a future API version.
- RICH#
Generic embed rendered from embed attributes
- IMAGE#
Image embed
- VIDEO#
Video embed
- GIFV#
Animated gif image embed rendered as a video embed
- ARTICLE#
Article embed
- LINK#
Link embed
EmbedThumbnail#
EmbedVideo#
EmbedImage#
- class EmbedImage[source]#
Bases:
objectRepresentation of the Embed Image
- url#
Source url of image (only supports http(s) and attachments)
- Type:
str
- proxy_url#
A proxied url of the image
- Type:
Optional[
str]
- height#
Height of the image
- Type:
Optional[
int]
- width#
Width of the image
- Type:
Optional[
int]
EmbedProvider#
EmbedField#
File#
File#
- class File[source]#
Bases:
objectA parameter object used for sending file objects.
- filepath#
A file-like object opened in binary mode and read mode or a filename representing a file in the hard drive to open.
Note
If the file-like object passed is opened via
openthen the modes ‘rb’ should be used. To pass binary data, consider usage ofio.BytesIO.- Type:
Union[
os.PathLike,io.BufferedIOBase]
- filename#
The filename to display when uploading to Discord. If this is not given then it defaults to
fp.nameor iffilepathis a string then thefilenamewill default to the string given.- Type:
Optional[
str]
- spoiler#
Whether the attachment is a spoiler.
- Type:
bool
Message#
AllowedMentions#
- class AllowedMentions[source]#
Bases:
objectA class that represents what mentions are allowed in a message.
- everyone#
Whether to allow everyone and here mentions. Defaults to
True.- Type:
bool
- users#
Controls the users being mentioned. If
True(the default) then users are mentioned based on the message content. IfFalsethen users are not mentioned at all. Or you can specify list of ids.- Type:
Union[
bool, List[Snowflake]]
- roles#
Controls the roles being mentioned. If
Truethen roles are mentioned based on the message content. IfFalsethen roles are not mentioned at all.- Type:
Union[
bool, List[Snowflake]]
- replied_user#
Whether to mention the author of the message being replied to.
- Type:
bool
- classmethod disabled()[source]#
A factory method that returns a
AllowedMentionswith all fields set toFalse
- classmethod enabled()[source]#
A factory method that returns a
AllowedMentionswith all fields explicitly set toTrue
MessageType#
MessageActivityType#
MessageFlags#
- class MessageFlags[source]#
Bases:
IntEnumMessage Flags
- CROSSPOSTED#
This message has been published to subscribed channels (via Channel Following)
- IS_CROSSPOST#
This message originated from a message in another channel (via Channel Following)
- SUPPRESS_EMBEDS#
Do not include any embeds when serializing this message
- SOURCE_MESSAGE_DELETED#
The source message for this crosspost has been deleted (via Channel Following)
- URGENT#
This message came from the urgent message system
- HAS_THREAD#
This message has an associated thread, with the same id as the message
- EPHEMERAL#
This message is only visible to the user who invoked the Interaction
- LOADING#
This message is an Interaction Response and the bot is “thinking”
- FAILED_TO_MENTION_SOME_ROLES_IN_THREAD#
This message failed to mention some roles and add their members to the thread
Message#
- activity
- application
- application_id
- attachments
- author
- channel
- channel_id
- components
- content
- edited_timestamp
- embeds
- flags
- guild
- guild_id
- id
- interaction
- mention_channels
- mention_everyone
- mention_roles
- mentions
- message_reference
- nonce
- pinned
- reactions
- sticker_items
- stickers
- thread
- timestamp
- tts
- type
- webhook_id
- clsMessage.from_dict
- asyncdelete
- asyncpin
- asyncunpin
- class Message[source]#
Bases:
APIModelBaseRepresents a message sent in a channel within Discord.
- id#
Id of the message
- Type:
Snowflake
- channel_id#
Id of the channel the message was sent in
- Type:
Snowflake
- channel#
Object of channel where message was sent in
- Type:
Channel
- guild#
Object of guild where message was sent in
- Type:
Guild
- guild_id#
Id of the guild the message was sent in
- Type:
Snowflake
- author#
The author of this message.
- Type:
- content#
Contents of the message
- Type:
str
- timestamp#
When this message was sent
- Type:
Timestamp
- edited_timestamp#
When this message was edited (or null if never)
- Type:
Timestamp
- tts#
Whether this was a TTS message
- Type:
bool
- mention_everyone#
Whether this message mentions everyone
- Type:
bool
- mentions#
Users specifically mentioned in the message
- Type:
typing.Any
- mention_roles#
Roles specifically mentioned in this message
- Type:
typing.Any
- mention_channels#
Channels specifically mentioned in this message
- Type:
typing.Any
- attachments#
Any attached files
- Type:
typing.Any
- embeds#
Any embedded content
- Type:
typing.Any
- reactions#
Reactions to the message
- Type:
typing.Any
- nonce#
Used for validating a message was sent
- Type:
intor str
- pinned#
Whether this message is pinned
- Type:
bool
- webhook_id#
If the message is generated by a webhook, this is the webhook’s id
- Type:
Snowflake
- type#
Type of message
- Type:
- activity#
Sent with Rich Presence-related chat embeds
- Type:
typing.Any
- application#
Sent with Rich Presence-related chat embeds
- Type:
typing.Any
- application_id#
If the message is an Interaction or application-owned webhook, this is the id of the application
- Type:
Snowflake
- message_reference#
Data showing the source of a crosspost, channel follow add, pin, or reply message
- Type:
typing.Any
- flags#
Message flags combined as a bitfield
- Type:
int
- interaction#
Sent if the message is a response to an Interaction
- Type:
typing.Any
- thread#
The thread that was started from this message, includes thread member object
- Type:
typing.Any
- components#
Sent if the message contains components like buttons, action rows, or other interactive components
- Type:
typing.Any
- sticker_items#
Sent if the message contains stickers
- Type:
typing.Any
- stickers#
Deprecated the stickers sent with the message
- Type:
typing.Any
- await delete(*, delay=None)[source]#
This function is a coroutine.
Deletes the message.
- Parameters:
delay (Optional[
float]) – If provided, the number of seconds to wait in the background before deleting the message.- Raises:
Forbidden – You do not have proper permissions to delete the message.
NotFound – The message was deleted already
HTTPException – Deleting the message failed.
- classmethod from_dict(data)[source]#
Generate a message from the given data.
- Parameters:
data (
dict) – The dictionary to convert into an unknown channel.
- await pin(*, reason=None)[source]#
This function is a coroutine.
Pins the message.
You must have the
MANAGE_MESSAGESpermission to do this in a non-private channel context.- Parameters:
reason (Optional[
str]) – The reason for pinning the message. Shows up on the audit log.- Raises:
HTTPException – Pinning the message failed, probably due to the channel having more than 50 pinned messages.
ForbiddenError – You do not have permissions to pin the message.
NotFound – The message or channel was not found or deleted.
- await unpin(*, reason=None)[source]#
This function is a coroutine.
Unpins the message.
You must have the
MANAGE_MESSAGESpermission to do this in a non-private channel context.- Parameters:
reason (Optional[
str]) – The reason for unpinning the message. Shows up on the audit log.- Raises:
HTTPException – Pinning the message failed, probably due to the channel having more than 50 pinned messages.
ForbiddenError – You do not have permissions to unpin the message.
NotFound – The message or channel was not found or deleted.