/// <summary> /// Disconnects from the current voice channel /// </summary> public void Disconnect() { try { if (_client.User.Type == DiscordUserType.User) { _client.ChangeVoiceState(new VoiceStateChange() { GuildId = null, ChannelId = null }); } else { _client.ChangeVoiceState(new VoiceStateChange() { GuildId = Server.Guild.Id, ChannelId = null }); } } catch { } _socket.Close(); UdpClient.Close(); }
public void Connect(ulong channelId, VoiceConnectionProperties properties = null) { if (!File.Exists("libsodium.dll")) { throw new FileNotFoundException("libsodium.dll was not found"); } else if (!File.Exists("opus.dll")) { throw new FileNotFoundException("opus.dll was not found"); } else if (!File.Exists("libsodium.dll")) { throw new FileNotFoundException("libsodium.dll was not found"); } _decoder = new OpusDecoder(); if (_client.User.Type == DiscordUserType.User) { KillPreviousConnection(); } var state = new VoiceStateProperties() { ChannelId = channelId, GuildId = _guildId }; if (properties != null) { if (properties.Muted.HasValue) { state.Muted = properties.Muted.Value; } if (properties.Deafened.HasValue) { state.Deafened = properties.Deafened.Value; } if (properties.Video.HasValue) { state.Video = properties.Video.Value; } } _channelId = channelId; _client.ChangeVoiceState(state); }
/// <summary> /// Disconnects from the current voice channel /// </summary> public void Disconnect() { try { _client.ChangeVoiceState(new VoiceStateChange() { GuildId = Server.Guild == null ? null : (ulong?)Server.Guild.Id, ChannelId = null }); } catch { } _socket.Close(); UdpClient.Close(); }