Esempio n. 1
0
        public async Task <Embed> PlayAsync(string query, ulong guildId)
        {
            _player = _lavaSocketClient.GetPlayer(guildId);
            var results = await _lavaRestClient.SearchYouTubeAsync(query);

            if (results.LoadType == LoadType.NoMatches || results.LoadType == LoadType.LoadFailed)
            {
                return(await EmbedHandler.CreateBasicEmbed("No Results", "Your search returned no results.", Color.Blue));
            }

            var track = results.Tracks.FirstOrDefault();

            if (_player.IsPlaying)
            {
                _player.Queue.Enqueue(track);
                return(await EmbedHandler.CreateMusicQueueEmbed(":arrow_right: " + track.Title + " added to queue", track.Uri.ToString()));
            }
            else
            {
                await _player.PlayAsync(track);

                return(await EmbedHandler.CreateMusicEmbed(":musical_note: Now playing " + track.Title + " :musical_note:", track.Uri.ToString()));
            }
        }