Example #1
0
 public void onReady(ReadyEvent event) {
   log("Setting up api related config...");
   Thread t =
       new Thread(
           () -> {
             TagCommand.initTags(event.getJDA(), logger);
             PublicLog.init(api, logger::logThrowable);
             this.api = event.getJDA();
             if (config.has("home")) home = api.getGuildById(config.getString("home"));
             new ModLogManager(api);
             User uOwner = api.getUserById(owner);
             try {
               log("Owner: " + uOwner.getUsername() + "#" + uOwner.getDiscriminator());
             } catch (NullPointerException e) {
               logger.logThrowable(
                   new NullPointerException(
                       "Owner could not be retrieved from the given id. Do you share a guild with this bot? - Caused by id: \""
                           + owner
                           + "\""));
             }
             this.handler.setApi(event.getJDA());
             try {
               initCommands(api);
             } catch (UnknownHostException | UnsupportedDataTypeException e) {
               logger.logThrowable(e);
             }
             AccountSettings as = new AccountSettings(console);
             console.setAccountSettings(as);
             as.setApi(api);
             if (audio) api.addEventListener(new MinnAudioManager());
             console.setTitle(
                 api.getSelfInfo().getUsername()
                     + "#"
                     + api.getSelfInfo()
                         .getDiscriminator()); // so you know which one is logged in!
             inviteurl = getInviteUrl();
             tmp.init(this);
             logger.logInfo("Setup completed.");
           });
   t.setDaemon(false);
   t.setPriority(Thread.MAX_PRIORITY);
   t.setName("onReady...");
   t.setUncaughtExceptionHandler((Thread.UncaughtExceptionHandler) logger);
   t.start();
 }