top of page

Host your own DH-servers? I coded a bot!

Run it in the server files and start games from a channel in your Discord

If you're like me and host multiple game servers for your friends, and want to host Dread Hunger servers as well, this DH-bot for Windows might be for you.

The pain with hosting Dread Hunger servers yourself, is that you need to create a new one for each round. You typically create a bunch of batchfiles for different maps, thralls and environmental settings and then you have to remote desktop to the other PC and start a new one every 20-40 minutes, or even worse....walk there!

That's why I spent some hours with Python and the Discord Developer Portal to create a bot that can start an array of different batch files remotely, all controlled via a designated channel in the Discord you administrate or co-administrate, with commands like /help, /test, /startserver1, /startserver2, /startserver3 etc. This way you and all the members on your Discord can start games themselves, even if you're not home. As long as the PC is on and the bot running.

It should also be said that you can create free modded and vanilla servers here and here, especially easy with the in-game Overlay by Serega and Vule, which I have uploaded here,

and I use them all myself. It's just nice to run your own from time to time, with your personal ship modifications and things like that. You know your style best!

Dependencies

To be able to run the bot on your physical server, you first need to install Python.

Make sure to tick the box with PATH in the Python installer options!

After that you need to run a CMD-window and type:

python -m pip install discord.py

Those are the dependencies and libraries your bot will need to work.

Restart your PC and it's good to go.

Port/NAT-Forwarding

This part is tricky! There are thousands of router models out there and only your user manual can tell you how to do this on your specific router, but if you already host servers, I'm sure you know how to do this already. Dread Hunger servers only need to forward port: 7777 TDP/UDP

Discordbotguidepicture

The Bot

The bot itself is just one small, simple file with code that you can download below.

Put it in your DH server files together with your start.bat files etc.

The only thing you need to change is the directory to the server files and insert a TOKEN from Discord,

which we will talk about later. You can use Notepad, but Notepad++ is much better

The code looks like this and you can download it from the bottom of the page:

Disclaimer: If some of your folders have spaces in their name, the paths might become undreadable to the code.

Making an App on Discord

Discordbotguidepicture

Log into the Discord Developer Portal with your regular account and click the button "New Application".

Give the bot a name. The app will look like a living, breathing member of your Discord server and this is the name everyone will see. The name visible in the members list can be edited later, but in the system it will never change.

Discordbotguidepicture

Add a profile picture and description (what it does and which text channel to use, perhaps?)

Discordbotguidepicture

Click the button "Reset Token" and a token will be generated for you. Save it in a note or something on your PC. Never show it to - or share it with anyone!!

Discordbotguidepicture

An example of what a token looks like.

Connecting the Bot to the Discord App

To get this done, all you have to do is to edit the file called "main.py" (the code) in notepad++ and paste the Discord-app token in it (near the very top), then hit save. 

Go to the 0Auth2 tab and tick the boxes for Bot and Admin. Scroll down and copy the link that was generated for you and paste it in a web browser. This will invite the app to Discord.

Discordbotguidepicture

Discordbotguidepicture

Go to the Bot tab on the left and make sure to toggle on the 4 switches as shown here, then hit "save".

Prepping the Bot

In order for the bot to work and run on your PC, you first have to locate the folder with all the DH server files in it (default name is "WindowsServer"). While you're in that folder, copy the path to it and then edit main.py by swapping out my path with yours. Hit save.

Discordbotguidepicture

Creating the Batch Files

We're going to use a lot of batch files. One to start the bot from the desktop or any other place or folder you would like to start the bot from, and 15 files for various server settings, maps++

Open the regular notepad and make a file that looks like this:

Discordbotguidepicture

Remove the path to my server folder and paste in yours. Save the file and name it

something like "DHbotstarter.bat" or whatever you'd like as long as it ends with .bat. You can put this file wherever. I keep mine on the desktop to start the bot fast and easy.

These are the files that the bot wil run. Either download the 15 I use and edit them all individually by removing my path to the server files and replacing them with yours. This would also be the time to tweak settings for days, minutes, cold intensity, predator damage etc.

Or you can just keep them like I do. The most important thing is that they are named start1.bat, start2.bat, start3.bat etc. etc., or else the bot will not be able to find them.

Here's a list of my 15 batchfiles and what their names imply:

start1.bat    =   Approach Normal 1 Thrall  
start2.bat    =   Approach Normal 2 Thrall          
start3.bat    =   Approach Easier 1 Thrall        
start4.bat    =   Approach Easier 2 Thrall      
start5.bat    =   The Summit Normal 1 Thrall   
start6.bat    =   The Summit Normal 2 Thrall
start7.bat    =   The Summit Easier 1 Thrall
start8.bat    =   The Summit Easier 2 Thrall
start9.bat    =   The Expanse Normal 1 Thrall
start10.bat  =   The Expanse Normal 2 Thrall
start11.bat  =   The Expanse Easier 1 Thrall
start12.bat  =   The Expanse Easier 2 Thrall
start13.bat  =   Soloplayer Approach
start14.bat  =   Soloplayer The Summit
start15.bat  =   Soloplayer The Expanse

Game Server Batch Files

Starting the Bot

Now that you've linked the bot and your Discord server, created a DHbotstarter.bat and edited the code in main.py, it's time to fire up the bot. Double click on DHbotstarter.bat and it will open up a CMD-window and run there. You will see that the new member in your Discord has changed his status from offline to online.

This is what start1.bat looks like on the inside:

C:\Users\DannyDevito\Desktop\WindowsServer\DreadHungerServer.exe Approach_Persistent?maxplayers=8?daysbeforeblizzard=3?dayminutes=9?predatordamage=1?coldintensity=1?hungerrate=1?coalburnrate=1?thralls=1 -log

This is start3.bat (Approach Map, easier difficulty):

C:\Users\Klatt\Desktop\WindowsServer\DreadHungerServer.exe Approach_Persistent?maxplayers=8?daysbeforeblizzard=4?dayminutes=12?predatordamage=0.5?coldintensity=0.75?hungerrate=0.75?coalburnrate=0.75?thralls=1 -log

As I said, feel free to edit and use my batch files (available for download below). Now you know how to make your own as well. If you want to make your own files:

Expanse is called: "Expanse_Persistent and The Summit is called: "Departure_Persistent".

Inside the Game Server Batch Files

Assigning the Bot a Text Channel

I recommend creating a new text channel on your Discord named "bot" or something. Right click on the channel and edit it. Go to permissions and add a role there (your app will pop up as a choice so pick that one), and just toggle on every setting you can. While you're in there, edit the permissions for the @everyone role as well, turn OFF their ability to write or post there and scroll down to "Use Application Commands" and turn that on.

Discordbotguidepicture
Discordbotguidepicture

To use the bot, just start typing "/" and suggestions will pop up, pick one and click enter twice or just write the whole command yourself. That's it! We did it!

Using the Bot

the end

logo

Downloads

bottom of page