Pincer Objects Message Section

Attachment

Attachment

class Attachment

Bases: pincer.utils.api_object.APIObject

Represents a Discord Attachment object

id

Attachment id

Type

Snowflake

filename

Name of file attached

Type

str

content_type

The attachment’s data type

Type

int

size

Size of file in bytes

Type

str

url

Source url of file

Type

str

proxy_url

A proxied url of file

Type

APINullable[str]

height

Height of file (if image)

Type

APINullable[Optional[int]]

width

Width of file (if image)

Type

APINullable[Optional[int]]

ButtonStyle

class ButtonStyle

Bases: enum.IntEnum

Buttons come in a variety of styles to convey different types of actions. These styles also define what fields are valid for a button.

Primary
  • color: blurple

  • required_field: custom_id

Secondary
  • color: gray

  • required_field: custom_id

Success
  • color: green

  • required_field: custom_id

Danger
  • color: red

  • required_field: custom_id

  • color: gray, navigates to a URL

  • required_field: url

Button

class Button

Bases: pincer.utils.api_object.APIObject

Represents a Discord Button object. Buttons are interactive components that render on messages.

They can be clicked by users, and send an interaction to your app when clicked.

type

2 for a button

Type

int

style

one of button styles

Type

ButtonStyle

label

text that appears on the button, max 80 characters

Type

APINullable[str]

emoji

name, id, and animated

Type

APINullable[Emoji]

custom_id

A developer-defined identifier for the button, max 100 characters

Type

APINullable[str]

url

A url for link-style buttons

Type

APINullable[str]

disabled

Whether the button is disabled (default False)

Type

APINullable[bool]

Component

MessageComponent

class MessageComponent

Bases: pincer.utils.api_object.APIObject

Represents a Discord Message Component object

type

Component type

Type

int

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]

disabled

Whether the component is disabled, defaults to False

Type

APINullable[bool]

style

One of button styles

Type

APINullable[ButtonStyle]

label

Text that appears on the button, max 80 characters

Type

APINullable[str]

emoji

name, id, and animated

Type

APINullable[Emoji]

url

A url for link-style buttons

Type

APINullable[str]

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, min 0, max 25

Type

APINullable[int]

max_values

The maximum number of items that can be chosen;

Default: 1, max 25

Type

APINullable[int]

components

A list of child components

Type

APINullable[List[MessageComponent]]

Context

MessageContext

Methods
class MessageContext

Bases: object

Represents the context of a message interaction.

id

The ID of the interaction.

Type

Snowflake

author

The user whom invoked the interaction.

Type

Union[GuildMember, User]

command

The local command object for the command to whom this context belongs.

Type

ClientCommandStructure

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

EmbedAuthor

class EmbedAuthor

Bases: object

Representation of the Embed Author class

name

Name of the author

Type

APINullable[str]

url

Url of the author

Type

APINullable[str]

icon_url

Url of the author icon

Type

APINullable[str]

proxy_icon_url

A proxied url of the author icon

Type

APINullable[str]

EmbedImage

Attributes
class EmbedImage

Bases: object

Representation of the Embed Image class

url

Source url of the image

Type

APINullable[str]

proxy_url

A proxied url of the image

Type

APINullable[str]

height

Height of the image

Type

APINullable[int]

width

Width of the image

Type

APINullable[int]

EmbedProvider

Attributes
class EmbedProvider

Bases: object

Representation of the Provider class

name

Name of the provider

Type

APINullable[str]

url

Url of the provider

Type

APINullable[str]

EmbedThumbnail

Attributes
class EmbedThumbnail

Bases: object

Representation of the Embed Thumbnail class

url

Source url of the thumbnail

Type

APINullable[str]

proxy_url

A proxied url of the thumbnail

Type

APINullable[str]

height

Height of the thumbnail

Type

APINullable[int]

width

Width of the thumbnail

Type

APINullable[int]

EmbedVideo

Attributes
class EmbedVideo

Bases: object

Representation of the Embed Video class

url

Source url of the video

Type

APINullable[str]

proxy_url

A proxied url of the video

Type

APINullable[str]

height

Height of the video

Type

APINullable[int]

width

Width of the video

Type

APINullable[int]

EmbedFooter

class EmbedFooter

Bases: object

Representation of the Embed Footer class

text

Footer text

Type

str

icon_url

Url of the footer icon

Type

APINullable[str]

proxy_icon_url

A proxied url of the footer icon

Type

APINullable[str]

Raises

EmbedFieldError: – Text is longer than 2048 characters

EmbedField

Attributes
class EmbedField

Bases: object

Representation of the Embed Field class

name

The name of the field

Type

str

value

The text in the field

Type

str

inline

Whether or not this field should display inline

Type

APINullable[bool]

Raises
  • EmbedFieldError: – Name is longer than 256 characters

  • EmbedFieldError: – Description is longer than 1024 characters

Embed

class Embed

Bases: pincer.utils.api_object.APIObject

Representation of the discord Embed class

title

Embed title.

Type

APINullable[str]

description

Embed description.

Type

APINullable[str]

color

Embed color code.

Type

APINullable[int]

fields

Fields information.

Type

List[EmbedField]

footer

Footer information.

Type

APINullable[EmbedFooter]

image

Image information.

Type

APINullable[EmbedImage]

provider

Provider information.

Type

APINullable[EmbedProvider]

thumbnail

Thumbnail information.

Type

APINullable[EmbedThumbnail]

timestamp

Timestamp of embed content in ISO format.

Type

APINullable[str]

url

Embed url.

Type

APINullable[str]

video

Video information.

Type

APINullable[EmbedVideo]

type

type of message

Type

APINullable[int]

add_field(name, value, inline=<MISSING>)

Adds a field to the embed. An embed can contain up to 25 fields.

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

  • value (str) – The text in the field

  • inline (APINullable[bool]) – Whether or not this field should display inline

Raises

EmbedFieldError: – Raised when there are more than 25 fields in the embed

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

Embed

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

Embed

Sets the embed footer. This is at the bottom of your embed.

Parameters
  • text (str) – Footer text

  • icon_url (APINullable[str]) – Url of the footer icon

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

Returns

The new embed object.

Return type

Embed

set_image(url=<MISSING>, proxy_url=<MISSING>, height=<MISSING>, width=<MISSING>)

Sets an image for your embed.

Parameters
  • 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

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

Embed

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

Embed

Emoji

Emoji

class Emoji

Bases: pincer.utils.api_object.APIObject

Representation of an emoji in a class.

id

Emoji id

Type

Optional[Snowflake]

name

Emoji name

Type

Optional[str]

animated

Whether this emoji is animated

Type

APINullable[bool]

available

Whether this emoji can be used, may be false due to loss of Server Boosts

Type

APINullable[bool]

managed

Whether this emoji is managed

Type

APINullable[bool]

require_colons

Whether this emoji must be wrapped in colons

Type

APINullable[bool]

roles

Roles allowed to use this emoji

Type

APINullable[List[Role]]

user

User that created this emoji

Type

APINullable[User]

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.

content

File bytes.

Type

bytes

filename

The name of the file when its uploaded to discord.

Type

str

classmethod from_file(filepath, filename=None)

Make a File object 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)

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

File

Raises

ModuleNotFoundError:Pillow is not installed

Message

AllowedMentions

Attributes
Methods
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]

roles

List of Role objects or snowflakes of allowed mentions.

Type

List[Union[Role, Snowflake]]

users

List of user objects or snowflakes of allowed mentions.

Type

List[Union[User Snowflake]]

reply

If replies should mention the author.

Default: True

Type

bool

to_dict()

Transform the current object to a dictionary representation.

Message

class Message

Bases: object

A discord message that will be send to discord

content

The text in the message.

Default: ""

Type

str

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]

embeds

Embed attached to the message. This is an Embed object.

Type

Optional[List[Embed]]

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]

property isempty

If the message is empty.

Type

bool

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

Attributes
class Reaction

Bases: pincer.utils.api_object.APIObject

Represents a Discord Reaction object

count

Times this emoji has been used to react

Type

int

me

Whether the current user reacted using this emoji

Type

bool

emoji

Emoji information

Type

Emoji

Reference

MessageReference

class MessageReference

Bases: pincer.utils.api_object.APIObject

Represents a Discord Message Reference object

message_id

Id of the originating message

Type

APINullable[Snowflake]

channel_id

Id of the originating message’s channel

Type

APINullable[Snowflake]

guild_id

Id of the originating message’s guild

Type

APINullable[Snowflake]

fail_if_not_exists

When sending, whether to error if the referenced message doesn’t exist instead of sending as a normal (non-reply) message, default true

Type

APINullable[bool]

Sticker

StickerType

Attributes
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

Attributes
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.

description

description of the sticker

Type

Optional[str]

format_type

type of sticker format

Type

StickerFormatType

id

id of the sticker

Type

Snowflake

name

name of the sticker

Type

str

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

str

type

type of sticker

Type

StickerType

available

whether this guild sticker can be used, may be false due to loss of Server Boosts

Type

APINullable[bool]

guild_id

id of the guild that owns this sticker

Type

APINullable[Snowflake]

pack_id

for standard stickers, id of the pack the sticker is from

Type

APINullable[Snowflake]

sort_value

the standard sticker’s sort order within its pack

Type

APINullable[int]

user

the user that uploaded the guild sticker

Type

APINullable[User]

StickerItem

Attributes
class StickerItem

Bases: pincer.utils.api_object.APIObject

Represents the smallest amount of data required to render a sticker. A partial sticker object.

id

Id of the sticker

Type

Snowflake

name

Name of the sticker

Type

str

format_type

Type of sticker format

Type

StickerFormatType

StickerPack

class StickerPack

Bases: pincer.utils.api_object.APIObject

Represents a pack of standard stickers.

id

Id of the sticker pack

Type

Snowflake

stickers

The stickers in the pack

Type

List[Sticker]

name

Name of the sticker pack

Type

str

sku_id

Id of the pack’s SKU

Type

Snowflake

description

Description of the sticker pack

Type

str

cover_sticker_id

Id of a sticker in the pack which is shown as the pack’s icon

Type

APINullable[Snowflake]

banner_asset_id

Id of the sticker pack’s banner image

Type

APINullable[Snowflake]

User Message

MessageActivityType

class MessageActivityType

Bases: enum.IntEnum

The activity people can perform on a rich presence activity.

Such an activity could for example be a spotify listen.

JOIN

Invite to join.

SPECTATE

Invite to spectate.

LISTEN

Invite to listen along.

JOIN_REQUEST

Request to join.

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

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

Attributes
class MessageActivity

Bases: pincer.utils.api_object.APIObject

Represents a Discord Message Activity object

type

type of message activity

Type

MessageActivity

party_id

party_id from a Rich Presence event

Type

APINullable[str]

AllowedMentionTypes

Attributes
class AllowedMentionTypes

Bases: str, enum.Enum

The allowed mentions.

ROLES

Controls role mentions

USERS

Controls user mentions

EVERYONE

Controls @everyone and @here mentions

UserMessage

class UserMessage

Bases: pincer.utils.api_object.APIObject

Represents a message sent in a channel within Discord.

id

Ud of the message

Type

Snowflake

channel_id

Id of the channel the message was sent in

Type

Snowflake

author

The author of this message (not guaranteed to be a valid user)

Type

User

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

Optional[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

List[GuildMember]

mention_roles

Roles specifically mentioned in this message

Type

List[Role]

attachments

Any attached files

Type

List[Attachment]

embeds

Any embedded content

Type

List[Embed]

pinned

Whether this message is pinned

Type

bool

type

Type of message

Type

MessageType

mention_channels

Channels specifically mentioned in this message

Type

APINullable[List[Channel]]

guild_id

Id of the guild the message was sent in

Type

APINullable[Snowflake]

member

Member properties for this message’s author

Type

APINullable[PartialGuildMember]

reactions

Reactions to the message

Type

APINullable[List[Reaction]]

nonce

User for validating a message was sent

Type

APINullable[Union[int, str]]

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 (only SUPPRESS_EMBEDS can currently be set/unset)

  • allowed_mentions (AllowedMentions) – allowed mentions for the message

  • attachments (List[Attachment]) – attached files to keep

  • components (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.

Parameters
  • emoji (str) – Emoji to get users for.

  • after (Snowflake) – Get users after this user ID. Returns all users if not provided.

    Default: 0

  • limit (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_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.

await remove_user_reaction(emoji, user_id)

This function is a coroutine.

Deletes another user’s reaction. Requires the MANAGE_MESSAGES intent.

Parameters
  • emoji (str) – Character for emoji. Does not need to be URL encoded.

  • user_id (Snowflake) – User ID

await unreact(emoji)

This function is a coroutine.

Delete a reaction the current user has made for the message.

Parameters

emoji (str) – Character for emoji. Does not need to be URL encoded.