Modified token getter
This commit is contained in:
1 parent
3885367a5a
commit
d95b4c40d0
2 files changed
+13
-10
No files matched your search
@@ -5,13 +5,13 @@ import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.JDABuilder;
|
||||
import net.dv8tion.jda.core.entities.Game;
|
||||
import netneutrality.db.DBController;
|
||||
import netneutrality.db.controllers.DBSettings;
|
||||
import netneutrality.handler.ConsoleHandler;
|
||||
import netneutrality.handler.EditHandler;
|
||||
import netneutrality.handler.LogHandler;
|
||||
import netneutrality.handler.NewCommandListener;
|
||||
import netneutrality.http.server.WebApi;
|
||||
import netneutrality.music.MusicManager;
|
||||
import netneutrality.utils.Settings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -20,20 +20,22 @@ import javax.security.auth.login.LoginException;
|
||||
public class MusicBot {
|
||||
|
||||
private static JDA jda;
|
||||
public static Logger LOGGER = LoggerFactory.getLogger(NewCommandListener.class);
|
||||
public static Logger LOGGER = LoggerFactory.getLogger(MusicBot.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("log4j.skipJansi", "false");
|
||||
DBController.init();
|
||||
|
||||
String token = ((DBSettings) DBController.get("settings")).getSettingsByKey("token");
|
||||
|
||||
try {
|
||||
jda = new JDABuilder(AccountType.BOT).setToken(token).buildBlocking();
|
||||
} catch (LoginException | IllegalArgumentException | InterruptedException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
jda = new JDABuilder(AccountType.BOT).setToken(Settings.TOKEN).build();
|
||||
jda.awaitReady();
|
||||
} catch (LoginException | IllegalArgumentException e) {
|
||||
LogHandler.log(e);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
jda.getPresence().setGame(Game.watching("me load..."));
|
||||
jda.addEventListener(new NewCommandListener(), new EditHandler());
|
||||
|
||||
@@ -48,7 +50,6 @@ public class MusicBot {
|
||||
|
||||
case "quit":
|
||||
shutdown();
|
||||
System.exit(0);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -56,12 +57,13 @@ public class MusicBot {
|
||||
}
|
||||
|
||||
public static void shutdown() {
|
||||
System.out.println("Shutting down...");
|
||||
LOGGER.info("[Net Neutrality] Shutting down...");
|
||||
MusicManager.disconnectPlayers();
|
||||
disconnect();
|
||||
DBController.shutdown();
|
||||
ThreadManager.shutdownExecutor();
|
||||
System.out.println("Shutdown complete");
|
||||
LOGGER.info("[Net Neutrality] Shutdown complete");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static JDA getJDA() {
|
||||
|
||||
@@ -11,6 +11,7 @@ public class Settings {
|
||||
|
||||
public static final String DATETIMEFORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
public static String PREFIX = ((DBSettings) DBController.get("settings")).getSettingsByKey("prefix");
|
||||
public static final String TOKEN = ((DBSettings) DBController.get("settings")).getSettingsByKey("token");
|
||||
|
||||
public static User getCreator() {
|
||||
return MusicBot.getJDA().getUserById(((DBSettings) DBController.get("settings")).getSettingsByKey("owner"));
|
||||
|
||||
Reference in new issue
Block a user