Class JavalinManager

java.lang.Object
dev.jacrispys.JavaBot.api.libs.utils.JavalinManager

public class JavalinManager extends Object
Web-based event listener to exchange Code's through Discord 0Auth
Link to API site: bot.insideagent.pro
  • Constructor Details

    • JavalinManager

      public JavalinManager(int port)
  • Method Details

    • initJavalin

      protected void initJavalin(int port)
      Initializes Javalin server to listen for queries
      Parameters:
      port - port to start the server on
    • exchangeCode

      protected boolean exchangeCode(String code)
      Http Request builder to exchange the 0Auth code given by discord for credentials
      Parameters:
      code - code to exchange
      Returns:
      True if data was successfully obtained from Discord, false otherwise
    • authorizeUser

      protected void authorizeUser(net.dv8tion.jda.api.utils.data.DataObject userData) throws SQLException
      Takes data from the exchangeCode(String) method to insert into the database
      Parameters:
      userData - DataObject (json) compiled from the Http request
      Throws:
      SQLException - if a database error occurs
    • tokenGenerator

      protected String tokenGenerator()
      Creates a token using a base 64 encoder that will be sent VIA dm's to the user
      Returns:
      the token generated