hikari.api.entity_factory
#
Core interface for an object that serializes/deserializes API objects.
EntityFactory
#
Bases: ABC
Interface for components that serialize and deserialize JSON payloads.
deserialize_application
abstractmethod
#
deserialize_application(payload: JSONObject) -> Application
Parse a raw payload from Discord into an application object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Application
|
The deserialized application object. |
deserialize_application_connection_metadata_record
abstractmethod
#
deserialize_application_connection_metadata_record(
payload: JSONObject,
) -> ApplicationRoleConnectionMetadataRecord
Parse a raw payload from Discord into an application connection metadata record object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ApplicationRoleConnectionMetadataRecord
|
The deserialized "application connection metadata record" object. |
deserialize_application_webhook
abstractmethod
#
deserialize_application_webhook(payload: JSONObject) -> ApplicationWebhook
Parse a raw payload from Discord into an application webhook object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ApplicationWebhook
|
The parsed application webhook object. |
deserialize_audit_log
abstractmethod
#
Parse a raw payload from Discord into an audit log object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
guild_id |
The ID of the guild this audit log belongs to.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AuditLog
|
The deserialized audit log object. |
deserialize_audit_log_entry
abstractmethod
#
deserialize_audit_log_entry(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> AuditLogEntry
Parse a raw payload from Discord into an audit log entry object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this entry belongs to. If passed then this
will be prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AuditLogEntry
|
The deserialized audit log entry object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_authorization_information
abstractmethod
#
deserialize_authorization_information(
payload: JSONObject,
) -> AuthorizationInformation
Parse a raw payload from Discord into an authorization information object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AuthorizationInformation
|
The deserialized authorization information object. |
deserialize_authorization_token
abstractmethod
#
deserialize_authorization_token(
payload: JSONObject,
) -> OAuth2AuthorizationToken
Parse a raw payload from Discord into an authorization token object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OAuth2AuthorizationToken
|
The deserialized OAuth2 authorization token object. |
deserialize_autocomplete_interaction
abstractmethod
#
deserialize_autocomplete_interaction(
payload: JSONObject,
) -> AutocompleteInteraction
Parse a raw payload from Discord into an autocomplete interaction object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AutocompleteInteraction
|
The deserialized autocomplete interaction object. |
deserialize_channel
abstractmethod
#
deserialize_channel(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> PartialChannel
Parse a raw payload from Discord into a channel object.
Note
This also deserializes to thread channels.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. This will be ignored
for DM and group DM channels and will be prioritised over
This is necessary in
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialChannel
|
The deserialized partial channel-derived object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
UnrecognisedEntityError
|
If the channel type is unknown. |
deserialize_channel_follow
abstractmethod
#
deserialize_channel_follow(payload: JSONObject) -> ChannelFollow
Parse a raw payload from Discord into a channel follow object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ChannelFollow
|
The deserialized channel follow object. |
deserialize_channel_follower_webhook
abstractmethod
#
deserialize_channel_follower_webhook(
payload: JSONObject,
) -> ChannelFollowerWebhook
Parse a raw payload from Discord into a channel follower webhook object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ChannelFollowerWebhook
|
The parsed channel follower webhook object. |
deserialize_command
abstractmethod
#
deserialize_command(
payload: JSONObject,
*,
guild_id: UndefinedNoneOr[Snowflake] = undefined.UNDEFINED
) -> PartialCommand
Parse a raw payload from Discord into a command object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this command belongs to. If this is specified
then this will be prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialCommand
|
The deserialized command object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
UnrecognisedEntityError
|
If the command type is unknown. |
deserialize_command_interaction
abstractmethod
#
deserialize_command_interaction(payload: JSONObject) -> CommandInteraction
Parse a raw payload from Discord into a command interaction object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CommandInteraction
|
The deserialized command interaction object. |
deserialize_component_interaction
abstractmethod
#
deserialize_component_interaction(payload: JSONObject) -> ComponentInteraction
Parser a raw payload from Discord into a component interaction object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ComponentInteraction
|
The deserialized component interaction. |
deserialize_context_menu_command
abstractmethod
#
deserialize_context_menu_command(
payload: JSONObject,
*,
guild_id: UndefinedNoneOr[Snowflake] = undefined.UNDEFINED
) -> ContextMenuCommand
Parse a raw payload from Discord into a context menu command object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this command belongs to. If this is specified
then this will be prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ContextMenuCommand
|
The deserialized context menu command object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_custom_emoji
abstractmethod
#
deserialize_custom_emoji(payload: JSONObject) -> CustomEmoji
Parse a raw payload from Discord into a custom emoji object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CustomEmoji
|
The deserialized custom emoji object. |
deserialize_dm
abstractmethod
#
deserialize_dm(payload: JSONObject) -> DMChannel
Parse a raw payload from Discord into a DM channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DMChannel
|
The deserialized DM channel object. |
deserialize_embed
abstractmethod
#
deserialize_embed(payload: JSONObject) -> Embed
Parse a raw payload from Discord into an embed object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Embed
|
The deserialized embed object. |
deserialize_emoji
abstractmethod
#
deserialize_emoji(payload: JSONObject) -> Union[UnicodeEmoji, CustomEmoji]
Parse a raw payload from Discord into an emoji object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
UnicodeEmoji or CustomEmoji
|
The deserialized custom or unicode emoji object. |
deserialize_entitlement
abstractmethod
#
deserialize_entitlement(payload: JSONObject) -> Entitlement
Parse a raw payload from Discord into an entitlement object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Entitlement
|
The deserialized entitlement object. |
deserialize_gateway_bot_info
abstractmethod
#
deserialize_gateway_bot_info(payload: JSONObject) -> GatewayBotInfo
Parse a raw payload from Discord into a gateway bot object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GatewayBotInfo
|
The deserialized gateway bot information object. |
deserialize_gateway_guild
abstractmethod
#
deserialize_gateway_guild(
payload: JSONObject, *, user_id: Snowflake
) -> GatewayGuildDefinition
Parse a raw payload from Discord into a guild object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
user_id |
The current user's ID.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GatewayGuildDefinition
|
The deserialized guild object and the internal collections as
maps of |
deserialize_group_dm
abstractmethod
#
deserialize_group_dm(payload: JSONObject) -> GroupDMChannel
Parse a raw payload from Discord into a group DM channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GroupDMChannel
|
The deserialized group DM object. |
deserialize_guild_category
abstractmethod
#
deserialize_guild_category(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> GuildCategory
Parse a raw payload from Discord into a guild category object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. If passed then this
will be prioritised over This currently only covers the gateway
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildCategory
|
The deserialized guild category object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_command_permissions
abstractmethod
#
deserialize_guild_command_permissions(
payload: JSONObject,
) -> GuildCommandPermissions
Parse a raw payload from Discord into guild command permissions object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildCommandPermissions
|
The deserialized guild command permissions object. |
deserialize_guild_forum_channel
abstractmethod
#
deserialize_guild_forum_channel(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> GuildForumChannel
Parse a raw payload from Discord into a guild forum channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. If passed then this
will be prioritised over This currently only covers the gateway
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildForumChannel
|
The deserialized guild forum channel object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_member_ban
abstractmethod
#
deserialize_guild_member_ban(payload: JSONObject) -> GuildBan
Parse a raw payload from Discord into a guild member ban object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildBan
|
The deserialized guild member ban object. |
deserialize_guild_news_channel
abstractmethod
#
deserialize_guild_news_channel(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> GuildNewsChannel
Parse a raw payload from Discord into a guild news channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. If passed then this
will be prioritised over This currently only covers the gateway
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildNewsChannel
|
The deserialized guild news channel object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_news_thread
abstractmethod
#
deserialize_guild_news_thread(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED,
member: UndefinedNoneOr[ThreadMember] = undefined.UNDEFINED
) -> GuildNewsThread
Parse a raw payload from Discord into a guild news thread object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. This will be
prioritised over Note
TYPE:
|
member |
The member object for the thread. If passed then this will be
prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildNewsThread
|
The deserialized guild news thread object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_preview
abstractmethod
#
deserialize_guild_preview(payload: JSONObject) -> GuildPreview
Parse a raw payload from Discord into a guild preview object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildPreview
|
The deserialized guild preview object. |
deserialize_guild_private_thread
abstractmethod
#
deserialize_guild_private_thread(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED,
member: UndefinedNoneOr[ThreadMember] = undefined.UNDEFINED
) -> GuildPrivateThread
Parse a raw payload from Discord into a guild private thread object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. This will be
prioritised over Note
TYPE:
|
member |
The member object for the thread. If passed then this will be
prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildPrivateThread
|
The deserialized guild private thread object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_public_thread
abstractmethod
#
deserialize_guild_public_thread(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED,
member: UndefinedNoneOr[ThreadMember] = undefined.UNDEFINED
) -> GuildPublicThread
Parse a raw payload from Discord into a guild public thread object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. This will be
prioritised over Note
TYPE:
|
member |
The member object for the thread. If passed then this will be
prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildPublicThread
|
The deserialized guild public thread object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_stage_channel
abstractmethod
#
deserialize_guild_stage_channel(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> GuildStageChannel
Parse a raw payload from Discord into a guild stage channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. If passed then this
will be prioritised over This currently only covers the gateway
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildStageChannel
|
The deserialized guild stage channel object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_sticker
abstractmethod
#
deserialize_guild_sticker(payload: JSONObject) -> GuildSticker
Parse a raw payload from Discord into a guild sticker object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildSticker
|
The deserialized guild sticker object. |
deserialize_guild_text_channel
abstractmethod
#
deserialize_guild_text_channel(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> GuildTextChannel
Parse a raw payload from Discord into a guild text channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. If passed then this
will be prioritised over This currently only covers the gateway
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildTextChannel
|
The deserialized guild text channel object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_thread
abstractmethod
#
deserialize_guild_thread(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED,
member: UndefinedNoneOr[ThreadMember] = undefined.UNDEFINED
) -> GuildThreadChannel
Parse a raw payload from Discord into a guild thread channel object.
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. If passed then this
will be prioritised over Note
TYPE:
|
member |
The member object for the thread. If passed then this will be
prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildThreadChannel
|
The deserialized guild thread channel object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_voice_channel
abstractmethod
#
deserialize_guild_voice_channel(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> GuildVoiceChannel
Parse a raw payload from Discord into a guild voice channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this channel belongs to. If passed then this
will be prioritised over This currently only covers the gateway
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildVoiceChannel
|
The deserialized guild voice channel object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_guild_widget
abstractmethod
#
deserialize_guild_widget(payload: JSONObject) -> GuildWidget
Parse a raw payload from Discord into a guild widget object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GuildWidget
|
The deserialized guild widget object. |
deserialize_implicit_token
abstractmethod
#
deserialize_implicit_token(query: Query) -> OAuth2ImplicitToken
Parse a query from Discord into an implicit token object.
PARAMETER | DESCRIPTION |
---|---|
query |
The query parameters to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OAuth2ImplicitToken
|
The deserialized OAuth2 implicit token object. |
deserialize_incoming_webhook
abstractmethod
#
deserialize_incoming_webhook(payload: JSONObject) -> IncomingWebhook
Parse a raw payload from Discord into a incoming webhook object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
IncomingWebhook
|
The parsed incoming webhook object. |
deserialize_integration
abstractmethod
#
deserialize_integration(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> Integration
Parse a raw payload from Discord into an integration object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this integration belongs to. If this is specified
then this will be prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Integration
|
The deserialized integration object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_interaction
abstractmethod
#
deserialize_interaction(payload: JSONObject) -> PartialInteraction
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
hikari.api.entity_factory.EntityFactory.deserialize_partial_interaction
should be compatible.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialInteraction
|
The deserialized interaction object. |
RAISES | DESCRIPTION |
---|---|
UnrecognisedEntityError
|
If the integration type is unknown. |
deserialize_invite
abstractmethod
#
deserialize_invite(payload: JSONObject) -> Invite
Parse a raw payload from Discord into an invite object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Invite
|
The deserialized invite object. |
deserialize_invite_with_metadata
abstractmethod
#
deserialize_invite_with_metadata(payload: JSONObject) -> InviteWithMetadata
Parse a raw payload from Discord into a invite with metadata object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
InviteWithMetadata
|
The deserialized invite with metadata object. |
deserialize_known_custom_emoji
abstractmethod
#
deserialize_known_custom_emoji(
payload: JSONObject, *, guild_id: Snowflake
) -> KnownCustomEmoji
Parse a raw payload from Discord into a known custom emoji object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
guild_id |
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
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
KnownCustomEmoji
|
The deserialized "known custom emoji" object. |
deserialize_member
abstractmethod
#
deserialize_member(
payload: JSONObject,
*,
user: UndefinedOr[User] = undefined.UNDEFINED,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> Member
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.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
user |
The user to attach to this member, should only be passed in situations where "user" is not included in the payload.
TYPE:
|
guild_id |
The ID of the guild this member belongs to. If this is specified
then this will be prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Member
|
The deserialized member object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_member_presence
abstractmethod
#
deserialize_member_presence(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> MemberPresence
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.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild the presence belongs to. If this is specified
then it is prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
MemberPresence
|
The deserialized member presence object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_message
abstractmethod
#
deserialize_message(payload: JSONObject) -> Message
Parse a raw payload from Discord into a message object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Message
|
The deserialized message object. |
deserialize_modal_interaction
abstractmethod
#
deserialize_modal_interaction(payload: JSONObject) -> ModalInteraction
Parse a raw payload from Discord into a modal interaction object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ModalInteraction
|
The deserialized modal interaction object. |
deserialize_my_user
abstractmethod
#
deserialize_my_user(payload: JSONObject) -> OwnUser
Parse a raw payload from Discord into a user object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OwnUser
|
The deserialized user object. |
deserialize_own_application_role_connection
abstractmethod
#
deserialize_own_application_role_connection(
payload: JSONObject,
) -> OwnApplicationRoleConnection
Parse a raw payload from Discord into an own application role connection object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OwnApplicationRoleConnection
|
The deserialized "own application role connection" object. |
deserialize_own_connection
abstractmethod
#
deserialize_own_connection(payload: JSONObject) -> OwnConnection
Parse a raw payload from Discord into an own connection object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OwnConnection
|
The deserialized "own connection" object. |
deserialize_own_guild
abstractmethod
#
deserialize_own_guild(payload: JSONObject) -> OwnGuild
Parse a raw payload from Discord into an own guild object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
OwnGuild
|
The deserialized "own guild" object. |
deserialize_partial_channel
abstractmethod
#
deserialize_partial_channel(payload: JSONObject) -> PartialChannel
Parse a raw payload from Discord into a partial channel object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialChannel
|
The deserialized "partial channel" object. |
deserialize_partial_integration
abstractmethod
#
deserialize_partial_integration(payload: JSONObject) -> PartialIntegration
Parse a raw payload from Discord into a partial integration object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialIntegration
|
The deserialized partial integration object. |
deserialize_partial_interaction
abstractmethod
#
deserialize_partial_interaction(payload: JSONObject) -> PartialInteraction
Parse a raw payload from Discord into a partial interaction object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialInteraction
|
The deserialized partial interaction object. |
deserialize_partial_message
abstractmethod
#
deserialize_partial_message(payload: JSONObject) -> PartialMessage
Parse a raw payload from Discord into a partial message object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialMessage
|
The deserialized partial message object. |
deserialize_partial_sticker
abstractmethod
#
deserialize_partial_sticker(payload: JSONObject) -> PartialSticker
Parse a raw payload from Discord into a partial sticker object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialSticker
|
The deserialized partial sticker object. |
deserialize_partial_token
abstractmethod
#
deserialize_partial_token(payload: JSONObject) -> PartialOAuth2Token
Parse a raw payload from Discord into a partial OAuth2 token object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialOAuth2Token
|
The deserialized partial OAuth2 token object. |
deserialize_permission_overwrite
abstractmethod
#
deserialize_permission_overwrite(payload: JSONObject) -> PermissionOverwrite
Parse a raw payload from Discord into a permission overwrite object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PermissionOverwrite
|
The deserialized permission overwrite object. |
deserialize_rest_guild
abstractmethod
#
deserialize_rest_guild(payload: JSONObject) -> RESTGuild
Parse a raw payload from Discord into a guild object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RESTGuild
|
The deserialized guild object. |
deserialize_role
abstractmethod
#
Parse a raw payload from Discord into a role object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
guild_id |
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
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Role
|
The deserialized role object. |
deserialize_scheduled_event
abstractmethod
#
deserialize_scheduled_event(payload: JSONObject) -> ScheduledEvent
Parse a raw payload from Discord into a scheduled event object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ScheduledEvent
|
The deserialized scheduled event object. |
RAISES | DESCRIPTION |
---|---|
UnrecognisedEntityError
|
If the scheduled event type is unknown. |
deserialize_scheduled_event_user
abstractmethod
#
deserialize_scheduled_event_user(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> ScheduledEventUser
Parse a raw payload from Discord into a scheduled event user object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild the user belongs to. If this is specified
then it is prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ScheduledEventUser
|
The deserialized scheduled event user object. |
deserialize_scheduled_external_event
abstractmethod
#
deserialize_scheduled_external_event(
payload: JSONObject,
) -> ScheduledExternalEvent
Parse a raw payload from Discord into a scheduled external event object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ScheduledExternalEvent
|
The deserialized scheduled external event object. |
deserialize_scheduled_stage_event
abstractmethod
#
deserialize_scheduled_stage_event(payload: JSONObject) -> ScheduledStageEvent
Parse a raw payload from Discord into a scheduled stage event object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ScheduledStageEvent
|
The deserialized scheduled stage event object. |
deserialize_scheduled_voice_event
abstractmethod
#
deserialize_scheduled_voice_event(payload: JSONObject) -> ScheduledVoiceEvent
Parse a raw payload from Discord into a scheduled voice event object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ScheduledVoiceEvent
|
The deserialized scheduled voice event object. |
deserialize_sku
abstractmethod
#
deserialize_sku(payload: JSONObject) -> SKU
Parse a raw payload from Discord into an SKU object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SKU
|
The deserialized SKU object. |
deserialize_slash_command
abstractmethod
#
deserialize_slash_command(
payload: JSONObject,
*,
guild_id: UndefinedNoneOr[Snowflake] = undefined.UNDEFINED
) -> SlashCommand
Parse a raw payload from Discord into a slash command object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this command belongs to. If this is specified
then this will be prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SlashCommand
|
The deserialized slash command object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_standard_sticker
abstractmethod
#
deserialize_standard_sticker(payload: JSONObject) -> StandardSticker
Parse a raw payload from Discord into a standard sticker object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
StandardSticker
|
The deserialized standard sticker object. |
deserialize_sticker_pack
abstractmethod
#
deserialize_sticker_pack(payload: JSONObject) -> StickerPack
Parse a raw payload from Discord into a sticker pack object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
StickerPack
|
The deserialized sticker pack object. |
deserialize_template
abstractmethod
#
deserialize_template(payload: JSONObject) -> Template
Parse a raw payload from Discord into a template object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Template
|
The deserialized template object. |
deserialize_thread_member
abstractmethod
#
deserialize_thread_member(
payload: JSONObject,
*,
thread_id: UndefinedOr[Snowflake] = undefined.UNDEFINED
) -> ThreadMember
Parse a raw payload from Discord into a thread member object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
thread_id |
ID of the thread this member belongs to. This will be
prioritised over Note
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ThreadMember
|
The deserialized thread member object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If |
deserialize_unicode_emoji
abstractmethod
#
deserialize_unicode_emoji(payload: JSONObject) -> UnicodeEmoji
Parse a raw payload from Discord into a unicode emoji object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
UnicodeEmoji
|
The deserialized unicode emoji object. |
deserialize_user
abstractmethod
#
deserialize_user(payload: JSONObject) -> User
Parse a raw payload from Discord into a user object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
User
|
The deserialized user object. |
deserialize_vanity_url
abstractmethod
#
deserialize_vanity_url(payload: JSONObject) -> VanityURL
Parse a raw payload from Discord into a vanity url object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
VanityURL
|
The deserialized vanity url object. |
deserialize_voice_region
abstractmethod
#
deserialize_voice_region(payload: JSONObject) -> VoiceRegion
Parse a raw payload from Discord into a voice region object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
VoiceRegion
|
The deserialized voice region object. |
deserialize_voice_state
abstractmethod
#
deserialize_voice_state(
payload: JSONObject,
*,
guild_id: UndefinedOr[Snowflake] = undefined.UNDEFINED,
member: UndefinedOr[Member] = undefined.UNDEFINED
) -> VoiceState
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.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
guild_id |
The ID of the guild this voice state belongs to. If this is specified
then this will be prioritised over
TYPE:
|
member |
The object of the member this voice state belongs to. If this is
specified then this will be prioritised over
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
VoiceState
|
The deserialized voice state object. |
RAISES | DESCRIPTION |
---|---|
KeyError
|
If This will also be raised if no |
deserialize_webhook
abstractmethod
#
deserialize_webhook(payload: JSONObject) -> PartialWebhook
Parse a raw payload from Discord into a webhook object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PartialWebhook
|
The deserialized webhook object. |
RAISES | DESCRIPTION |
---|---|
UnrecognisedEntityError
|
If the channel type is unknown. |
deserialize_welcome_screen
abstractmethod
#
deserialize_welcome_screen(payload: JSONObject) -> WelcomeScreen
Parse a raw payload from Discord into a guild welcome screen object.
PARAMETER | DESCRIPTION |
---|---|
payload |
The JSON payload to deserialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
WelcomeScreen
|
The deserialized guild welcome screen object. |
serialize_application_connection_metadata_record
abstractmethod
#
serialize_application_connection_metadata_record(
record: ApplicationRoleConnectionMetadataRecord,
) -> JSONObject
Serialize an application connection metadata record object to a json serializable dict.
PARAMETER | DESCRIPTION |
---|---|
record |
The record object to serialize. |
RETURNS | DESCRIPTION |
---|---|
JSONObject
|
The serialized representation of the record object. |
serialize_command_option
abstractmethod
#
serialize_command_option(option: CommandOption) -> JSONObject
Serialize a command option object to a json serializable dict.
PARAMETER | DESCRIPTION |
---|---|
option |
The command option object to serialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
JSONObject
|
The serialized representation of the command option. |
serialize_command_permission
abstractmethod
#
serialize_command_permission(permission: CommandPermission) -> JSONObject
Serialize a command permission object to a json serializable dict.
PARAMETER | DESCRIPTION |
---|---|
permission |
The command permission object to serialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
JSONObject
|
The serialized representation of the command permission. |
serialize_embed
abstractmethod
#
serialize_embed(embed: Embed) -> Tuple[JSONObject, List[Resource[AsyncReader]]]
Serialize an embed object to a json serializable dict.
PARAMETER | DESCRIPTION |
---|---|
embed |
The embed object to serialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[JSONObject, List[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
abstractmethod
#
serialize_forum_tag(tag: ForumTag) -> JSONObject
Serialize a forum tag object to a json serializable dict.
PARAMETER | DESCRIPTION |
---|---|
tag |
The forum tag object to serialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
JSONObject
|
The serialized representation of the forum tag. |
serialize_permission_overwrite
abstractmethod
#
serialize_permission_overwrite(overwrite: PermissionOverwrite) -> JSONObject
Serialize a permission overwrite object to a json serializable dict.
PARAMETER | DESCRIPTION |
---|---|
overwrite |
The permission overwrite object to serialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
JSONObject
|
The serialized representation of the permission overwrite. |
serialize_welcome_channel
abstractmethod
#
serialize_welcome_channel(welcome_channel: WelcomeChannel) -> JSONObject
Serialize a welcome channel object to a json serializable dict.
PARAMETER | DESCRIPTION |
---|---|
welcome_channel |
The guild welcome channel object to serialize.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
JSONObject
|
The serialized representation of the welcome channel. |
GatewayGuildDefinition
#
Bases: ABC
Structure for handling entities within guild create and update events.
Warning
The methods on this class may raise LookupError
if called
when the relevant resource isn't available in the inner payload.
channels
abstractmethod
#
channels() -> Mapping[Snowflake, PermissibleGuildChannel]
Get a mapping of channel IDs to the channels that belong to the guild.
emojis
abstractmethod
#
emojis() -> Mapping[Snowflake, KnownCustomEmoji]
Get a mapping of emoji IDs to the emojis that belong to the guild.
members
abstractmethod
#
Get a mapping of user IDs to the members that belong to the guild.
Note
This may be a partial mapping of members in the guild.
presences
abstractmethod
#
presences() -> Mapping[Snowflake, MemberPresence]
Get a mapping of user IDs to the presences that are active in the guild.
Note
This may be a partial mapping of presences active in the guild.
roles
abstractmethod
#
Get a mapping of role IDs to the roles that belong to the guild.
stickers
abstractmethod
#
stickers() -> Mapping[Snowflake, GuildSticker]
Get a mapping of sticker IDs to the stickers that belong to the guild.
threads
abstractmethod
#
threads() -> Mapping[Snowflake, GuildThreadChannel]
Get a mapping of thread IDs to the public threads the bot can access in the guild.
voice_states
abstractmethod
#
voice_states() -> Mapping[Snowflake, VoiceState]
Get a mapping of user IDs to the voice states that are active in the guild.