/OZ-CSC-480-HCI-521-Fall-2022

For fall 2022 project at Oswego

Primary LanguageJavaApache License 2.0Apache-2.0

Prerequisites

Setup

  • Moving forward, make sure you are in the DB_Engine_Networking directory. Consider this folder the root/parent directory.

Discord Application

  • First, obtain your application client id & client secret. Client Keys
  • While you're under this tab enter your redirect uris. Replace localhost with the FQDN if the project is not running locally
http://localhost:9443/ibm/api/social-login/redirect/discordLogin
https://localhost:9443/ibm/api/social-login/redirect/discordLogin

Redirect Uris

  • Then, under bot obtain your token. Bot Token
  • Finally, enable the bots intents under the bot tab. It requires MESSAGE CONTENT INTENT & SERVER MEMBERS INTENT to be enabled Bot Intents

MySQL

  • Enter your MySQL shell
  • Create a MySQL user with all privileges on all databases. The command to do this is
    CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;

    Replace username and password with your own.

    Replace localhost with the IP the user will be accessing from. If the MySQL server is running on the same machine you can leave it as localhost.

DiscordBot

  • In the root of DiscordBot module (folder) create a file called .env with the following content:
DISCORD_BOT_TOKEN=""

OPEN_LIBERTY_FQDN="http://localhost:9080"

MYSQL_URL="jdbc:mysql://localhost:3306/"

MYSQL_INITIALIZATION_USER="OZ_init"
MYSQL_INITIALIZATION_USER_PASSWORD="password"

MYSQL_REST_USER="OZ_rest"
MYSQL_REST_USER_PASSWORD="password"

MYSQL_BOT_USER="OZ_bot"
MYSQL_BOT_USER_PASSWORD="password"

Note: It is recommended to surround the values with quotes to prevent some machines causing issues with special characters.

  • Set DISCORD_BOT_TOKEN equal to the token of your discord bot.
  • Set OPEN_LIBERTY_FQDN equal to the url of your OpenLiberty server + port (if applicable)
  • Set MYSQL_URL equal to the URL of your MySQL server. localhost being the IP address, then 3306 being the port (default).
  • Set MYSQL_INITIALIZATION_USER equal to the username of the MySQL user you created earlier.
  • Set MYSQL_INITIALIZATION_USER_PASSWORD equal to the password of the MySQL user you created earlier.
  • Set MYSQL_REST_USER_PASSWORD AND MYSQL_BOT_USER_PASSWORD to two new, unique passwords. These users will be created. You can change their usernames if you'd like, but it isn't necessary.

OpenLiberty

  • Copy the .env file from the DiscordBot module to the root of OpenLiberty module.
  • Make sure you are in the root of the OpenLiberty module.

CLIENT_ID and CLIENT_SECRET are the client id and client secret of your discord application.

If you are on a UNIX based system, run the following commands: export DISCORD_CLIENT_ID=CLIENT_ID and export DISCORD_CLIENT_SECRET=CLIENT_SECRET If you are on a Windows system, follow this guide to set environment variables.

Running DiscordBot & OpenLiberty

  • In the root/parent directory of the project run mvn clean install to build the project.
  • In the root of the DiscordBot module run mvn exec:java to run the bot.
  • In the root of the OpenLiberty module run mvn liberty:run to run OpenLiberty or run it in dev mode with mvn liberty:dev.

Done!