mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-19 20:11:59 +03:00
rudimentary dm voice call support
This commit is contained in:
@@ -1180,10 +1180,11 @@ void DiscordClient::AcceptVerificationGate(Snowflake guild_id, VerificationGateI
|
||||
#ifdef WITH_VOICE
|
||||
void DiscordClient::ConnectToVoice(Snowflake channel_id) {
|
||||
auto channel = GetChannel(channel_id);
|
||||
if (!channel.has_value() || !channel->GuildID.has_value()) return;
|
||||
if (!channel.has_value()) return;
|
||||
m_voice_channel_id = channel_id;
|
||||
VoiceStateUpdateMessage m;
|
||||
m.GuildID = *channel->GuildID;
|
||||
if (channel->GuildID.has_value())
|
||||
m.GuildID = channel->GuildID;
|
||||
m.ChannelID = channel_id;
|
||||
m.PreferredRegion = "newark";
|
||||
m_websocket.Send(m);
|
||||
@@ -2179,7 +2180,13 @@ void DiscordClient::HandleGatewayVoiceServerUpdate(const GatewayMessage &msg) {
|
||||
printf("token: %s\n", data.Token.c_str());
|
||||
m_voice.SetEndpoint(data.Endpoint);
|
||||
m_voice.SetToken(data.Token);
|
||||
m_voice.SetServerID(data.GuildID);
|
||||
if (data.GuildID.has_value()) {
|
||||
m_voice.SetServerID(*data.GuildID);
|
||||
} else if (data.ChannelID.has_value()) {
|
||||
m_voice.SetServerID(*data.ChannelID);
|
||||
} else {
|
||||
puts("no guild or channel id in voice server?");
|
||||
}
|
||||
m_voice.SetUserID(m_user_data.ID);
|
||||
m_voice.Start();
|
||||
}
|
||||
|
||||
@@ -666,13 +666,14 @@ void to_json(nlohmann::json &j, const VoiceStateUpdateMessage &m) {
|
||||
|
||||
void from_json(const nlohmann::json &j, VoiceServerUpdateData &m) {
|
||||
JS_D("token", m.Token);
|
||||
JS_D("guild_id", m.GuildID);
|
||||
JS_D("endpoint", m.Endpoint);
|
||||
JS_ON("guild_id", m.GuildID);
|
||||
JS_ON("channel_id", m.ChannelID);
|
||||
}
|
||||
#endif
|
||||
|
||||
void from_json(const nlohmann::json &j, VoiceState &m) {
|
||||
JS_O("guild_id", m.GuildID);
|
||||
JS_ON("guild_id", m.GuildID);
|
||||
JS_N("channel_id", m.ChannelID);
|
||||
JS_D("deaf", m.IsDeafened);
|
||||
JS_D("mute", m.IsMuted);
|
||||
|
||||
@@ -891,8 +891,9 @@ struct VoiceStateUpdateMessage {
|
||||
|
||||
struct VoiceServerUpdateData {
|
||||
std::string Token;
|
||||
Snowflake GuildID;
|
||||
std::string Endpoint;
|
||||
std::optional<Snowflake> GuildID;
|
||||
std::optional<Snowflake> ChannelID;
|
||||
|
||||
friend void from_json(const nlohmann::json &j, VoiceServerUpdateData &m);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user