Discord Bot Base - Any Revision, Any Base.
This bot uses the JavaCord library. I have used JavaCord and Discord4J and much prefer JavaCord simply because it is more object oriented and queues messages for you, not to send too many messages and potentially have discord ban your bot.
All documentation regarding Javacord can be found here: https://github.com/Javacord/Javacord
You will need to include this dependency:
Gradle:
Code:
repositories { mavenCentral() }
dependencies { implementation 'org.javacord:javacord:3.0.4' }
Maven:
Code:
<dependency>
<groupId>org.javacord</groupId>
<artifactId>javacord</artifactId>
<version>3.0.4</version>
<type>pom</type>
</dependency>
Create a new class:
With this class now in your server, you will need to initialize the class to run on server start, that can be done with:
So, looking back at the JavaCord class you created, you will need to make some changes depending on your base. The commands can use the same means that your in game commands use, for example the kick command. The code in the above kick command can be replaced with the code from what your server currently uses. The potential is really endless.
Please be careful with these commands and be sure to check for discord admin where required.
There is also other checks that JavaCord supports such as by Discord role, and Discord user ID. Please refer to the github page.
Now let's set up our Bot.
Follow this link: https://discordapp.com/developers/applications/
Set up a new application
Give your bot a name and a profile picture (these only appear in your developer window)
https://gyazo.com/3119f4f5b968cfd3992f78f894b99456.png
Head to the Bot tab of the application settings
Name your bot and give it a picture (This is what will appear in your server when the bot speaks)
Reveal the token on this page and copy it.
https://i.gyazo.com/5fd56ae1f6621fb0...9551beaf9d.png
Paste this token in your JavaCord class we created earlier and run your server.
After the bot initializes it will print out a URL in your server console. Navigate to that url to invite the bot to your discord server.
You're done!
Adding Triggered Messages Throughout Your Server:
There is a method created in this class to easily send messages on events from within the server, whether you want to send logs, drops, events, kills or whatever.
simply call:
Code:
JavaCord.sendMessage("channel", "msg")
For example when a rare drop is announced in game, you can add this call immediately after the in-game announcement to also announce rare drops in discord.
Some Tips:- Do not give the bot administration or any other permissions of the sort. If you want to use a bot for user management or other features, use Dyno or MEE6. With this client token being in your source, if your source gets leaked so does the discord token. This can lead to your entire discord server being griefed or deleted.
- When adding new commands, be sure that it is checking for the proper discord permissions, such as for kick or ban commands if you plan on adding those to this bot.
- READ THE JAVACORD API AND JOIN THEIR DISCORD. There is many more capabilities with this bot such as creating embeds. The community is helpful, but will not spoon-feed you.
Good luck!