Skip to content

Commit 7cb10ad

Browse files
authored
Add support for changing voice status (#2982)
API documentation: discord/discord-api-docs#6400
1 parent 57af3e0 commit 7cb10ad

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

src/builder/edit_channel.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ impl<'a> EditChannel<'a> {
141141
self
142142
}
143143

144+
/// The status of the voice channel. Can be empty.
145+
///
146+
/// Must be between 0 and 1024 characters long.
147+
///
148+
/// This is for [voice] channels only.
149+
///
150+
/// [voice]: ChannelType::Voice
151+
pub fn status(mut self, status: impl Into<String>) -> Self {
152+
self.status = Some(status.into());
153+
self
154+
}
155+
144156
/// Is the channel inappropriate for work?
145157
///
146158
/// This is for [text] channels only.
@@ -324,6 +336,24 @@ impl<'a> Builder for EditChannel<'a> {
324336
}
325337
}
326338

339+
if let Some(status) = &self.status {
340+
#[derive(Serialize)]
341+
struct EditVoiceStatusBody<'a> {
342+
status: &'a str,
343+
}
344+
345+
cache_http
346+
.http()
347+
.edit_voice_status(
348+
ctx,
349+
&EditVoiceStatusBody {
350+
status: status.as_str(),
351+
},
352+
self.audit_log_reason,
353+
)
354+
.await?;
355+
}
356+
327357
cache_http.http().edit_channel(ctx, &self, self.audit_log_reason).await
328358
}
329359
}

src/http/client.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,28 @@ impl Http {
24122412
.await
24132413
}
24142414

2415+
/// Changes a voice channel's status.
2416+
pub async fn edit_voice_status(
2417+
&self,
2418+
channel_id: ChannelId,
2419+
map: &impl serde::Serialize,
2420+
audit_log_reason: Option<&str>,
2421+
) -> Result<()> {
2422+
let body = to_vec(map)?;
2423+
2424+
self.wind(204, Request {
2425+
body: Some(body),
2426+
multipart: None,
2427+
headers: audit_log_reason.map(reason_into_header),
2428+
method: LightMethod::Put,
2429+
route: Route::ChannelVoiceStatus {
2430+
channel_id,
2431+
},
2432+
params: None,
2433+
})
2434+
.await
2435+
}
2436+
24152437
/// Edits a the webhook with the given data.
24162438
///
24172439
/// The Value is a map with optional values of:

src/http/routing.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ routes! ('a, {
194194
api!("/channels/{}/polls/{}/expire", channel_id, message_id),
195195
Some(RatelimitingKind::PathAndId(channel_id.into()));
196196

197+
ChannelVoiceStatus { channel_id: ChannelId },
198+
api!("/channels/{}/voice-status", channel_id),
199+
Some(RatelimitingKind::PathAndId(channel_id.into()));
200+
197201
Gateway,
198202
api!("/gateway"),
199203
Some(RatelimitingKind::Path);

0 commit comments

Comments
 (0)