Skip to content

MrMame/HowTo_JavaDiscordApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How To : Discord API

Test project to get used to Java Discord API lib

App - How to deploy and run

  1. Clone the repo to your machine
  2. Run Mavens install lifecycle
  3. Go to Mavens target/externalConfigs folder and rename the default_discordSettings.properties file. Remove the leading default_ string. This will let the application read the file for gathering all necessary data for connecting to discord.
  4. Copy the following files from mavens target folder to your desired application folder:
   target
   |
   +-- HowTo_JavaDiscordAPI-<versionNumber>.jar
       |
       +-- lib/
       |
       +-- externalConfigs/
  1. Now go to your applications folder and type the following command, for running the application java -jar HowTo_JavaDiscordAPI-<versionNumber>.jar

App - Features

External .properties-file

Properties-Files placed inside the projects src/main/resources/externalConfigs folder will be moved to externalConfigs subfolder of the installed JAR file as soon as mavens install lifecycle is getting started. The copy-mechanism is defined in the pom.xml file, using mavens maven-resources-plugin. Those properties files will not be included inside the JAR output file of your application if you're going to run mavens install lifecycle. To exclude the folder from JAR file, the maven-jar-plugin is used inside the pom.xml.

Keep in mind that you can place your discordSettings.properties file with your discord token into the project folder. This file is already git-ignored.

Deploy all dependencies into lib sub-folder

When you are going to use Mavens install lifecycle, all project related dependencies are going to be copied to the /lib subfolder of the installed project by using maven-dependency-plugin inside the pom.xml file. Additionally, you have to point to the new lib folder inside the JAR's MANIFEST file. This is set by using the classPath value of Mavens maven-jar-plugin inside the pom.xml file.

App - Property Settings

log4j.properties

You can define the behaviour of the log4j-logger by changing the values inside the log4j.properties file. A short description can be found on the Oracle website here.

discordSettings.properties

Here you have to put all the Discord related stuff into. The file is located at the externalConfigs subfolder of the installed application or at the project folder src/main/java/resources/externalConfigs

  • settings.discord.token=
    Put in the token for your discord-application (bot). Before this application can be run, you have to ensure that you have created a discord bot first. Here is a small HowTo on how to create your own discord bot for getting you started.

App - Dependencies

Java Discord API

Discord API Wrapper for Java.

slf4j - Logging API with log4j

JDA only uses the logging API slf4j. You can select whatever logger lib you want that is compatible with slf4j. So both dependencies are necessary. I decided to use log4j. This is included in the reload4j lib.

Appendix - Tutorial Links

Some links to video tutorials I used for tose examples in here

YouTube-Channels

Technical Informations

About

Testing the Java Discord API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages