hikari.impl.entity_factory#

Basic implementation of an entity factory for general bots and HTTP apps.

Module Contents#

class hikari.impl.entity_factory.EntityFactoryImpl(app)[source]#

Bases: hikari.api.entity_factory.EntityFactory

Standard implementation for a serializer/deserializer.

This will convert objects to/from JSON compatible representations.

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

Object of the application this entity factory is bound to.

deserialize_application(payload)[source]#

Parse a raw payload from Discord into an application object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.Application

The deserialized application object.

deserialize_application_connection_metadata_record(payload)[source]#

Parse a raw payload from Discord into an application connection metadata record object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.ApplicationRoleConnectionMetadataRecord

The deserialized “application connection metadata record” object.

deserialize_application_webhook(payload)[source]#

Parse a raw payload from Discord into an application webhook object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.webhooks.ApplicationWebhook

The parsed application webhook object.

deserialize_audit_log(payload, *, guild_id)[source]#

Parse a raw payload from Discord into an audit log object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this audit log belongs to.

Returns:
hikari.audit_logs.AuditLog

The deserialized audit log object.

deserialize_audit_log_entry(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into an audit log entry object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this entry belongs to. If passed then this will be prioritised over "guild_id" in the payload.

Returns:
hikari.audit_logs.AuditLogEntry

The deserialized audit log entry object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_authorization_information(payload)[source]#

Parse a raw payload from Discord into an authorization information object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.AuthorizationInformation

The deserialized authorization information object.

deserialize_authorization_token(payload)[source]#

Parse a raw payload from Discord into an authorization token object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.OAuth2AuthorizationToken

The deserialized OAuth2 authorization token object.

deserialize_autocomplete_interaction(payload)[source]#

Parse a raw payload from Discord into an autocomplete interaction object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.interactions.command_interactions.AutocompleteInteraction

The deserialized autocomplete interaction object.

deserialize_channel(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a channel object.

Note

This also deserializes to thread channels.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this channel belongs to. This will be ignored for DM and group DM channels and will be prioritised over "guild_id" in the payload when passed.

This is necessary in GUILD_CREATE events, where "guild_id" is not included in the channel’s payload

Returns:
hikari.channels.PartialChannel

The deserialized partial channel-derived object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload of a guild channel.

hikari.errors.UnrecognisedEntityError

If the channel type is unknown.

deserialize_channel_follow(payload)[source]#

Parse a raw payload from Discord into a channel follow object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.channels.ChannelFollow

The deserialized channel follow object.

deserialize_channel_follower_webhook(payload)[source]#

Parse a raw payload from Discord into a channel follower webhook object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.webhooks.ChannelFollowerWebhook

The parsed channel follower webhook object.

deserialize_command(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a command object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedNoneOr[hikari.snowflakes.Snowflake]

The ID of the guild this command belongs to. If this is specified then this will be prioritised over "guild_id" in the payload.

Returns:
hikari.commands.PartialCommand

The deserialized command object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload for the payload of the integration.

hikari.errors.UnrecognisedEntityError

If the command type is unknown.

deserialize_command_interaction(payload)[source]#

Parse a raw payload from Discord into a command interaction object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.interactions.command_interactions.CommandInteraction

The deserialized command interaction object.

deserialize_component_interaction(payload)[source]#

Parser a raw payload from Discord into a component interaction object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.interactions.component_interactions.ComponentInteraction

The deserialized component interaction.

deserialize_context_menu_command(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a context menu command object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedNoneOr[hikari.snowflakes.Snowflake]

The ID of the guild this command belongs to. If this is specified then this will be prioritised over "guild_id" in the payload.

Returns:
hikari.commands.ContextMenuCommand

The deserialized context menu command object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload for the payload of the integration.

deserialize_custom_emoji(payload)[source]#

Parse a raw payload from Discord into a custom emoji object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.emojis.CustomEmoji

The deserialized custom emoji object.

deserialize_dm(payload)[source]#

Parse a raw payload from Discord into a DM channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.channels.DMChannel

The deserialized DM channel object.

deserialize_embed(payload)[source]#

Parse a raw payload from Discord into an embed object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.embeds.Embed

The deserialized embed object.

deserialize_emoji(payload)[source]#

Parse a raw payload from Discord into an emoji object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.emojis.UnicodeEmoji or hikari.emojis.CustomEmoji

The deserialized custom or unicode emoji object.

deserialize_gateway_bot_info(payload)[source]#

Parse a raw payload from Discord into a gateway bot object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.sessions.GatewayBotInfo

The deserialized gateway bot information object.

deserialize_gateway_guild(payload, *, user_id)[source]#

Parse a raw payload from Discord into a guild object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

user_idhikari.snowflakes.Snowflake

The current user’s ID.

Returns:
GatewayGuildDefinition

The deserialized guild object and the internal collections as maps of hikari.snowflakes.Snowflake mapping to hikari.channels.GuildChannel, hikari.guilds.Member, hikari.presences.MemberPresence, hikari.guilds.Role, hikari.emojis.KnownCustomEmoji, and hikari.stickers.GuildSticker. This is provided in several components to allow separate caching and linking between entities in various relational cache implementations internally.

deserialize_group_dm(payload)[source]#

Parse a raw payload from Discord into a group DM channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.channels.GroupDMChannel

The deserialized group DM object.

deserialize_guild_category(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild category object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this channel belongs to. If passed then this will be prioritised over "guild_id" in the payload.

This currently only covers the gateway GUILD_CREATE event, where it is not included in the channel’s payload.

Returns:
hikari.channels.GuildCategory

The deserialized guild category object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_command_permissions(payload)[source]#

Parse a raw payload from Discord into guild command permissions object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.commands.GuildCommandPermissions

The deserialized guild command permissions object.

deserialize_guild_forum_channel(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild forum channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.snowflakes.Snowflake

The ID of the guild this channel belongs to. If passed then this will be prioritised over "guild_id" in the payload.

This currently only covers the gateway GUILD_CREATE event, where it is not included in the channel’s payload.

Returns:
hikari.channels.GuildForumChannel

The deserialized guild forum channel object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_member_ban(payload)[source]#

Parse a raw payload from Discord into a guild member ban object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.guilds.GuildBan

The deserialized guild member ban object.

deserialize_guild_news_channel(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild news channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.snowflakes.Snowflake

The ID of the guild this channel belongs to. If passed then this will be prioritised over "guild_id" in the payload.

This currently only covers the gateway GUILD_CREATE event, where it is not included in the channel’s payload.

Returns:
hikari.channels.GuildNewsChannel

The deserialized guild news channel object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_news_thread(payload, *, guild_id=undefined.UNDEFINED, member=undefined.UNDEFINED, user_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild news thread object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this channel belongs to. This will be prioritised over "guild_id" in the payload when passed.

Note

guild_id currently only covers the gateway GUILD_CREATE event where "guild_id" is not included in the channel’s payload.

memberhikari.undefined.UndefinedNoneOr[hikari.channels.ThreadMember]

The member object for the thread. If passed then this will be prioritised over "member" in the payload when passed.

Returns:
hikari.channels.GuildNewsThread

The deserialized guild news thread object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_preview(payload)[source]#

Parse a raw payload from Discord into a guild preview object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.guilds.GuildPreview

The deserialized guild preview object.

deserialize_guild_private_thread(payload, *, guild_id=undefined.UNDEFINED, member=undefined.UNDEFINED, user_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild private thread object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this channel belongs to. This will be prioritised over "guild_id" in the payload when passed.

Note

guild_id currently only covers the gateway GUILD_CREATE event where "guild_id" is not included in the channel’s payload.

memberhikari.undefined.UndefinedNoneOr[hikari.channels.ThreadMember]

The member object for the thread. If passed then this will be prioritised over "member" in the payload when passed.

Returns:
hikari.channels.GuildPrivateThread

The deserialized guild private thread object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_public_thread(payload, *, guild_id=undefined.UNDEFINED, member=undefined.UNDEFINED, user_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild public thread object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this channel belongs to. This will be prioritised over "guild_id" in the payload when passed.

Note

guild_id currently only covers the gateway GUILD_CREATE event where "guild_id" is not included in the channel’s payload.

memberhikari.undefined.UndefinedNoneOr[hikari.channels.ThreadMember]

The member object for the thread. If passed then this will be prioritised over "member" in the payload when passed.

Returns:
hikari.channels.GuildPublicThread

The deserialized guild public thread object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_stage_channel(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild stage channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.snowflakes.Snowflake

The ID of the guild this channel belongs to. If passed then this will be prioritised over "guild_id" in the payload.

This currently only covers the gateway GUILD_CREATE event, where it is not included in the channel’s payload.

Returns:
hikari.channels.GuildStageChannel

The deserialized guild stage channel object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_sticker(payload)[source]#

Parse a raw payload from Discord into a guild sticker object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.stickers.GuildSticker

The deserialized guild sticker object.

deserialize_guild_text_channel(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild text channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this channel belongs to. If passed then this will be prioritised over "guild_id" in the payload.

This currently only covers the gateway GUILD_CREATE event, where it is not included in the channel’s payload.

Returns:
hikari.channels.GuildTextChannel

The deserialized guild text channel object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_thread(payload, *, guild_id=undefined.UNDEFINED, member=undefined.UNDEFINED, user_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild thread channel object.

Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this channel belongs to. If passed then this will be prioritised over "guild_id" in the payload.

Note

guild_id currently only covers the gateway GUILD_CREATE event where "guild_id" is not included in the channel’s payload.

memberhikari.undefined.UndefinedNoneOr[hikari.channels.ThreadMember]

The member object for the thread. If passed then this will be prioritised over "member" in the payload when passed.

Returns:
hikari.channels.GuildThreadChannel

The deserialized guild thread channel object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_voice_channel(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a guild voice channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.snowflakes.Snowflake

The ID of the guild this channel belongs to. If passed then this will be prioritised over "guild_id" in the payload.

This currently only covers the gateway GUILD_CREATE event, where it is not included in the channel’s payload.

Returns:
hikari.channels.GuildVoiceChannel

The deserialized guild voice channel object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_guild_widget(payload)[source]#

Parse a raw payload from Discord into a guild widget object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.guilds.GuildWidget

The deserialized guild widget object.

deserialize_implicit_token(query)[source]#

Parse a query from Discord into an implicit token object.

Parameters:
queryhikari.internal.data_binding.Query

The query parameters to deserialize.

Returns:
hikari.applications.OAuth2ImplicitToken

The deserialized OAuth2 implicit token object.

deserialize_incoming_webhook(payload)[source]#

Parse a raw payload from Discord into a incoming webhook object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.webhooks.IncomingWebhook

The parsed incoming webhook object.

deserialize_integration(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into an integration object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this integration belongs to. If this is specified then this will be prioritised over "guild_id" in the payload.

Returns:
hikari.guilds.Integration

The deserialized integration object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload for the payload of the integration.

deserialize_interaction(payload)[source]#

Parse a raw payload from Discord into an interaction object.

Note

This isn’t required to implement logic for deserializing PING interactions and if you want to unmarshal those EntityFactory.deserialize_partial_interaction should be compatible.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.interactions.base_interactions.PartialInteraction

The deserialized interaction object.

Raises:
hikari.errors.UnrecognisedEntityError

If the integration type is unknown.

deserialize_invite(payload)[source]#

Parse a raw payload from Discord into an invite object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.invites.Invite

The deserialized invite object.

deserialize_invite_with_metadata(payload)[source]#

Parse a raw payload from Discord into a invite with metadata object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.invites.InviteWithMetadata

The deserialized invite with metadata object.

deserialize_known_custom_emoji(payload, *, guild_id)[source]#

Parse a raw payload from Discord into a known custom emoji object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

guild_idhikari.snowflakes.Snowflake

The ID of the guild this emoji belongs to. This is used to ensure that the guild a known custom emoji belongs to is remembered by allowing for a context based artificial guild_id attribute.

Returns:
hikari.emojis.KnownCustomEmoji

The deserialized “known custom emoji” object.

deserialize_member(payload, *, user=undefined.UNDEFINED, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a member object.

Note

guild_id covers cases such as the GUILD_CREATE gateway event and GET Guild Member where "guild_id" is not included in the returned payload.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
userhikari.undefined.UndefinedOr[hikari.users.User]

The user to attach to this member, should only be passed in situations where “user” is not included in the payload.

guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this member belongs to. If this is specified then this will be prioritised over "guild_id" in the payload.

Returns:
hikari.guilds.Member

The deserialized member object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload.

deserialize_member_presence(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a member presence object.

Note

At the time of writing, the only place where guild_id will be mandatory is when parsing presences sent in a GUILD_CREATE event from Discord, since the guild_id attribute in the payload will have been omitted for redundancy.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild the presence belongs to. If this is specified then it is prioritised over guild_id in the payload.

Returns:
hikari.presences.MemberPresence

The deserialized member presence object.

Raises:
KeyError

If guild_id is not an attribute of the payload dict, and no guild ID was passed for the guild_id parameter.

If this is raised, no guild ID info was provided anywhere.

deserialize_message(payload)[source]#

Parse a raw payload from Discord into a message object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.messages.Message

The deserialized message object.

deserialize_modal_interaction(payload)[source]#

Parse a raw payload from Discord into a modal interaction object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.interactions.modal_interactions.ModalInteraction

The deserialized modal interaction object.

deserialize_my_user(payload)[source]#

Parse a raw payload from Discord into a user object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.users.OwnUser

The deserialized user object.

deserialize_own_application_role_connection(payload)[source]#

Parse a raw payload from Discord into an own application role connection object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.OwnApplicationRoleConnection

The deserialized “own application role connection” object.

deserialize_own_connection(payload)[source]#

Parse a raw payload from Discord into an own connection object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.OwnConnection

The deserialized “own connection” object.

deserialize_own_guild(payload)[source]#

Parse a raw payload from Discord into an own guild object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.OwnGuild

The deserialized “own guild” object.

deserialize_partial_channel(payload)[source]#

Parse a raw payload from Discord into a partial channel object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.channels.PartialChannel

The deserialized “partial channel” object.

deserialize_partial_integration(payload)[source]#

Parse a raw payload from Discord into a partial integration object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.guilds.PartialIntegration

The deserialized partial integration object.

deserialize_partial_interaction(payload)[source]#

Parse a raw payload from Discord into a partial interaction object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.interactions.base_interactions.PartialInteraction

The deserialized partial interaction object.

deserialize_partial_message(payload)[source]#

Parse a raw payload from Discord into a partial message object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.messages.PartialMessage

The deserialized partial message object.

deserialize_partial_sticker(payload)[source]#

Parse a raw payload from Discord into a partial sticker object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.stickers.PartialSticker

The deserialized partial sticker object.

deserialize_partial_token(payload)[source]#

Parse a raw payload from Discord into a partial OAuth2 token object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.applications.PartialOAuth2Token

The deserialized partial OAuth2 token object.

deserialize_permission_overwrite(payload)[source]#

Parse a raw payload from Discord into a permission overwrite object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.channels.PermissionOverwrite

The deserialized permission overwrite object.

deserialize_rest_guild(payload)[source]#

Parse a raw payload from Discord into a guild object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.guilds.RESTGuild

The deserialized guild object.

deserialize_role(payload, *, guild_id)[source]#

Parse a raw payload from Discord into a role object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

guild_idhikari.snowflakes.Snowflake

The ID of the guild this role belongs to. This is used to ensure that the guild a role belongs to is remembered by allowing for a context based artificial guild_id attribute.

Returns:
hikari.guilds.Role

The deserialized role object.

deserialize_scheduled_event(payload)[source]#

Parse a raw payload from Discord into a scheduled event object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.scheduled_events.ScheduledEvent

The deserialized scheduled event object.

Raises:
hikari.errors.UnrecognisedEntityError

If the scheduled event type is unknown.

deserialize_scheduled_event_user(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a scheduled event user object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild the user belongs to. If this is specified then it is prioritised over guild_id in the payload.

Returns:
hikari.scheduled_events.ScheduledEventUser

The deserialized scheduled event user object.

deserialize_scheduled_external_event(payload)[source]#

Parse a raw payload from Discord into a scheduled external event object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.scheduled_events.ScheduledExternalEvent

The deserialized scheduled external event object.

deserialize_scheduled_stage_event(payload)[source]#

Parse a raw payload from Discord into a scheduled stage event object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.scheduled_events.ScheduledStageEvent

The deserialized scheduled stage event object.

deserialize_scheduled_voice_event(payload)[source]#

Parse a raw payload from Discord into a scheduled voice event object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.scheduled_events.ScheduledVoiceEvent

The deserialized scheduled voice event object.

deserialize_slash_command(payload, *, guild_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a slash command object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedNoneOr[hikari.snowflakes.Snowflake]

The ID of the guild this command belongs to. If this is specified then this will be prioritised over "guild_id" in the payload.

Returns:
hikari.commands.SlashCommand

The deserialized slash command object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload for the payload of the integration.

deserialize_standard_sticker(payload)[source]#

Parse a raw payload from Discord into a standard sticker object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.stickers.StandardSticker

The deserialized standard sticker object.

deserialize_sticker_pack(payload)[source]#

Parse a raw payload from Discord into a sticker pack object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.stickers.StickerPack

The deserialized sticker pack object.

deserialize_template(payload)[source]#

Parse a raw payload from Discord into a template object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.templates.Template

The deserialized template object.

deserialize_thread_member(payload, *, thread_id=undefined.UNDEFINED, user_id=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a thread member object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
thread_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

ID of the thread this member belongs to. This will be prioritised over "id" in the payload when passed.

Note

thread_id currently only covers the gateway GUILD_CREATE event where the field are is included in the thread member’s payload.

Returns:
hikari.channels.ThreadMember

The deserialized thread member object.

Raises:
KeyError

If thread_id or user_id is left as hikari.undefined.UNDEFINED when the relevant field isn’t present in the passed payload.

deserialize_unicode_emoji(payload)[source]#

Parse a raw payload from Discord into a unicode emoji object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.emojis.UnicodeEmoji

The deserialized unicode emoji object.

deserialize_user(payload)[source]#

Parse a raw payload from Discord into a user object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.users.User

The deserialized user object.

deserialize_vanity_url(payload)[source]#

Parse a raw payload from Discord into a vanity url object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.invites.VanityURL

The deserialized vanity url object.

deserialize_voice_region(payload)[source]#

Parse a raw payload from Discord into a voice region object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.voices.VoiceRegion

The deserialized voice region object.

deserialize_voice_state(payload, *, guild_id=undefined.UNDEFINED, member=undefined.UNDEFINED)[source]#

Parse a raw payload from Discord into a voice state object.

Note

At the time of writing, GUILD_CREATE events are the only known place where neither guild_id nor member will be keys on the payload. In this case, you will need to provide the former parameters explicitly.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Other Parameters:
guild_idhikari.undefined.UndefinedOr[hikari.snowflakes.Snowflake]

The ID of the guild this voice state belongs to. If this is specified then this will be prioritised over "guild_id" in the payload.

memberhikari.undefined.UndefinedOr[hikari.guilds.Member]

The object of the member this voice state belongs to. If this is specified then this will be prioritised over "member" in the payload.

Returns:
hikari.voices.VoiceState

The deserialized voice state object.

Raises:
KeyError

If guild_id is left as hikari.undefined.UNDEFINED when "guild_id" is not present in the passed payload for the payload of the voice state.

This will also be raised if no member data was passed in any acceptable place.

deserialize_webhook(payload)[source]#

Parse a raw payload from Discord into a webhook object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.webhooks.PartialWebhook

The deserialized webhook object.

Raises:
hikari.errors.UnrecognisedEntityError

If the channel type is unknown.

deserialize_welcome_screen(payload)[source]#

Parse a raw payload from Discord into a guild welcome screen object.

Parameters:
payloadhikari.internal.data_binding.JSONObject

The JSON payload to deserialize.

Returns:
hikari.guilds.WelcomeScreen

The deserialized guild welcome screen object.

serialize_application_connection_metadata_record(record)[source]#

Serialize an application connection metadata record object to a json serializable dict.

Parameters:
recordhikari.applications.ApplicationRoleConnectionMetadataRecord

The record object to serialize.

Returns:
hikari.internal.data_binding.JSONObject

The serialized representation of the record object.

serialize_command_option(option)[source]#

Serialize a command option object to a json serializable dict.

Parameters:
optionhikari.commands.CommandOption

The command option object to serialize.

Returns:
hikari.internal.data_binding.JSONObject

The serialized representation of the command option.

serialize_command_permission(permission)[source]#

Serialize a command permission object to a json serializable dict.

Parameters:
permissionhikari.commands.CommandPermission

The command permission object to serialize.

Returns:
hikari.internal.data_binding.JSONObject

The serialized representation of the command permission.

serialize_embed(embed)[source]#

Serialize an embed object to a json serializable dict.

Parameters:
embedhikari.embeds.Embed

The embed object to serialize.

Returns:
typing.Tuple[hikari.internal.data_binding.JSONObject, typing.List[hikari.files.Resource]]

A tuple with two items in it. The first item will be the serialized embed representation. The second item will be a list of resources to upload with the embed.

serialize_forum_tag(tag)[source]#

Serialize a forum tag object to a json serializable dict.

Parameters:
taghikari.channels.ForumTag

The forum tag object to serialize.

Returns:
hikari.internal.data_binding.JSONObject

The serialized representation of the forum tag.

serialize_permission_overwrite(overwrite)[source]#

Serialize a permission overwrite object to a json serializable dict.

Parameters:
overwritehikari.channels.PermissionOverwrite

The permission overwrite object to serialize.

Returns:
hikari.internal.data_binding.JSONObject

The serialized representation of the permission overwrite.

serialize_welcome_channel(welcome_channel)[source]#

Serialize a welcome channel object to a json serializable dict.

Parameters:
welcome_channelhikari.guilds.WelcomeChannel

The guild welcome channel object to serialize.

Returns:
hikari.internal.data_binding.JSONObject

The serialized representation of the welcome channel.