Pincer Objects Message Section¶
Attachment¶
Attachment¶
- class Attachment¶
Bases:
pincer.utils.api_object.APIObject
Represents a Discord Attachment object
Component¶
MessageComponent¶
- class MessageComponent¶
Bases:
pincer.utils.api_object.APIObject
Represents a Discord Message Component object
- options¶
The choices in the select, max 25
- Type
List[
SelectOption
]
- custom_id¶
A developer-defined identifier for the component, max 100 characters
- Type
APINullable[
str
]
- style¶
One of button styles
- Type
APINullable[
ButtonStyle
]
- placeholder¶
Custom placeholder text if nothing is selected, max 100 characters
- Type
APINullable[
str
]
- min_values¶
The minimum number of items that must be chosen;
Default:1
, min0
, max25
- Type
APINullable[
int
]
- max_values¶
The maximum number of items that can be chosen;
Default:1
, max25
- Type
APINullable[
int
]
- components¶
A list of child components
- Type
APINullable[List[
MessageComponent
]]
Context¶
MessageContext¶
- class MessageContext¶
Bases:
object
Represents the context of a message interaction.
- author¶
The user whom invoked the interaction.
- Type
Union[
GuildMember
,User
]
- command¶
The local command object for the command to whom this context belongs.
- guild_id¶
The ID of the guild the interaction was invoked in. Can be None if it wasn’t invoked in a guild.
- Type
Optional[
Snowflake
]
- channel_id¶
The ID of the channel the interaction was invoked in. Can be None if it wasn’t invoked in a channel.
- Type
Optional[
Snowflake
]
- await ack(flags=None)¶
This function is a coroutine.
Alias for
ack()
.:param flags
InteractionFlags
: The flags which must be applied to the reply.
- await followup(message)¶
This function is a coroutine.
Alias for
followup()
.:param message
MessageConvertable
: The message to sent.
- await reply(message)¶
This function is a coroutine.
Alias for
reply()
.:param message
MessageConvertable
: The response message!
- await send(message)¶
This function is a coroutine.
Send a response for an interaction. This object returns the sent object and may be used several times after each other. (first one will always be the main interaction response)
reply()
Method gets called for initial send.
response()
Method gets called for initial send to get response.
followup()
Method gets called for second message and onwards.
UserMessage
The message that was sent.
Embed¶
EmbedImage¶
EmbedProvider¶
EmbedThumbnail¶
EmbedVideo¶
EmbedField¶
Embed¶
- defadd_field
- defadd_fields
- defset_author
- defset_footer
- defset_image
- defset_thumbnail
- defset_timestamp
- class Embed¶
Bases:
pincer.utils.api_object.APIObject
Representation of the discord Embed class
- fields¶
Fields information.
- Type
List[
EmbedField
]
Footer information.
- Type
APINullable[
EmbedFooter
]
- image¶
Image information.
- Type
APINullable[
EmbedImage
]
- provider¶
Provider information.
- Type
APINullable[
EmbedProvider
]
- thumbnail¶
Thumbnail information.
- Type
APINullable[
EmbedThumbnail
]
- video¶
Video information.
- Type
APINullable[
EmbedVideo
]
- add_field(name, value, inline=<MISSING>)¶
Adds a field to the embed. An embed can contain up to 25 fields.
- add_fields(field_list, checks=<class 'bool'>, map_title=<class 'str'>, map_values=<class 'str'>, inline=True)¶
Add multiple fields from a list, dict or generator of fields with possible mapping.
- Parameters
field_list (Union[Dict[Any, Any], Iterable[Iterable[Any, Any]]]) – A iterable or generator of the fields to add. If the field_list type is a dictionary, will take items.
checks (Optional[Callable[[Any], Any]]) – A filter function to remove embed fields.
map_title (Optional[Callable[[Any],
str
]]) – A transform function to change the titles.map_values (Optional[Callable[[Any],
str
]]) – A transform function to change the values.inline (
bool
) – Whether to create grid or each field on a new line.
- Raises
EmbedFieldError: – Raised when there are more than 25 fields in the embed
- Returns
The new embed object.
- Return type
- set_author(icon_url=<MISSING>, name=<MISSING>, proxy_icon_url=<MISSING>, url=<MISSING>)¶
Set the author message for the embed. This is the top field of the embed.
- Parameters
icon_url (APINullable[
str
]) – The icon which will be next to the author name.name (APINullable[
str
]) – The name for the author (so the message).proxy_icon_url (APINullable[
str
]) – A proxied url of the author icon.url (APINullable[
str
]) – The url for the author name, this will make the name field a link/url.
- Returns
The new embed object.
- Return type
Sets the embed footer. This is at the bottom of your embed.
- set_image(url=<MISSING>, proxy_url=<MISSING>, height=<MISSING>, width=<MISSING>)¶
Sets an image for your embed.
- set_thumbnail(height=<MISSING>, url=<MISSING>, proxy_url=<MISSING>, width=<MISSING>)¶
Sets the thumbnail of the embed. This image is bigger than the
image
property.- url: APINullable[
str
] Source url of the video
- proxy_url: APINullable[
str
] A proxied url of the video
- height: APINullable[
int
] Height of the video
- width: APINullable[
int
] Width of the video
- Returns
The new embed object.
- Return type
- url: APINullable[
- set_timestamp(time)¶
Discord uses iso format for time stamps. This function will set the time to that format.
- Parameters
time (
datetime.datetime
) – The datetime to set the timestamp to.- Returns
The new embed object.
- Return type
Emoji¶
Emoji¶
- class Emoji¶
Bases:
pincer.utils.api_object.APIObject
Representation of an emoji in a class.
File¶
File¶
- class File¶
Bases:
pincer.utils.api_object.APIObject
A file that is prepared by the user to be send to the discord API.
- classmethod from_file(filepath, filename=None)¶
Make a
File
object from a file stored locally.
- classmethod from_pillow_image(img, filename, image_format=None, **kwargs)¶
Creates a file object from a PIL image Supports GIF, PNG, JPEG, and WEBP.
- Parameters
img (
Image
) – Pillow image object.filename – The filename to be used when uploaded to discord. The extension is used as image_format unless otherwise specified.
image_format – The image_format to be used if you want to override the file extension.
- Returns
The new file object.
- Return type
- Raises
ModuleNotFoundError: –
Pillow
is not installed
Message¶
AllowedMentions¶
- class AllowedMentions¶
Bases:
pincer.utils.api_object.APIObject
Represents the entities the client can mention
- parse¶
An array of allowed mention types to parse from the content.
- Type
List[
AllowedMentionTypes
]
- to_dict()¶
Transform the current object to a dictionary representation.
Message¶
- defserialize
- class Message¶
Bases:
object
A discord message that will be send to discord
- attachments¶
Attachments on the message. This is a File object. You can also attach a Pillow Image or string. Pillow images will be converted to PNGs. They will use the naming scheme
image%
where % is the images index in the attachments array. Strings will be read as a filepath. The name of the file that the string points to will be used as the name.- Type
Optional[List[
File
]]
- allowed_mentions¶
The allowed mentions for the message.
- Type
Optional[
AllowedMentions
]
- components¶
The components of the message.
- Type
Optional[List[
MessageComponent
]]
- flags¶
The interaction flags for the message.
- Type
Optional[
InteractionFlags
]
- type¶
The type of the callback.
- Type
Optional[
CallbackType
]
- serialize(message_type=None)¶
- Parameters
message_type (Optional[
pincer.objects.app.CallbackType
]) – Callback type of message.- Returns
(content_type, data)
- Return type
Tuple[str, Union[Payload, Dict]]
- Raises
pincer.exceptions.CommandReturnIsEmpty – Command does not have content, an embed, or attachment.
Reaction¶
Reaction¶
Reference¶
MessageReference¶
- class MessageReference¶
Bases:
pincer.utils.api_object.APIObject
Represents a Discord Message Reference object
Sticker¶
StickerType¶
- class StickerType¶
Bases:
enum.IntEnum
Displays from where the sticker comes from.
- STANDARD¶
Sticker is included in the default Discord sticker pack.
- GUILD¶
Sticker is a custom sticker from a discord server.
StickerFormatType¶
- class StickerFormatType¶
Bases:
enum.IntEnum
The type of the sticker.
- PNG¶
Sticker is of PNG format.
- APNG¶
Sticker is animated with APNG format.
- LOTTIE¶
Sticker is animated with with LOTTIE format. (vector based)
Sticker¶
- class Sticker¶
Bases:
pincer.utils.api_object.APIObject
Represents a Discord sticker.
- format_type¶
type of sticker format
- Type
- tags¶
for guild stickers, the Discord name of a unicode emoji representing the sticker’s expression. For standard stickers, a comma-separated list of related expressions.
- Type
- type¶
type of sticker
- Type
StickerItem¶
- class StickerItem¶
Bases:
pincer.utils.api_object.APIObject
Represents the smallest amount of data required to render a sticker. A partial sticker object.
- format_type¶
Type of sticker format
- Type
StickerPack¶
- class StickerPack¶
Bases:
pincer.utils.api_object.APIObject
Represents a pack of standard stickers.
User Message¶
MessageActivityType¶
MessageFlags¶
- class MessageFlags¶
Bases:
enum.IntEnum
Special message properties.
- CROSSPOSTED¶
The 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”
MessageType¶
- APPLICATION_COMMAND
- CALL
- CHANNEL_FOLLOW_ADD
- CHANNEL_ICON_CHANGE
- CHANNEL_NAME_CHANGE
- CHANNEL_PINNED_MESSAGE
- DEFAULT
- GUILD_DISCOVERY_DISQUALIFIED
- GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING
- GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING
- GUILD_DISCOVERY_REQUALIFIED
- GUILD_INVITE_REMINDER
- GUILD_MEMBER_JOIN
- RECIPIENT_ADD
- RECIPIENT_REMOVE
- REPLY
- THREAD_CREATED
- THREAD_STARTER_MESSAGE
- USER_PREMIUM_GUILD_SUBSCRIPTION
- USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1
- USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2
- USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3
- class MessageType¶
Bases:
enum.IntEnum
Represents the type of the message.
- DEFAULT¶
Normal message.
- RECIPIENT_ADD¶
Recipient is added.
- RECIPIENT_REMOVE¶
Recipient is removed.
- CALL¶
A call is being made.
- CHANNEL_NAME_CHANGE¶
The group channel name is changed.
- CHANNEL_ICON_CHANGE¶
The group channel icon is changed.
- CHANNEL_PINNED_MESSAGE¶
A message is pinned.
- GUILD_MEMBER_JOIN¶
A member joined.
- USER_PREMIUM_GUILD_SUBSCRIPTION¶
A boost.
- USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1¶
A boost that reached tier 1.
- USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2¶
A boost that reached tier 2.
- USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3¶
A boost that reached tier 3.
- CHANNEL_FOLLOW_ADD¶
A channel is subscribed to.
- GUILD_DISCOVERY_DISQUALIFIED¶
The guild is disqualified from discovery,
- GUILD_DISCOVERY_REQUALIFIED¶
The guild is requalified for discovery.
- GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING¶
Warning about discovery violations.
- GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING¶
Final warning about discovery violations.
- THREAD_CREATED¶
A thread is created.
- REPLY¶
A message reply.
- APPLICATION_COMMAND¶
Slash command is used and responded to.
- THREAD_STARTER_MESSAGE¶
The initial message in a thread when its created off a message.
- GUILD_INVITE_REMINDER¶
??
MessageActivity¶
- class MessageActivity¶
Bases:
pincer.utils.api_object.APIObject
Represents a Discord Message Activity object
- type¶
type of message activity
- Type
AllowedMentionTypes¶
UserMessage¶
- activity
- application
- application_id
- attachments
- author
- channel_id
- components
- content
- edited_timestamp
- embeds
- flags
- guild_id
- id
- interaction
- member
- mention_channels
- mention_everyone
- mention_roles
- mentions
- message_reference
- nonce
- pinned
- reactions
- referenced_message
- sticker_items
- thread
- timestamp
- tts
- type
- webhook_id
- asyncdelete
- asyncedit
- asyncget_most_recent
- asyncget_reactions
- asyncreact
- asyncremove_all_reactions
- asyncremove_emoji
- asyncremove_user_reaction
- asyncunreact
- class UserMessage¶
Bases:
pincer.utils.api_object.APIObject
Represents a message sent in a channel within Discord.
- mentions¶
Users specifically mentioned in the message
- Type
List[
GuildMember
]
- attachments¶
Any attached files
- Type
List[
Attachment
]
- type¶
Type of message
- Type
- member¶
Member properties for this message’s author
- Type
APINullable[
PartialGuildMember
]
- webhook_id¶
If the message is generated by a webhook, this is the webhook’s id
- Type
APINullable[
Snowflake
]
- activity¶
Sent with Rich Presence-related chat embeds
- Type
APINullable[
MessageActivity
]
- application¶
Sent with Rich Presence-related chat embeds
- Type
APINullable[
Application
]
- application_id¶
If the message is a response to an Interaction, this is the id of the interaction’s application
- Type
APINullable[
Snowflake
]
- message_reference¶
Data showing the source of a crosspost, channel follow add, pin, or reply message
- Type
APINullable[
MessageReference
]
- flags¶
Message flags combined as a bitfield
- Type
APINullable[
MessageFlags
]
- referenced_message¶
The message associated with the message_reference
- Type
APINullable[Optional[
UserMessage
]]
- interaction¶
Sent if the message is a response to an Interaction
- Type
APINullable[
MessageInteraction
]
- thread¶
The thread that was started from this message, includes thread member object
- Type
APINullable[
Channel
]
- components¶
Sent if the message contains components like buttons, action rows, or other interactive components
- Type
APINullable[List[
MessageComponent
]]
- sticker_items¶
Sent if the message contains stickers
- Type
APINullable[List[
StickerItem
]]
- await delete()¶
This function is a coroutine.
Delete a message. Requires the
MANAGE_MESSAGES
intent if the message was not sent by the current user.
- await edit(content=None, embeds=None, flags=None, allowed_mentions=None, attachments=None, components=None)¶
This function is a coroutine.
Edit a previously sent message. The fields content, embeds, and flags can be edited by the original message author. Other users can only edit flags and only if they have the
MANAGE_MESSAGES
permission in the corresponding channel. When specifying flags, ensure to include all previously set flags/bits in addition to ones that you are modifying.- Parameters
content (
str
) – The message contents (up to 2000 characters)Default:None
embeds (List[
Embed
]) – Embedded rich content (up to 6000 characters)flags (
int
) – Edit the flags of a message (onlySUPPRESS_EMBEDS
can currently be set/unset)allowed_mentions (
AllowedMentions
) – allowed mentions for the messageattachments (List[
Attachment
]) – attached files to keepcomponents (List[
MessageComponent
]) – the components to include with the message
- await get_most_recent()¶
This function is a coroutine.
Certain Discord methods don’t return the message object data after its updated. This function can be run to get the most recent version of the message object.
- async for ... in get_reactions(emoji, after=0, limit=25)¶
This function is a coroutine.
Returns the users that reacted with this emoji.
- await react(emoji)¶
This function is a coroutine.
Create a reaction for the message. Requires the
READ_MESSAGE_HISTORY` intent. ``ADD_REACTIONS
intent is required if nobody else has reacted using the emoji.- Parameters
emoji (
str
) – Character for emoji. Does not need to be URL encoded.
- await remove_all_reactions()¶
This function is a coroutine.
Delete all reactions on a message. Requires the
MANAGE_MESSAGES
intent.
- await remove_emoji(emoji)¶
This function is a coroutine.
Deletes all the reactions for a given emoji on a message. Requires the
MANAGE_MESSAGES
intent.- Parameters
emoji (
str
) – Character for emoji. Does not need to be URL encoded.