-
Notifications
You must be signed in to change notification settings - Fork 74
Setup Guide (Windows)
If you want to run D-Zone for your Discord server, you will need the following:
- A computer to run the node server
- The computer you're on right now would be fine, or you can use a node.js hosting service.
- A port available on the node server for the websocket
- This means port forwarding on your router, like when you host a game server.
- A web host or local host for the client files
- If hosting on HTTPS, you will need to provide an SSL certificate (try Let's Encrypt)
- People tend to get stuck on this one, please find a web host before proceeding.
First, you must install Nodejs. It's recommended to use the latest LTS release.
Start cmd and type the following to test if node is indeed installed:
node -v
.
If the command returns the latest LTS version, your all set!
It's suggested to use git, as this is easier to update then using the zip methode. Simply install git here. To download D-Zone go to your preferd location using cmd and do the following:
git clone https://github.com/vegeta897/d-zone
cd d-zone
Then install the node modules that are needed to run d-zone: npm install --no-optional
If all goes well, you should now have a node_modules
folder.
You can update D-Zone now by just typing git pull
.
Set the env variable or make a .env
file in the d-zone folder and add the following:
token=yourtokenhere
Change yourtokenhere
to the correct bot token that you can get here.
Copy and rename the discord-config-example.json
to discord-config.json
and set the default d-zone server:
{
"url": "http://youripordomain.com/web/index.html",
"infoCommand": "!d-zone",
"servers": [
{
"id": "1234567891234567",
"default": true,
"ignoreChannels": ["members-Only","testing"],
"password": "This is optional"
}
]
}
Change the url to the public ip adres. With curl https://myexternalip.com/raw
you can find the ip address.
If you use a domain, use that in the url field instead.
Change the id to the default id of your own server. You can find this by going to:
If you don't want to use a password for a server remove the line as followed:
{
"url": "http://youripordomain.com/web/index.html",
"infoCommand": "!d-zone",
"servers": [
{
"id": "1234567891234567",
"default": true,
"ignoreChannels": ["members-Only","testing"]
}
]
}
If you want an easier way to automatically include all servers your bot resides in, simply after you added your bot token and then run the update script by doing: "Update Configuration.bat"
. If you already have servers in your config with optional parameters, they will not be overwritten.
Re-run this command whenever a new server has joined, or has left.
Check if the port the websocket will run on is free with: netstat -na | find "3000"
. Change 3000 to any port you wish to use. If cmd returns withoud any connections, it's free.
Copy and rename the socket-config-example.json
to socket-config.json
.
The following should be present:
{
"address": "192.168.0.1",
"port": "3000",
"secure": false
}
Make sure to use the domain or ip corresponding to what is filled in here.
After filling in the socket-config.json, run the following command to generate the bundle.js:
npm run-script build
.
Only repeat this when the socket-config.json has changed.
To serve the view of D-Zone, a web server needs to be setup. In this instruction Apache2 is used. Because Apache2 is best for hosting websites on Windows clients. Also nginx seems to hint to not use nginx on windows
Install Apache2 from here.
Unzip it in the C:/
directory.
With cmd, go to the following directory: C:/Apache24/bin
and run Apache2 by doing: httpd.exe
. Go to this adres: http://localhost/ .
If it returns It works!
then Apache2 is correctly working.
To enable Apache2 with the system, stop the current proces and install the service: httpd.exe -k install
. Then start it again with httpd.exe -k start
. After a reboot, check again if Apache2 still works.
The web files need to be copied to the right place. It's suggested to make a new folder in the Apache2 folder called d-zone
.
Futhermore, in the conf folder of Apache2. Change inside the httpd.conf file the following line:
DocumentRoot "${SRVROOT}/htdocs"
<Directory "${SRVROOT}/htdocs">
To this:
DocumentRoot "${SRVROOT}/d-zone"
<Directory "${SRVROOT}/d-zone">
Restart Apache2 to see the changes. Now that's set, copy the web files using the following command:
robocopy "c:/Users/Test User/Desktop/d-zone/web/" c:/Apache24/d-zone/ /MIR /XD "script"
This will only copy all the files from the web/ folder, to the Apache2 d-zone folder. The folder script will be excluded. As this isn't required for the website. This means that if the destination is newer, it will be overriden! So do all your changes in the d-zone project!
Now that everything is inplace, type the following to start D-Zone.
Given that your in the project folder:
npm start
Check trough your webbrowser if d-zone is running.
- If you get the
upgrade required
error you have visited the websocket. - If you get stuck on
connecting...
check if the port is indeed open.
If you are hosting with HTTPS enabled (recommended), you need to also set your cert
and key
variables to the full paths of your certificates. To this, it's recommanded to use letsencrypt-win-simple. Just follow the instructions and check if HTTPS is indeed working.
To make D-Zone work with HTTPS, set the following in the .env
file:
token=yourtokenhere
cert=D:\Users\<username>\AppData\Roaming\letsencrypt-win-simple\httpsacme-stage.api.letsencrypt.org\<domain-name>-all.pfx
key=D:\Users\<username>\AppData\Roaming\letsencrypt-win-simple\httpsacme-stage.api.letsencrypt.org\ca-<hex>-crt.pem
Change in the socket-config.json
the secure field from false to true:
{
"address": "192.168.0.1",
"port": "3000",
"secure": true
}
Lastly, change in discord-config.json the HTTP url to HTTPS.
{
"url": "https://yourdomainonly.com/",
"infoCommand": "!d-zone",
"servers": [
{
"id": "1234567891234567",
"default": true,
"ignoreChannels": ["members-Only","testing"],
"password": "This is optional"
}
]
}
Again, repeat npm run-script build
and restart D-Zone. If you visit it on HTTPS it should work still.
To keep D-Zone running, a proces manager needs to be used so it can continue to run after the terminal session has been closed.
Install qckwinsvc by doing:
npm install -g qckwinsvc
To start D-Zone with pm2 type the following once:
qckwinsvc
Fill in the questions, give the full path to the .js file. For example: C:\Users\Test User\Desktop\d-zone\index.js
Documenation about qckwinsvc.
Respect the privacy of the users in your Discord server. By creating a D-Zone for your server without a password, you are allowing anyone with the URL to view any conversations your bot has permission to see.
The build
script creates a minified bundle file with no source mapping, while watch
is not minified but is quicker to run and has source mapping. So, watch
is good for development and build
is good for deployment. If you have no idea what this means, use build