private Task _audioClient_StreamCreated(ulong userID, AudioInStream arg2)
 {
     //Triggers when user joined to the channel
     Logging.Log($"Stream created {userID}", LogLevel.LogLevel_DEBUG);
     using (IEffectPlayback joinSound = new Mp3SoundEffect(_audioJoin))
     {
         joinSound.LoadStream();
         joinSound.Play();
     }
     return(Task.Run(() => { ListenUserAsync(arg2, userID); }));
 }
        private Task _audioClient_Disconnected(Exception arg)
        {
            VoiceDisconnected?.Invoke(this, EventArgs.Empty);

            using (IEffectPlayback leaveSound = new Mp3SoundEffect(_audioDisconnected))
            {
                leaveSound.LoadStream();
                leaveSound.Play();
            }
            return(Task.CompletedTask);
        }
        private Task _audioClient_StreamDestroyed(ulong arg)
        {
            Logging.Log($"Stream destroyed {arg}", LogLevel.LogLevel_DEBUG);
            var v = _soundServices.SingleOrDefault(x => x.UserID == arg);

            if (v == null)
            {
                return(Task.CompletedTask);
            }
            _soundServices.Remove(v);
            v.Dispose();
            //play sound when a users leaves the channel
            using (IEffectPlayback leaveSound = new Mp3SoundEffect(_audioLeave))
            {
                leaveSound.LoadStream();
                leaveSound.Play();
            }
            return(Task.CompletedTask);
        }
        internal async Task JoinChannel(IVoiceChannel voiceChannel)
        {
            try
            {
                _voiceChannel = voiceChannel;
                _audioClient  = await _voiceChannel.ConnectAsync();

                _audioClient.Disconnected    += _audioClient_Disconnected;
                _audioClient.StreamCreated   += _audioClient_StreamCreated;
                _audioClient.StreamDestroyed += _audioClient_StreamDestroyed;
                _outStream = _audioClient.CreatePCMStream(AudioApplication.Voice);
                VoiceConnected?.Invoke(this, EventArgs.Empty);
                using (IEffectPlayback joinSound = new Mp3SoundEffect(_audioJoin))
                {
                    joinSound.LoadStream();
                    joinSound.Play();
                }
                await ListenToUsersAsync();
            }
            catch (Exception ex) { Logging.Log(ex); }
        }