diff --git a/src/grom.gleam b/src/grom.gleam index 5326d55..e86bdab 100644 --- a/src/grom.gleam +++ b/src/grom.gleam @@ -2414,8 +2414,673 @@ fn forum_tag_emoji_to_json(emoji: ForumTagEmoji) -> Json { ]) } -// Get rid of me!! Use actual messages -pub type Message +pub type Message { + Message( + id: Snowflake(Message), + channel_id: Snowflake(Channel), + author: User, + /// If your app doesn't have the `MESSAGE_CONTENT` privileged intent enabled, + /// this will be an empty string. + content: String, + sent_timestamp: Timestamp, + edited_tmestamp: Option(Timestamp), + /// Whether the message is text-to-speech-enabled. + is_tts: Bool, + mentions_everyone: Bool, + mentioned_users: List(User), + mentioned_roles_ids: List(Snowflake(Role)), + /// If your app doesn't have the `MESSAGE_CONTENT` privileged intent enabled, + /// this will be an empty list. + attachments: List(MessageAttachment), + /// If your app doesn't have the `MESSAGE_CONTENT` privileged intent enabled, + /// this will be an empty list. + embeds: List(MessageEmbed), + reactions: List(MessageReaction), + /// Used for verifying a message was sent. + nonce: Option(MessageNonce), + is_pinned: Bool, + /// If the message was generated by a webhook, this is its ID. + webhook_id: Option(Snowflake(Webhook)), + type_: MessageType, + /// If the message is an interaction or application-owned webhook, this is its ID. + application_id: Option(Snowflake(Application)), + flags: List(MessageFlag), + /// Information regarding a crossposted message, channel follow add notification, + /// pin notificatio, reply, etc. + reference: Option(MessageReference), + /// Snapshots of a forwarded message. + snapshots: List(MessageSnapshot), + /// If this message is a reply or similar, this will be its parent message. + referenced_message: Option(Message), + /// If your app doesn't have the `MESSAGE_CONTENT` privileged intent enabled, + /// this will be an empty list. + components: List(MessageComponent), + /// Sent if the message was sent as a result of an interaction + interaction_metadata: Option(MessageInteractionMetadata), + /// Sent if the message was the one that started a thread. + thread: Option(Thread), + sticker_items: List(StickerItem), + /// Only sent if the message was sent in a thread. + approximate_position_in_thread: Option(Int), + /// If the message is a notification about a role subscription purchase, this will contain additional data about it. + role_subscription_purchase_notification: Option( + RoleSubscriptionPurchaseNotification, + ), + /// If your app doesn't have the `MESSAGE_CONTENT` privileged intent enabled, + /// this will be `None`. + /// + /// Also `None` if the message doesn't have a poll :) + poll: Option(Poll), + call: Option(MessageCall), + ) +} + +pub type MessageCall { + MessageCall( + participants_ids: List(Snowflake(User)), + end_timestamp: Option(Timestamp), + ) +} + +pub type Poll { + Poll( + question: String, + answers: List(PollAnswer), + end_timestamp: Timestamp, + allows_multiselect: Bool, + results: Option(PollResults), + ) +} + +pub type PollResults { + PollResults( + /// Whether the votes have been precisely counted. + is_finalized: Bool, + answer_counts: List(PollAnswerCount), + ) +} + +pub type PollAnswerCount { + PollAnswerCount(answer_id: Int, count: Int, current_user_voted: Bool) +} + +pub type PollAnswer { + PollAnswer(id: Int, text: String, emoji: Option(Emoji)) +} + +pub type RoleSubscriptionPurchaseNotification { + RoleSubscriptionPurchaseNotification( + listing_id: Snowflake(Sku), + tier_name: String, + /// Cumulative number of months the user has been subscribed for. + total_months_subscribed: Int, + /// Whether the notification is for a renewal rather than a new purhase. + is_renewal: Bool, + ) +} + +pub type Interaction + +pub type MessageInteractionMetadata { + MessageInteractionMetadata( + interaction_id: Snowflake(Interaction), + triggering_user: User, + /// If the interaction's application was guild-installed, this will be the guild's ID. + installed_guild_id: Option(Snowflake(Guild)), + /// If the interaction's application was user-installed, this will be the user's ID. + installed_user_id: Option(Snowflake(User)), + /// If this message is a follow-up message to an interaction, this will be its parent's ID. + original_response_message_id: Option(Snowflake(Message)), + /// If the interaction was a user command invokement, this will be its target user. + target_user: Option(User), + /// If the interaction was a message command invokement, this will be its target message's ID. + /// + /// Note: You can retrieve the target message from `referenced_message` field of the original message. + target_message_id: Option(Snowflake(Message)), + ) +} + +pub type MessageSnapshot { + MessageSnapshot( + type_: MessageType, + content: String, + embeds: List(MessageEmbed), + attachments: List(MessageAttachment), + edited_timestamp: Option(Timestamp), + flags: List(MessageFlag), + mentioned_users: List(User), + mentioned_roles_ids: List(Snowflake(Role)), + sticker_items: List(StickerItem), + components: List(MessageComponent), + ) +} + +pub type MessageComponent { + MessageActionRowComponent(MessageActionRow) + MessageSectionComponent(MessageSection) + MessageTextDisplayComponent(MessageTextDisplay) + MessageMediaGalleryComponent(MessageMediaGallery) + MessageFileComponent(MessageFile) + MessageSeparatorComponent(MessageSeparator) + MessageContainerComponent(MessageContainer) +} + +pub type MessageContainer { + MessageContainer( + id: Int, + components: List(ContainerComponent), + accent_colour: Option(Colour), + is_spoiler: Bool, + ) +} + +pub type ContainerComponent { + ContainerActionRow(MessageActionRow) + ContainerTextDisplay(MessageTextDisplay) + ContainerSection(MessageSection) + ContainerMediaGallery(MessageMediaGallery) + ContainerSeparator(MessageSeparator) + ContainerFile(MessageFile) +} + +pub type MessageFile { + MessageFile( + id: Int, + media: UnfurledMediaItem, + is_spoiler: Bool, + file_name: String, + size_bytes: Int, + ) +} + +pub type MessageSection { + MessageSection( + id: Int, + components: List(SectionComponent), + accessory: SectionAccessory, + ) +} + +pub type MessageMediaGallery { + MessageMediaGallery(id: Int, items: List(MediaGalleryItem)) +} + +pub type MediaGalleryItem { + MediaGalleryItem( + media: UnfurledMediaItem, + description: Option(String), + is_spoiler: Bool, + ) +} + +pub type SectionComponent { + SectionTextDisplay(MessageTextDisplay) +} + +pub type MessageTextDisplay { + MessageTextDisplay(id: Int, content: String) +} + +pub type SectionAccessory { + SectionButton(MessageButton) + SectionThumbnail(MessageThumbnail) +} + +pub type MessageThumbnail { + MessageThumbnail( + id: Int, + media: UnfurledMediaItem, + description: Option(String), + is_spoiler: Bool, + ) +} + +pub type UnfurledMediaItem { + UnfurledMediaItem( + url: String, + proxy_url: String, + content_type: String, + flags: List(UnfurledMediaItemFlag), + /// Only present if the item is an image or video. + metadata: Option(UnfurledMediaItemMetadata), + /// Only present if the item was uploaded as an attachment. + attachment_id: Option(Snowflake(MessageAttachment)), + ) +} + +pub type MessageSeparator { + MessageSeparator(id: Int, is_divider_visible: Bool, spacing: SeparatorSpacing) +} + +pub type UnfurledMediaItemMetadata { + UnfurledMediaItemMetadata( + /// In pixels. + height: Int, + /// In pixels. + width: Int, + /// [Thumbhash](https://evanw.github.io/thumbhash/) representation of a placeholder. + placeholder: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) version. + placeholder_version: Int, + ) +} + +pub type UnfurledMediaItemFlag { + UnfurledMediaItemIsAnimated +} + +pub type MessageActionRow { + MessageActionRow(id: Int, components: List(ActionRowComponent)) +} + +pub type ActionRowComponent { + ActionRowButton(MessageButton) + ActionRowStringSelect(MessageStringSelect) + ActionRowUserSelect(MessageUserSelect) + ActionRowRoleSelect(MessageRoleSelect) + ActionRowMentionableSelect(MessageMentionableSelect) + ActionRowChannelSelect(MessageChannelSelect) +} + +pub type MessageStringSelect { + MessageStringSelect( + id: Int, + custom_id: String, + options: List(StringSelectOption), + placeholder: Option(String), + min_values: Int, + max_values: Int, + is_disabled: Bool, + ) +} + +pub type MessageUserSelect { + MessageUserSelect( + id: Int, + custom_id: String, + placeholder: Option(String), + default_users: List(Snowflake(User)), + min_values: Int, + max_values: Int, + is_required: Bool, + ) +} + +pub type MessageRoleSelect { + MessageRoleSelect( + id: Int, + custom_id: String, + placeholder: Option(String), + default_roles: List(Snowflake(Role)), + min_values: Int, + max_values: Int, + is_required: Bool, + ) +} + +pub type MessageMentionableSelect { + MessageMentionableSelect( + id: Int, + custom_id: String, + placeholder: Option(String), + default_users: List(Snowflake(User)), + default_roles: List(Snowflake(Role)), + min_values: Int, + max_values: Int, + is_required: Bool, + ) +} + +pub type MessageChannelSelect { + MessageChannelSelect( + id: Int, + custom_id: String, + placeholder: Option(String), + default_channels: List(Snowflake(Channel)), + channel_types: List(ChannelSelectType), + min_values: Int, + max_values: Int, + is_required: Bool, + ) +} + +pub type MessageButton { + MessageButtonRegular(RegularMessageButton) + MessageButtonLink(LinkMessageButton) + MessageButtonPremium(PremiumMessageButton) +} + +pub type RegularMessageButton { + RegularMessageButton( + id: Int, + style: RegularButtonStyle, + label: Option(String), + emoji: Option(ComponentEmoji), + custom_id: String, + is_disabled: Bool, + ) +} + +pub type LinkMessageButton { + LinkMessageButton( + id: Int, + label: Option(String), + emoji: Option(ComponentEmoji), + url: String, + is_disabled: Bool, + ) +} + +pub type PremiumMessageButton { + PremiumMessageButton(id: Int, sku_id: Snowflake(Sku), is_disabled: Bool) +} + +/// A partial representation of a sticker. +pub type StickerItem { + StickerItem( + id: Snowflake(Sticker), + name: String, + format_type: StickerFormatType, + ) +} + +/// Information regarding a crossposted message, channel follow add notification, +/// pin notification reply, etc. +pub type MessageReference { + ReplyMessageReference( + original_message_id: Snowflake(Message), + original_channel_id: Snowflake(Channel), + original_guild_id: Option(Snowflake(Guild)), + ) + ForwardMessageReference( + original_message_id: Snowflake(Message), + original_channel_id: Snowflake(Channel), + original_guild_id: Option(Snowflake(Guild)), + ) +} + +pub type MessageFlag { + MessageIsCrossposted + MessageIsCrosspost + MessageHasSuppressedEmbeds + MessageSourceDeleted + MessageIsUrgent + MessageHasThread + MessageIsEphemeral + MessageIsLoading + MessageFailedToMentionSomeRolesInThread + MessageHasSuppressedNotifications + MessageIsVoiceMessage + MessageHasSnapshot + MessageUsesComponentsV2 +} + +pub type MessageType { + /// Deletable. + MessageIsNormalMessage + /// Not deletable. + MessageIsRecipientAddNotification + /// Not deletable. + MessageIsRecipientRemoveNotification + /// Not deletable. + MessageIsCallNotification + /// Not deletable. + MessageIsChannelNameChangeNotification + /// Not deletable. + MessageIsChannelIconChangeNotification + /// Deletable. + MessageIsPinnedMessageNotification + /// Deletable. + MessageIsUserJoinNotification + /// Deletable. + MessageIsGuildBoostNotification + /// Deletable. + MessageIsGuildBoostTier1Notification + /// Deletable. + MessageIsGuildBoostTier2Notification + /// Deletable. + MessageIsGuildBoostTier3Notification + /// Deletable. + MessageIsChannelFollowAddedNotification + /// Deletable. + MessageIsGuildDiscoveryDisqualificationNotification + /// Deletable. + MessageIsGuildDiscoveryRequalificationNotification + /// Deletable. + MessageIsGuildDiscoveryGracePeriodInitialWarning + /// Deletable. + MessageIsGuildDiscoveryGracePeriodFinalWarning + /// Deletable. + MessageIsThreadCreationNotification + /// Deletable. + MessageIsReply + /// Deletable. + MessageIsSlashCommand + /// Not deletable. + MessageIsThreadStarterMessage + /// Deletable. + MessageIsGuildInviteReminder + /// Deletable. + MessageIsContextMenuCommand + /// Deletable by members with the `AllowManagingMessages` permission. + MessageIsAutoModerationActionNotification + /// Deletable. + MessageIsRoleSubscriptionPurchaseNotification + /// Deletable. + MessageIsInteractionPremiumUpsell + /// Deletable. + MessageIsStageStartNotification + /// Deletable. + MessageIsStageEndNotification + /// Deletable. + MessageIsNewStageSpeakerNotification + /// Deletable. + MessageIsNewStageTopicNotification + /// Deletable. + MessageIsGuildApplicationPremiumSubscriptionNotification + /// Deletable. + MessageIsGuildIncidentAlertModeEnabledNotification + /// Deletable. + MessageIsGuildIncidentAlertModeDisabledNotification + /// Deletable. + MessageIsRaidReportNotification + /// Deletable. + MessageIsFalseAlarmReportNotification + /// Deletable. + MessageIsPurchaseNotification + /// Deletable. + MessageIsPollResult +} + +pub type Webhook + +pub type MessageNonce { + IntMessageNonce(Int) + StringMessageNonce(String) +} + +pub type MessageReaction { + MessageReaction( + /// Sum of all reactions (normal + super). + count: Int, + super_count: Int, + normal_count: Int, + current_user_reacted: Bool, + current_user_super_reacted: Bool, + emoji: Emoji, + super_colours: List(Colour), + ) +} + +pub type MessageAttachment { + MessageAttachment( + id: Snowflake(MessageAttachment), + file_name: String, + title: Option(String), + description: Option(String), + content_type: Option(String), + size_bytes: Int, + url: String, + proxy_url: String, + /// If the attachment is an image, video, audio, voice message or a clip, additional information about it will live here. + data: Option(MessageAttachmentData), + flags: List(MessageAttachmentFlag), + ) +} + +pub type MessageEmbed { + MessageEmbed( + title: Option(String), + type_: Option(EmbedType), + description: Option(String), + url: Option(String), + timestamp: Option(Timestamp), + colour: Option(Colour), + footer: Option(EmbedFooter), + image: Option(EmbedImage), + thumbnail: Option(EmbedImage), + video: Option(EmbedVideo), + author: Option(EmbedAuthor), + fields: Option(List(EmbedField)), + ) +} + +pub type EmbedField { + EmbedField(name: String, value: String, is_inline: Bool) +} + +pub type EmbedAuthor { + EmbedAuthor( + name: String, + url: Option(String), + icon_url: Option(String), + proxy_icon_url: Option(String), + ) +} + +pub type EmbedImage { + EmbedImage( + url: String, + proxy_url: String, + /// In pixels. + height: Int, + /// In pixels. + width: Int, + content_type: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) representation of a placeholder. + placeholder: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) version. + placeholder_version: Int, + description: Option(String), + flags: List(EmbedImageFlag), + ) +} + +pub type EmbedVideo { + EmbedVideo( + url: String, + proxy_url: String, + /// In pixels. + height: Int, + /// In pixels. + width: Int, + content_type: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) representation of a placeholder. + placeholder: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) version. + placeholder_version: Int, + description: Option(String), + ) +} + +pub type EmbedImageFlag { + EmbedImageIsAnimated +} + +pub type EmbedFooter { + EmbedFooter( + text: String, + icon_url: Option(String), + proxy_icon_url: Option(String), + ) +} + +pub type EmbedType { + RichEmbed + ImageEmbed + VideoEmbed + GifEmbed + ArticleEmbed + LinkEmbed + PollResultsEmbed +} + +pub type MessageAttachmentFlag { + MessageAttachmentIsThumbnail + MessageAttachmentIsRemix + MessageAttachmentIsSpoiler + MessageAttachmentIsAnimated +} + +pub type MessageAttachmentData { + MessageAttachmentImage(ImageMessageAttachment) + MessageAttachmentVideo(VideoMessageAttachment) + MessageAttachmentAudio(AudioMessageAttachment) + MessageAttachmentVoice(VoiceMessageAttachment) + MessageAttachmentClip(ClipMessageAttachment) +} + +pub type ImageMessageAttachment { + ImageMessageAttachment( + /// In pixels. + height: Int, + /// In pixels. + width: Int, + /// [Thumbhash](https://evanw.github.io/thumbhash/) representation of a placeholder. + placeholder: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) version. + placeholder_version: Int, + ) +} + +pub type VideoMessageAttachment { + VideoMessageAttachment( + /// In pixels. + height: Int, + /// In pixels. + width: Int, + /// [Thumbhash](https://evanw.github.io/thumbhash/) representation of a placeholder. + placeholder: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) version. + placeholder_version: Int, + duration: Duration, + ) +} + +pub type AudioMessageAttachment { + AudioMessageAttachment(duration: Duration) +} + +pub type VoiceMessageAttachment { + VoiceMessageAttachment(duration: Duration, waveform: BitArray) +} + +pub type ClipMessageAttachment { + ClipMessageAttachment( + /// In pixels. + height: Int, + /// In pixels. + width: Int, + /// [Thumbhash](https://evanw.github.io/thumbhash/) representation of a placeholder. + placeholder: String, + /// [Thumbhash](https://evanw.github.io/thumbhash/) version. + placeholder_version: Int, + duration: Duration, + participants: List(User), + created_timestamp: Timestamp, + application: Option(Application), + ) +} /// Permission overwrites are used to grant/deny specific permissions to members /// (personally or per-role) in specific channels.