Use dedicated method for loading Config, clean exception types and handling

This commit is contained in:
Reperak 2021-11-07 20:57:50 -06:00
parent 0fa9ceef8e
commit d11b9a97a4
No known key found for this signature in database
GPG key ID: 12F30C9BA6950C0C
2 changed files with 21 additions and 8 deletions

View file

@ -13,9 +13,13 @@ import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.shadew.json.JsonSyntaxException;
import javax.security.auth.login.LoginException;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
@ -43,10 +47,12 @@ public class Bot {
return Bot.INSTANCE;
}
public static void main(String[] args) throws Exception {
@SneakyThrows({ JsonSyntaxException.class, FileNotFoundException.class, LoginException.class,
InterruptedException.class })
public static void main(String[] args) {
Bot bot = Bot.getInstance();
bot.setConfig(new Config("./config.json5"));
bot.setConfig(Config.loadFrom("./config.json5"));
bot.setJda(JDABuilder.createDefault(bot.getConfig().getPropreties().get("token"), GUILD_MESSAGES,
GUILD_VOICE_STATES).build().awaitReady());