rive-models 1.2.1

Revolt API models for the Rive ecosystem.
Documentation
use serde::{Deserialize, Serialize};

use crate::{attachment::Attachment, user::User};

bitflags::bitflags! {
    /// User badge bitfield
    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct BotFlags: u64 {
        const Verified = 1;
        const Official = 2;
    }
}
crate::impl_serde_bitflags!(BotFlags);

/// Public bot
#[derive(Deserialize, Debug, Clone)]
pub struct PublicBot {
    /// Bot Id
    #[serde(rename = "_id")]
    pub id: String,
    /// Bot Username
    pub username: String,
    /// Profile Avatar
    pub avatar: Option<Attachment>,
    /// Profile Description
    pub description: Option<String>,
}

/// Representation of a bot on Revolt
#[derive(Deserialize, Debug, Clone)]
pub struct Bot {
    /// Bot Id
    ///
    /// This equals the associated bot user's id.
    #[serde(rename = "_id")]
    pub id: String,
    /// User Id of the bot owner
    pub owner: String,
    /// Token used to authenticate requests for this bot
    pub token: String,
    /// Whether the bot is public
    /// (may be invited by anyone)
    pub public: bool,

    /// Whether to enable analytics
    #[serde(default)]
    pub analytics: bool,
    /// Whether this bot should be publicly discoverable
    #[serde(default)]
    pub discoverable: bool,
    /// Reserved; URL for handling interactions
    pub interactions_url: Option<String>,
    /// URL for terms of service
    pub terms_of_service_url: Option<String>,
    /// URL for privacy policy
    pub privacy_policy_url: Option<String>,

    /// Enum of bot flags
    pub flags: Option<BotFlags>,
}

/// Partial representation of a bot on Revolt
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
pub struct PartialBot {
    /// Bot Id
    ///
    /// This equals the associated bot user's id.
    #[serde(rename = "_id")]
    pub id: Option<String>,
    /// User Id of the bot owner
    pub owner: Option<String>,
    /// Token used to authenticate requests for this bot
    pub token: Option<String>,
    /// Whether the bot is public
    /// (may be invited by anyone)
    pub public: Option<bool>,

    /// Whether to enable analytics
    pub analytics: Option<bool>,
    /// Whether this bot should be publicly discoverable
    pub discoverable: Option<bool>,
    /// Reserved; URL for handling interactions
    pub interactions_url: Option<String>,
    /// URL for terms of service
    pub terms_of_service_url: Option<String>,
    /// URL for privacy policy
    pub privacy_policy_url: Option<String>,

    /// Enum of bot flags
    pub flags: Option<BotFlags>,
}

/// Owned bot.
///
/// Contains bot and user information.
#[derive(Deserialize, Debug, Clone)]
pub struct OwnedBot {
    /// Bot object
    pub bot: Bot,
    /// User object
    pub user: User,
}

/// Optional fields on bot object
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub enum FieldsBot {
    Token,
    InteractionsURL,
}

/// Owned bots.
///
/// Both lists are sorted by their IDs.
#[derive(Deserialize, Debug, Clone)]
pub struct OwnedBots {
    /// Bot objects
    pub bots: Vec<Bot>,
    /// User objects
    pub users: Vec<User>,
}