Exemple #1
0
        public async Task Join(string songUrl = "")
        {
            if (_audio.Exist(Context.Guild.Id))
            {
                await ReplyAsync("Already joined.");

                return;
            }

            IVoiceChannel vc = (Context.User as IGuildUser)?.VoiceChannel;

            if (vc == null)
            {
                await ReplyAsync("Your not in a voice channel, please join one and try again.");

                return;
            }

            AudioSession session = _audio.MakeSession(vc, Context.Channel);

            var bgw = new BackgroundWorker();

            bgw.DoWork += (sender, args) => { session.ConnectAsync(); };

            bgw.RunWorkerAsync();

            if (songUrl != "")
            {
                await session.AddSong(new Uri(songUrl));
            }

            //This is a test
            //session.AddSong("youtube", "P5MpLQ8TQcQ");
            //var song = session.AddSong("https://www.youtube.com/watch?v=2zmfP9pi2cI"); The class will figure out the URL
            //session.Play();
            //session.Play(song); Instantly push first in queue and play
        }