Pincer Objects Message#
Attachment#
Attachment#
- class Attachment#
Bases:
pincer.utils.api_object.APIObjectRepresents a Discord Attachment object
Context#
MessageContext#
- class MessageContext#
Bases:
objectRepresents 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.Default:None- await deferred_update_ack(flags=None)#
This function is a coroutine.
Alias for
deferred_update_ack().:param flags
InteractionFlags: The flags which must be applied to the reply.Default:None- await followup(message)#
This function is a coroutine.
Alias for
followup().:param message
MessageConvertable: The message to send.
- 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.
- Returns
The message that was sent.
- Return type
- await update(message)#
This function is a coroutine.
Alias for
update().:param message
MessageConvertable: The parts of the message to edit.
Embed#
EmbedImage#
EmbedProvider#
EmbedThumbnail#
EmbedVideo#
EmbedField#
Embed#
Methods- defadd_field
- defadd_fields
- defset_author
- defset_footer
- defset_image
- defset_thumbnail
- defset_timestamp
- class Embed#
Bases:
pincer.utils.api_object.APIObjectRepresentation 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
imageproperty.- 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.APIObjectRepresentation of an emoji in a class.
File#
File#
Methods- class File#
Bases:
objectA file that is prepared by the user to be sent to the discord API.
- classmethod from_file(filepath, filename=None)#
Make a
Fileobject from a file stored locally.- Parameters
filepath (
str) – The path to the file you want to send. Must be string. The file’s name in the file path is used as the name when uploaded to discord by default.filename (
str) – The name of the file. Will override the default name.Default:os.path.basename(filepath)- Returns
The new file object.
- Return type
- classmethod from_pillow_image(img, filename=None, 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: –
Pillowis not installed
- property uri#
- returns: The uri for the image.
See https://discord.com/developers/docs/reference#api-versioning.
- Return type
Message#
AllowedMentions#
- class AllowedMentions#
Bases:
pincer.utils.api_object.APIObjectRepresents the entities the client can mention
- parse#
An array of allowed mention types to parse from the content.
- Type
List[
AllowedMentionTypes]
- reply#
If replies should mention the author.
Default:True- Type
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
Message#
AttributesMethods- defserialize
- class Message#
Bases:
objectA discord message that will be sent to discord
- content#
The text in the message.
Default:""- Type
- 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]]
- tts#
Whether the message should be spoken to the user.
Default:False- Type
Optional[
bool]
- 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, allow_empty=False)#
- 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#
Attributes- class MessageReference#
Bases:
pincer.utils.api_object.APIObject,pincer.utils.api_object.ChannelProperty,pincer.utils.api_object.GuildPropertyRepresents a Discord Message Reference object
Sticker#
StickerType#
- class StickerType#
Bases:
enum.IntEnumDisplays 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.IntEnumThe type of the sticker.
- PNG#
Sticker is of PNG format.
- APNG#
Sticker is animated with APNG format.
- LOTTIE#
Sticker is animated with LOTTIE format. (vector based)
Sticker#
AttributesMethods- clsSticker.from_id
- asyncmodify
- class Sticker#
Bases:
pincer.utils.api_object.APIObjectRepresents 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
- available#
whether this guild sticker can be used, may be false due to loss of Server Boosts
- Type
APINullable[
bool]
- classmethod await from_id(_id)#
This function is a coroutine. Returns a sticker object for the given sticker ID.
- Parameters
_id (Snowflake) – id of the sticker
- Returns
sticker object of the given ID
- Return type
- await modify(name=None, description=None, tags=None, reason=None)#
This function is a coroutine. Modify the given sticker. Requires the
MANAGE_EMOJIS_AND_STICKERS permission.- Parameters
name (Optional[
str]Default:None) – name of the sticker (2-30 characters)description (Optional[
str]Default:None) – description of the sticker (2-100 characters)tags (Optional[
str]Default:None) – autocomplete/suggestion tags for the sticker (max 200 characters)reason (Optional[
str]) – reason for modifying the sticker- Returns
the modified sticker
- Return type
StickerItem#
Attributes- class StickerItem#
Bases:
pincer.utils.api_object.APIObjectRepresents the smallest amount of data required to render a sticker. A partial sticker object.
- format_type#
Type of sticker format
- Type
StickerPack#
Attributes- class StickerPack#
Bases:
pincer.utils.api_object.APIObjectRepresents a pack of standard stickers.
User Message#
MessageActivityType#
AttributesMessageFlags#
- class MessageFlags#
Bases:
enum.IntFlagSpecial 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#
Attributes- 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.IntEnumRepresents 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 it’s created off a message.
- GUILD_INVITE_REMINDER#
??
MessageActivity#
- class MessageActivity#
Bases:
pincer.utils.api_object.APIObjectRepresents a Discord Message Activity object
- type#
type of message activity
- Type
AllowedMentionTypes#
UserMessage#
Attributes- 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
Methods- clsUserMessage.from_id
- asynccrosspost
- 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,pincer.utils.api_object.GuildProperty,pincer.utils.api_object.ChannelPropertyRepresents 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 crosspost()#
This function is a coroutine. Crosspost a message in a News Channel to following channels.
This endpoint requires the
SEND_MESSAGESpermission, if the current user sent the message, or additionally theMANAGE_MESSAGESpermission, for all other messages, to be present for the current user.- Returns
The crossposted message
- Return type
UserMessage
- await delete()#
This function is a coroutine.
Delete a message. Requires the
MANAGE_MESSAGESintent 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_MESSAGESpermission 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:Noneembeds (List[
Embed]) – Embedded rich content (up to 6000 characters)flags (
int) – Edit the flags of a message (onlySUPPRESS_EMBEDScan 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- classmethod await from_id(client, _id, channel_id)#
This function is a coroutine.
Creates a UserMessage object It is recommended to use the
get_messagefunction fromClientmost of the time.- Parameters
- Returns
The message object.
- Return type
- 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.
- get_reactions(emoji, after=0, limit=25)#
This function is a coroutine.
Returns the users that reacted with this emoji.
- Parameters
emoji (
str) – Emoji to get users for.after (
Snowflake) – Get users after this user ID. Returns all users if not provided.Default:0limit (
int) – Max number of users to return (1-100).Default:25- await react(emoji)#
This function is a coroutine.
Create a reaction for the message. Requires the
READ_MESSAGE_HISTORY` intent. ``ADD_REACTIONSintent 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_MESSAGESintent.
- await remove_emoji(emoji)#
This function is a coroutine.
Deletes all the reactions for a given emoji on a message. Requires the
MANAGE_MESSAGESintent.- Parameters
emoji (
str) – Character for emoji. Does not need to be URL encoded.