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 Config config;
    public static final String VERSION = "0.1";

    public static void main(String[] args) {
        config = null;

        System.out.println("Attempting to read \"config.cfg\"");

        try {
            config = new Config("config.cfg");


        } 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(config.TOKEN).buildAsync();
        } catch (Exception e) {
            System.err.println("FATAL: Could not connect to Discord");
            System.exit(1);
        }

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

        // commands
        Commands commands = Commands.getInstance();

        // utility commands
        commands.addCommand(new HelpCommand());
        commands.addCommand(new StatusCommand());
        commands.addCommand(new ShutdownCommand());
        commands.addCommand(new PingCommand());

        // music
        commands.addCommand(new PlayCommand());
        commands.addCommand(new PauseCommand());
        commands.addCommand(new NowPlayingCommand());
        commands.addCommand(new SkipCommand());
        commands.addCommand(new RepeatCommand());
        commands.addCommand(new QueueCommand());
        commands.addCommand(new ClearCommand());

        // setup listeners
        commands.setupListeners(api);

    }

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


@@ -277,72 +277,25 @@
 File
-;%0Aimport java.io.FileNotFoundException;%0Aimport java.util.Scanner
+NotFoundException
 ;%0A%0A/
@@ -338,16 +338,24 @@
 t %7B%0A    
+private 
 static J
@@ -492,31 +492,8 @@
 s) %7B
-%0A        config = null;
 %0A%0A  
@@ -736,17 +736,54 @@
 ig.txt%5C%22
-%22
+ in %22 + System.getProperty(%22user.dir%22)
 );%0A     

add current directory to FileNotFound error message, remove unused imports, remove extraneous null initializer for config