serenity/builder/
edit_soundboard.rs1#[cfg(feature = "http")]
2use super::Builder;
3#[cfg(feature = "http")]
4use crate::http::CacheHttp;
5#[cfg(feature = "http")]
6use crate::internal::prelude::*;
7use crate::model::prelude::*;
8
9#[derive(Clone, Debug, Default, Serialize)]
19#[must_use]
20pub struct EditSoundboard<'a> {
21 #[serde(skip_serializing_if = "Option::is_none")]
22 name: Option<String>,
23 #[serde(skip_serializing_if = "Option::is_none")]
24 volume: Option<f64>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 emoji_id: Option<EmojiId>,
27 #[serde(skip_serializing_if = "Option::is_none")]
28 emoji_name: Option<String>,
29
30 #[serde(skip)]
31 audit_log_reason: Option<&'a str>,
32}
33
34impl<'a> EditSoundboard<'a> {
35 pub fn new() -> Self {
37 Self::default()
38 }
39
40 pub fn name(mut self, name: impl Into<String>) -> Self {
44 self.name = Some(name.into());
45 self
46 }
47
48 pub fn volume(mut self, volume: f64) -> Self {
52 self.volume = volume.into();
53 self
54 }
55
56 pub fn emoji_id(mut self, id: EmojiId) -> Self {
58 self.emoji_id = Some(id);
59 self
60 }
61
62 pub fn emoji_name(mut self, name: String) -> Self {
64 self.emoji_name = Some(name);
65 self
66 }
67
68 pub fn audit_log_reason(mut self, reason: &'a str) -> Self {
70 self.audit_log_reason = Some(reason);
71 self
72 }
73}
74
75#[cfg(feature = "http")]
76#[async_trait::async_trait]
77impl Builder for EditSoundboard<'_> {
78 type Context<'ctx> = (GuildId, SoundId);
79 type Built = Soundboard;
80
81 async fn execute(
94 self,
95 cache_http: impl CacheHttp,
96 ctx: Self::Context<'_>,
97 ) -> Result<Self::Built> {
98 cache_http.http().edit_guild_soundboard(ctx.0, ctx.1, &self, self.audit_log_reason).await
99 }
100}