Skip to main content

serenity/builder/
edit_guild_incident_actions.rs

1#[cfg(feature = "http")]
2use crate::http::Http;
3#[cfg(feature = "http")]
4use crate::internal::prelude::*;
5use crate::model::prelude::*;
6
7/// A builder for editing guild incident actions.
8///
9/// [Discord's docs]: https://discord.com/developers/docs/resources/guild#modify-guild-incident-actions
10#[derive(Clone, Debug, Default, Serialize)]
11#[must_use]
12pub struct EditGuildIncidentActions {
13    invites_disabled_until: Option<Timestamp>,
14    dms_disabled_until: Option<Timestamp>,
15}
16
17impl EditGuildIncidentActions {
18    pub fn new() -> Self {
19        Self::default()
20    }
21
22    /// Sets the time until which guild invites will remain disabled, which can be at most 24 hours
23    /// in the future.
24    pub fn invites_disabled_until(mut self, timestamp: Timestamp) -> Self {
25        self.invites_disabled_until = Some(timestamp);
26        self
27    }
28
29    /// Sets the time at which direct messages for users within the guild will remain disabled,
30    /// which can be at most 24 hours in the future.
31    pub fn dms_disabled_until(mut self, timestamp: Timestamp) -> Self {
32        self.dms_disabled_until = Some(timestamp);
33        self
34    }
35
36    /// Modifies the guild's incident actions.
37    ///
38    /// # Errors
39    ///
40    /// Returns [`Error::Http`] if invalid data is given. See [Discord's docs] for more details.
41    ///
42    /// May also return [`Error::Json`] if there is an error in deserializing the API response.
43    #[cfg(feature = "http")]
44    pub async fn execute(self, http: &Http, guild_id: GuildId) -> Result<IncidentsData> {
45        http.edit_guild_incident_actions(guild_id, &self).await
46    }
47}