rive_models/
bot.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{attachment::Attachment, user::User};
4
5bitflags::bitflags! {
6    /// User badge bitfield
7    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
8    pub struct BotFlags: u64 {
9        const Verified = 1;
10        const Official = 2;
11    }
12}
13crate::impl_serde_bitflags!(BotFlags);
14
15/// Public bot
16#[derive(Deserialize, Debug, Clone)]
17pub struct PublicBot {
18    /// Bot Id
19    #[serde(rename = "_id")]
20    pub id: String,
21    /// Bot Username
22    pub username: String,
23    /// Profile Avatar
24    pub avatar: Option<Attachment>,
25    /// Profile Description
26    pub description: Option<String>,
27}
28
29/// Representation of a bot on Revolt
30#[derive(Deserialize, Debug, Clone)]
31pub struct Bot {
32    /// Bot Id
33    ///
34    /// This equals the associated bot user's id.
35    #[serde(rename = "_id")]
36    pub id: String,
37    /// User Id of the bot owner
38    pub owner: String,
39    /// Token used to authenticate requests for this bot
40    pub token: String,
41    /// Whether the bot is public
42    /// (may be invited by anyone)
43    pub public: bool,
44
45    /// Whether to enable analytics
46    #[serde(default)]
47    pub analytics: bool,
48    /// Whether this bot should be publicly discoverable
49    #[serde(default)]
50    pub discoverable: bool,
51    /// Reserved; URL for handling interactions
52    pub interactions_url: Option<String>,
53    /// URL for terms of service
54    pub terms_of_service_url: Option<String>,
55    /// URL for privacy policy
56    pub privacy_policy_url: Option<String>,
57
58    /// Enum of bot flags
59    pub flags: Option<BotFlags>,
60}
61
62/// Partial representation of a bot on Revolt
63#[derive(Serialize, Deserialize, Default, Debug, Clone)]
64pub struct PartialBot {
65    /// Bot Id
66    ///
67    /// This equals the associated bot user's id.
68    #[serde(rename = "_id")]
69    pub id: Option<String>,
70    /// User Id of the bot owner
71    pub owner: Option<String>,
72    /// Token used to authenticate requests for this bot
73    pub token: Option<String>,
74    /// Whether the bot is public
75    /// (may be invited by anyone)
76    pub public: Option<bool>,
77
78    /// Whether to enable analytics
79    pub analytics: Option<bool>,
80    /// Whether this bot should be publicly discoverable
81    pub discoverable: Option<bool>,
82    /// Reserved; URL for handling interactions
83    pub interactions_url: Option<String>,
84    /// URL for terms of service
85    pub terms_of_service_url: Option<String>,
86    /// URL for privacy policy
87    pub privacy_policy_url: Option<String>,
88
89    /// Enum of bot flags
90    pub flags: Option<BotFlags>,
91}
92
93/// Owned bot.
94///
95/// Contains bot and user information.
96#[derive(Deserialize, Debug, Clone)]
97pub struct OwnedBot {
98    /// Bot object
99    pub bot: Bot,
100    /// User object
101    pub user: User,
102}
103
104/// Optional fields on bot object
105#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
106pub enum FieldsBot {
107    Token,
108    InteractionsURL,
109}
110
111/// Owned bots.
112///
113/// Both lists are sorted by their IDs.
114#[derive(Deserialize, Debug, Clone)]
115pub struct OwnedBots {
116    /// Bot objects
117    pub bots: Vec<Bot>,
118    /// User objects
119    pub users: Vec<User>,
120}