DBS is a Java library that makes it very easy for you to create Discord Bots in Java.
It includes many basic functions and a few easy-to-use extra elements.
NOTE: THIS README IS OUTDATED! IT WILL BE UPDATED SOON!
Please see the JDA Docs for more general information about Discord Bots in Java.
Implementing DiscordBotStuff into your project
To activate and use DiscordBotStuff into your project, you have to put the following line into your Main class:
new de.thedesigncraft.discord.core.DBS(YOUR_SETUP);Be sure to replace YOUR_SETUP with a DBSSetup, which you can create using the DBSSetupBuilder. An example Main class could look like this:
package dev.weirddude.discord.bot;
import de.thedesigncraft.discord.core.DBS;
import de.thedesigncraft.discord.core.setup.DBSSetup;
import de.thedesigncraft.discord.core.setup.DBSSetupBuilder;
public class MyBot {
public static void main(String[] args) {
DBSSetupBuilder builder = new DBSSetupBuilder();
builder.setMainPackage("dev.weirddude.discord.bot");
builder.setToken("YOUR_TOKEN");
DBSSetup setup = builder.build();
new DBS(setup);
}
}After setting all the required setup values, there are still a few more that you can set:
- Intents (
addGatewayIntents()) - CacheFlags (
addCacheFlags()) - MemberCachePolicy (
setMemberCachePolicy()) - EventListeners (
addEventListeners()!! Note: You only have to add EventListeners here, that are not in the main package, which you have set in the setup !!) - Activity (
setActivity()) - Status (
setStatus())
To get more information about what you can set at the bot startup, see DBSSetupBuilder.
Be sure to replace the VERSION key below with the one of the versions shown above!
If you haven't yet created a settings.xml file, or you haven't yet added your GitHub-Authentication in the settings.xml file, take a look at Preparing your settings.xml file.
<repository>
<id>github</id>
<name>GitHub TheDesignCraftYT Apache Maven Packages</name>
<url>https://maven.pkg.github.com/TheDesignCraftYT/DBS</url>
</repository><dependency>
<groupId>de.thedesigncraft.discord</groupId>
<artifactId>dbs</artifactId>
<version>VERSION</version>
</dependency>If you don't already have a settings.xml file, create one at ~/.m2/settings.xml.
Inside the <servers> tag, add a <server> child tag with an <id>, set your GitHub username as <username> and add a personal GitHub access token in <password>.
In the end it should look like this:
<server>
<id>github</id>
<username>USERNAME</username>
<password>TOKEN</password>
</server>Be sure to replace USERNAME below with your GitHub username and TOKEN with a personal GitHub access token.
Gradle Groovy:
repositories {
maven {
url = uri 'https://maven.pkg.github.com/TheDesignCraftYT/DBS'
credentials {
username = project.findProperty('gpr.user') ?: 'USERNAME'
password = project.findProperty('gpr.key') ?: 'TOKEN'
}
}
}dependencies {
implementation 'de.thedesigncraft.discord.dbs:dbs:VERSION'
}Kotlin DSL:
repositories {
maven {
url = uri("https://maven.pkg.github.com/TheDesignCraftYT/DBS")
credentials {
username = project.findProperty("gpr.user") as String? ?: "USERNAME"
password = project.findProperty("gpr.key") as String? ?: "TOKEN"
}
}
}dependencies {
implementation("de.thedesigncraft.discord.dbs:dbs:VERSION")
}