예제 #1
0
        private async Task Add()
        {
            int i = await CheckForPlaylist();

            if (i != -1)
            {
                Playlist list = Storage.PlayLists[i];
                try
                {
                    int i2 = 0;
                    int.TryParse(msg[3], out i2);
                    if (player.HasSearch())
                    {
                        list.Add(player.source.SearchList[i2 - 1], true);
                        Storage.SavePlayList(Storage.PlayLists[i]);
                        await ctx.RespondAsync("Added song " + DiscordString.Bold(player.source.SearchList[i2 - 1].Title) + " to playlist " + DiscordString.Bold(list.Name) + "\n" + list.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    await ctx.RespondAsync("Could not add song to playlist due to unknow error");
                }
            }
        }
예제 #2
0
        public async void RunCommand(CommandContext ctx, List <BaseCommand> list)
        {
            string[] msg = ctx.Message.Content.ToString().Split(' ');

            if (msg.Length <= 1)
            {
                StringBuilder builder = new StringBuilder(DiscordString.Bold("Commands:\n").Underline().ToString());

                foreach (BaseCommand command in list)
                {
                    builder.Append(command.Help() + "\n");
                }

                await ctx.RespondAsync(builder.ToString());
            }
            else
            {
                foreach (BaseCommand command in list)
                {
                    if (msg[1].Equals(command.name))
                    {
                        await ctx.RespondAsync(command.Help());
                    }
                }
            }
        }
예제 #3
0
 public override string Help()
 {
     return(DiscordString.Bold("Playlist: ") +
            "\nUse !playlist create [name] to create a new playlist" +
            "\nUse !playlist add [name of playlist] [number] to add a song from !search to a playlist" +
            "\nUse !playlist delete [name of playlist] [number] to delete a song from the playlist" +
            "\nUse !playlist play [name of playlist] to play a playlist" +
            "\nUse !playlist show to show the songs in a playlist");
 }
예제 #4
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder(DiscordString.Bold("Current playlist\n").Underline().ToString());

            for (int i = 0; i < Songs.Count; i++)
            {
                PlaylistSong song = Songs[i];
                builder.Append($"{DiscordString.Bold($"{i + 1}:")} {song.Song.Title}");
                if (i == Index - 1)
                {
                    builder.Append($" - {DiscordString.Bold("Currently playing!")}");
                }

                builder.Append("\n");
            }
            return(builder.ToString());
        }
예제 #5
0
        public async Task RunCommand(CommandContext ctx, Player player)
        {
            // Parse user input
            string[] msg   = ctx.Message.Content.Split(" ");
            string   input = "";
            bool     play  = false;

            if (msg[1].Equals("-p") && msg.Length != 2)
            {
                play  = true;
                input = input + msg[2];
                for (int i = 3; i < msg.Length; i++)
                {
                    input = input + " " + msg[i];
                }
            }
            else
            {
                input = input + msg[1];
                for (int i = 2; i < msg.Length; i++)
                {
                    input = input + " " + msg[i];
                }
            }

            List <Song> list = await DoSearch(input, player);

            StringBuilder builder = new StringBuilder(DiscordString.Bold("Search results:").Underline().ToString());

            for (int i = 0; i < list.Count; i++)
            {
                Song song = list[i];
                builder.Append($"\n{DiscordString.Bold($"{i+1}:")} {song.Title}");
            }
            await ctx.RespondAsync(builder.ToString());

            // Play the song if the play flag was set
            if (play)
            {
                player.Play();
            }
        }
예제 #6
0
        private async Task Delete()
        {
            int i = await CheckForPlaylist();

            if (i != -1)
            {
                Playlist list = Storage.PlayLists[i];
                try
                {
                    try
                    {
                        int i2 = 0;
                        int.TryParse(msg[3], out i2);
                        string name = list.Songs[i2 - 1].Song.Title;
                        list.Songs.RemoveAt(i2 - 1);
                        Storage.SavePlayList(Storage.PlayLists[i]);
                        await ctx.RespondAsync("Deleted song " + DiscordString.Bold(name) + " from playlist " + DiscordString.Bold(list.Name));
                    }
                    catch (Exception ex)
                    {
                        //TODO delete by string
                        Console.WriteLine(ex);
                        //Console.WriteLine("Number didn't work, trying string now");
                        //try
                        //{
                        //    for (int i2 = 3; i2 < msg.Length; i2++) ;
                        //}
                        //catch (Exception ex2)
                        //{
                        //    Console.WriteLine(ex);
                        //    await ctx.RespondAsync("Wrong format use: !playlist delete [playlist] [number/name of song]");
                        //}
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    await ctx.RespondAsync("Wrong format use: !playlist delete [playlist] [number/name of song]");
                }
            }
        }
예제 #7
0
 public override string Help()
 {
     return(DiscordString.Bold("Start: ") + "\nUse !start to start playing music when the bot has been stopped with the Stop command");
 }
예제 #8
0
 public override string Help()
 {
     return(DiscordString.Bold("Help: ") + "\nUse !help to get a list of how to use all the commands" +
            "\nUse !help [name of command] to get information on how to use that command");
 }
예제 #9
0
 public override string Help()
 {
     return(DiscordString.Bold("Next: ") + "\nUse !next to skip the current song");
 }
예제 #10
0
 public override string Help()
 {
     return(DiscordString.Bold("Leave: ") + "\nUse !leave to stop the bot and dismiss the bot from the voicechannel");
 }
예제 #11
0
 public override string Help()
 {
     return(DiscordString.Bold("Stop: ") + "\nUse !stop to stop bot playing music");
 }
예제 #12
0
 public override string Help()
 {
     return(DiscordString.Bold("Join: ") + "\nUse !join when you are in a voice channel to let the bot join your voicechannel");
 }
예제 #13
0
 public override string Help()
 {
     return(DiscordString.Bold("Search: ") + "\nUse !search [name of song] to search for a song to play/add to playlist");
 }