public async Task Delete(CommandContext ctx, [Description("Playlist name")] string playlistName, [Description("Song name")][RemainingText] string songName) { var playlist = await _context.Playlists.Include(p => p.Songs).SingleOrDefaultAsync(p => p.Name == playlistName && p.ServerId == ctx.Guild.Id); if (playlist == null) { await ctx.RespondAsync($"Playlist {Formatter.Bold(playlistName)} does not exist."); return; } try { await _playlistService.DeleteSongFromPlaylistAsync(songName, playlist); } catch (Exception e) { await ctx.RespondAsync(e.Message); return; } var embed = new PlaylistEmbedBuilder($"Song {Formatter.Bold(songName)} deleted successfully from playlist {Formatter.Bold(playlistName)}"); await ctx.RespondAsync(embed : embed.EmbedBuilder); }
private async Task GetCurrentTrackAsync() { if (Queue.Count() == 0) { var embed = new PlaylistEmbedBuilder($"No more tracks on playlist"); await _ctx.RespondAsync(embed : embed.EmbedBuilder); } CurrentSong = Queue.Peek(); }
public async Task Play() { if (_ctx.Member.VoiceState == null || _ctx.Member.VoiceState.Channel == null) { await _ctx.RespondAsync("You are not in a voice channel."); return; } if (Connection == null) { await _ctx.RespondAsync("Lavalink is not connected."); return; } await Connection.PlayAsync(CurrentSong); var embed = new PlaylistEmbedBuilder($"Now playing { Formatter.MaskedUrl(Queue.Peek().Title, Queue.Peek().Uri) }"); await _ctx.RespondAsync(embed : embed.EmbedBuilder); }
public async Task Create(CommandContext ctx, [Description("Your playlist name")] string playlistName) { var playlist = await _context.Playlists.SingleOrDefaultAsync(p => p.Name == playlistName && p.ServerId == ctx.Guild.Id); if (playlist != null) { await ctx.RespondAsync($"Playlist {Formatter.Bold(playlistName)} already exists on this server."); return; } playlist = new Playlist { Name = playlistName, ServerId = ctx.Guild.Id, ServerName = ctx.Guild.Name }; await _playlistService.AddPlaylist(playlist); var embed = new PlaylistEmbedBuilder($"New playlist {Formatter.Bold(playlistName)} created successfully by {Formatter.Mention(ctx.User, true)}."); await ctx.RespondAsync(embed : embed.EmbedBuilder); }