メッセージとインタラクション¶
モデルの型付けとデコードの仕組みはモデルのガイドで説明しています。ここにあるクラスはすべて bostie からインポートできます。
bostie.models.base.Model
¶
bostie.models.message
¶
DEFAULT_ALLOWED_MENTIONS
module-attribute
¶
DEFAULT_ALLOWED_MENTIONS = AllowedMentions(parse=('users', 'roles'))
Attachment
¶
Resolved
¶
Bases: Model
The users, members, roles, channels, messages and files mentioned by id.
EmbedField
¶
EmbedFooter
¶
EmbedAuthor
¶
EmbedMedia
¶
Bases: Builder
An embed image, thumbnail or video.
EmbedProvider
¶
Embed
¶
Bases: Builder
A rich embed, as received in messages or built to send one.
ReactionCountDetails
¶
Bases: Model
The reactions of one emoji, split into super reactions and normal ones.
Reaction
¶
MessageReference
¶
Bases: Builder
StickerItem
¶
PollMedia
¶
Bases: Builder
The text of a poll question or answer, and the emoji of an answer.
PollAnswer
¶
PollAnswerCount
¶
PollResults
¶
Poll
¶
PollCreateRequest
¶
Bases: Builder
A poll to send; it stays open duration hours, 24 when not given.
SharedClientTheme
¶
Bases: Builder
A client theme shared in a message; colors are hex strings.
AllowedMentions
¶
Bases: Builder
Which mentions in a message may notify; parse=() silences all of them.
Sent with a bot that has a default, it changes only the kinds of mention it sets.
MessageActivity
¶
MessageApplication
¶
Bases: PartialApplication
The app behind the Rich Presence invite a message carries.
ChannelMention
¶
RoleSubscriptionData
¶
MessageCall
¶
InteractionMetadata
¶
Bases: Model, Snowflake
The interaction a message answers; its type picks the subclass.
authorizing_integration_owners
instance-attribute
¶
authorizing_integration_owners: dict[ApplicationIntegrationType, int]
original_response_message_id
class-attribute
instance-attribute
¶
original_response_message_id: int | None = None
CommandInteractionMetadata
¶
Bases: InteractionMetadata
A command run; the target is set for user and message commands.
ComponentInteractionMetadata
¶
Bases: InteractionMetadata
ModalInteractionMetadata
¶
Bases: InteractionMetadata
triggering_interaction_metadata
property
¶
triggering_interaction_metadata: InteractionMetadata
The command or component that opened the modal, decoded on each access.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
authorizing_integration_owners
instance-attribute
¶
authorizing_integration_owners: dict[ApplicationIntegrationType, int]
MentionedUser
¶
Bases: User
A user a message mentions, with their member when it was sent in a guild.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
avatar_decoration_data
class-attribute
instance-attribute
¶
avatar_decoration_data: AvatarDecorationData | None = None
display_name_styles
class-attribute
instance-attribute
¶
display_name_styles: DisplayNameStyles | None = None
SnapshotMessage
¶
PartialMessage
¶
Bases: Model, Snowflake
A message as an interaction resolves it, with only some of its fields.
message_reference
class-attribute
instance-attribute
¶
message_reference: MessageReference | None = None
referenced_message
property
¶
referenced_message: Message | WebhookMessage | None
The message this one replies to, decoded on each access.
Message
¶
Bases: _Message
A message in a channel, sent by a user or a bot.
author_member
property
¶
author_member: ResolvedMember | None
The author as a guild member, when the message carries its member.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
message_reference
class-attribute
instance-attribute
¶
message_reference: MessageReference | None = None
referenced_message
property
¶
referenced_message: Message | WebhookMessage | None
The message this one replies to, decoded on each access.
shared_client_theme
class-attribute
instance-attribute
¶
shared_client_theme: SharedClientTheme | None = None
mention_channels
class-attribute
instance-attribute
¶
mention_channels: tuple[ChannelMention, ...] = ()
message_snapshots
class-attribute
instance-attribute
¶
message_snapshots: tuple[MessageSnapshot, ...] = ()
role_subscription_data
class-attribute
instance-attribute
¶
role_subscription_data: RoleSubscriptionData | None = None
interaction_metadata
property
¶
interaction_metadata: InteractionMetadata | None
The interaction this message answers, decoded on each access.
WebhookMessage
¶
Bases: _Message
A message a webhook sent, interaction responses included.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
message_reference
class-attribute
instance-attribute
¶
message_reference: MessageReference | None = None
referenced_message
property
¶
referenced_message: Message | WebhookMessage | None
The message this one replies to, decoded on each access.
shared_client_theme
class-attribute
instance-attribute
¶
shared_client_theme: SharedClientTheme | None = None
mention_channels
class-attribute
instance-attribute
¶
mention_channels: tuple[ChannelMention, ...] = ()
message_snapshots
class-attribute
instance-attribute
¶
message_snapshots: tuple[MessageSnapshot, ...] = ()
role_subscription_data
class-attribute
instance-attribute
¶
role_subscription_data: RoleSubscriptionData | None = None
interaction_metadata
property
¶
interaction_metadata: InteractionMetadata | None
The interaction this message answers, decoded on each access.
MessagePin
¶
MessageSearchResults
¶
EditParts
¶
Bases: TypedDict
The parts of a message to edit: a part not given stays and None clears it.
With files or attachments, only the listed attachments stay.
decode_message
¶
decode_message(data: bytes) -> Message | WebhookMessage
Decode a message into Message, or WebhookMessage when a webhook sent it.
bostie.models.components
¶
KnownComponent
¶
KnownComponent = ActionRow | Button | StringSelect | UserSelect | RoleSelect | MentionableSelect | ChannelSelect | Section | TextDisplay | Thumbnail | MediaGallery | FileComponent | Separator | Container
KnownSubmitted
¶
KnownSubmitted = SubmittedTextDisplay | SubmittedLabel | SubmittedTextInput | SubmittedStringSelect | SubmittedUserSelect | SubmittedRoleSelect | SubmittedMentionableSelect | SubmittedChannelSelect | SubmittedFileUpload | SubmittedRadioGroup | SubmittedCheckboxGroup | SubmittedCheckbox
PartialEmoji
¶
ActionRow
¶
Button
¶
Bases: _Component
SelectOption
¶
Bases: Builder
SelectDefaultValue
¶
StringSelect
¶
Bases: _Select
UserSelect
¶
Bases: _EntitySelect
default_values
class-attribute
instance-attribute
¶
default_values: tuple[SelectDefaultValue, ...] = ()
RoleSelect
¶
Bases: _EntitySelect
default_values
class-attribute
instance-attribute
¶
default_values: tuple[SelectDefaultValue, ...] = ()
MentionableSelect
¶
Bases: _EntitySelect
default_values
class-attribute
instance-attribute
¶
default_values: tuple[SelectDefaultValue, ...] = ()
ChannelSelect
¶
Bases: _EntitySelect
default_values
class-attribute
instance-attribute
¶
default_values: tuple[SelectDefaultValue, ...] = ()
ContentScanMetadata
¶
Bases: Builder
What Discord's content scan found in a media item.
UnfurledMediaItem
¶
Bases: Builder
An image, video or file shown by a component; only url is set when sending.
content_scan_metadata
class-attribute
instance-attribute
¶
content_scan_metadata: ContentScanMetadata | None = None
Section
¶
TextDisplay
¶
Thumbnail
¶
Bases: _Component
MediaGalleryItem
¶
MediaGallery
¶
Bases: _Component
FileComponent
¶
Bases: _Component
A file attached to the message, shown in its place among the components.
Separator
¶
Container
¶
Bases: _Component
UnknownComponent
¶
SubmittedTextDisplay
¶
Bases: _Submitted
A text display of a submitted modal, which carries no answer.
SubmittedLabel
¶
Bases: _Submitted
A label of a submitted modal and the answered component inside it.
SubmittedInput
¶
Bases: _Submitted
What the user answered in one component of a modal.
SubmittedTextInput
¶
Bases: SubmittedInput
SubmittedValues
¶
Bases: SubmittedInput
The options picked in a string select or a checkbox group.
SubmittedIds
¶
Bases: SubmittedInput
The users, roles or channels picked in a select, or the files uploaded.
SubmittedStringSelect
¶
Bases: SubmittedValues
SubmittedUserSelect
¶
Bases: SubmittedIds
SubmittedRoleSelect
¶
Bases: SubmittedIds
SubmittedMentionableSelect
¶
Bases: SubmittedIds
SubmittedChannelSelect
¶
Bases: SubmittedIds
SubmittedFileUpload
¶
Bases: SubmittedIds
SubmittedRadioGroup
¶
Bases: SubmittedInput
SubmittedCheckboxGroup
¶
Bases: SubmittedValues
SubmittedCheckbox
¶
Bases: SubmittedInput
decode_components
¶
Decode components; those of unknown type or shape become UnknownComponent.
decode_submitted
¶
decode_submitted(raws: Iterable[Raw]) -> tuple[SubmittedComponent, ...]
Decode a modal's answered components; unknown ones become UnknownComponent.
bostie.models.interaction
¶
Interaction
¶
Interaction = CommandInteraction | ComponentInteraction | AutocompleteInteraction | ModalSubmitInteraction | UnknownInteraction
InteractionDataOption
¶
CommandData
¶
ComponentData
¶
StringSelectData
¶
Bases: ComponentData
A string select and the options picked in it.
EntitySelectData
¶
Bases: ComponentData
A user, role, mentionable or channel select and the ids picked in it.
ApplicationCommandOptionChoice
¶
ApplicationCommandOption
¶
Bases: Builder
An option of a slash command; subcommands and groups nest their options.
name_localizations
class-attribute
instance-attribute
¶
description_localizations
class-attribute
instance-attribute
¶
choices
class-attribute
instance-attribute
¶
choices: tuple[ApplicationCommandOptionChoice, ...] = ()
ApplicationCommand
¶
Bases: Model, Snowflake
A command of the app, global or in the guild of guild_id.
name_localizations
class-attribute
instance-attribute
¶
description_localizations
class-attribute
instance-attribute
¶
integration_types
class-attribute
instance-attribute
¶
integration_types: tuple[ApplicationIntegrationType, ...] = ()
contexts
class-attribute
instance-attribute
¶
contexts: tuple[InteractionContextType, ...] | None = None
CommandPermission
¶
GuildCommandPermissions
¶
CommandInteraction
¶
Bases: _Interaction
A slash, user or message command run.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
authorizing_integration_owners
instance-attribute
¶
authorizing_integration_owners: dict[ApplicationIntegrationType, int]
entitlements
property
¶
entitlements: tuple[PartialEntitlement, ...]
The user's entitlements to the app's SKUs; test ones have no period.
AutocompleteInteraction
¶
Bases: _Interaction
A request for choices while the user types an option.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
authorizing_integration_owners
instance-attribute
¶
authorizing_integration_owners: dict[ApplicationIntegrationType, int]
entitlements
property
¶
entitlements: tuple[PartialEntitlement, ...]
The user's entitlements to the app's SKUs; test ones have no period.
ComponentInteraction
¶
Bases: _Interaction
A button press or a select menu pick.
data
property
¶
data: ComponentData
The component and what was picked in it, decoded on each access.
message
property
¶
message: Message | WebhookMessage
The message the component is on, decoded on each access.
message_flags
property
¶
message_flags: MessageFlags
The flags of the component's message, decoded without the rest of it.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
authorizing_integration_owners
instance-attribute
¶
authorizing_integration_owners: dict[ApplicationIntegrationType, int]
entitlements
property
¶
entitlements: tuple[PartialEntitlement, ...]
The user's entitlements to the app's SKUs; test ones have no period.
ModalSubmitData
¶
ModalSubmitInteraction
¶
Bases: _Interaction
A modal submit.
message
property
¶
message: Message | WebhookMessage | None
The message whose component opened the modal, decoded on each access.
message_flags
property
¶
message_flags: MessageFlags | None
The flags of that message, decoded alone, or None without a message.
raw_json
class-attribute
instance-attribute
¶
raw_json: bytes | None = msgspec.field(default=None, name='__bostie_raw__')
authorizing_integration_owners
instance-attribute
¶
authorizing_integration_owners: dict[ApplicationIntegrationType, int]
entitlements
property
¶
entitlements: tuple[PartialEntitlement, ...]
The user's entitlements to the app's SKUs; test ones have no period.
UnknownInteraction
¶
decode_interaction
¶
decode_interaction(data: bytes) -> Interaction
Decode an interaction into the model of its type, or UnknownInteraction.