Пример #1
0
        public async Task Insert(CommandContext ctx, int pos, [RemainingText] string name = null)
        {
            if (name == null)
            {
                name = await SelectPL(ctx);

                if (name == null)
                {
                    return;
                }
            }
            pos = pos - 1;
            var inter = ctx.Client.GetInteractivity();
            var p     = await PlaylistDB.GetPlaylistsSimple(ctx.Member.Id);

            if (!p.Any(x => x == name))
            {
                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, name);

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

                return;
            }
            var msg = await ctx.RespondAsync(embed : new DiscordEmbedBuilder().WithTitle("Insert Song").WithDescription($"Please enter the song searchterm or URL now\n" +
                                                                                                                        $"No prefix needed!").Build());

            var hm2 = await inter.WaitForMessageAsync(x => x.Author == ctx.Member, TimeSpan.FromSeconds(30));

            await msg.DeleteAsync();

            var got = await PlaylistDB.GetSong(hm2.Result.Content, ctx);

            if (got == null)
            {
                return;
            }
            got.Tracks.Reverse();
            await PlaylistDB.InsertEntry(name, ctx.Member.Id, got.Tracks, pos);

            var ent = await pls.GetEntries();

            if (got.Tracks.Count > 1)
            {
                await ctx.RespondAsync(embed : new DiscordEmbedBuilder().WithTitle("Insert Song").WithDescription($"Inserted entry -> {got.Tracks[0].Title} at {pos + 1}!\n" +
                                                                                                                  $"And {got.Tracks.Count - 2} more!").Build());
            }
            else
            {
                await ctx.RespondAsync(embed : new DiscordEmbedBuilder().WithTitle("Insert Song").WithDescription($"Inserted entry -> {got.Tracks[0].Title} at {pos + 1}!").Build());
            }
        }