package com.robothand.highqualitybot;

import com.robothand.highqualitybot.command.*;
import com.robothand.highqualitybot.music.GuildMusicPlayer;
import net.dv8tion.jda.core.AccountType;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.JDABuilder;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * main class
 */
public class Bot {
    static JDA api;
    public static String PREFIX;

    public static void main(String[] args) {
        File config;
        String token;

        System.out.println("Attempting to read \"config.txt\"");
        config = new File("config.txt");
        token = null;

        try {
            Scanner s = new Scanner(config);

            // token
            token = s.nextLine();

            // prefix
            PREFIX = s.nextLine();

        } catch (FileNotFoundException e) {
            System.err.println("FATAL: could not find file \"config.txt\"");
            System.exit(1);
        }

        System.out.println("Connecting to Discord...");
        try {
            api = new JDABuilder(AccountType.BOT).setToken(token).buildAsync();
        } catch (Exception e) {
            System.err.println("FATAL: Could not connect to Discord");
            System.exit(1);
        }

        // prepare the audio sources
        GuildMusicPlayer.setupSources();

        // help command
        HelpCommand help = new HelpCommand();
        api.addEventListener(help.addCommand(help));

        // utility commands
        api.addEventListener(help.addCommand(new ShutdownCommand()));
        api.addEventListener(help.addCommand(new PingCommand()));

        // music
        api.addEventListener(help.addCommand(new PlayCommand()));
        api.addEventListener(help.addCommand(new PauseCommand()));
        api.addEventListener(help.addCommand(new NowPlayingCommand()));
        api.addEventListener(help.addCommand(new SkipCommand()));
        api.addEventListener(help.addCommand(new RepeatCommand()));
        api.addEventListener(help.addCommand(new QueueCommand()));

    }

    public static JDA getAPI() {
        return api;
    }
}


@@ -1372,21 +1372,16 @@
   //
- help
  command
 %0A   
@@ -1376,16 +1376,17 @@
  command
+s
 %0A       
@@ -1390,161 +1390,145 @@
     
-Help
 Command
- help = new HelpCommand();%0A        api.addEventListener(help.addCommand(help));%0A%0A        // utility commands%0A        api.addEventListener(help
+s commands = Commands.getInstance();%0A%0A        // utility commands%0A        commands.addCommand(new HelpCommand());%0A        commands
 .add
@@ -1549,33 +1549,32 @@
 utdownCommand())
-)
 ;%0A        api.ad
@@ -1571,33 +1571,16 @@
     
-api.addEventListener(help
+commands
 .add
@@ -1601,25 +1601,24 @@
 ngCommand())
-)
 ;%0A%0A        /
@@ -1637,33 +1637,16 @@
     
-api.addEventListener(help
+commands
 .add
@@ -1663,33 +1663,32 @@
 w PlayCommand())
-)
 ;%0A        api.ad
@@ -1685,33 +1685,16 @@
     
-api.addEventListener(help
+commands
 .add
@@ -1712,33 +1712,32 @@
  PauseCommand())
-)
 ;%0A        api.ad
@@ -1734,33 +1734,16 @@
     
-api.addEventListener(help
+commands
 .add
@@ -1766,33 +1766,32 @@
 layingCommand())
-)
 ;%0A        api.ad
@@ -1788,33 +1788,16 @@
     
-api.addEventListener(help
+commands
 .add
@@ -1814,33 +1814,32 @@
 w SkipCommand())
-)
 ;%0A        api.ad
@@ -1836,33 +1836,16 @@
     
-api.addEventListener(help
+commands
 .add
@@ -1872,17 +1872,16 @@
 mmand())
-)
 ;%0A      
@@ -1886,33 +1886,16 @@
     
-api.addEventListener(help
+commands
 .add
@@ -1921,16 +1921,79 @@
 mmand())
+;%0A%0A        // setup listeners%0A        commands.addListeners(api
 );%0A%0A    

modify main method to register commands with singleton