diff --git a/.idea/Blizcord.iml b/.idea/Blizcord.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/.idea/Blizcord.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/com/github/bleuzen/blizcord/bot/commands/Command.java b/src/com/github/bleuzen/blizcord/bot/commands/Command.java index 9227a25..e894178 100644 --- a/src/com/github/bleuzen/blizcord/bot/commands/Command.java +++ b/src/com/github/bleuzen/blizcord/bot/commands/Command.java @@ -35,6 +35,7 @@ public static void init() { commands.add(new Play()); commands.add(new Playtime()); commands.add(new Repeat()); + commands.add(new Rmlist()); commands.add(new Save()); commands.add(new Search()); commands.add(new Seek()); diff --git a/src/com/github/bleuzen/blizcord/bot/commands/Help.java b/src/com/github/bleuzen/blizcord/bot/commands/Help.java index 7e48663..d803cb4 100644 --- a/src/com/github/bleuzen/blizcord/bot/commands/Help.java +++ b/src/com/github/bleuzen/blizcord/bot/commands/Help.java @@ -28,7 +28,8 @@ public void execute(String arg, User author, MessageChannel channel, Guild guild + "!save (Save the current playlist)\n" + "!load (Load a saved playlist)\n" + "!loadshuffle (Load a list and shuffle it)\n" - + "!lists (List the saved playlists)\n" + + "!rmlist (Delete a saved playlist)\n" + + "!lists (List all saved playlists)\n" + "!pause (Pause or resume the current track)\n" + "!stop (Stop the playback and clear the playlist)\n" + "!volume (Change the playback volume)\n" diff --git a/src/com/github/bleuzen/blizcord/bot/commands/Rmlist.java b/src/com/github/bleuzen/blizcord/bot/commands/Rmlist.java new file mode 100644 index 0000000..568401f --- /dev/null +++ b/src/com/github/bleuzen/blizcord/bot/commands/Rmlist.java @@ -0,0 +1,50 @@ +package com.github.bleuzen.blizcord.bot.commands; + +import com.github.bleuzen.blizcord.Config; +import com.github.bleuzen.blizcord.bot.AudioPlayerThread; +import com.github.bleuzen.blizcord.bot.Bot; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.entities.User; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; + +class Rmlist extends Command { + + @Override + public String getName() { + return "rmlist"; + } + + @Override + public boolean isAdminOnly() { + return true; + } + + @Override + public void execute(String arg, User author, MessageChannel channel, Guild guild) { + // arg = playlist + if(arg == null) { + channel.sendMessage(author.getAsMention() + " ``Please specify a playlist name. Put it behind this command.``").queue(); + return; + } + File playlistFile = new File(new File(Config.getAppDir(), "playlists"), arg); + if(!playlistFile.exists()) { + channel.sendMessage(author.getAsMention() + " Playlist doesn't exist: ``" + arg + "``").queue(); + return; + } + try { + playlistFile.delete(); + channel.sendMessage(author.getAsMention() + " Playlist deleted: ``" + arg + "``").queue(); + } catch (Exception e) { + channel.sendMessage(author.getAsMention() + " Failed to delete playlist: ``" + arg + "``").queue(); + } + } + +}