private static async Task PlayNextAfterRemove(AudioQueue audioQueue, LavalinkPlayer player) { if (audioQueue.Queue.ElementAtOrDefault(0) != null) { audioQueue.PlayingTrackIndex = 0; AudioQueues.SaveQueues(); LavalinkTrack track = audioQueue.Queue.ElementAtOrDefault(0); await player.PlayAsync(track); } await Task.CompletedTask; }
public async Task YouTubeCmd([Remainder] string query) { LavalinkPlayer player = _lavaManager.GetPlayer(Context.Guild.Id) ?? await _lavaManager.JoinAsync((Context.User as IVoiceState).VoiceChannel); LoadTracksResponse r = await _lavaManager.GetTracksAsync($"ytsearch:{query}"); LavalinkTrack tr = r.Tracks.First(); await player.PlayAsync(tr); await ReplyAsync("", embed : GetTrackInfoEmbed(tr, Context.User)); }
private async Task TrackEnd(LavalinkPlayer player, LavalinkTrack track, string type) { if (type == "STOPPED") { return; } try { await player.PlayAsync(player.VoiceChannel.Guild.Id.PopTrack()); } catch (Exception e) { Console.WriteLine(e.Message); } }
private async Task MovePlayerInternalAsync(LavalinkPlayer player, LavalinkNode node) { var wasPlaying = player.State == PlayerState.Playing; // destroy (NOT DISCONNECT) the player await player.DestroyAsync(); // update the communication node player.LavalinkSocket = node; // resend voice update to the new node await player.UpdateAsync(); // play track if one is playing if (wasPlaying) { // restart track await player.PlayAsync(player.CurrentTrack); } // add player to the new node node.Players.TryAdd(player.GuildId, player); }
private static async Task <bool> SongIsFirst(LavalinkPlayer player, AudioQueue audioQueue, LavalinkTrack track, YoutubeVideo video, SocketCommandContext context, string songAlert, int choose) { ISocketMessageChannel channel = context.Channel; SocketUserMessage message = context.Message; LavalinkTrack secondTrack = audioQueue.Queue.ElementAtOrDefault(1); if (secondTrack == null) { audioQueue.PlayingTrackIndex = 0; AudioQueues.SaveQueues(); await player.PlayAsync(track); if (video != null) { songAlert = "PLAY_PLAYED_SONG"; await SongInfo(channel, message, video, choose, songAlert); } return(true); } return(false); }