Pincer Objects App Section

Applications

Application

class Application

Bases: pincer.utils.api_object.APIObject

Represents a Discord application. (eg Bot, OAuth)

bot_public

when false only app owner can join the app’s bot to guilds

Type

bool

bot_require_code_grant

when true the app’s bot will only join upon completion of the full oauth2 code grant flow

Type

bool

description

the description of the app

Type

str

id

the id of the app

Type

Snowflake

icon

the icon hash of the app

Type

Optional[str]

name

the name of the app

Type

str

privacy_policy_url

the url of the app’s privacy policy

Type

APINullable[str]

summary

if this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku

Type

str

verify_key

the hex encoded key for verification in interactions and the GameSDK’s GetTicket

Type

str

cover_image

the application’s default rich presence invite cover image hash

Type

APINullable[str]

flags

the application’s public flags

Type

APINullable[int]

guild_id

if this application is a game sold on Discord, this field will be the guild to which it has been linked

Type

APINullable[Snowflake]

owner

partial user object containing info on the owner of the application

Type

APINullable[User]

primary_sku_id

if this application is a game sold on Discord, this field will be the id of the “Game SKU” that is created, if exists

Type

APINullable[Snowflake]

rpc_origins

an array of rpc origin urls, if rpc is enabled

Type

APINullable[List[str]]

slug

if this application is a game sold on Discord, this field will be the URL slug that links to the store page

Type

APINullable[str]

terms_of_service_url

the url of the app’s terms of service

Type

APINullable[str]

Commands

AppCommandType

Attributes
class AppCommandType

Bases: enum.IntEnum

Defines the different types of application commands.

CHAT_INPUT

Slash commands; a text-based command that shows up when a user types /

USER

A UI-based command that shows up when you right click or tap on a user

MESSAGE

A UI-based command that shows up when you right click or tap on a message

AppCommandOptionType

class AppCommandOptionType

Bases: enum.IntEnum

Represents a parameter type.

SUB_COMMAND

The parameter will be a subcommand.

SUB_COMMAND_GROUP

The parameter will be a group of subcommands.

STRING

The parameter will be a string.

INTEGER

The parameter will be an integer/number. (-2^53 and 2^53)

BOOLEAN

The parameter will be a boolean.

USER

The parameter will be a Discord user object.

CHANNEL

The parameter will be a Discord channel object.

ROLE

The parameter will be a Discord role object.

MENTIONABLE

The parameter will be mentionable.

NUMBER

The parameter will be a float. (-2^53 and 2^53)

AppCommandInteractionDataOption

Attributes
class AppCommandInteractionDataOption

Bases: pincer.utils.api_object.APIObject

Represents a Discord Application Command Interaction Data Option

name

The name of the parameter

Type

str

value

The value of the pair

Type

str

type

Value of application command option type

Type

APINullable[str]

options

Present if this option is a group or subcommand

Type

APINullable[List[AppCommandInteractionDataOption]]

AppCommandOption

class AppCommandOption

Bases: pincer.utils.api_object.APIObject

Represents a Discord Application Command Option object

type

The type of option

Type

AppCommandOptionType

name

1-32 lowercase character name matching ^[w-]{1,32}$

Type

str

description

1-100 character description

Type

str

required

If the parameter is required or optional

Default: False

Type

APINullable[bool]

choices

Choices for STRING, INTEGER, and NUMBER types for the user to pick from, max 25

Type

APINullable[List[AppCommandOptionChoice]]

options

If the option is a subcommand or subcommand group type, this nested options will be the parameters

Type

APINullable[List[AppCommandOptionChoice]]

AppCommand

class AppCommand

Bases: pincer.utils.api_object.APIObject

Represents a Discord Application Command object

type

The type of command, defaults 1 if not set

Type

AppCommandType

name

1-32 character name

Type

str

description

1-100 character description for CHAT_INPUT commands, empty string for USER and MESSAGE commands

Type

str

id

Unique id of the command

Type

APINullable[Snowflake]

version

Auto-incrementing version identifier updated during substantial record changes

Type

APINullable[Snowflake]

application_id

Unique id of the parent application

Type

APINullable[Snowflake]

options

The parameters for the command, max 25

Type

APINullable[List[AppCommandOption]]

guild_id

Guild id of the command, if not global

Type

APINullable[Snowflake]

default_permission

Whether the command is enabled by default when the app is added to a guild

Type

APINullable[bool]

add_option(option)

Add a new option field to the current application command.

Parameters

option (AppCommandOption) – The option which will be appended.

ClientCommandStructure

class ClientCommandStructure

Bases: object

Represents the structure of how the client saves the existing commands in the register.

app

The command application.

Type

AppCommand

call

The coroutine which should be called when the command gets executed.

Type

Coro

cooldown

Amount of times for cooldown

Type

int

cooldown_scale

Search time for cooldown

Type

float

cooldown_scope

The type of cooldown

Type

ThrottleScope

Intents

Intents

class Intents

Bases: enum.IntEnum

Discord client intents.

These give your client more permissions.

Note

The given Intents must also be enabled for your client on the discord dashboard.

NONE

No intents.

GUILDS

Guilds intent.

GUILD_MEMBERS

Members intent.

GUILD_BANS

Bans intent.

GUILD_EMOJIS_AND_STICKERS

Emoji and Sticker intent.

GUILD_INTEGRATIONS

Integrations intent.

GUILD_WEBHOOKS

Webhooks intent.

GUILD_INVITES

Invites intent.

GUILD_VOICE_STATES

Voice states intent.

GUILD_PRESENCES

Presences intent.

GUILD_MESSAGES

Message intent.

GUILD_MESSAGE_REACTIONS

Reactions to messages intent.

GUILD_MESSAGE_TYPING

Typing to messages intent.

DIRECT_MESSAGES

DM messages intent.

DIRECT_MESSAGE_REACTIONS

DM reaction to messages intent.

DIRECT_MESSAGE_TYPING

DM typing to messages intent.

staticmethod all()

Intents: Method of all intents

Interaction Base

CallbackType

class CallbackType

Bases: enum.IntEnum

The types of response a client can give to a interaction.

PONG

ACK a Ping

MESSAGE

Respond to an interaction with a message

DEFERRED_MESSAGE

ACK an interaction and edit a response later, the user sees a loading state

DEFERRED_UPDATE_MESSAGE

For components, ACK an interaction and edit the original message later

UPDATE_MESSAGE

For components, edit the message the component was attached to

InteractionType

class InteractionType

Bases: enum.IntEnum

Represents the different types of interactions the client can have with a member.

PING

Ping an interaction.

APPLICATION_COMMAND

A “slash” command.

MESSAGE_COMPONENT

A ui component like buttons and selects.

MessageInteraction

class InteractionFlags

Bases: enum.IntEnum

EPHEMERAL

only the user receiving the message can see it

ResolvedData

class ResolvedData

Bases: pincer.utils.api_object.APIObject

Represents a Discord Resolved Data structure

users

Map of Snowflakes to user objects

Type

APINullable[Dict[Snowflake, User]]

members

Map of Snowflakes to partial member objects

Type

APINullable[Dict[Snowflake, GuildMember]]

roles

Map of Snowflakes to role objects

Type

APINullable[Dict[Snowflake, Role]]

channels

Map of Snowflakes to partial channel objects

Type

APINullable[Dict[Snowflake, Channel]]

messages

Map of Snowflakes to partial message objects

Type

APINullable[Dict[Snowflake, UserMessage]]

InteractionData

class InteractionData

Bases: pincer.utils.api_object.APIObject

Represents a Discord Interaction Data structure

id

The ID of the invoked command

Type

Snowflake

name

The name of the invoked command

Type

str

type

The type of the invoked command

Type

int

resolved

Converted users + roles + channels

Type

APINullable[ResolvedData]

options

The params + values from the user

Type

APINullable[AppCommandInteractionDataOption]

custom_id

The custom_id of the component

Type

APINullable[str]

component_type

The type of the component

Type

APINullable[int]

values

The values the user selected

Type

APINullable[SelectOption]

target_id

Id of the user or message targeted by a user or message command

Type

APINullable[Snowflake]

Interaction

class Interaction

Bases: pincer.utils.api_object.APIObject

Represents a Discord Interaction object

id

Id of the interaction

Type

Snowflake

application_id

Id of the application this interaction is for

Type

Snowflake

type

The type of interaction

Type

InteractionType

token

A continuation token for responding to the interaction

Type

str

version

Read-only property, always 1

Type

int

data

The command data payload

Type

APINullable[InteractionData]

guild_id

The guild it was sent from

Type

APINullable[Snowflake]

channel_id

The channel it was sent from

Type

APINullable[Snowflake]

member

Guild member data for the invoking user, including permissions

Type

APINullable[GuildMember]

user

User object for the invoking user, if invoked in a DM

Type

APINullable[User]

message

For components, the message they were attached to

Type

APINullable[UserMessage]

await ack(flags=None)

This function is a coroutine.

Acknowledge an interaction, any flags here are applied to the reply.

:param flags InteractionFlags: The flags which must be applied to the reply.

Raises

InteractionAlreadyAcknowledged – The interaction was already acknowledged, this can be because a reply or ack was already sent.

await build()

This function is a coroutine.

Sets the parameters in the interaction that need information from the discord API.

await convert(option)

This function is a coroutine.

Sets an AppCommandInteractionDataOption value parameter to the payload type

await delete()

This function is a coroutine.

Delete the interaction.

Raises

InteractionDoesNotExist – Exception raised when no reply has been sent.

await delete_followup(message)

This function is a coroutine.

Remove a followup message by id.

:param message Union[UserMessage: The id/followup object of the followup message that must be deleted. :param int]: The id/followup object of the followup message that must be deleted.

await edit(message)

This function is a coroutine.

Edit an interaction. This is also the way to reply to interactions whom have been acknowledged.

:param message MessageConvertable: The new message!

Returns

The updated message object.

Return type

UserMessage

Raises

InteractionDoesNotExist – Exception raised when no reply has been sent.

await edit_followup(message_id, message)

This function is a coroutine.

Edit a followup message.

:param message_id int: The id of the original followup message. :param message MessageConvertable: The message new message.

Returns

The updated message object.

Return type

UserMessage

await followup(message)

This function is a coroutine.

Create a follow up message for the interaction. This allows you to respond with multiple messages.

:param message MessageConvertable: The message to sent.

Returns

The message that has been sent.

Return type

UserMessage

await get_followup(message_id)

This function is a coroutine.

Get a followup message by id.

:param message_id int: The id of the original followup message that must be fetched.

Returns

The fetched message object.

Return type

UserMessage

await reply(message)

This function is a coroutine.

Initial reply, only works if no ACK has been sent yet.

:param message MessageConvertable: The response message!

Raises
  • UseFollowup – Exception raised when a reply has already been sent so a followup() should be used instead.

  • InteractionTimedOut – Exception raised when discord had to wait too long for a reply. You can extend the discord wait time by using the ack() function.

await response()

This function is a coroutine.

Gets the original response for an interaction.

Returns

The fetched response!

Return type

UserMessage

Select Menu

SelectOption

class SelectOption

Bases: pincer.utils.api_object.APIObject

Represents a Discord Select Option object

label

The user-facing name of the option, max 100 characters

Type

str

value

The def-defined value of the option, max 100 characters

Type

str

description

An additional description of the option, max 100 characters

Type

APINullable[str]

emoji

id, name, and animated

Type

APINullable[Emoji]

default

Will render this option as selected by default

Type

APINullable[bool]

SelectMenu

class SelectMenu

Bases: pincer.utils.api_object.APIObject

Represents a Discord Select Menu object

type

3 for a select menu

Type

int

custom_id

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

Type

str

options

The choices in the select, max 25

Type

List[SelectOption]

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

Default: 1

Type

APINullable[int]

max_values

The maximum number of items that can be chosen; max 25

Default: 1

Type

APINullable[int]

disabled

Disable the select

Default: False

Type

APINullable[bool]

Session Start Limit

SessionStartLimit

class SessionStartLimit

Bases: pincer.utils.api_object.APIObject

Represents a Discord Session Start Limit object

total

The total number of session starts the current user is allowed

Type

int

remaining

The remaining number of session starts the current user is allowed

Type

int

reset_after

The number of milliseconds after which the limit resets

Type

int

max_concurrency

The number of identify requests allowed per 5 seconds

Type

int

Throttle Scope

ThrottleScope

Attributes
class ThrottleScope

Bases: enum.Enum

On what the cooldown should be set/on what should the cooldown be set.

GUILD

The cooldown is per guild.

CHANNEL

The cooldown is per channel.

USER

The cooldown is per user.

GLOBAL

The cooldown is global.

Throttling

ThrottleInterface

class ThrottleInterface

Bases: abc.ABC

An ABC for throttling.

DefaultThrottleHandler

Methods
class DefaultThrottleHandler

Bases: pincer.objects.app.throttling.ThrottleInterface, abc.ABC

The default throttlehandler based off the ThrottleInterface ABC

staticmethod get_key_from_scope(ctx)

Retrieve the the appropriate key from the context through the throttle scope.

Parameters

ctx (MessageContext) – The context to retrieve with

Returns

The throttlescope enum

Return type

Optional[int]