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"); } } }
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()); } } } }
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"); }
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()); }
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(); } }
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]"); } } }
public override string Help() { return(DiscordString.Bold("Start: ") + "\nUse !start to start playing music when the bot has been stopped with the Stop command"); }
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"); }
public override string Help() { return(DiscordString.Bold("Next: ") + "\nUse !next to skip the current song"); }
public override string Help() { return(DiscordString.Bold("Leave: ") + "\nUse !leave to stop the bot and dismiss the bot from the voicechannel"); }
public override string Help() { return(DiscordString.Bold("Stop: ") + "\nUse !stop to stop bot playing music"); }
public override string Help() { return(DiscordString.Bold("Join: ") + "\nUse !join when you are in a voice channel to let the bot join your voicechannel"); }
public override string Help() { return(DiscordString.Bold("Search: ") + "\nUse !search [name of song] to search for a song to play/add to playlist"); }