gaato/discord/model does not have a README file
test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}pub(all) suberror AllowedMentionsError {
ParseAndExplicit(typ~ : AllowedMentionType)
TooManyRoles(count~ : Int)
TooManyUsers(count~ : Int)
} derive(Eq, Debug)pub(all) struct ActionMetadata {
channel_id : Id[ChannelMarker]?
duration_seconds : Int?
custom_message : String?
} derive(ToJson, Debug, FromJson)pub(all) struct Activity {
name : String
typ : ActivityType
url : Nullable[String]?
created_at : Int64
timestamps : ActivityTimestamps?
application_id : Id[ApplicationMarker]?
status_display_type : Nullable[Int]?
details : Nullable[String]?
details_url : Nullable[String]?
state : Nullable[String]?
state_url : Nullable[String]?
emoji : Nullable[ActivityEmoji]?
party : ActivityParty?
assets : ActivityAssets?
secrets : ActivitySecrets?
instance : Bool?
flags : ActivityFlags?
buttons : Array[ActivityButton]?
} derive(ToJson, Debug)pub(all) struct ActivityEmoji {
name : String
id : Id[EmojiMarker]?
animated : Bool?
} derive(ToJson, Debug, FromJson)impl ToJson for ActivityFlagsimpl Debug for ActivityFlagsimpl FromJson for ActivityFlagspub(all) struct ActivityInstance {
application_id : Id[ApplicationMarker]
instance_id : String
launch_id : Id[GenericMarker]
location : ActivityLocation
users : Array[Id[UserMarker]]
} derive(ToJson, Debug, FromJson)pub(all) struct ActivityLocation {
id : String
kind : ActivityLocationKind
channel_id : Id[ChannelMarker]
guild_id : Nullable[Id[GuildMarker]]?
} derive(ToJson, Debug, FromJson)impl ToJson for ActivityLocationKindimpl FromJson for ActivityLocationKindimpl ToJson for ActivityTimestampsimpl FromJson for ActivityTimestampsimpl ToJson for ActivityTypeimpl FromJson for ActivityTypeimpl ToJson for AllowedMentionTypeimpl ToJson for AllowedMentionsfn AllowedMentions::AllowedMentions(parse? : Array[AllowedMentionType], roles? : Array[Id[RoleMarker]], users? : Array[Id[UserMarker]], replied_user? : Bool) -> AllowedMentions raise AllowedMentionsErrortest "allow selected users without parsing every user mention" {
let user_id : @model.UserId = Id(42UL)
let mentions = @model.AllowedMentions(
parse=[Roles],
users=[user_id],
replied_user=false,
)
json_inspect(mentions, content={
"parse": ["roles"],
"users": ["42"],
"replied_user": false,
})
}pub(all) struct Application {
id : Id[ApplicationMarker]
name : String
icon : Nullable[ImageHash]
description : String
bot : User?
owner : User?
flags : ApplicationFlags?
flags_new : ApplicationFlags?
approximate_guild_count : Int?
approximate_user_install_count : Int?
rpc_origins : Array[String]?
bot_public : Bool?
bot_require_code_grant : Bool?
terms_of_service_url : String?
privacy_policy_url : String?
verify_key : String?
team : Nullable[Team]?
guild_id : Id[GuildMarker]?
guild : PartialGuild?
primary_sku_id : Id[SkuMarker]?
slug : String?
cover_image : ImageHash?
approximate_user_authorization_count : Int?
redirect_uris : Array[String]?
interactions_endpoint_url : Nullable[String]?
role_connections_verification_url : Nullable[String]?
event_webhooks_url : Nullable[String]?
event_webhooks_status : ApplicationEventWebhookStatus?
event_webhooks_types : Array[String]?
tags : Array[String]?
install_params : InstallParams?
integration_types_config : Map[String, ApplicationIntegrationTypeConfiguration]?
custom_install_url : String?
} derive(ToJson, Debug, FromJson)pub(all) struct ApplicationCommand {
id : Id[CommandMarker]
typ : ApplicationCommandType?
application_id : Id[ApplicationMarker]
guild_id : Id[GuildMarker]?
name : String
name_localizations : Nullable[Map[String, String]]?
description : String
description_localizations : Nullable[Map[String, String]]?
options : Array[CommandOption]?
default_member_permissions : Nullable[Permissions]
dm_permission : Bool?
nsfw : Bool?
integration_types : Array[ApplicationIntegrationType]?
contexts : Nullable[Array[InteractionContextType]]?
version : Id[CommandVersionMarker]
handler : EntryPointCommandHandlerType?
name_localized : String?
description_localized : String?
} derive(ToJson, Debug, FromJson)pub(all) struct ApplicationCommandPermission {
id : Id[GenericMarker]
typ : ApplicationCommandPermissionType
permission : Bool
} derive(ToJson, Debug, FromJson)impl ToJson for ApplicationCommandPermissionTypeimpl FromJson for ApplicationCommandPermissionTypefn from_json(json : Json, path : JsonPath) -> ApplicationCommandPermissionType raise JsonDecodeErrorimpl ToJson for ApplicationCommandTypeimpl FromJson for ApplicationCommandTypeimpl ToJson for ApplicationEventWebhookStatusimpl FromJson for ApplicationEventWebhookStatusimpl BitAnd for ApplicationFlagsimpl BitOr for ApplicationFlagsimpl ToJson for ApplicationFlagsimpl Debug for ApplicationFlagsimpl FromJson for ApplicationFlagsimpl ToJson for ApplicationIntegrationTypeimpl FromJson for ApplicationIntegrationTypepub(all) struct ApplicationIntegrationTypeConfiguration {
oauth2_install_params : InstallParams?
} derive(ToJson, Debug, FromJson)pub enum ApplicationMarker {
}fn from_json(json : Json, path : JsonPath) -> ApplicationRoleConnectionMetadataType raise JsonDecodeErrorfn ApplicationRoleConnectionMetadataType::from_int(value : Int) -> ApplicationRoleConnectionMetadataTypefn ApplicationRoleConnectionMetadataType::to_int(self : ApplicationRoleConnectionMetadataType) -> Intpub(all) struct Attachment {
id : Id[AttachmentMarker]
filename : String
title : String?
description : String?
content_type : String?
size : Int
url : String
proxy_url : String
height : Nullable[Int]?
width : Nullable[Int]?
ephemeral : Bool?
duration_secs : Double?
waveform : String?
flags : AttachmentFlags?
placeholder : String?
placeholder_version : Int?
clip_participants : Array[User]?
clip_created_at : Timestamp?
application : Nullable[Application]?
} derive(ToJson, Debug, FromJson)impl BitAnd for AttachmentFlagsimpl BitOr for AttachmentFlagsimpl ToJson for AttachmentFlagsimpl Debug for AttachmentFlagsimpl FromJson for AttachmentFlagspub(all) struct AttachmentRequest {
id : Id[AttachmentMarker]
filename : String?
title : String?
description : String?
duration_secs : Double?
waveform : String?
is_spoiler : Bool?
} derive(Debug)impl ToJson for AttachmentRequestpub(all) struct AuditLog {
audit_log_entries : Array[AuditLogEntry]
users : Array[User]
webhooks : Array[Webhook]
integrations : Array[Integration]
application_commands : Array[ApplicationCommand]
auto_moderation_rules : Array[AutoModerationRule]
threads : Array[Channel]
guild_scheduled_events : Array[GuildScheduledEvent]
} derive(ToJson, Debug, FromJson)pub(all) struct AuditLogEntry {
target_id : Nullable[String]
changes : Array[AuditLogChange]?
user_id : Nullable[Id[UserMarker]]
id : Id[AuditLogEntryMarker]
action_type : AuditLogEvent
options : Json?
reason : String?
} derive(ToJson, Debug, FromJson)pub(all) enum AuditLogEvent {
GuildUpdate
ChannelCreate
ChannelUpdate
ChannelDelete
ChannelOverwriteCreate
ChannelOverwriteUpdate
ChannelOverwriteDelete
MemberKick
MemberPrune
MemberBanAdd
MemberBanRemove
MemberUpdate
MemberRoleUpdate
MemberMove
MemberDisconnect
BotAdd
RoleCreate
RoleUpdate
RoleDelete
InviteCreate
InviteUpdate
InviteDelete
WebhookCreate
WebhookUpdate
WebhookDelete
EmojiCreate
EmojiUpdate
EmojiDelete
MessageDelete
MessageBulkDelete
MessagePin
MessageUnpin
IntegrationCreate
IntegrationUpdate
IntegrationDelete
StageInstanceCreate
StageInstanceUpdate
StageInstanceDelete
StickerCreate
StickerUpdate
StickerDelete
GuildScheduledEventCreate
GuildScheduledEventUpdate
GuildScheduledEventDelete
ThreadCreate
ThreadUpdate
ThreadDelete
ApplicationCommandPermissionUpdate
SoundboardSoundCreate
SoundboardSoundUpdate
SoundboardSoundDelete
AutoModerationRuleCreate
AutoModerationRuleUpdate
AutoModerationRuleDelete
AutoModerationBlockMessage
AutoModerationFlagToChannel
AutoModerationUserCommunicationDisabled
AutoModerationQuarantineUser
CreatorMonetizationRequestCreated
CreatorMonetizationTermsAccepted
OnboardingPromptCreate
OnboardingPromptUpdate
OnboardingPromptDelete
OnboardingCreate
OnboardingUpdate
HomeSettingsCreate
HomeSettingsUpdate
VoiceChannelStatusCreate
VoiceChannelStatusDelete
Unknown(Int)
} derive(Eq, Debug)impl ToJson for AuditLogEventimpl FromJson for AuditLogEventpub(all) struct AutoModerationAction {
typ : AutoModerationActionType
metadata : ActionMetadata?
} derive(ToJson, Debug, FromJson)pub(all) struct AutoModerationActionExecutionEvent {
guild_id : Id[GuildMarker]
action : AutoModerationAction
rule_id : Id[AutoModerationRuleMarker]
rule_trigger_type : AutoModerationTriggerType
user_id : Id[UserMarker]
channel_id : Id[ChannelMarker]?
message_id : Id[MessageMarker]?
alert_system_message_id : Id[MessageMarker]?
content : String
matched_keyword : Nullable[String]
matched_content : Nullable[String]
} derive(ToJson, Debug, FromJson)impl ToJson for AutoModerationActionTypeimpl FromJson for AutoModerationActionTypeimpl ToJson for AutoModerationEventTypeimpl FromJson for AutoModerationEventTypeimpl ToJson for AutoModerationKeywordPresetTypeimpl FromJson for AutoModerationKeywordPresetTypepub(all) struct AutoModerationRule {
id : Id[AutoModerationRuleMarker]
guild_id : Id[GuildMarker]
name : String
creator_id : Id[UserMarker]
event_type : AutoModerationEventType
trigger_type : AutoModerationTriggerType
trigger_metadata : TriggerMetadata
actions : Array[AutoModerationAction]
enabled : Bool
exempt_roles : Array[Id[RoleMarker]]
exempt_channels : Array[Id[ChannelMarker]]
} derive(ToJson, Debug, FromJson)impl ToJson for AutoModerationTriggerTypeimpl FromJson for AutoModerationTriggerTypepub(all) struct AvailableGuildCreateEvent {
guild : Guild
joined_at : Timestamp
large : Bool
unavailable : Bool?
member_count : Int
voice_states : Array[VoiceState]
members : Array[GuildMember]
channels : Array[Channel]
threads : Array[Channel]
presences : Array[PresenceUpdateEvent]
stage_instances : Array[StageInstance]
guild_scheduled_events : Array[GuildScheduledEvent]
soundboard_sounds : Array[SoundboardSound]
} derive(Debug)impl FromJson for AvailableGuildCreateEventpub(all) struct BulkBanResponse {
banned_users : Array[Id[UserMarker]]
failed_users : Array[Id[UserMarker]]
} derive(ToJson, Debug, FromJson)impl ToJson for ButtonStyleimpl FromJson for ButtonStylepub(all) struct Channel {
id : Id[ChannelMarker]
typ : ChannelType
guild_id : Id[GuildMarker]?
position : Int?
permission_overwrites : Array[Overwrite]?
name : Nullable[String]?
topic : Nullable[String]?
nsfw : Bool?
last_message_id : Nullable[Id[MessageMarker]]?
bitrate : Int?
user_limit : Int?
rate_limit_per_user : Int?
recipients : Array[User]?
icon : Nullable[ImageHash]?
owner_id : Id[UserMarker]?
application_id : Id[ApplicationMarker]?
managed : Bool?
parent_id : Nullable[Id[ChannelMarker]]?
last_pin_timestamp : Nullable[Timestamp]?
rtc_region : Nullable[String]?
video_quality_mode : VideoQualityMode?
message_count : Int?
member_count : Int?
thread_metadata : ThreadMetadata?
thread_member : ThreadMember?
default_auto_archive_duration : ThreadAutoArchiveDuration?
permissions : Permissions?
flags : ChannelFlags?
total_message_sent : Int?
available_tags : Array[ForumTag]?
applied_tags : Array[Id[GenericMarker]]?
default_reaction_emoji : Nullable[DefaultReaction]?
default_thread_rate_limit_per_user : Int?
default_sort_order : Nullable[SortOrderType]?
default_forum_layout : ForumLayoutType?
} derive(ToJson, Debug, FromJson)impl BitAnd for ChannelFlagsimpl BitOr for ChannelFlagsimpl ToJson for ChannelFlagsimpl Debug for ChannelFlagsimpl FromJson for ChannelFlagspub(all) struct ChannelInfoEvent {
guild_id : Id[GuildMarker]
channels : Array[ChannelInfo]
} derive(ToJson, Debug, FromJson)pub(all) struct ChannelMention {
id : Id[ChannelMarker]
guild_id : Id[GuildMarker]
typ : ChannelType
name : String
} derive(ToJson, Debug, FromJson)pub(all) struct ChannelPins {
items : Array[MessagePin]
has_more : Bool
} derive(ToJson, Debug, FromJson)pub(all) struct ChannelPinsUpdateEvent {
guild_id : Id[GuildMarker]?
channel_id : Id[ChannelMarker]
last_pin_timestamp : Nullable[Timestamp]?
} derive(ToJson, Debug, FromJson)impl ToJson for ChannelTypeimpl FromJson for ChannelTypepub(all) struct ClientStatus {
desktop : PresenceStatus?
mobile : PresenceStatus?
web : PresenceStatus?
} derive(ToJson, Debug)impl FromJson for ClientStatuspub(all) struct CommandData {
id : Id[CommandMarker]
name : String
typ : ApplicationCommandType
resolved : ResolvedData?
options : Array[CommandDataOption]?
guild_id : Id[GuildMarker]?
target_id : Id[GenericMarker]?
} derive(ToJson, Debug, FromJson)pub(all) struct CommandDataOption {
name : String
typ : CommandOptionType
value : Json?
options : Array[CommandDataOption]?
focused : Bool?
} derive(ToJson, Debug, FromJson)pub(all) struct CommandOption {
typ : CommandOptionType
name : String
name_localizations : Nullable[Map[String, String]]?
description : String
description_localizations : Nullable[Map[String, String]]?
required : Bool?
choices : Array[CommandOptionChoice]?
options : Array[CommandOption]?
channel_types : Array[ChannelType]?
min_value : Json?
max_value : Json?
min_length : Int?
max_length : Int?
autocomplete : Bool?
} derive(ToJson, Debug, FromJson)impl ToJson for CommandOptionTypeimpl FromJson for CommandOptionTypepub(all) enum Component {
ActionRow(ActionRow)
Button(Button)
StringSelect(SelectMenu)
TextInput(TextInput)
UserSelect(SelectMenu)
RoleSelect(SelectMenu)
MentionableSelect(SelectMenu)
ChannelSelect(SelectMenu)
Section(Section)
TextDisplay(TextDisplay)
Thumbnail(Thumbnail)
MediaGallery(MediaGallery)
File(FileComponent)
Separator(Separator)
Container(Container)
Label(Label)
FileUpload(FileUpload)
RadioGroup(RadioGroup)
CheckboxGroup(CheckboxGroup)
Checkbox(Checkbox)
Unknown(Json)
} derive(Debug)pub(all) struct ComponentData {
custom_id : String
component_type : Int
values : Array[String]?
resolved : ResolvedData?
} derive(ToJson, Debug, FromJson)pub(all) struct Connection {
id : String
name : String
typ : ConnectionService
revoked : Bool?
integrations : Array[Integration]?
verified : Bool
friend_sync : Bool
show_activity : Bool
two_way_link : Bool
visibility : Int
} derive(ToJson, Debug, FromJson)impl ToJson for ConnectionServiceimpl FromJson for ConnectionServicepub(all) struct CurrentUserGuild {
id : Id[GuildMarker]
name : String
icon : Nullable[ImageHash]
banner : Nullable[ImageHash]
owner : Bool
permissions : Permissions
features : Array[GuildFeature]
approximate_member_count : Int?
approximate_presence_count : Int?
} derive(ToJson, Debug, FromJson)impl ToJson for DefaultMessageNotificationsimpl FromJson for DefaultMessageNotificationspub(all) struct Embed {
title : String?
typ : EmbedType?
url : String?
description : String?
timestamp : Timestamp?
color : Int?
footer : EmbedFooter?
image : EmbedImage?
thumbnail : EmbedThumbnail?
video : EmbedVideo?
provider : EmbedProvider?
author : EmbedAuthor?
fields : Array[EmbedField]?
flags : EmbedFlags?
} derive(ToJson, Debug, FromJson)test "construct an outgoing embed" {
let embed = @model.Embed(
title="Build complete",
description="All checks passed.",
timestamp=Timestamp("2026-07-15T00:00:00Z"),
color=0x57F287,
footer=EmbedFooter("build 42"),
fields=[
EmbedField("Target", "native", inline=true),
EmbedField("Tests", "325 passed", inline=true),
],
)
json_inspect(embed, content={
"title": "Build complete",
"description": "All checks passed.",
"timestamp": "2026-07-15T00:00:00Z",
"color": 5763719,
"footer": { "text": "build 42" },
"fields": [
{ "name": "Target", "value": "native", "inline": true },
{ "name": "Tests", "value": "325 passed", "inline": true },
],
})
}fn Embed::Embed(title? : String, description? : String, url? : String, timestamp? : Timestamp, color? : Int, footer? : EmbedFooter, image? : EmbedImage, thumbnail? : EmbedThumbnail, author? : EmbedAuthor, fields? : Array[EmbedField]) -> Embedimpl ToJson for EmbedFlagsimpl Debug for EmbedFlagsimpl FromJson for EmbedFlagspub(all) struct Entitlement {
id : Id[EntitlementMarker]
sku_id : Id[SkuMarker]
application_id : Id[ApplicationMarker]
user_id : Id[UserMarker]?
typ : EntitlementType
deleted : Bool
starts_at : Nullable[Timestamp]?
ends_at : Nullable[Timestamp]?
guild_id : Id[GuildMarker]?
consumed : Bool?
} derive(ToJson, Debug, FromJson)impl ToJson for EntitlementOwnerTypeimpl FromJson for EntitlementOwnerTypeimpl ToJson for EntitlementTypeimpl FromJson for EntitlementTypeimpl ToJson for EntryPointCommandHandlerTypeimpl FromJson for EntryPointCommandHandlerTypepub(all) enum Event {
ApplicationCommandPermissionsUpdate(GuildApplicationCommandPermissions)
AutoModerationActionExecution(AutoModerationActionExecutionEvent)
AutoModerationRuleCreate(AutoModerationRule)
AutoModerationRuleDelete(AutoModerationRule)
AutoModerationRuleUpdate(AutoModerationRule)
ChannelCreate(Channel)
ChannelDelete(Channel)
ChannelInfo(ChannelInfoEvent)
ChannelPinsUpdate(ChannelPinsUpdateEvent)
ChannelUpdate(Channel)
EntitlementCreate(Entitlement)
EntitlementDelete(Entitlement)
EntitlementUpdate(Entitlement)
GuildAuditLogEntryCreate(GuildAuditLogEntryCreateEvent)
GuildBanAdd(GuildBanEvent)
GuildBanRemove(GuildBanEvent)
GuildCreate(GuildCreateEvent)
GuildDelete(UnavailableGuild)
GuildEmojisUpdate(GuildEmojisUpdateEvent)
GuildIntegrationsUpdate(GuildIntegrationsUpdateEvent)
GuildMemberAdd(GuildMemberAddEvent)
GuildMemberRemove(GuildMemberRemoveEvent)
GuildMembersChunk(GuildMembersChunkEvent)
GuildMemberUpdate(GuildMemberUpdateEvent)
GuildRoleCreate(GuildRoleEvent)
GuildRoleDelete(GuildRoleDeleteEvent)
GuildRoleUpdate(GuildRoleEvent)
GuildScheduledEventCreate(GuildScheduledEvent)
GuildScheduledEventDelete(GuildScheduledEvent)
GuildScheduledEventUpdate(GuildScheduledEvent)
GuildScheduledEventUserAdd(GuildScheduledEventUserEvent)
GuildScheduledEventUserRemove(GuildScheduledEventUserEvent)
GuildSoundboardSoundCreate(SoundboardSound)
GuildSoundboardSoundDelete(GuildSoundboardSoundDeleteEvent)
GuildSoundboardSoundsUpdate(SoundboardSoundsEvent)
GuildSoundboardSoundUpdate(SoundboardSound)
SoundboardSounds(SoundboardSoundsEvent)
GuildStickersUpdate(GuildStickersUpdateEvent)
GuildUpdate(Guild)
IntegrationCreate(IntegrationEvent)
IntegrationDelete(IntegrationDeleteEvent)
IntegrationUpdate(IntegrationEvent)
InteractionCreate(Interaction)
InviteCreate(InviteCreateEvent)
InviteDelete(InviteDeleteEvent)
MessageCreate(MessageCreateEvent)
MessageDelete(MessageDeleteEvent)
MessageDeleteBulk(MessageDeleteBulkEvent)
MessagePollVoteAdd(MessagePollVoteEvent)
MessagePollVoteRemove(MessagePollVoteEvent)
MessageReactionAdd(MessageReactionAddEvent)
MessageReactionRemove(MessageReactionRemoveEvent)
MessageReactionRemoveAll(MessageReactionRemoveAllEvent)
MessageReactionRemoveEmoji(MessageReactionRemoveEmojiEvent)
MessageUpdate(MessageUpdateEvent)
PresenceUpdate(PresenceUpdateEvent)
RateLimited(GatewayRateLimitedEvent)
Ready(Ready)
Resumed
StageInstanceCreate(StageInstance)
StageInstanceDelete(StageInstance)
StageInstanceUpdate(StageInstance)
SubscriptionCreate(Subscription)
SubscriptionDelete(Subscription)
SubscriptionUpdate(Subscription)
ThreadCreate(ThreadCreateEvent)
ThreadDelete(ThreadDeleteEvent)
ThreadListSync(ThreadListSyncEvent)
ThreadMembersUpdate(ThreadMembersUpdateEvent)
ThreadMemberUpdate(ThreadMemberUpdateEvent)
ThreadUpdate(Channel)
TypingStart(TypingStartEvent)
UserUpdate(User)
VoiceChannelEffectSend(VoiceChannelEffectSendEvent)
VoiceChannelStartTimeUpdate(VoiceChannelStartTimeUpdateEvent)
VoiceChannelStatusUpdate(VoiceChannelStatusUpdateEvent)
VoiceServerUpdate(VoiceServerUpdateEvent)
VoiceStateUpdate(VoiceState)
WebhooksUpdate(WebhooksUpdateEvent)
Unknown(t~ : String, d~ : Json)
} derive(Debug)pub(all) enum EventKind {
KApplicationCommandPermissionsUpdate
KAutoModerationActionExecution
KAutoModerationRuleCreate
KAutoModerationRuleDelete
KAutoModerationRuleUpdate
KChannelCreate
KChannelDelete
KChannelInfo
KChannelPinsUpdate
KChannelUpdate
KEntitlementCreate
KEntitlementDelete
KEntitlementUpdate
KGuildAuditLogEntryCreate
KGuildBanAdd
KGuildBanRemove
KGuildCreate
KGuildDelete
KGuildEmojisUpdate
KGuildIntegrationsUpdate
KGuildMemberAdd
KGuildMemberRemove
KGuildMembersChunk
KGuildMemberUpdate
KGuildRoleCreate
KGuildRoleDelete
KGuildRoleUpdate
KGuildScheduledEventCreate
KGuildScheduledEventDelete
KGuildScheduledEventUpdate
KGuildScheduledEventUserAdd
KGuildScheduledEventUserRemove
KGuildSoundboardSoundCreate
KGuildSoundboardSoundDelete
KGuildSoundboardSoundsUpdate
KGuildSoundboardSoundUpdate
KSoundboardSounds
KGuildStickersUpdate
KGuildUpdate
KIntegrationCreate
KIntegrationDelete
KIntegrationUpdate
KInteractionCreate
KInviteCreate
KInviteDelete
KMessageCreate
KMessageDelete
KMessageDeleteBulk
KMessagePollVoteAdd
KMessagePollVoteRemove
KMessageReactionAdd
KMessageReactionRemove
KMessageReactionRemoveAll
KMessageReactionRemoveEmoji
KMessageUpdate
KPresenceUpdate
KRateLimited
KReady
KResumed
KStageInstanceCreate
KStageInstanceDelete
KStageInstanceUpdate
KSubscriptionCreate
KSubscriptionDelete
KSubscriptionUpdate
KThreadCreate
KThreadDelete
KThreadListSync
KThreadMembersUpdate
KThreadMemberUpdate
KThreadUpdate
KTypingStart
KUserUpdate
KVoiceChannelEffectSend
KVoiceChannelStartTimeUpdate
KVoiceChannelStatusUpdate
KVoiceServerUpdate
KVoiceStateUpdate
KWebhooksUpdate
KUnknown
} derive(Eq, Debug)impl ToJson for ExplicitContentFilterimpl FromJson for ExplicitContentFilterpub(all) struct FileComponent {
id : Int?
file : UnfurledMediaItem
spoiler : Bool?
name : String?
size : Int?
} derive(ToJson, Debug, FromJson)pub(all) struct FollowedChannel {
channel_id : Id[ChannelMarker]
webhook_id : Id[WebhookMarker]
} derive(ToJson, Debug, FromJson)impl ToJson for ForumLayoutTypeimpl FromJson for ForumLayoutTypepub(all) struct ForumTag {
id : Id[GenericMarker]
name : String
moderated : Bool
emoji_id : Nullable[Id[EmojiMarker]]
emoji_name : Nullable[String]
} derive(ToJson, Debug, FromJson)pub(all) struct ForumTagRequest {
id : Id[GenericMarker]?
name : String
moderated : Bool?
emoji_id : Id[EmojiMarker]?
emoji_name : String?
} derive(Debug)impl ToJson for ForumTagRequestpub(all) struct GameDirectMessage {
id : Id[MessageMarker]
typ : MessageType?
content : String?
channel_id : Id[ChannelMarker]?
channel : Channel?
author : User?
recipient_id : Id[UserMarker]?
timestamp : Timestamp?
edited_timestamp : Nullable[Timestamp]?
flags : MessageFlags?
application_id : Id[ApplicationMarker]?
attachments : Array[Attachment]?
components : Array[Component]?
activity : MessageActivity?
application : Json?
raw : Json
} derive(Debug)impl ToJson for GameDirectMessageimpl FromJson for GameDirectMessagepub(all) struct GatewayBotInfo {
url : String
shards : Int
session_start_limit : SessionStartLimit
} derive(ToJson, Debug, FromJson)pub(all) struct Guild {
id : Id[GuildMarker]
name : String
icon : Nullable[ImageHash]
icon_hash : Nullable[ImageHash]?
splash : Nullable[ImageHash]
discovery_splash : Nullable[ImageHash]
owner : Bool?
owner_id : Id[UserMarker]
permissions : Permissions?
afk_channel_id : Nullable[Id[ChannelMarker]]
afk_timeout : Int
widget_enabled : Bool?
widget_channel_id : Nullable[Id[ChannelMarker]]?
verification_level : VerificationLevel
default_message_notifications : DefaultMessageNotifications
explicit_content_filter : ExplicitContentFilter
roles : Array[Role]
emojis : Array[Emoji]
features : Array[GuildFeature]
mfa_level : MfaLevel
application_id : Nullable[Id[ApplicationMarker]]
system_channel_id : Nullable[Id[ChannelMarker]]
system_channel_flags : SystemChannelFlags
rules_channel_id : Nullable[Id[ChannelMarker]]
max_presences : Nullable[Int]?
max_members : Int?
vanity_url_code : Nullable[String]
description : Nullable[String]
banner : Nullable[ImageHash]
premium_tier : PremiumTier
premium_subscription_count : Int?
preferred_locale : String
public_updates_channel_id : Nullable[Id[ChannelMarker]]
max_video_channel_users : Int?
max_stage_video_channel_users : Int?
approximate_member_count : Int?
approximate_presence_count : Int?
welcome_screen : WelcomeScreen?
nsfw_level : NsfwLevel?
stickers : Array[Sticker]?
premium_progress_bar_enabled : Bool?
safety_alerts_channel_id : Nullable[Id[ChannelMarker]]
incidents_data : Nullable[IncidentsData]?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildApplicationCommandPermissions {
id : Id[CommandMarker]
application_id : Id[ApplicationMarker]
guild_id : Id[GuildMarker]
permissions : Array[ApplicationCommandPermission]
} derive(ToJson, Debug, FromJson)pub(all) struct GuildAuditLogEntryCreateEvent {
guild_id : Id[GuildMarker]
entry : AuditLogEntry
} derive(Debug)impl FromJson for GuildAuditLogEntryCreateEventpub(all) enum GuildCreateEvent {
Available(AvailableGuildCreateEvent)
Unavailable(UnavailableGuild)
} derive(Debug)impl FromJson for GuildCreateEventpub(all) enum GuildFeature {
AnimatedBanner
AnimatedIcon
ApplicationCommandPermissionsV2
AutoModeration
Banner
Community
CreatorMonetizableProvisional
CreatorStorePage
DeveloperSupportServer
Discoverable
Featurable
HasDirectoryEntry
Hub
InvitesDisabled
InviteSplash
LinkedToHub
MemberVerificationGateEnabled
MoreSoundboard
MonetizationEnabled
MoreStickers
News
Partnered
PreviewEnabled
PrivateThreads
RaidAlertsDisabled
RelayEnabled
RoleIcons
RoleSubscriptionsAvailableForPurchase
RoleSubscriptionsEnabled
Soundboard
TicketedEventsEnabled
VanityUrl
Verified
VipRegions
WelcomeScreenEnabled
GuildTags
EnhancedRoleColors
GuestsEnabled
PinPermissionMigrationComplete
Unknown(String)
} derive(Eq, Debug)pub(all) struct GuildIntegrationsUpdateEvent {
guild_id : Id[GuildMarker]
} derive(ToJson, Debug, FromJson)pub(all) struct GuildMember {
user : User?
nick : Nullable[String]?
avatar : Nullable[ImageHash]?
banner : Nullable[ImageHash]?
roles : Array[Id[RoleMarker]]
joined_at : Nullable[Timestamp]
premium_since : Nullable[Timestamp]?
deaf : Bool?
mute : Bool?
flags : GuildMemberFlags?
pending : Bool?
permissions : Permissions?
communication_disabled_until : Nullable[Timestamp]?
avatar_decoration_data : Nullable[AvatarDecorationData]?
collectibles : Nullable[Collectibles]?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildMemberAddEvent {
guild_id : Id[GuildMarker]
guild_member : GuildMember
} derive(Debug)impl FromJson for GuildMemberAddEventimpl BitAnd for GuildMemberFlagsimpl BitOr for GuildMemberFlagsimpl ToJson for GuildMemberFlagsimpl Debug for GuildMemberFlagsimpl FromJson for GuildMemberFlagspub(all) struct GuildMemberUpdateEvent {
guild_id : Id[GuildMarker]
roles : Array[Id[RoleMarker]]
user : User
nick : Nullable[String]?
avatar : Nullable[ImageHash]
joined_at : Nullable[Timestamp]
premium_since : Nullable[Timestamp]?
deaf : Bool?
mute : Bool?
pending : Bool?
communication_disabled_until : Nullable[Timestamp]?
flags : GuildMemberFlags?
avatar_decoration_data : Nullable[AvatarDecorationData]?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildMembersChunkEvent {
guild_id : Id[GuildMarker]
members : Array[GuildMember]
chunk_index : Int
chunk_count : Int
not_found : Array[Json]?
presences : Array[PresenceUpdateEvent]?
nonce : String?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildOnboarding {
guild_id : Id[GuildMarker]
prompts : Array[OnboardingPrompt]
default_channel_ids : Array[Id[ChannelMarker]]
enabled : Bool
mode : OnboardingMode
} derive(ToJson, Debug, FromJson)pub(all) struct GuildPreview {
id : Id[GuildMarker]
name : String
icon : Nullable[ImageHash]
splash : Nullable[ImageHash]
discovery_splash : Nullable[ImageHash]
emojis : Array[Emoji]
features : Array[GuildFeature]
approximate_member_count : Int
approximate_presence_count : Int
description : Nullable[String]
stickers : Array[Sticker]
} derive(ToJson, Debug, FromJson)pub(all) struct GuildRoleDeleteEvent {
guild_id : Id[GuildMarker]
role_id : Id[RoleMarker]
} derive(ToJson, Debug, FromJson)pub(all) struct GuildScheduledEvent {
id : Id[ScheduledEventMarker]
guild_id : Id[GuildMarker]
channel_id : Nullable[Id[ChannelMarker]]
creator_id : Nullable[Id[UserMarker]]?
name : String
description : Nullable[String]?
scheduled_start_time : Timestamp
scheduled_end_time : Nullable[Timestamp]
privacy_level : GuildScheduledEventPrivacyLevel
status : GuildScheduledEventStatus
entity_type : GuildScheduledEventEntityType
entity_id : Nullable[Id[GenericMarker]]
entity_metadata : Nullable[EntityMetadata]
creator : User?
user_count : Int?
image : Nullable[ImageHash]?
recurrence_rule : Nullable[GuildScheduledEventRecurrenceRule]
} derive(ToJson, Debug, FromJson)impl ToJson for GuildScheduledEventEntityTypeimpl FromJson for GuildScheduledEventEntityTypeimpl ToJson for GuildScheduledEventPrivacyLevelimpl FromJson for GuildScheduledEventPrivacyLevelpub(all) struct GuildScheduledEventRecurrenceRule {
start : Timestamp
end : Nullable[Timestamp]?
frequency : GuildScheduledEventRecurrenceRuleFrequency
interval : Int
by_weekday : Array[GuildScheduledEventRecurrenceRuleWeekday]?
by_n_weekday : Array[GuildScheduledEventRecurrenceRuleNWeekday]?
by_month : Array[GuildScheduledEventRecurrenceRuleMonth]?
by_month_day : Array[Int]?
by_year_day : Array[Int]?
count : Int?
} derive(ToJson, Debug, FromJson)fn from_json(json : Json, path : JsonPath) -> GuildScheduledEventRecurrenceRuleFrequency raise JsonDecodeErrorfn GuildScheduledEventRecurrenceRuleFrequency::from_int(value : Int) -> GuildScheduledEventRecurrenceRuleFrequencyfn GuildScheduledEventRecurrenceRuleFrequency::to_int(self : GuildScheduledEventRecurrenceRuleFrequency) -> Intfn from_json(json : Json, path : JsonPath) -> GuildScheduledEventRecurrenceRuleMonth raise JsonDecodeErrorfn GuildScheduledEventRecurrenceRuleMonth::from_int(value : Int) -> GuildScheduledEventRecurrenceRuleMonthfn GuildScheduledEventRecurrenceRuleMonth::to_int(self : GuildScheduledEventRecurrenceRuleMonth) -> Intpub(all) struct GuildScheduledEventRecurrenceRuleNWeekday {
n : Int
day : GuildScheduledEventRecurrenceRuleWeekday
} derive(ToJson, Debug, FromJson)fn from_json(json : Json, path : JsonPath) -> GuildScheduledEventRecurrenceRuleWeekday raise JsonDecodeErrorfn GuildScheduledEventRecurrenceRuleWeekday::from_int(value : Int) -> GuildScheduledEventRecurrenceRuleWeekdayfn GuildScheduledEventRecurrenceRuleWeekday::to_int(self : GuildScheduledEventRecurrenceRuleWeekday) -> Intimpl ToJson for GuildScheduledEventStatusimpl FromJson for GuildScheduledEventStatuspub(all) struct GuildScheduledEventUser {
guild_scheduled_event_id : Id[ScheduledEventMarker]
user : User
guild_member : GuildMember?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildScheduledEventUserEvent {
guild_scheduled_event_id : Id[ScheduledEventMarker]
user_id : Id[UserMarker]
guild_id : Id[GuildMarker]
} derive(ToJson, Debug, FromJson)pub(all) struct GuildSoundboardSoundDeleteEvent {
sound_id : Id[SoundboardSoundMarker]
guild_id : Id[GuildMarker]
} derive(ToJson, Debug, FromJson)pub(all) struct GuildTemplate {
code : String
name : String
description : Nullable[String]
usage_count : Int
creator_id : Id[UserMarker]
creator : User
created_at : Timestamp
updated_at : Timestamp
source_guild_id : Id[GuildMarker]
serialized_source_guild : GuildTemplateSource
is_dirty : Nullable[Bool]
} derive(ToJson, Debug, FromJson)pub(all) struct GuildTemplateChannel {
id : Int
typ : ChannelType
name : String
position : Int
topic : Nullable[String]?
bitrate : Int?
user_limit : Int?
nsfw : Bool?
rate_limit_per_user : Int?
parent_id : Nullable[Int]?
permission_overwrites : Array[GuildTemplatePermissionOverwrite]?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildTemplatePermissionOverwrite {
id : Int
typ : Int
allow : GuildTemplatePermissions
deny : GuildTemplatePermissions
} derive(ToJson, Debug, FromJson)impl ToJson for GuildTemplatePermissionsimpl Debug for GuildTemplatePermissionsimpl FromJson for GuildTemplatePermissionspub(all) struct GuildTemplateRole {
id : Int
name : String
permissions : GuildTemplatePermissions
color : Int
colors : Nullable[RoleColors]?
hoist : Bool
mentionable : Bool
icon : Nullable[ImageHash]?
unicode_emoji : Nullable[String]?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildTemplateSource {
name : String?
description : Nullable[String]?
region : String?
verification_level : VerificationLevel?
default_message_notifications : DefaultMessageNotifications?
explicit_content_filter : ExplicitContentFilter?
preferred_locale : String?
afk_timeout : Int?
roles : Array[GuildTemplateRole]?
channels : Array[GuildTemplateChannel]?
afk_channel_id : Nullable[Int]?
system_channel_id : Nullable[Int]?
system_channel_flags : SystemChannelFlags?
icon_hash : Nullable[ImageHash]?
} derive(ToJson, Debug, FromJson)pub(all) struct GuildWidget {
id : Id[GuildMarker]
name : String
instant_invite : Nullable[String]
channels : Array[GuildWidgetChannel]
members : Array[GuildWidgetMember]
presence_count : Int
} derive(ToJson, Debug, FromJson)pub(all) struct GuildWidgetChannel {
id : Id[ChannelMarker]
name : String
position : Int
} derive(ToJson, Debug, FromJson)pub(all) struct Id[M](UInt64)test "parse and explicitly retag a snowflake" {
let user_id : @model.UserId = @model.Id::parse("175928847299117063")
inspect(user_id.to_string(), content="175928847299117063")
inspect(user_id.timestamp_ms(), content="1462015105796")
let guild_id : @model.GuildId = user_id.cast()
assert_eq(guild_id.value(), user_id.value())
}pub(all) struct InstallParams {
scopes : Array[String]
permissions : Permissions
} derive(ToJson, Debug, FromJson)pub(all) struct Integration {
id : Id[IntegrationMarker]?
name : String?
typ : String?
enabled : Bool?
syncing : Bool?
role_id : Id[RoleMarker]?
enable_emoticons : Bool?
expire_behavior : IntegrationExpireBehavior?
expire_grace_period : Int?
user : User?
account : IntegrationAccount?
synced_at : Timestamp?
subscriber_count : Int?
revoked : Bool?
application : IntegrationApplication?
application_id : Id[ApplicationMarker]?
scopes : Array[String]?
} derive(ToJson, Debug, FromJson)pub(all) struct IntegrationDeleteEvent {
id : Id[IntegrationMarker]
guild_id : Id[GuildMarker]
application_id : Id[ApplicationMarker]?
} derive(ToJson, Debug, FromJson)impl FromJson for IntegrationEventimpl ToJson for IntegrationExpireBehaviorimpl FromJson for IntegrationExpireBehaviortest "compose the gateway event subscriptions a bot needs" {
let intents = @model.Intents::guilds() |
@model.Intents::guild_messages() |
@model.Intents::message_content()
inspect(
intents.bits(),
content=(
#|33281
),
)
assert_true(intents.contains(@model.Intents::message_content()))
}pub(all) struct Interaction {
id : Id[InteractionMarker]
application_id : Id[ApplicationMarker]
typ : InteractionType
data : InteractionData?
guild : PartialGuild?
guild_id : Id[GuildMarker]?
channel : Channel?
channel_id : Id[ChannelMarker]?
guild_member : GuildMember?
user : User?
token : String
version : Int
message : Message?
app_permissions : Permissions?
locale : String?
guild_locale : String?
entitlements : Array[Entitlement]?
authorizing_integration_owners : Map[String, String]?
context : InteractionContextType?
attachment_size_limit : Int?
} derive(Debug)impl ToJson for Interactionimpl FromJson for Interactionpub(all) struct InteractionCallback {
id : Id[InteractionMarker]
typ : InteractionType
activity_instance_id : String?
response_message_id : Id[MessageMarker]?
response_message_loading : Bool?
response_message_ephemeral : Bool?
} derive(ToJson, Debug, FromJson)pub(all) struct InteractionCallbackResource {
typ : InteractionResponseType
activity_instance : InteractionCallbackActivityInstance?
message : Message?
} derive(ToJson, Debug, FromJson)pub(all) struct InteractionCallbackResponse {
interaction : InteractionCallback
resource : InteractionCallbackResource?
} derive(ToJson, Debug, FromJson)impl ToJson for InteractionContextTypeimpl FromJson for InteractionContextTypepub(all) enum InteractionData {
Command(CommandData)
Component(ComponentData)
Modal(ModalData)
Unknown(Json)
} derive(Debug)impl ToJson for InteractionDatapub(all) struct InteractionResponse {
typ : InteractionResponseType
data : Json?
} derive(ToJson, Debug, FromJson)impl ToJson for InteractionResponseTypeimpl FromJson for InteractionResponseTypeimpl ToJson for InteractionTypeimpl FromJson for InteractionTypepub(all) struct Invite {
typ : InviteType?
code : String
guild : PartialGuild?
channel : Nullable[PartialChannel]?
inviter : User?
target_type : InviteTargetType?
target_user : User?
target_application : Application?
approximate_presence_count : Int?
approximate_member_count : Int?
expires_at : Nullable[Timestamp]?
guild_scheduled_event : GuildScheduledEvent?
flags : InviteFlags?
roles : Array[PartialRole]?
uses : Int?
max_uses : Int?
max_age : Int?
temporary : Bool?
created_at : Timestamp?
} derive(ToJson, Debug, FromJson)pub(all) struct InviteCreateEvent {
channel_id : Id[ChannelMarker]
code : String
created_at : Timestamp
guild_id : Id[GuildMarker]?
inviter : User?
max_age : Int
max_uses : Int
target_type : InviteTargetType?
target_user : User?
target_application : Json?
temporary : Bool
uses : Int
expires_at : Nullable[Timestamp]
role_ids : Array[Id[RoleMarker]]?
} derive(ToJson, Debug, FromJson)pub(all) struct InviteDeleteEvent {
channel_id : Id[ChannelMarker]
guild_id : Id[GuildMarker]?
code : String
} derive(ToJson, Debug, FromJson)impl ToJson for InviteFlagsimpl Debug for InviteFlagsimpl FromJson for InviteFlagsimpl ToJson for InviteTargetTypeimpl FromJson for InviteTargetTypepub(all) struct LobbyMessage {
id : Id[MessageMarker]
typ : MessageType
content : String
lobby_id : Id[GenericMarker]
channel_id : Id[ChannelMarker]
author : User
metadata : Json?
flags : MessageFlags
application_id : Id[ApplicationMarker]?
timestamp : Timestamp?
edited_timestamp : Nullable[Timestamp]?
raw : Json
} derive(Debug)impl ToJson for LobbyMessageimpl FromJson for LobbyMessagepub(all) struct LobbyMessageDeleteEvent {
id : Id[MessageMarker]
lobby_id : Id[GenericMarker]
raw : Json
} derive(Debug)impl ToJson for LobbyMessageDeleteEventimpl FromJson for LobbyMessageDeleteEventpub(all) struct MediaGallery {
id : Int?
items : Array[MediaGalleryItem]
} derive(ToJson, Debug, FromJson)pub(all) struct MediaGalleryItem {
media : UnfurledMediaItem
description : String?
spoiler : Bool?
} derive(ToJson, Debug, FromJson)pub(all) struct Message {
id : Id[MessageMarker]
channel_id : Id[ChannelMarker]
author : User
content : String
timestamp : Timestamp
edited_timestamp : Nullable[Timestamp]
tts : Bool
mention_everyone : Bool
mentions : Array[User]
mention_roles : Array[Id[RoleMarker]]
mention_channels : Array[ChannelMention]?
attachments : Array[Attachment]
embeds : Array[Embed]
reactions : Array[Reaction]?
nonce : Nonce?
pinned : Bool
webhook_id : Id[WebhookMarker]?
typ : MessageType
activity : MessageActivity?
application_id : Id[ApplicationMarker]?
message_reference : MessageReference?
flags : MessageFlags?
referenced_message : Nullable[Message]?
thread : Channel?
components : Array[Component]?
sticker_items : Array[StickerItem]?
position : Int?
role_subscription_data : RoleSubscriptionData?
poll : Poll?
call : MessageCall?
application : Application?
interaction_metadata : MessageInteractionMetadata?
resolved : ResolvedData?
message_snapshots : Array[MessageSnapshot]?
shared_client_theme : SharedClientTheme?
} derive(ToJson, Debug, FromJson)pub(all) struct MessageActivity {
typ : MessageActivityType
party_id : String?
} derive(ToJson, Debug, FromJson)impl ToJson for MessageActivityTypeimpl FromJson for MessageActivityTypepub(all) struct MessageCreateEvent {
message : Message
guild_id : Id[GuildMarker]?
guild_member : GuildMember?
mention_members : Map[Id[UserMarker], GuildMember]
channel_type : ChannelType?
} derive(Debug)impl FromJson for MessageCreateEventpub(all) struct MessageDeleteBulkEvent {
ids : Array[Id[MessageMarker]]
channel_id : Id[ChannelMarker]
guild_id : Id[GuildMarker]?
} derive(ToJson, Debug, FromJson)pub(all) struct MessageDeleteEvent {
id : Id[MessageMarker]
channel_id : Id[ChannelMarker]
guild_id : Id[GuildMarker]?
} derive(ToJson, Debug, FromJson)impl BitAnd for MessageFlagsimpl BitOr for MessageFlagsimpl ToJson for MessageFlagsimpl Debug for MessageFlagsimpl FromJson for MessageFlagspub(all) struct MessageInteractionMetadata {
id : Id[InteractionMarker]
typ : InteractionType
user : User
authorizing_integration_owners : Map[String, String]
original_response_message_id : Id[MessageMarker]?
target_user : User?
target_message_id : Id[MessageMarker]?
interacted_message_id : Id[MessageMarker]?
triggering_interaction_metadata : MessageInteractionMetadata?
} derive(ToJson, Debug, FromJson)pub(all) struct MessagePollVoteEvent {
user_id : Id[UserMarker]
channel_id : Id[ChannelMarker]
message_id : Id[MessageMarker]
guild_id : Id[GuildMarker]?
answer_id : Int
} derive(ToJson, Debug, FromJson)pub(all) struct MessageReactionAddEvent {
user_id : Id[UserMarker]
channel_id : Id[ChannelMarker]
message_id : Id[MessageMarker]
guild_id : Id[GuildMarker]?
guild_member : GuildMember?
emoji : Emoji
message_author_id : Id[UserMarker]?
burst : Bool
burst_colors : Array[String]?
typ : Int
} derive(ToJson, Debug, FromJson)pub(all) struct MessageReactionRemoveAllEvent {
channel_id : Id[ChannelMarker]
message_id : Id[MessageMarker]
guild_id : Id[GuildMarker]?
} derive(ToJson, Debug, FromJson)pub(all) struct MessageReactionRemoveEmojiEvent {
channel_id : Id[ChannelMarker]
message_id : Id[MessageMarker]
guild_id : Id[GuildMarker]?
emoji : Emoji
} derive(ToJson, Debug, FromJson)pub(all) struct MessageReactionRemoveEvent {
user_id : Id[UserMarker]
channel_id : Id[ChannelMarker]
message_id : Id[MessageMarker]
guild_id : Id[GuildMarker]?
emoji : Emoji
burst : Bool
typ : Int
} derive(ToJson, Debug, FromJson)pub(all) struct MessageReference {
typ : MessageReferenceType?
message_id : Id[MessageMarker]?
channel_id : Id[ChannelMarker]?
guild_id : Id[GuildMarker]?
fail_if_not_exists : Bool?
} derive(ToJson, Debug, FromJson)impl ToJson for MessageReferenceTypeimpl FromJson for MessageReferenceTypepub(all) struct MessageSnapshotContent {
typ : MessageType?
content : String?
embeds : Array[Embed]?
attachments : Array[Attachment]?
timestamp : Timestamp?
edited_timestamp : Nullable[Timestamp]?
flags : MessageFlags?
mentions : Array[User]?
mention_roles : Array[Id[RoleMarker]]?
sticker_items : Array[StickerItem]?
components : Array[Component]?
} derive(ToJson, Debug, FromJson)pub(all) enum MessageType {
Default
RecipientAdd
RecipientRemove
Call
ChannelNameChange
ChannelIconChange
ChannelPinnedMessage
UserJoin
GuildBoost
GuildBoostTier1
GuildBoostTier2
GuildBoostTier3
ChannelFollowAdd
GuildDiscoveryDisqualified
GuildDiscoveryRequalified
GuildDiscoveryGracePeriodInitialWarning
GuildDiscoveryGracePeriodFinalWarning
ThreadCreated
Reply
ChatInputCommand
ThreadStarterMessage
GuildInviteReminder
ContextMenuCommand
AutoModerationAction
RoleSubscriptionPurchase
InteractionPremiumUpsell
StageStart
StageEnd
StageSpeaker
StageRaiseHand
StageTopic
GuildApplicationPremiumSubscription
GuildIncidentAlertModeEnabled
GuildIncidentAlertModeDisabled
GuildIncidentReportRaid
GuildIncidentReportFalseAlarm
PurchaseNotification
PollResult
Unknown(Int)
} derive(Eq, Debug)impl ToJson for MessageTypeimpl FromJson for MessageTypepub(all) struct MessageUpdateEvent {
message : Message
before : Message?
guild_id : Id[GuildMarker]?
guild_member : GuildMember?
mention_members : Map[Id[UserMarker], GuildMember]
channel_type : ChannelType?
} derive(Debug)impl FromJson for MessageUpdateEventtest "convert nullable and PATCH values to options" {
let nickname = @model.Nullable::from_option(Some("Moon"))
debug_inspect(
nickname.to_option(),
content=(
#|Some("Moon")
),
)
let missing : @model.Undefinable[String] = Missing
let cleared : @model.Undefinable[String] = Null
assert_true(missing.to_option() is None)
assert_true(cleared.to_option() is None)
}pub struct ObjBuilder {
// private fields
}test "build a PATCH object with omitted and cleared fields" {
let nickname : String? = None
let avatar : @model.Undefinable[String] = Null
json_inspect(
@model.ObjBuilder()
.field("name", "discord.mbt")
.opt("nickname", nickname)
.und("avatar", avatar)
.build(),
content={ "name": "discord.mbt", "avatar": null },
)
}fn[T : ToJson] ObjBuilder::und(self : ObjBuilder, key : String, value : Undefinable[T]) -> ObjBuilderimpl ToJson for OnboardingModeimpl FromJson for OnboardingModepub(all) struct OnboardingPrompt {
id : Id[GenericMarker]
typ : OnboardingPromptType
options : Array[OnboardingPromptOption]
title : String
single_select : Bool
required : Bool
in_onboarding : Bool
} derive(ToJson, Debug, FromJson)pub(all) struct OnboardingPromptOption {
id : Id[GenericMarker]
channel_ids : Array[Id[ChannelMarker]]
role_ids : Array[Id[RoleMarker]]
emoji : Emoji?
emoji_id : Id[EmojiMarker]?
emoji_name : String?
emoji_animated : Bool?
title : String
description : Nullable[String]
} derive(ToJson, Debug, FromJson)impl ToJson for OnboardingPromptTypeimpl FromJson for OnboardingPromptTypepub(all) struct Overwrite {
id : Id[GenericMarker]
typ : OverwriteType
allow : Permissions
deny : Permissions
} derive(ToJson, Debug, FromJson)impl ToJson for OverwriteTypeimpl FromJson for OverwriteTypepub(all) struct PartialChannel {
id : Id[ChannelMarker]
typ : ChannelType?
name : Nullable[String]?
icon : Nullable[ImageHash]?
permissions : Permissions?
} derive(ToJson, Debug, FromJson)pub(all) struct PartialGuild {
id : Id[GuildMarker]
name : String?
icon : Nullable[ImageHash]?
splash : Nullable[ImageHash]?
banner : Nullable[ImageHash]?
description : Nullable[String]?
features : Array[GuildFeature]?
verification_level : VerificationLevel?
vanity_url_code : Nullable[String]?
nsfw_level : NsfwLevel?
premium_subscription_count : Int?
locale : String?
} derive(ToJson, Debug, FromJson)pub(all) struct PartialRole {
id : Id[RoleMarker]
name : String
position : Int
color : Int
colors : RoleColors?
icon : Nullable[ImageHash]?
unicode_emoji : Nullable[String]?
} derive(ToJson, Debug, FromJson)impl BitAnd for Permissionsimpl BitOr for Permissionsimpl ToJson for Permissionsimpl Debug for Permissionsimpl FromJson for Permissionspub(all) struct Poll {
question : PollMedia
answers : Array[PollAnswer]
expiry : Nullable[Timestamp]
allow_multiselect : Bool
layout_type : PollLayoutType
results : PollResults?
} derive(ToJson, Debug, FromJson)pub(all) struct PollCreateRequest {
question : PollMedia
answers : Array[PollMedia]
duration : Int?
allow_multiselect : Bool?
layout_type : PollLayoutType?
} derive(Debug)impl ToJson for PollCreateRequestimpl ToJson for PollLayoutTypeimpl FromJson for PollLayoutTypepub(all) struct PollResults {
is_finalized : Bool
answer_counts : Array[PollAnswerCount]
} derive(ToJson, Debug, FromJson)impl ToJson for PremiumTypeimpl FromJson for PremiumTypepub(all) struct PresenceUpdateEvent {
user : PresenceUser?
guild_id : Id[GuildMarker]?
status : PresenceStatus?
activities : Array[Activity]?
client_status : ClientStatus?
} derive(ToJson, Debug)impl FromJson for PresenceUpdateEventimpl FromJson for PresenceUserpub(all) struct RadioGroup {
id : Int?
custom_id : String
options : Array[RadioOption]
required : Bool?
value : String?
} derive(ToJson, Debug, FromJson)impl ToJson for ReactionTypeimpl FromJson for ReactionTypepub(all) struct Ready {
v : Int
user : User
guilds : Array[UnavailableGuild]
session_id : String
resume_gateway_url : String
shard : Array[Int]?
application : ReadyApplication
} derive(ToJson, Debug, FromJson)pub(all) struct ReadyApplication {
id : Id[ApplicationMarker]
flags : ApplicationFlags?
} derive(ToJson, Debug, FromJson)pub(all) struct Role {
id : Id[RoleMarker]
name : String
color : Int
colors : RoleColors?
hoist : Bool
icon : Nullable[ImageHash]?
unicode_emoji : Nullable[String]?
position : Int
permissions : Permissions
managed : Bool
mentionable : Bool
tags : RoleTags?
flags : RoleFlags?
} derive(ToJson, Debug, FromJson)pub(all) struct RoleTags {
bot_id : Id[UserMarker]?
premium_subscriber : Bool
integration_id : Id[IntegrationMarker]?
subscription_listing_id : Id[SkuMarker]?
available_for_purchase : Bool
guild_connections : Bool
} derive(Eq, Debug)pub(all) struct SelectDefaultValue {
id : Id[GenericMarker]
typ : String
} derive(ToJson, Debug, FromJson)pub(all) struct SelectMenu {
id : Int?
custom_id : String
placeholder : String?
min_values : Int?
max_values : Int?
disabled : Bool?
options : Array[SelectOption]?
channel_types : Array[ChannelType]?
default_values : Array[SelectDefaultValue]?
values : Array[String]?
} derive(ToJson, Debug, FromJson)impl FromJson for SessionStartLimitimpl ToJson for SortOrderTypeimpl FromJson for SortOrderTypepub(all) struct SoundboardSound {
name : String
sound_id : Id[SoundboardSoundMarker]
volume : Double
emoji_id : Nullable[Id[EmojiMarker]]
emoji_name : Nullable[String]
guild_id : Id[GuildMarker]?
available : Bool
user : User?
} derive(ToJson, Debug, FromJson)pub(all) struct SoundboardSoundsEvent {
soundboard_sounds : Array[SoundboardSound]
guild_id : Id[GuildMarker]
} derive(ToJson, Debug, FromJson)pub(all) struct StageInstance {
id : Id[StageInstanceMarker]
guild_id : Id[GuildMarker]
channel_id : Id[ChannelMarker]
topic : String
privacy_level : StagePrivacyLevel
guild_scheduled_event_id : Nullable[Id[ScheduledEventMarker]]
} derive(ToJson, Debug, FromJson)impl ToJson for StagePrivacyLevelimpl FromJson for StagePrivacyLevelpub(all) struct Sticker {
id : Id[StickerMarker]
pack_id : Id[StickerPackMarker]?
name : String
description : Nullable[String]
tags : String
asset : String?
typ : StickerType
format_type : StickerFormatType
available : Bool?
guild_id : Id[GuildMarker]?
user : User?
sort_value : Int?
} derive(ToJson, Debug, FromJson)impl ToJson for StickerFormatTypeimpl FromJson for StickerFormatTypepub(all) struct StickerItem {
id : Id[StickerMarker]
name : String
format_type : StickerFormatType
} derive(ToJson, Debug, FromJson)pub(all) struct StickerPack {
id : Id[StickerPackMarker]
stickers : Array[Sticker]
name : String
sku_id : Id[SkuMarker]
cover_sticker_id : Id[StickerMarker]?
description : String
banner_asset_id : Id[GenericMarker]?
} derive(ToJson, Debug, FromJson)pub(all) struct StickerPacksResponse {
sticker_packs : Array[StickerPack]
} derive(ToJson, Debug, FromJson)pub(all) struct Subscription {
id : Id[GenericMarker]
user_id : Id[UserMarker]
sku_ids : Array[Id[SkuMarker]]
entitlement_ids : Array[Id[EntitlementMarker]]
renewal_sku_ids : Nullable[Array[Id[SkuMarker]]]
current_period_start : Timestamp
current_period_end : Timestamp
status : SubscriptionStatus
canceled_at : Nullable[Timestamp]
country : String?
} derive(ToJson, Debug, FromJson)impl ToJson for SubscriptionStatusimpl FromJson for SubscriptionStatusimpl BitAnd for SystemChannelFlagsimpl BitOr for SystemChannelFlagsimpl ToJson for SystemChannelFlagsimpl Debug for SystemChannelFlagsimpl FromJson for SystemChannelFlagsfn SystemChannelFlags::suppress_role_subscription_purchase_notification_replies() -> SystemChannelFlagsimpl ToJson for TargetUsersJobStatusCodeimpl FromJson for TargetUsersJobStatusCodepub(all) struct Team {
icon : Nullable[ImageHash]
id : Id[TeamMarker]
members : Array[TeamMember]
name : String
owner_user_id : Id[UserMarker]
} derive(ToJson, Debug, FromJson)pub(all) struct TeamMember {
membership_state : TeamMembershipState
team_id : Id[TeamMarker]
user : User
role : String?
} derive(ToJson, Debug, FromJson)impl ToJson for TeamMembershipStateimpl FromJson for TeamMembershipStatepub(all) struct TextInput {
id : Int?
custom_id : String
style : TextInputStyle?
label : String?
min_length : Int?
max_length : Int?
required : Bool?
value : String?
placeholder : String?
} derive(ToJson, Debug, FromJson)impl ToJson for TextInputStyleimpl FromJson for TextInputStyleimpl ToJson for ThreadAutoArchiveDurationimpl FromJson for ThreadAutoArchiveDurationimpl FromJson for ThreadCreateEventpub(all) struct ThreadDeleteEvent {
id : Id[ChannelMarker]
guild_id : Id[GuildMarker]
parent_id : Id[ChannelMarker]
typ : ChannelType
} derive(ToJson, Debug, FromJson)pub(all) struct ThreadListSyncEvent {
guild_id : Id[GuildMarker]
channel_ids : Array[Id[ChannelMarker]]?
threads : Array[Channel]
members : Array[ThreadMember]
} derive(ToJson, Debug, FromJson)pub(all) struct ThreadMember {
id : Id[ChannelMarker]?
user_id : Id[UserMarker]?
join_timestamp : Timestamp
flags : Int
guild_member : GuildMember?
} derive(ToJson, Debug, FromJson)pub(all) struct ThreadMemberUpdateEvent {
guild_id : Id[GuildMarker]
thread_member : ThreadMember
} derive(Debug)impl FromJson for ThreadMemberUpdateEventpub(all) struct ThreadMembersUpdateEvent {
id : Id[ChannelMarker]
guild_id : Id[GuildMarker]
member_count : Int
added_members : Array[ThreadMember]?
removed_member_ids : Array[Id[UserMarker]]?
} derive(ToJson, Debug, FromJson)pub(all) struct Thumbnail {
id : Int?
media : UnfurledMediaItem
description : String?
spoiler : Bool?
} derive(ToJson, Debug, FromJson)test "parse a Discord timestamp without losing its source text" {
let timestamp = @model.Timestamp("2021-03-11T18:15:37.907000+00:00")
inspect(timestamp.to_string(), content="2021-03-11T18:15:37.907000+00:00")
inspect(timestamp.unix_ms(), content="1615486537907")
}pub(all) struct TypingStartEvent {
channel_id : Id[ChannelMarker]
guild_id : Id[GuildMarker]?
user_id : Id[UserMarker]
timestamp : Int64
guild_member : GuildMember?
} derive(ToJson, Debug)impl FromJson for TypingStartEventpub(all) struct UnavailableGuild {
id : Id[GuildMarker]
unavailable : Bool
} derive(ToJson, Debug, FromJson)impl ToJson for Undefinable[T]impl FromJson for Undefinable[T]pub(all) struct User {
id : Id[UserMarker]
username : String
discriminator : String
global_name : Nullable[String]?
avatar : Nullable[ImageHash]
bot : Bool?
system : Bool?
mfa_enabled : Bool?
banner : Nullable[ImageHash]?
accent_color : Nullable[Int]?
locale : String?
verified : Bool?
email : Nullable[String]?
flags : UserFlags?
premium_type : PremiumType?
public_flags : UserFlags?
avatar_decoration : Nullable[ImageHash]?
avatar_decoration_data : Nullable[AvatarDecorationData]?
collectibles : Nullable[Collectibles]?
primary_guild : Nullable[UserPrimaryGuild]?
} derive(ToJson, Debug, FromJson)impl ToJson for VerificationLevelimpl FromJson for VerificationLevelimpl ToJson for VideoQualityModeimpl FromJson for VideoQualityModepub(all) struct VoiceChannelEffectSendEvent {
channel_id : Id[ChannelMarker]
guild_id : Id[GuildMarker]
user_id : Id[UserMarker]
emoji : Nullable[Emoji]?
animation_type : Nullable[Int]?
animation_id : Int?
sound_id : Json?
sound_volume : Double?
} derive(ToJson, Debug, FromJson)pub(all) struct VoiceChannelStartTimeUpdateEvent {
id : Id[ChannelMarker]
guild_id : Id[GuildMarker]
voice_start_time : Nullable[Int64]?
} derive(ToJson, Debug, FromJson)pub(all) struct VoiceChannelStatusUpdateEvent {
id : Id[ChannelMarker]
guild_id : Id[GuildMarker]
status : Nullable[String]
} derive(ToJson, Debug, FromJson)pub(all) struct VoiceState {
guild_id : Id[GuildMarker]?
channel_id : Nullable[Id[ChannelMarker]]
user_id : Id[UserMarker]
guild_member : GuildMember?
session_id : String
deaf : Bool
mute : Bool
self_deaf : Bool
self_mute : Bool
self_stream : Bool?
self_video : Bool?
suppress : Bool
request_to_speak_timestamp : Nullable[Timestamp]
} derive(ToJson, Debug, FromJson)pub(all) struct Webhook {
id : Id[WebhookMarker]
typ : WebhookType
guild_id : Nullable[Id[GuildMarker]]?
channel_id : Nullable[Id[ChannelMarker]]
user : User?
name : Nullable[String]
avatar : Nullable[ImageHash]
token : String?
application_id : Nullable[Id[ApplicationMarker]]
source_guild : PartialGuild?
source_channel : PartialChannel?
url : String?
} derive(ToJson, Debug, FromJson)pub(all) enum WebhookEvent {
ApplicationAuthorized(ApplicationAuthorizedEvent)
ApplicationDeauthorized(ApplicationDeauthorizedEvent)
EntitlementCreate(Entitlement)
EntitlementUpdate(Entitlement)
EntitlementDelete(Entitlement)
LobbyMessageCreate(LobbyMessage)
LobbyMessageUpdate(LobbyMessage)
LobbyMessageDelete(LobbyMessageDeleteEvent)
GameDirectMessageCreate(GameDirectMessage)
GameDirectMessageUpdate(GameDirectMessage)
GameDirectMessageDelete(GameDirectMessage)
QuestUserEnrollment
Unknown(typ~ : String, data~ : Json?)
} derive(Debug)pub(all) struct WebhookEventPayload {
version : Int
application_id : Id[ApplicationMarker]
typ : WebhookPayloadType
event : WebhookEventBody?
} derive(ToJson, Debug, FromJson)pub(all) enum WebhookEventType {
ApplicationAuthorized
ApplicationDeauthorized
EntitlementCreate
EntitlementUpdate
EntitlementDelete
LobbyMessageCreate
LobbyMessageUpdate
LobbyMessageDelete
GameDirectMessageCreate
GameDirectMessageUpdate
GameDirectMessageDelete
QuestUserEnrollment
Unknown(String)
} derive(Eq, Debug)impl ToJson for WebhookEventTypeimpl FromJson for WebhookEventTypeimpl ToJson for WebhookPayloadTypeimpl FromJson for WebhookPayloadTypepub(all) struct WebhooksUpdateEvent {
guild_id : Id[GuildMarker]
channel_id : Id[ChannelMarker]
} derive(ToJson, Debug, FromJson)pub(all) struct WelcomeScreenChannel {
channel_id : Id[ChannelMarker]
description : String
emoji_id : Nullable[Id[EmojiMarker]]
emoji_name : Nullable[String]
} derive(ToJson, Debug, FromJson)test "flatten optional nullable fields" {
let absent : @model.Nullable[String]? = None
let null_value : @model.Nullable[String]? = Some(Null)
let present : @model.Nullable[String]? = Some(Value("Moon"))
debug_inspect(
[
@model.flatten(absent),
@model.flatten(null_value),
@model.flatten(present),
],
content=(
#|[None, None, Some("Moon")]
),
)
}test "detect top-level Components V2 layouts" {
let row : @model.Component = ActionRow({ id: None, components: [], })
let container : @model.Component = Container({
id: None,
components: [],
accent_color: None,
spoiler: None,
})
assert_false(@model.requires_components_v2([row]))
assert_true(@model.requires_components_v2([row, container]))
}Install
Download zipAn experimental Discord library for MoonBit: typed APIs, a native gateway with voice (DAVE E2EE), and JS/serverless HTTP interactions.
Dependencies