-
Notifications
You must be signed in to change notification settings - Fork 9
Running The Discord Bot
- Java 11
- MySQL/MariaDB
Download and install version 11 (or above) of the JDK, I recommend doing so via AdoptOpenJDK. Download and install MariaDB community server via https://mariadb.com/downloads/.
Open your preferred terminal and run these commands individually:
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh" # run this if you don't want to open a new terminal
sdk install java 11.0.10.hs-adpt
Follow the relevant guide here for installing MySQL.
Verify your install works by opening a new terminal, and running java -version
. It should say the java version is 11 somewhere in the message.
You can also verify the MySQL/MariaDB install by running mysql --version
in your terminal.
You'll need to create a database for docdex, and optionally a user (avoid using root in production environments for security). First open your terminal, and login to mysql:
mysql -u root -p
If you set a password during install, you'll be required to enter it after you run that command. Don't be alarmed if the characters don't show up as you're typing them, this is intentional. Otherwise, just press enter without typing anything when it asks for a password.
Once in, type these commands individually, in order:
CREATE DATABASE docdex;
CREATE USER 'docdex'@'localhost' IDENTIFIED BY '{password}';
GRANT ALL PRIVILEGES ON docdex.* TO 'docdex'@'localhost';
FLUSH PRIVILEGES;
exit;
Make sure to replace
{password}
with a secure password.
You can either use the public instance, or run your own. To run the bot, simply execute the following command:
java -Xmx1G -jar discord.jar
On first run, a config will generate, and then the application will immediately shut down. Populate the config with your token, along with your docdex link. The default prefix is d;
, and you should familiarise yourself with the commands which are accessible via d;help
.
- Paginations will cease to function after 15 minutes with no activity. i.e. if someone hasn't reacted to a pagination for 15 minutes, the pagination will no longer work.
- If you set your prefix to something stupid and can't use the bot anymore, simply send
@DocDex resetprefix
. Removing the bot from your server will not remove its saved settings.
The bot's config is split up into sections like the apps, with some basic bot details at the top, a section for mysql settings, and a section for the bots presence/activity settings. Here is the basic structure of the bot settings:
token: string "dsdjaklsdjkladj"
prefix: string "d;"
url: string "https://docdex.helpch.at"
default_javadoc: "jdk"
This is fairly self explanatory. The token refers to your bot's token, which can be fetched from your discord application. The prefix is the default prefix of the bot, however keep in mind it can be changed on a per server basis. The url refers to your docdex app instance. Do not append any of the routes onto the end, the bot will do that for you. The default javadoc is the default javadoc the search & metadata commands will use. I recommend leaving it as jdk.
The mysql settings structure is as follows:
host: string "127.0.0.1"
port: int 3306
username: string "docdex"
password: string "1234"
database: string "database"
table_prefix: string "docdex_"
pool_size: int 10
The first half is todo with your connection, and the second todo with the actual database
itself. The host should refer to whatever your mysql instance is being hosted on. If localhost,
use 127.0.0.1
or localhost
. If you're using an external instance, use its public ip.
The username and password are the same that we used in the mysql setup earlier. If you left
it as is, the username should be docdex
, and the password whatever you replaced {password}
with.
The database name, likewise, if left as is from the mysql setup above, should be docdex
.
The table prefix refers to what all the tables in the database are prefixed with. You probably
don't need to change this. The pool size is how many connections to the database are actively
maintained at any one time. 10 is a very fair number, and it's unlikely you'll ever need to increase
it. You may actually want to consider decreasing it.
status: enum "online"
activity: enum "watching"
message: string "the docs (d;help)"
The status refers to the online status of your bot, e.g. online, offline, etc. The value
MUST be one of the values listed here.
It is case insensitive. The activity once again, is another enum value (also case insensitive),
and must be one of the values listed here.
Keep in mind, bots cannot have a custom status. DEFAULT
refers to the
playing
status. The message can be any string. This example presence would look like this:
Feel free to contact me (PiggyPiglet) via discord for support.
-
API
- Routes
- Object Structure
- Population
- Running
- Commands
- Discord
- Development
- Quick Links