Example #1
0
        public async Task Move(CommandContext ctx, int oldpos, int newpos, [RemainingText] string pl = null)
        {
            if (pl == null)
            {
                pl = await SelectPL(ctx);

                if (pl == null)
                {
                    return;
                }
            }
            oldpos = oldpos - 1;
            newpos = newpos - 1;
            var p = await PlaylistDB.GetPlaylistsSimple(ctx.Member.Id);

            if (!p.Any(x => x == pl))
            {
                await ctx.RespondAsync(embed : new DiscordEmbedBuilder().WithTitle("Insert Song").WithDescription("**Error** You dont have a playlist with that name!").Build());

                return;
            }
            var pls = await PlaylistDB.GetPlaylist(ctx.Member.Id, pl);

            if (pls.ExternalService != ExtService.None)
            {
                await ctx.RespondAsync(embed : new DiscordEmbedBuilder().WithTitle("Insert Song").WithDescription("**Error** This playlist is a fixed one, you cant move songs!").Build());

                return;
            }
            var e = await pls.GetEntries();

            if (e[newpos] == null | e[oldpos] == null)
            {
                return;
            }
            await PlaylistDB.MoveListItems(pl, ctx.Member.Id, oldpos, newpos);

            await ctx.RespondAsync(embed : new DiscordEmbedBuilder().WithTitle("Move Song").WithDescription($"Moved entry -> {e[oldpos].track.Title} to position {newpos+1}!").Build());
        }