Пример #1
0
        public async Task PlayMusic([Remainder] string music)
        {
            Bot bot = Program.GetBot(Context.Client);

            Console.WriteLine("Wait pool...");
            bot.ResPool.WaitOne();
            Console.WriteLine("Pool is got");

            MusicService musicService = await JoinChannelByUser(Context.User);

            if (musicService.IsPlay)
            {
                await musicService.StopMusic();

                Console.WriteLine("stop music");
            }

            bool   starts        = false;
            string searchcommand = "search ";

            if (music.StartsWith(searchcommand))
            {
                starts = true;
                music  = music.Substring(searchcommand.Length);
            }

            if (musicService != null)
            {
                await musicService.PlayMusic(music, starts);
            }
            Console.WriteLine("release pool");
            bot.ResPool.Release(1);
        }
Пример #2
0
        public async Task StopMusic()
        {
            Bot          bot          = Program.GetBot(Context.Client);
            MusicService musicService = bot.GetMusicService(Context.Guild.Id);

            if (musicService != null)
            {
                await musicService.StopMusic();
            }
        }