Source code of the Impulse Discord bot.
Install the latest version of Java Development Kit (JDK) 8 which can be found here.
On Linux you gotta open a terminal (ctrl+alt+t) and type the following command: sudo apt-get install openjdk-8-jdk
, once you've installed that make sure to also install JavaFX by running sudo apt-get install openjfx
.
If you are not planning on using shards, e.g. your bot is in less than 2500 servers, then you can ignore this. Since version 2.0 sharding has been totally revamped, instead of every shard just running in 1 process and totally defying the meaning of sharding, shards now run all in their own process and are connected to a server using Netty.
Now I hear you ask, how do I start the server and the shards? Well, simple:
- If you have not yet started the bot at least once, there is no config, do that first so a config is generated and fill it out.
- Set the variable 'shards' in the config to at least 2.
- Start the server by just double clicking the Impulse jar file, it should say starting server and give a success message a few seconds later.
- There you go, you just started the server! Yes, it was that easy.
- No config is needed here, the clients get the config from the server.
- On windows, make a start.bat file that is somewhat like the following:
@echo off
java -jar <jar file>.jar -shard <shardId>
Just make sure that the Impulse jar file, which is indeed the same as the server, starts the jar file with the -shard parameters and make sure to change and to the corresponding variables. Note: shard ids are index-based meaning they start at 0 and end at shardcount-1.
- Now repeat that for each shard.
- As soon as every shard is online, the server should start sending packets to each of them to tell them to log in, once they're all logged in, they will start listening to commands.
- That's it, you're done!
If you're planning on starting the server on let's say VPS 1 and you want to start the clients on a different one, or want the clients distributed over multiple hosts (read computers) then you're gonna have to follow these steps:
- Make sure port 62192 on the host of the server is forwarded, you can find how to do so online, but if that does not help, search on how to do it with UPnP if your router supports that.
- In the start file of each of the clients, you're gonna have to add -hostname <ip of the server's host> to the end of the line that starts with java -jar. You can use a custom domain and its DNS to change the ip to a domain name instead of an ip but that's unnecessary, as long as port 62192 is forwarded on the host.
Since Impulse 2.0 you can now make your own extensions! All you need to do is the following:
- Create a new project in your favourite IDE.
- Add the latest version of Impulse to the build path.
- Make a class that implements com.impulsebot.utils.commands.Extension.
- Make sure to add the main class to the manifest in order for the extension to be able to load.