A barebones Java-based Discord bot example written using Discord4J.
For a barbones python-based example, See also CSSBot_Py.
For a full example written in C#, See also CSSBot.
This repository utilizes Gradle in order to automate the process of building the environment.
- Gradle(4.5.1)
- Java JDK(8)
- Optional IntelliJ idea
Note For a detailed description of how to set up your environment with Gradle (for beginners), please see Setting Up Your Environment.
After cloning and forking the repository, run the following command within the local directory:
gradle build
To build the IntelliJ idea files, run the following command:
gradle idea
Note For more tasks, see also Usage
We have designed this barebones example to be quite easy to set up. All you need to do is find out your bot's user token. In order to do that, we must register our bot on discord.
-
Navigate to the Discord API docs and login.
-
Click on the "New App" button.
-
Name your app. Click "Create App".
-
Click "Create a Bot User".
-
Locate your bot's user token.
- Your user token must not be shared with anyone. If it is posted publicly, change it ASAP.
-
Create a new file in your directory:
config.properties
-
Add your token to the first line in the file. Example (inside
config.properties
):token=[TOKEN GOES HERE]
All of these commands must be run in the command line (or terminal) in the same directory as the local repository.
To build runnable executables of the bot:
gradle build
To execute the bot:
gradle run
Note If running in Windows, you can stop the Bot from running by performing CTRL + C
and then confirming the decision by pressing Y
To clean the repository of the current build:
gradle clean
To create the necessary IntelliJ files:
gradle idea
To clean the IntelliJ files:
gradle cleanIdea
To see all available tasks:
gradle tasks