Skip to main content

djs_model/rest/
application.rs

1//! Bodies of the [application endpoints](https://docs.discord.com/developers/resources/application).
2
3use compact_str::CompactString;
4use serde::Serialize;
5
6use crate::{
7    application::{ApplicationFlags, EventWebhookStatus, InstallParams, IntegrationTypesConfig},
8    util::{ImageData, Patch},
9    webhook_event::WebhookEventType,
10};
11
12/// The body of [Edit Current Application](https://docs.discord.com/developers/resources/application#edit-current-application).
13///
14/// Every field is optional; only the fields that are set change.
15///
16/// discord.js counterpart: the argument of `ClientApplication#edit`.
17///
18/// # Examples
19///
20/// ```
21/// use djs_model::{
22///     application::InstallParams,
23///     oauth2::Scope,
24///     permissions::Permissions,
25///     rest::EditCurrentApplication,
26/// };
27///
28/// let mut body = EditCurrentApplication::default();
29/// body.description = Some("A bot written in Rust".into());
30/// body.install_params = Some(InstallParams::new(
31///     [Scope::Bot, Scope::ApplicationsCommands],
32///     Permissions::SEND_MESSAGES,
33/// ));
34/// assert_eq!(
35///     serde_json::to_string(&body)?,
36///     r#"{"description":"A bot written in Rust","install_params":{"scopes":["bot","applications.commands"],"permissions":"2048"}}"#
37/// );
38/// # Ok::<(), serde_json::Error>(())
39/// ```
40#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
41#[non_exhaustive]
42pub struct EditCurrentApplication {
43    /// The custom authorization URL, used when the app's install link is a custom URL.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub custom_install_url: Option<CompactString>,
46    /// The description.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub description: Option<CompactString>,
49    /// The URL that users are sent to to verify their linked roles.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub role_connections_verification_url: Option<CompactString>,
52    /// The settings of the in-app authorization link, used when the install link is the one
53    /// Discord provides.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub install_params: Option<InstallParams>,
56    /// The default scopes and permissions of each installation context.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub integration_types_config: Option<IntegrationTypesConfig>,
59    /// The public flags. Only `GATEWAY_PRESENCE_LIMITED`, `GATEWAY_GUILD_MEMBERS_LIMITED` and
60    /// `GATEWAY_MESSAGE_CONTENT_LIMITED` can be changed.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub flags: Option<ApplicationFlags>,
63    /// The new icon; [`Patch::Clear`] removes it.
64    #[serde(skip_serializing_if = "Patch::is_keep")]
65    pub icon: Patch<ImageData>,
66    /// The new default rich presence invite cover image; [`Patch::Clear`] removes it.
67    #[serde(skip_serializing_if = "Patch::is_keep")]
68    pub cover_image: Patch<ImageData>,
69    /// The URL that receives interactions over HTTP instead of the gateway. Discord checks
70    /// that it answers its validation requests.
71    #[serde(skip_serializing_if = "Option::is_none")]
72    pub interactions_endpoint_url: Option<CompactString>,
73    /// Tags describing the app (up to 5, 20 characters each).
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub tags: Option<Vec<CompactString>>,
76    /// The URL that receives [webhook events](crate::webhook_event).
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub event_webhooks_url: Option<CompactString>,
79    /// Enables ([`Enabled`](EventWebhookStatus::Enabled)) or disables
80    /// ([`Disabled`](EventWebhookStatus::Disabled)) webhook events.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub event_webhooks_status: Option<EventWebhookStatus>,
83    /// The webhook events to receive.
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub event_webhooks_types: Option<Vec<WebhookEventType>>,
86}