use crate::models::payloads::application::APIApplication;
use crate::models::payloads::base::{
APIInteractionDataResolved, APIMessageInteraction, APIMessageInteractionMetadata,
};
use crate::models::payloads::emoji::APIPartialEmoji;
use crate::models::payloads::guild::APIGuildMember;
use crate::models::payloads::permissions::APIRole;
use crate::models::payloads::poll::APIPoll;
use crate::models::payloads::sticker::{APISticker, APIStickerItem};
use crate::models::payloads::user::APIUser;
use crate::utils::serde::flags_numeric;
use bitflags::bitflags;
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBasePartialChannel {
pub id: String,
#[serde(rename = "type")]
pub r#type: ChannelType,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APINameableChannel {
pub name: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIPartialChannel {
pub id: String,
#[serde(rename = "type")]
pub r#type: ChannelType,
pub name: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIInviteChannel {
pub icon: Option<String>,
pub recipients: Option<Vec<APIInviteChannelRecipient>>,
pub id: String,
#[serde(rename = "type")]
pub r#type: ChannelType,
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIInviteChannelRecipient {
pub username: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIWebhookSourceChannel {
pub id: String,
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIChannelBase {
pub id: String,
#[serde(rename = "type")]
pub r#type: ChannelType,
#[serde(with = "flags_numeric")]
pub flags: ChannelFlags,
}
pub type TextChannelType = ChannelType;
pub type GuildChannelType = ChannelType;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISlowmodeChannel {
pub rate_limit_per_user: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISortableChannel {
pub position: i64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APITextBasedChannel {
pub last_message_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIPinChannel {
pub last_pin_timestamp: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildChannel {
pub name: String,
pub guild_id: Option<String>,
pub permission_overwrites: Option<Vec<APIOverwrite>>,
pub parent_id: Option<String>,
pub nsfw: Option<bool>,
}
pub type GuildTextChannelType = ChannelType;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildTextChannel {
pub default_auto_archive_duration: Option<ThreadAutoArchiveDuration>,
pub default_thread_rate_limit_per_user: Option<i64>,
pub topic: Option<String>,
}
pub type APITextChannel = APIGuildTextChannel;
pub type APINewsChannel = APIGuildTextChannel;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildCategoryChannel {}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIVoiceChannelBase {
pub bitrate: Option<i64>,
pub user_limit: Option<i64>,
pub rtc_region: Option<String>,
pub video_quality_mode: Option<VideoQualityMode>,
}
pub type APIGuildVoiceChannel = APIVoiceChannelBase;
pub type APIGuildStageVoiceChannel = APIVoiceChannelBase;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIDMChannelBase {
pub recipients: Option<Vec<APIUser>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIDMChannel {
pub name: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGroupDMChannel {
pub name: Option<String>,
pub application_id: Option<String>,
pub icon: Option<String>,
pub owner_id: Option<String>,
pub last_message_id: Option<String>,
pub managed: Option<bool>,
}
pub type ThreadChannelType = ChannelType;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadChannel {
pub member: Option<APIThreadMember>,
pub thread_metadata: Option<APIThreadMetadata>,
pub message_count: Option<i64>,
pub member_count: Option<i64>,
pub owner_id: Option<String>,
pub total_message_sent: Option<i64>,
pub applied_tags: Vec<String>,
}
pub type APIPublicThreadChannel = APIThreadChannel;
pub type APIPrivateThreadChannel = APIThreadChannel;
pub type APIAnnouncementThreadChannel = APIThreadChannel;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildForumTag {
pub id: String,
pub name: String,
pub moderated: bool,
pub emoji_id: Option<String>,
pub emoji_name: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildForumDefaultReactionEmoji {
pub emoji_id: Option<String>,
pub emoji_name: Option<String>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum SortOrderType {
LatestActivity = 0,
CreationDate = 1,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ForumLayoutType {
NotSet = 0,
ListView = 1,
GalleryView = 2,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadOnlyChannel {
pub topic: Option<String>,
pub last_message_id: Option<String>,
pub rate_limit_per_user: Option<i64>,
pub last_pin_timestamp: Option<String>,
pub default_auto_archive_duration: Option<ThreadAutoArchiveDuration>,
pub available_tags: Vec<APIGuildForumTag>,
pub default_thread_rate_limit_per_user: Option<i64>,
pub default_reaction_emoji: Option<APIGuildForumDefaultReactionEmoji>,
pub default_sort_order: Option<SortOrderType>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIGuildForumChannel {
pub default_forum_layout: ForumLayoutType,
}
pub type APIGuildMediaChannel = APIThreadOnlyChannel;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIChannel {
APIAnnouncementThreadChannel(APIAnnouncementThreadChannel),
APIDMChannel(APIDMChannel),
APIGroupDMChannel(APIGroupDMChannel),
APIGuildCategoryChannel(APIGuildCategoryChannel),
APIGuildForumChannel(APIGuildForumChannel),
APIGuildMediaChannel(APIGuildMediaChannel),
APIGuildStageVoiceChannel(APIGuildStageVoiceChannel),
APIGuildVoiceChannel(APIGuildVoiceChannel),
APINewsChannel(APINewsChannel),
APIPrivateThreadChannel(APIPrivateThreadChannel),
APIPublicThreadChannel(APIPublicThreadChannel),
APITextChannel(APITextChannel),
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ChannelType {
GuildText = 0,
DM = 1,
GuildVoice = 2,
GroupDM = 3,
GuildCategory = 4,
GuildAnnouncement = 5,
AnnouncementThread = 10,
PublicThread = 11,
PrivateThread = 12,
GuildStageVoice = 13,
GuildDirectory = 14,
GuildForum = 15,
GuildMedia = 16,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum VideoQualityMode {
Auto = 1,
Full = 2,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageMentions {
pub mentions: Vec<APIUser>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseMessageNoChannel {
pub id: String,
pub author: APIUser,
pub content: String,
pub timestamp: String,
pub edited_timestamp: Option<String>,
pub tts: bool,
pub mention_everyone: bool,
pub mention_roles: Vec<APIRole>,
pub mention_channels: Option<Vec<APIChannelMention>>,
pub attachments: Vec<APIAttachment>,
pub embeds: Vec<APIEmbed>,
pub reactions: Option<Vec<APIReaction>>,
pub nonce: Option<serde_json::Value>,
pub pinned: bool,
pub webhook_id: Option<String>,
pub r#type: MessageType,
pub activity: Option<APIMessageActivity>,
pub application: Option<APIApplication>,
pub application_id: Option<String>,
pub message_reference: Option<APIMessageReference>,
#[serde(default, with = "crate::utils::serde::flags_numeric_opt")]
pub flags: Option<MessageFlags>,
pub referenced_message: Option<Box<APIMessage>>,
pub interaction_metadata: Option<APIMessageInteractionMetadata>,
pub interaction: Option<APIMessageInteraction>,
pub thread: Option<APIChannel>,
pub components: Option<Vec<APIMessageTopLevelComponent>>,
pub sticker_items: Option<Vec<APIStickerItem>>,
pub stickers: Option<Vec<APISticker>>,
pub position: Option<i64>,
pub role_subscription_data: Option<APIMessageRoleSubscriptionData>,
pub resolved: Option<APIInteractionDataResolved>,
pub poll: Option<APIPoll>,
pub message_snapshots: Option<Vec<APIMessageSnapshot>>,
pub call: Option<APIMessageCall>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseMessage {
pub channel_id: String,
pub id: String,
pub author: APIUser,
pub content: String,
pub timestamp: String,
pub edited_timestamp: Option<String>,
pub tts: bool,
pub mention_everyone: bool,
pub mention_roles: Vec<APIRole>,
pub mention_channels: Option<Vec<APIChannelMention>>,
pub attachments: Vec<APIAttachment>,
pub embeds: Vec<APIEmbed>,
pub reactions: Option<Vec<APIReaction>>,
pub nonce: Option<serde_json::Value>,
pub pinned: bool,
pub webhook_id: Option<String>,
pub r#type: MessageType,
pub activity: Option<APIMessageActivity>,
pub application: Option<APIApplication>,
pub application_id: Option<String>,
pub message_reference: Option<APIMessageReference>,
#[serde(default, with = "crate::utils::serde::flags_numeric_opt")]
pub flags: Option<MessageFlags>,
pub referenced_message: Option<Box<APIMessage>>,
pub interaction_metadata: Option<APIMessageInteractionMetadata>,
pub interaction: Option<APIMessageInteraction>,
pub thread: Option<APIChannel>,
pub components: Option<Vec<APIMessageTopLevelComponent>>,
pub sticker_items: Option<Vec<APIStickerItem>>,
pub stickers: Option<Vec<APISticker>>,
pub position: Option<i64>,
pub role_subscription_data: Option<APIMessageRoleSubscriptionData>,
pub resolved: Option<APIInteractionDataResolved>,
pub poll: Option<APIPoll>,
pub message_snapshots: Option<Vec<APIMessageSnapshot>>,
pub call: Option<APIMessageCall>,
}
pub type APIMessage = APIBaseMessage;
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum MessageType {
Default = 0,
RecipientAdd = 1,
RecipientRemove = 2,
Call = 3,
ChannelNameChange = 4,
ChannelIconChange = 5,
ChannelPinnedMessage = 6,
UserJoin = 7,
GuildBoost = 8,
GuildBoostTier1 = 9,
GuildBoostTier2 = 10,
GuildBoostTier3 = 11,
ChannelFollowAdd = 12,
GuildDiscoveryDisqualified = 14,
GuildDiscoveryRequalified = 15,
GuildDiscoveryGracePeriodInitialWarning = 16,
GuildDiscoveryGracePeriodFinalWarning = 17,
ThreadCreated = 18,
Reply = 19,
ChatInputCommand = 20,
ThreadStarterMessage = 21,
GuildInviteReminder = 22,
ContextMenuCommand = 23,
AutoModerationAction = 24,
RoleSubscriptionPurchase = 25,
InteractionPremiumUpsell = 26,
StageStart = 27,
StageEnd = 28,
StageSpeaker = 29,
StageRaiseHand = 30,
StageTopic = 31,
GuildApplicationPremiumSubscription = 32,
GuildIncidentAlertModeEnabled = 36,
GuildIncidentAlertModeDisabled = 37,
GuildIncidentReportRaid = 38,
GuildIncidentReportFalseAlarm = 39,
PurchaseNotification = 44,
PollResult = 46,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageActivity {
pub r#type: MessageActivityType,
pub party_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageReference {
pub r#type: Option<MessageReferenceType>,
pub message_id: Option<String>,
pub channel_id: String,
pub guild_id: Option<String>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum MessageActivityType {
Join = 1,
Spectate = 2,
Listen = 3,
JoinRequest = 5,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum MessageReferenceType {
Default = 0,
Forward = 1,
}
bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(transparent)]
pub struct MessageFlags: u64 {
const CROSSPOSTED = 1 << 0;
const IS_CROSSPOST = 1 << 1;
const SUPPRESS_EMBEDS = 1 << 2;
const SOURCE_MESSAGE_DELETED = 1 << 3;
const URGENT = 1 << 4;
const HAS_THREAD = 1 << 5;
const EPHEMERAL = 1 << 6;
const LOADING = 1 << 7;
const FAILED_TO_MENTION_SOME_ROLES = 1 << 8;
const SHOULD_SHOW_LINK_NOT_DISCORD_WARN = 1 << 10;
const SUPPRESS_NOTIFICATIONS = 1 << 12;
const IS_VOICE_MESSAGE = 1 << 13;
const HAS_SNAPSHOT = 1 << 14;
const IS_COMPONENTS_V2 = 1 << 15;
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageCall {
pub participants: Vec<String>,
pub ended_timestamp: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageRoleSubscriptionData {
pub role_subscription_listing_id: String,
pub tier_name: String,
pub total_months_subscribed: i64,
pub is_renewal: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIFollowedChannel {
pub channel_id: String,
pub webhook_id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIReaction {
pub count: i64,
pub count_details: APIReactionCountDetails,
pub me: bool,
pub me_burst: bool,
pub emoji: APIPartialEmoji,
pub burst_colors: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIReactionCountDetails {
pub burst: i64,
pub normal: i64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIOverwrite {
pub id: String,
pub r#type: OverwriteType,
pub allow: String,
pub deny: String,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum OverwriteType {
Role = 0,
Member = 1,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadMetadata {
pub archived: bool,
pub auto_archive_duration: ThreadAutoArchiveDuration,
pub archive_timestamp: String,
pub locked: bool,
pub invitable: Option<bool>,
pub create_timestamp: Option<String>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u32)]
pub enum ThreadAutoArchiveDuration {
OneHour = 60,
OneDay = 1_440,
ThreeDays = 4_320,
OneWeek = 10_080,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadMember {
pub id: Option<String>,
pub user_id: Option<String>,
pub join_timestamp: String,
pub flags: ThreadMemberFlags,
pub member: Option<APIGuildMember>,
}
bitflags! {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ThreadMemberFlags: u32 {
const HasInteracted = 1 << 0;
const AllMessages = 1 << 1;
const OnlyMentions = 1 << 2;
const NoMessages = 1 << 3;
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThreadList {
pub threads: Vec<APIChannel>,
pub members: Vec<APIThreadMember>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbed {
pub title: Option<String>,
pub r#type: Option<EmbedType>,
pub description: Option<String>,
pub url: Option<String>,
pub timestamp: Option<String>,
pub color: Option<i64>,
pub footer: Option<APIEmbedFooter>,
pub image: Option<APIEmbedImage>,
pub thumbnail: Option<APIEmbedThumbnail>,
pub video: Option<APIEmbedVideo>,
pub provider: Option<APIEmbedProvider>,
pub author: Option<APIEmbedAuthor>,
pub fields: Option<Vec<APIEmbedField>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum EmbedType {
#[serde(rename = "rich")]
Rich,
#[serde(rename = "image")]
Image,
#[serde(rename = "video")]
Video,
#[serde(rename = "gifv")]
GIFV,
#[serde(rename = "article")]
Article,
#[serde(rename = "link")]
Link,
#[serde(rename = "auto_moderation_message")]
AutoModerationMessage,
#[serde(rename = "poll_result")]
PollResult,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedThumbnail {
pub url: String,
pub proxy_url: Option<String>,
pub height: Option<i64>,
pub width: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedVideo {
pub url: Option<String>,
pub proxy_url: Option<String>,
pub height: Option<i64>,
pub width: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedImage {
pub url: String,
pub proxy_url: Option<String>,
pub height: Option<i64>,
pub width: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedProvider {
pub name: Option<String>,
pub url: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedAuthor {
pub name: String,
pub url: Option<String>,
pub icon_url: Option<String>,
pub proxy_icon_url: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedFooter {
pub text: String,
pub icon_url: Option<String>,
pub proxy_icon_url: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIEmbedField {
pub name: String,
pub value: String,
pub inline: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIAttachment {
pub id: String,
pub filename: String,
pub title: Option<String>,
pub description: Option<String>,
pub content_type: Option<String>,
pub size: i64,
pub url: String,
pub proxy_url: String,
pub height: Option<i64>,
pub width: Option<i64>,
pub ephemeral: Option<bool>,
pub duration_secs: Option<f64>,
pub waveform: Option<String>,
pub flags: Option<AttachmentFlags>,
}
bitflags! {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AttachmentFlags: u32 {
const IsRemix = 1 << 2;
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIChannelMention {
pub id: String,
pub guild_id: String,
pub r#type: ChannelType,
pub name: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum AllowedMentionsTypes {
Everyone,
Role,
User,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIAllowedMentions {
pub parse: Option<Vec<AllowedMentionsTypes>>,
pub roles: Option<Vec<String>>,
pub users: Option<Vec<String>>,
pub replied_user: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseComponent<T> {
pub r#type: T,
pub id: Option<i32>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ComponentType {
ActionRow = 1,
Button = 2,
StringSelect = 3,
TextInput = 4,
UserSelect = 5,
RoleSelect = 6,
MentionableSelect = 7,
ChannelSelect = 8,
Section = 9,
TextDisplay = 10,
Thumbnail = 11,
MediaGallery = 12,
File = 13,
Separator = 14,
ContentInventoryEntry = 16,
Container = 17,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIActionRowComponent<T> {
pub r#type: ComponentType,
pub id: Option<i32>,
pub components: Vec<T>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonBase<Style> {
pub r#type: ComponentType,
pub id: Option<i32>,
pub style: Style,
pub disabled: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentBase<Style> {
pub r#type: ComponentType,
pub id: Option<i32>,
pub style: Style,
pub disabled: Option<bool>,
pub label: Option<String>,
pub emoji: Option<APIMessageComponentEmoji>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageComponentEmoji {
pub id: Option<String>,
pub name: Option<String>,
pub animated: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentWithCustomId {
pub r#type: ComponentType,
pub id: Option<i32>,
pub style: ButtonStyle,
pub disabled: Option<bool>,
pub label: Option<String>,
pub emoji: Option<APIMessageComponentEmoji>,
pub custom_id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentWithURL {
pub r#type: ComponentType,
pub id: Option<i32>,
pub style: ButtonStyle,
pub disabled: Option<bool>,
pub label: Option<String>,
pub emoji: Option<APIMessageComponentEmoji>,
pub url: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIButtonComponentWithSKUId {
pub r#type: ComponentType,
pub id: Option<i32>,
pub style: ButtonStyle,
pub disabled: Option<bool>,
pub sku_id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIButtonComponent {
APIButtonComponentWithCustomId(APIButtonComponentWithCustomId),
APIButtonComponentWithSKUId(APIButtonComponentWithSKUId),
APIButtonComponentWithURL(APIButtonComponentWithURL),
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ButtonStyle {
Primary = 1,
Secondary = 2,
Success = 3,
Danger = 4,
Link = 5,
Premium = 6,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum TextInputStyle {
Short = 1,
Paragraph = 2,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseSelectMenuComponent<T> {
pub custom_id: String,
pub placeholder: Option<String>,
pub min_values: Option<i64>,
pub max_values: Option<i64>,
pub disabled: Option<bool>,
pub r#type: T,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIBaseAutoPopulatedSelectMenuComponent<T, D> {
pub default_values: Option<Vec<APISelectMenuDefaultValue<D>>>,
pub custom_id: String,
pub placeholder: Option<String>,
pub min_values: Option<i64>,
pub max_values: Option<i64>,
pub disabled: Option<bool>,
pub r#type: T,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIStringSelectComponent {
pub options: Vec<APISelectMenuOption>,
pub custom_id: String,
pub placeholder: Option<String>,
pub min_values: Option<i64>,
pub max_values: Option<i64>,
pub disabled: Option<bool>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
pub type APIUserSelectComponent =
APIBaseAutoPopulatedSelectMenuComponent<ComponentType, SelectMenuDefaultValueType>;
pub type APIRoleSelectComponent =
APIBaseAutoPopulatedSelectMenuComponent<ComponentType, SelectMenuDefaultValueType>;
pub type APIMentionableSelectComponent =
APIBaseAutoPopulatedSelectMenuComponent<ComponentType, SelectMenuDefaultValueType>;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIChannelSelectComponent {
pub channel_types: Option<Vec<ChannelType>>,
pub default_values: Option<Vec<APISelectMenuDefaultValue<SelectMenuDefaultValueType>>>,
pub custom_id: String,
pub placeholder: Option<String>,
pub min_values: Option<i64>,
pub max_values: Option<i64>,
pub disabled: Option<bool>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum SelectMenuDefaultValueType {
Channel,
Role,
User,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISelectMenuDefaultValue<T> {
pub r#type: T,
pub id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIAutoPopulatedSelectMenuComponent {
APIChannelSelectComponent(APIChannelSelectComponent),
APIMentionableSelectComponent(APIMentionableSelectComponent),
APIRoleSelectComponent(APIRoleSelectComponent),
APIUserSelectComponent(APIUserSelectComponent),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APISelectMenuComponent {
APIChannelSelectComponent(APIChannelSelectComponent),
APIMentionableSelectComponent(APIMentionableSelectComponent),
APIRoleSelectComponent(APIRoleSelectComponent),
APIStringSelectComponent(APIStringSelectComponent),
APIUserSelectComponent(APIUserSelectComponent),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISelectMenuOption {
pub label: String,
pub value: String,
pub description: Option<String>,
pub emoji: Option<APIMessageComponentEmoji>,
pub default: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APITextInputComponent {
pub style: TextInputStyle,
pub custom_id: String,
pub label: String,
pub placeholder: Option<String>,
pub value: Option<String>,
pub min_length: Option<i64>,
pub max_length: Option<i64>,
pub required: Option<bool>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum UnfurledMediaItemLoadingState {
Unknown = 0,
Loading = 1,
LoadedSuccess = 2,
LoadedNotFound = 3,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIUnfurledMediaItem {
pub url: String,
pub proxy_url: Option<String>,
pub width: Option<i64>,
pub height: Option<i64>,
pub placeholder: Option<String>,
pub placeholder_version: Option<i64>,
pub content_type: Option<String>,
pub loading_state: Option<UnfurledMediaItemLoadingState>,
pub flags: Option<i64>,
pub attachment_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISectionComponent {
pub components: Vec<APITextDisplayComponent>,
pub accessory: APISectionAccessoryComponent,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APITextDisplayComponent {
pub content: String,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIThumbnailComponent {
pub media: APIUnfurledMediaItem,
pub description: Option<String>,
pub spoiler: Option<bool>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMediaGalleryItem {
pub media: APIUnfurledMediaItem,
pub description: Option<String>,
pub spoiler: Option<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMediaGalleryComponent {
pub items: Vec<APIMediaGalleryItem>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIFileComponent {
pub file: APIUnfurledMediaItem,
pub spoiler: Option<bool>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum SeparatorSpacingSize {
Small = 1,
Large = 2,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APISeparatorComponent {
pub divider: Option<bool>,
pub spacing: Option<SeparatorSpacingSize>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIContainerComponent {
pub accent_color: Option<i64>,
pub spoiler: Option<bool>,
pub components: Vec<APIComponentInContainer>,
pub r#type: ComponentType,
pub id: Option<i32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageSnapshot {
pub message: APIMessageSnapshotFields,
pub guild_id: Option<String>,
}
bitflags! {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ChannelFlags: u32 {
const GuildFeedRemoved = 1 << 0;
const Pinned = 1 << 1;
const ActiveChannelsRemoved = 1 << 2;
const RequireTag = 1 << 4;
const IsSpam = 1 << 5;
const IsGuildResourceChannel = 1 << 7;
const ClydeAI = 1 << 8;
const IsScheduledForDeletion = 1 << 9;
const HideMediaDownloadOptions = 1 << 15;
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIMessageComponent {
APIActionRowComponent(APIActionRowComponent<APIComponentInMessageActionRow>),
APIButtonComponent(APIButtonComponent),
APIContainerComponent(APIContainerComponent),
APIFileComponent(APIFileComponent),
APIMediaGalleryComponent(APIMediaGalleryComponent),
APISectionComponent(APISectionComponent),
APISelectMenuComponent(APISelectMenuComponent),
APISeparatorComponent(APISeparatorComponent),
APITextDisplayComponent(APITextDisplayComponent),
APIThumbnailComponent(APIThumbnailComponent),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIMessageTopLevelComponent {
APIActionRowComponent(APIActionRowComponent<APIComponentInMessageActionRow>),
APIContainerComponent(APIContainerComponent),
APIFileComponent(APIFileComponent),
APIMediaGalleryComponent(APIMediaGalleryComponent),
APISectionComponent(APISectionComponent),
APISeparatorComponent(APISeparatorComponent),
APITextDisplayComponent(APITextDisplayComponent),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIModalComponent {
APIActionRowComponent(APIActionRowComponent<APIComponentInModalActionRow>),
APIComponentInModalActionRow(APIComponentInModalActionRow),
}
pub type APIComponentInActionRow = APIComponentInMessageActionRow;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIComponentInMessageActionRow {
APIButtonComponent(APIButtonComponent),
APISelectMenuComponent(APISelectMenuComponent),
}
pub type APIComponentInModalActionRow = APITextInputComponent;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APISectionAccessoryComponent {
APIButtonComponent(APIButtonComponent),
APIThumbnailComponent(APIThumbnailComponent),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum APIComponentInContainer {
APIActionRowComponent(APIActionRowComponent<APIComponentInMessageActionRow>),
APIFileComponent(APIFileComponent),
APIMediaGalleryComponent(APIMediaGalleryComponent),
APISectionComponent(APISectionComponent),
APISeparatorComponent(APISeparatorComponent),
APITextDisplayComponent(APITextDisplayComponent),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessageSnapshotFields {
pub attachments: Vec<APIAttachment>,
pub components: Option<Vec<APIMessageTopLevelComponent>>,
pub content: String,
pub edited_timestamp: Option<String>,
pub embeds: Vec<APIEmbed>,
pub flags: MessageFlags,
pub mention_roles: Vec<APIRole>,
pub mentions: Vec<APIUser>,
pub sticker_items: Option<Vec<APIStickerItem>>,
pub stickers: Option<Vec<APISticker>>,
pub timestamp: String,
pub r#type: MessageType,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIMessagePin {
pub pinned_at: String,
pub message: APIMessage,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIRoleId {
pub id: String,
}