Vaerys_Dawn

Intended log

Apr 16th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.38 KB | None | 0 0
  1. public class Main {
  2.  
  3.  
  4.     final static Logger logger = LoggerFactory.getLogger(Main.class);
  5.  
  6.     public static void main(String[] args) throws UnknownHostException {
  7.         System.out.println("Starting Program...");
  8.  
  9.         Runtime.getRuntime().addShutdownHook(new Thread() {
  10.             @Override
  11.             public void run() {
  12.                 logger.info(">>> Running Shutdown Process <<<");
  13.                 Globals.saveFiles();
  14.             }
  15.         });
  16.  
  17.  
  18.  
  19.         String token;
  20.         // you need to set a token in Token/Token.txt for the bot to run
  21.         try {
  22.             Discord4J.disableAudio();
  23.             FileHandler.createDirectory(Constants.DIRECTORY_STORAGE);
  24.             FileHandler.createDirectory(Constants.DIRECTORY_GLOBAL_IMAGES);
  25.             FileHandler.createDirectory(Constants.DIRECTORY_COMP);
  26.             FileHandler.createDirectory(Constants.DIRECTORY_BACKUPS);
  27.             FileHandler.createDirectory(Constants.DIRECTORY_TEMP);
  28.             FileHandler.createDirectory(Constants.DIRECTORY_OLD_FILES);
  29.             FileHandler.createDirectory(Constants.DIRECTORY_ERROR);
  30.             if (!Files.exists(Paths.get(Constants.FILE_CONFIG))) {
  31.                 FileHandler.writeToJson(Constants.FILE_CONFIG, new Config());
  32.             }
  33.             if (!Files.exists(Paths.get(Constants.FILE_GLOBAL_DATA))) {
  34.                 FileHandler.writeToJson(Constants.FILE_GLOBAL_DATA, new GlobalData());
  35.             }
  36.  
  37.             //load config phase 1
  38.             Config config = (Config) FileHandler.readFromJson(Constants.FILE_CONFIG, Config.class);
  39.             GlobalData globalData = (GlobalData) FileHandler.readFromJson(Constants.FILE_GLOBAL_DATA, GlobalData.class);
  40.  
  41.  
  42.             config.initObject();
  43.             FileHandler.writeToJson(Constants.FILE_CONFIG, config);
  44.  
  45.             //getting bot token
  46.             token = FileHandler.readFromFile(Constants.FILE_TOKEN).get(0);
  47.             if (token == null) {
  48.                 logger.error("!!!BOT TOKEN NOT VALID PLEASE CHECK \"Storage/Token.txt\" AND UPDATE THE TOKEN!!!");
  49.             }
  50.  
  51.             IDiscordClient client = Client.getClient(token, false);
  52.  
  53.             //load config phase 2
  54.             Globals.initConfig(client, config, globalData);
  55.  
  56.             PatchHandler.globalPatches();
  57.  
  58.             //login + register listener.
  59.             EventDispatcher dispatcher = client.getDispatcher();
  60.             dispatcher.registerListener(new AnnotationListener());
  61.             client.login();
  62.  
  63.             //Init Patch system.
  64.  
  65.  
  66.             //timed events get
  67.             new TimedEvents();
  68.  
  69.             while (!client.isReady()) ;
  70.  
  71.             //makes sure that nothing in the config file will cause an error
  72.             Globals.validateConfig();
  73.             Globals.setVersion();
  74.             consoleInput();
  75.         } catch (DiscordException ex) {
  76.             logger.error(ex.getErrorMessage());
  77.         } catch (RateLimitException e) {
  78.             e.printStackTrace();
  79.         }
  80.     }
  81.  
  82.     private static void consoleInput() {
  83.         Scanner scanner = new Scanner(System.in);
  84.         while (!Globals.isReady) ;
  85.         logger.info("Console input initiated.");
  86.  
  87.         while (scanner.hasNextLine()) {
  88.             while (Globals.consoleMessageCID == null) ;
  89.             IChannel channel = Globals.getClient().getChannelByID(Globals.consoleMessageCID);
  90.             String message = scanner.nextLine();
  91.             message = message.replace("#Dawn#", Globals.getClient().getUserByID("153159020528533505").getName());
  92.             message = message.replace("teh", "the");
  93.             message = message.replace("Teh", "The");
  94.             System.out.println(message);
  95.             if (!message.equals("")) {
  96.                 Utility.sendMessage(message, channel);
  97.             }
  98.         }
  99.     }
  100. }
  101.  
  102. Starting Program...
  103. 22:39:40.941 [main] INFO  org.eclipse.jetty.util.log - Logging initialized @579ms to org.eclipse.jetty.util.log.Slf4jLog
  104. 22:39:40.947 [main] INFO  sx.blah.discord.Discord4J - Discord4J v2.7.1-SNAPSHOT (c96db79af5703aed7377b2c9868b0bbe42a81408-c96db79) (https://github.com/austinv11/Discord4J)
  105. 22:39:40.947 [main] INFO  sx.blah.discord.Discord4J - A Java binding for the official Discord API, forked from the inactive https://github.com/nerd/Discord4J. Copyright (c) 2017, Licensed under GNU GPLv2
  106. 22:39:40.947 [main] INFO  sx.blah.discord.Discord4J - Disabled audio.
  107. 22:39:42.119 [main] INFO  Main.Globals - 62 Commands Loaded. //ignore these, they are my command init checks.
  108. 22:39:42.120 [main] INFO  Main.Globals - 6 DM Commands Loaded.
  109. 22:39:42.120 [main] INFO  Main.Globals - 10 Command Types Loaded.
  110. 22:39:42.120 [main] INFO  Main.Globals - 9 Channel Types Loaded.
  111. 22:39:42.120 [main] INFO  Main.Globals - 27 Guild Toggles Loaded.
  112. 22:39:42.120 [main] INFO  Main.Globals - 8 Slash Commands Loaded.
  113. 22:39:43.800 [HttpClient@3232228-16] INFO  sx.blah.discord.Discord4J - Websocket Connected.
  114. 22:39:44.136 [HttpClient@3232228-18] INFO  sx.blah.discord.Discord4J - Connected to Discord Gateway v5. Receiving 1 guilds.
  115. 22:39:44.299 [Event Dispatcher Handler] INFO  Main.AnnotationListener - Starting Guild get process for Guild with ID: 254790152851816458
  116. 22:39:45.091 [Event Dispatcher Handler] INFO  Main.AnnotationListener - Finished Initialising Guild With ID: 254790152851816458
  117. 22:39:45.105 [main] INFO  Main.Globals - Bot version : 2.6.0
  118. 22:39:45.107 [main] INFO  Main.Main - Console input initiated.
Advertisement
Add Comment
Please, Sign In to add comment