hikari.applications#

Application and entities related to discord’s OAuth2 flow.

Module Contents#

class hikari.applications.Application[source]#

Bases: hikari.guilds.PartialApplication

Represents the information of an Oauth2 Application.

property cover_image_url: Optional[hikari.files.URL][source]#

Rich presence cover image URL for this application, if set.

app: hikari.traits.RESTAware[source]#

Client application that models may use for procedures.

cover_image_hash: Optional[str][source]#

The CDN’s hash of this application’s default rich presence invite cover image.

custom_install_url: Optional[str][source]#

The URL of this application’s custom authorization link.

flags: ApplicationFlags[source]#

The flags for this application.

install_parameters: Optional[ApplicationInstallParameters][source]#

Settings for the application’s default in-app authorization link, if enabled.

is_bot_code_grant_required: bool[source]#

True if this application’s bot is requiring code grant for invites.

is_bot_public: bool[source]#

True if the bot associated with this application is public.

owner: hikari.users.User[source]#

The application’s owner.

privacy_policy_url: Optional[str][source]#

The URL of this application’s privacy policy.

public_key: bytes[source]#

The key used for verifying interaction and GameSDK payload signatures.

rpc_origins: Optional[Sequence[str]][source]#

A collection of this application’s RPC origin URLs, if RPC is enabled.

tags: Sequence[str][source]#

A sequence of tags describing the content and functionality of the application.

team: Optional[Team][source]#

The team this application belongs to.

If the application is not part of a team, this will be None.

terms_of_service_url: Optional[str][source]#

The URL of this application’s terms of service.

make_cover_image_url(*, ext='png', size=4096)[source]#

Generate the rich presence cover image URL for this application, if set.

Parameters:
extstr

The extension to use for this URL, defaults to png. Supports png, jpeg, jpg and webp.

sizeint

The size to set for the URL, defaults to 4096. Can be any power of two between 16 and 4096.

Returns:
typing.Optional[hikari.files.URL]

The URL, or None if no cover image exists.

Raises:
ValueError

If the size is not an integer power of 2 between 16 and 4096 (inclusive).

class hikari.applications.ApplicationFlags[source]#

Bases: hikari.internal.enums.Flag

The known application flag bits.

APPLICATION_COMMAND_BADGE[source]#

Denotes that the application has at least one global application command.

EMBEDDED[source]#

Denotes that the application has functionality that’s specially embedded in Discord’s client.

GUILD_MEMBERS_INTENT[source]#

Denotes that the application has the GUILD_MEMBERS intent enabled in it’s dashboard.

GUILD_PRESENCES_INTENT[source]#

Denotes that the application has the GUILD_PRESENCES intent enabled in it’s dashboard.

MESSAGE_CONTENT_INTENT[source]#

Denotes that the application has message content intent enabled in it’s dashboard.

MESSAGE_CONTENT_INTENT_LIMITED[source]#

Denotes that the application has message content access while pending verification.

VERIFICATION_PENDING_GUILD_LIMIT[source]#

Denotes that the application’s verification is pending.

VERIFIED_FOR_GUILD_MEMBERS_INTENT[source]#

Denotes that a verified application can use the GUILD_MEMBERS intent.

VERIFIED_FOR_GUILD_PRESENCES[source]#

Denotes that a verified application can use the GUILD_PRESENCES intent.

class hikari.applications.AuthorizationApplication[source]#

Bases: hikari.guilds.PartialApplication

The application model found attached to AuthorizationInformation.

is_bot_code_grant_required: Optional[bool][source]#

True if this application’s bot is requiring code grant for invites.

Will be None if this application doesn’t have a bot.

is_bot_public: Optional[bool][source]#

True if the bot associated with this application is public.

Will be None if this application doesn’t have an associated bot.

privacy_policy_url: Optional[str][source]#

The URL of this application’s privacy policy.

public_key: bytes[source]#

The key used for verifying interaction and GameSDK payload signatures.

terms_of_service_url: Optional[str][source]#

The URL of this application’s terms of service.

class hikari.applications.AuthorizationInformation[source]#

Model for the data returned by Get Current Authorization Information.

application: AuthorizationApplication[source]#

The current application.

expires_at: datetime.datetime[source]#

When the access token this data was retrieved with expires.

scopes: Sequence[Union[OAuth2Scope, str]][source]#

A sequence of the scopes the current user has authorized the application for.

user: Optional[hikari.users.User][source]#

The user who has authorized this token if they included the identify scope.

class hikari.applications.ConnectionVisibility[source]#

Bases: int, hikari.internal.enums.Enum

Describes who can see a connection with a third party account.

EVERYONE = 1[source]#

Everyone can see the connection.

NONE = 0[source]#

Implies that only you can see the corresponding connection.

class hikari.applications.InviteApplication[source]#

Bases: hikari.guilds.PartialApplication

Represents the information of an Invite Application.

property cover_image_url: Optional[hikari.files.URL][source]#

Rich presence cover image URL for this application, if set.

app: hikari.traits.RESTAware[source]#

Client application that models may use for procedures.

cover_image_hash: Optional[str][source]#

The CDN’s hash of this application’s default rich presence invite cover image.

public_key: bytes[source]#

The key used for verifying interaction and GameSDK payload signatures.

make_cover_image_url(*, ext='png', size=4096)[source]#

Generate the rich presence cover image URL for this application, if set.

Parameters:
extstr

The extension to use for this URL, defaults to png. Supports png, jpeg, jpg and webp.

sizeint

The size to set for the URL, defaults to 4096. Can be any power of two between 16 and 4096.

Returns:
typing.Optional[hikari.files.URL]

The URL, or None if no cover image exists.

Raises:
ValueError

If the size is not an integer power of 2 between 16 and 4096 (inclusive).

class hikari.applications.OAuth2AuthorizationToken[source]#

Bases: PartialOAuth2Token

Model for the OAuth2 token data returned by the authorization grant flow.

guild: Optional[hikari.guilds.RESTGuild][source]#

Object of the guild the user was added to.

This will only be present if this token was authorized with the bot scope, otherwise this will be None.

refresh_token: int[source]#

Refresh token used to obtain new access tokens with the same grant.

webhook: Optional[hikari.webhooks.IncomingWebhook][source]#

Object of the webhook that was created.

This will only be present if this token was authorized with the webhooks.incoming scope, otherwise this will be None.

class hikari.applications.OAuth2ImplicitToken[source]#

Bases: PartialOAuth2Token

Model for the OAuth2 token data returned by the implicit grant flow.

state: Optional[str][source]#

State parameter that was present in the authorization request if provided.

class hikari.applications.OAuth2Scope[source]#

Bases: str, hikari.internal.enums.Enum

OAuth2 Scopes that Discord allows.

These are categories of permissions for applications using the OAuth2 API directly. Most users will only ever need the BOT scope when developing bots.

ACTIVITIES_READ = 'activities.read'[source]#

Enables fetching the “Now Playing/Recently Played” list.

Note

You must be whitelisted to use this scope.

ACTIVITIES_WRITE = 'activities.write'[source]#

Enables updating a user’s activity.

Note

You must be whitelisted to use this scope.

Note

This is not required to use the GameSDK activity manager.

APPLICATIONS_BUILDS_READ = 'applications.builds.read'[source]#

Enables reading build data for a user’s applications.

Note

You must be whitelisted to use this scope.

APPLICATIONS_BUILDS_UPLOAD = 'applications.builds.upload'[source]#

Enables uploading/updating builds for a user’s applications.

Note

You must be whitelisted to use this scope.

APPLICATIONS_COMMANDS = 'applications.commands'[source]#

Allows your application’s commands to be used in a guild.

This is used in Discord’s special Bot Authorization Flow like OAuth2Scope.BOT in-order to join an application into a guild as an application command providing integration.

APPLICATIONS_COMMANDS_PERMISSION_UPDATE = 'applications.commands.permissions.update'[source]#

Allows your application to update its commands permissions via a bearer token.

APPLICATIONS_COMMANDS_UPDATE = 'applications.commands.update'[source]#

Allows your application to update its commands via a bearer token.

APPLICATIONS_ENTITLEMENTS = 'applications.entitlements'[source]#

Enables reading entitlements for a user’s applications.

APPLICATIONS_STORE_UPDATE = 'applications.store.update'[source]#

Enables reading/updating store data for the user’s applications.

This includes store listings, achievements, SKU’s, etc.

Note

The store API is deprecated and may be removed in the future.

BOT = 'bot'[source]#

Enables adding a bot application to a guild.

Note

This requires you to have set up a bot account for your application.

CONNECTIONS = 'connections'[source]#

Enables viewing third-party linked accounts such as Twitch.

EMAIL = 'email'[source]#

Enable the application to view the user’s email and application info.

GROUP_DM_JOIN = 'gdm.join'[source]#

Enables joining users into a group DM.

Warning

This cannot add the bot to a group DM.

GUILDS = 'guilds'[source]#

Enables viewing the guilds the user is in.

GUILDS_JOIN = 'guilds.join'[source]#

Enables adding the user to a specific guild.

Note

This requires you to have set up a bot account for your application.

GUILDS_MEMBERS_READ = 'guilds.members.read'[source]#

Used to read the current user’s guild members.

IDENTIFY = 'identify'[source]#

Enables viewing info about itself.

Note

This does not include email address info. Use the EMAIL scope instead to retrieve this information.

RELATIONSHIPS_READ = 'relationships.read'[source]#

Enables viewing a user’s friend list.

Note

You must be whitelisted to use this scope.

RPC = 'rpc'[source]#

Enables the RPC application to control the local user’s Discord client.

Note

You must be whitelisted to use this scope.

RPC_MESSAGES_READ = 'messages.read'[source]#

Enables the RPC application to read messages from all channels the user is in.

RPC_NOTIFICATIONS_READ = 'rpc.notifications.read'[source]#

Enables the RPC application to read from all channels the user is in.

Note

You must be whitelisted to use this scope.

WEBHOOK_INCOMING = 'webhook.incoming'[source]#

Used to generate a webhook that is returned in the OAuth2 token response.

This is used during authorization code grants.

class hikari.applications.OwnConnection[source]#

Represents a user’s connection with a third party account.

Returned by the GET Current User Connections endpoint.

id: str[source]#

The string ID of the third party connected account.

Warning

Seeing as this is a third party ID, it will not be a snowflakes.

integrations: Sequence[hikari.guilds.PartialIntegration][source]#

A sequence of the partial guild integration objects this connection has.

is_activity_visible: bool[source]#

True if this connection’s activities are shown in the user’s presence.

is_friend_sync_enabled: bool[source]#

True if friends should be added based on this connection.

is_revoked: bool[source]#

True if the connection has been revoked.

is_verified: bool[source]#

True if the connection has been verified.

name: str[source]#

The username of the connected account.

type: str[source]#

The type of service this connection is for.

visibility: Union[ConnectionVisibility, int][source]#

The visibility of the connection.

class hikari.applications.OwnGuild[source]#

Bases: hikari.guilds.PartialGuild

Represents a user bound partial guild object.

features: Sequence[Union[str, hikari.guilds.GuildFeature]][source]#

A list of the features in this guild.

is_owner: bool[source]#

True when the current user owns this guild.

my_permissions: hikari.permissions.Permissions[source]#

The guild-level permissions that apply to the current user or bot.

class hikari.applications.PartialOAuth2Token[source]#

Model for partial OAuth2 token data returned by the API.

This will generally only be returned when by the client credentials OAuth2 flow.

access_token: str[source]#

Access token issued by the authorization server.

expires_in: datetime.timedelta[source]#

Lifetime of this access token.

scopes: Sequence[Union[OAuth2Scope, str]][source]#

Scopes the access token has access to.

token_type: Union[TokenType, str][source]#

Type of token issued by the authorization server.

class hikari.applications.Team[source]#

Bases: hikari.snowflakes.Unique

Represents a development team, along with all its members.

property icon_url: Optional[hikari.files.URL][source]#

Icon URL, or None if no icon exists.

app: hikari.traits.RESTAware[source]#

Client application that models may use for procedures.

icon_hash: Optional[str][source]#

The CDN hash of this team’s icon.

If no icon is provided, this will be None.

id: hikari.snowflakes.Snowflake[source]#

The ID of this entity.

members: Mapping[hikari.snowflakes.Snowflake, TeamMember][source]#

A mapping containing each member in this team.

The mapping maps keys containing the member’s ID to values containing the member object.

name: str[source]#

The name of this team.

owner_id: hikari.snowflakes.Snowflake[source]#

The ID of this team’s owner.

make_icon_url(*, ext='png', size=4096)[source]#

Generate the icon URL for this team if set.

Parameters:
extstr

The extension to use for this URL, defaults to png. Supports png, jpeg, jpg and webp.

sizeint

The size to set for the URL, defaults to 4096. Can be any power of two between 16 and 4096 inclusive.

Returns:
typing.Optional[hikari.files.URL]

The URL, or None if no icon exists.

Raises:
ValueError

If the size is not an integer power of 2 between 16 and 4096 (inclusive).

class hikari.applications.TeamMember[source]#

Bases: hikari.users.User

Represents a member of a Team.

property app: hikari.traits.RESTAware[source]#

Return the app that is bound to the user object.

membership_state: Union[TeamMembershipState, int][source]#

The state of this user’s membership.

permissions: Sequence[str][source]#

This member’s permissions within a team.

At the time of writing, this will always be a sequence of one str, which will always be "*". This may change in the future, however.

team_id: hikari.snowflakes.Snowflake[source]#

The ID of the team this member belongs to.

user: hikari.users.User[source]#

The user representation of this team member.

class hikari.applications.TeamMembershipState[source]#

Bases: int, hikari.internal.enums.Enum

Represents the state of a user’s team membership.

ACCEPTED = 2[source]#

Denotes the user has accepted the invite and is now a member.

INVITED = 1[source]#

Denotes the user has been invited to the team but has yet to accept.

class hikari.applications.TokenType[source]#

Bases: str, hikari.internal.enums.Enum

Token types used within Hikari clients.

BASIC = 'Basic'[source]#

OAuth2 basic token type.

BEARER = 'Bearer'[source]#

OAuth2 bearer token type.

BOT = 'Bot'[source]#

Bot token type.

hikari.applications.get_token_id(token)[source]#

Try to get the bot ID stored in a token.

Returns:
hikari.snowflakes.Snowflake

The ID that was extracted from the token.

Raises:
ValueError

If the passed token has an unexpected format.