public async Task PlayAsync(params string[] Args) { if (Client.State == PlayerState.Paused) { Client.State = PlayerState.Playing; return; } EmbedBuilder Builder = new EmbedBuilder() { Color = Client.Color, Title = GetEntry("Enqueue") }; if (Args.Length > 0) { if (Args[0] == "soundcloud" && Args.Length > 1) { if (Args[1] == "playlist" && Args.Length > 2) { List <Models.SoundCloud.Playlist> playlists = Client.SearchSoundCloudPlaylist(string.Join(" ", Args.Skip(2))); Models.SoundCloud.Playlist playlist = await Global.MusicHandler.Select(Client, playlists, Context, Language); if (playlist == null) { Builder.Description = GetEntry("SCPlaylistCancelled"); await Context.Channel.SendMessageAsync("", embed : Builder.Build()); } else { Client.Enqueue(playlist); Builder.Url = playlist.Url; Builder.Description = GetEntry("SCPlaylistEnqueued"); Builder.AddField(GetEntry("TitleTrackCount"), playlist.Title + " | " + playlist.TrackCount); Builder.AddField(GetEntry("PlaylistMadeBy"), playlist.User.Username); Builder.ThumbnailUrl = playlist.ThumbnailUrl; await Context.Channel.SendMessageAsync("", embed : Builder.Build()); if (Client.State < PlayerState.Playing) { await Client.PlayAsync(Context); } } } else { List <Models.SoundCloud.Track> tracks = Client.SearchSoundCloudTrack(string.Join(" ", Args.Skip(1))); Models.SoundCloud.Track track = await Global.MusicHandler.Select(Client, tracks, Context, Language); if (track == null) { Builder.Description = GetEntry("SCTrackCancelled"); await Context.Channel.SendMessageAsync("", embed : Builder.Build()); } else { Client.Enqueue(track); if (Client.State < PlayerState.Playing) { await Client.PlayAsync(Context); } else { Builder.Url = track.Url; Builder.Description = GetEntry("SCTrackEnqueued"); Builder.AddField(GetEntry("TitleUploadedBy"), track.Title + " | " + track.User.Username); Builder.ThumbnailUrl = track.ThumbnailUrl; await Context.Channel.SendMessageAsync("", embed : Builder.Build()); } } } } else if (Args[0].ToLower() == "listen.moe") { Client.EnqueueLISTENmoe(Args.Length > 1 && Args[1].ToLower() == "kpop"); Builder.Description = "LISTEN.moe"; await Context.Channel.SendMessageAsync("", embed : Builder.Build()); if (Client.State < PlayerState.Playing) { await Client.PlayAsync(Context); } } else { string url = string.Join(" ", Args); YoutubeClient client = new YoutubeClient(); PlaylistId? id = PlaylistId.TryParse(url); if (id.HasValue) { List <PlaylistVideo> videos = await client.Playlists.GetVideosAsync(id.Value).ToListAsync(); if (videos.Count == 0) { Builder.Description = GetEntry("YTPlaylistEmpty"); await Context.Channel.SendMessageAsync("", embed : Builder.Build()); } else { YoutubeExplode.Playlists.Playlist playlist = await client.Playlists.GetAsync(id.Value); Client.Enqueue(playlist); if (Client.State < PlayerState.Playing) { await Client.PlayAsync(Context); } else { Builder.Url = playlist.Url; Builder.Description = GetEntry("YTPlaylistEnqueued"); Builder.AddField(GetEntry("TitleUploadedBy"), playlist.Title + " | " + playlist.Author); Builder.ThumbnailUrl = videos[0].Thumbnails.GetMaxResUrl(); await Context.Channel.SendMessageAsync("", embed : Builder.Build()); } } } VideoId?vid = VideoId.TryParse(url); if (vid.HasValue) { Video video = await client.Videos.GetAsync(vid.Value); await EnqueueVideo(video, Builder); } else { List <VideoSearchResult> videos = await Client.SearchYouTubeVideoAsync(url); VideoSearchResult video = await Global.MusicHandler.Select(Client, videos, Context, Language); if (video == null) { Builder.Description = GetEntry("YTVideoCancelled"); await Context.Channel.SendMessageAsync("", embed : Builder.Build()); } else { await EnqueueVideo(video, Builder); } } } } else { if (Client.Queue.Count != 0 && Client.State < PlayerState.Playing) { await Client.PlayAsync(Context); } else { await Context.Channel.SendMessageAsync(GetEntry("Empty")); } } }
public void Enqueue(Models.SoundCloud.Playlist Playlist) { Queue.AddRange(Global.SoundCloud.GetTracks(Playlist).Select(t => new MusicItem(t))); PropertyChanged?.Invoke(); }