Skip to content

Commit 3237a74

Browse files
authored
feat: Added the ability to set voice channel statuses (#1064)
1 parent 468a197 commit 3237a74

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

include/dpp/cluster.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,6 +3703,17 @@ class DPP_EXPORT cluster {
37033703
*/
37043704
void skus_get(command_completion_event_t callback = utility::log_error());
37053705

3706+
/**
3707+
* @brief Set the status of a voice channel.
3708+
*
3709+
* @see https://github.com/discord/discord-api-docs/pull/6400 (please replace soon).
3710+
* @param channel_id The channel to update.
3711+
* @param status The new status for the channel.
3712+
* @param callback Function to call when the API call completes.
3713+
* On success the callback will contain a dpp::confirmation object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
3714+
*/
3715+
void channel_set_voice_status(snowflake channel_id, const std::string& status, command_completion_event_t callback = utility::log_error());
3716+
37063717
#include <dpp/cluster_sync_calls.h>
37073718
#ifdef DPP_CORO
37083719
#include <dpp/cluster_coro_calls.h>

include/dpp/cluster_coro_calls.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,18 @@
576576
*/
577577
[[nodiscard]] async<confirmation_callback_t> co_channels_get(snowflake guild_id);
578578

579+
/**
580+
* @brief Set the status of a voice channel.
581+
*
582+
* @see dpp::cluster::channel_set_voice_status
583+
* @see https://github.com/discord/discord-api-docs/pull/6400 (please replace soon).
584+
* @param channel_id The channel to update.
585+
* @param status The new status for the channel.
586+
* @return confirmation returned object on completion
587+
* \memberof dpp::cluster
588+
*/
589+
[[nodiscard]] async<confirmation_callback_t> co_channel_set_voice_status(snowflake channel_id, const std::string& status);
590+
579591
/**
580592
* @brief Create a dm channel
581593
* @see dpp::cluster::create_dm_channel

include/dpp/cluster_sync_calls.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,21 @@ confirmation channel_typing_sync(snowflake cid);
714714
*/
715715
channel_map channels_get_sync(snowflake guild_id);
716716

717+
/**
718+
* @brief Set the status of a voice channel.
719+
*
720+
* @see dpp::cluster::channel_set_voice_status
721+
* @see https://github.com/discord/discord-api-docs/pull/6400 (please replace soon).
722+
* @param channel_id The channel to update.
723+
* @param status The new status for the channel.
724+
* @return confirmation returned object on completion
725+
* \memberof dpp::cluster
726+
* @throw dpp::rest_exception upon failure to execute REST function
727+
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
728+
* Avoid direct use of this function inside an event handler.
729+
*/
730+
confirmation channel_set_voice_status_sync(snowflake channel_id, const std::string& status);
731+
717732
/**
718733
* @brief Create a dm channel
719734
* @see dpp::cluster::create_dm_channel

src/dpp/cluster/channel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,9 @@ void cluster::channels_get(snowflake guild_id, command_completion_event_t callba
9898
rest_request_list<channel>(this, API_PATH "/guilds", std::to_string(guild_id), "channels", m_get, "", callback);
9999
}
100100

101+
void cluster::channel_set_voice_status(snowflake channel_id, const std::string& status, command_completion_event_t callback) {
102+
json j({ {"status", status} });
103+
rest_request<confirmation>(this, API_PATH "/channels", std::to_string(channel_id), "voice-status", m_put, j.dump(), callback);
104+
}
105+
101106
} // namespace dpp

src/dpp/cluster_coro_calls.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ async<confirmation_callback_t> cluster::co_channels_get(snowflake guild_id) {
219219
return async{ this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::channels_get), guild_id };
220220
}
221221

222+
async<confirmation_callback_t> cluster::co_channel_set_voice_status(snowflake channel_id, const std::string& status) {
223+
return async{ this, static_cast<void (cluster::*)(snowflake, const std::string&, command_completion_event_t)>(&cluster::channel_set_voice_status), channel_id, status };
224+
}
225+
222226
async<confirmation_callback_t> cluster::co_create_dm_channel(snowflake user_id) {
223227
return async{ this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::create_dm_channel), user_id };
224228
}

src/dpp/cluster_sync_calls.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ channel_map cluster::channels_get_sync(snowflake guild_id) {
217217
return dpp::sync<channel_map>(this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::channels_get), guild_id);
218218
}
219219

220+
confirmation cluster::channel_set_voice_status_sync(snowflake channel_id, const std::string& status) {
221+
return dpp::sync<confirmation>(this, static_cast<void (cluster::*)(snowflake, const std::string&, command_completion_event_t)>(&cluster::channel_set_voice_status), channel_id, status);
222+
}
223+
220224
channel cluster::create_dm_channel_sync(snowflake user_id) {
221225
return dpp::sync<channel>(this, static_cast<void (cluster::*)(snowflake, command_completion_event_t)>(&cluster::create_dm_channel), user_id);
222226
}

0 commit comments

Comments
 (0)