Jump to content

[Discord bot for DCS] DBS (Digital Bot Simulator) by Asta☠


Recommended Posts

Hello,

Almost 4 years ago I did a Discord bot to share to players what is the current mission on the server, mission time (to see if it's day or night), and even see who is flying on a server without need to start DCS.

So I did something using Node.JS + Discord.IO.
But it's not a very neat solution because it means each server owner needs to create and host his own Discord.

The best solution would be ED to has his own Discord bot because all those data are already available:
image.png
Then, only one bot would be existing, and server owners wouldn't need to host their own Discord bot to connect their server to their community Discord.

Of course I opened to ED a ticket to see if there were interested (maybe 3 year ago?), at this moment we didn't give a next.

I continued to develop my bot, I shared a bit more information, server's password, SRS version and parameters for example. But those data would not be accessible from a ED server (I guess, but I may be wrong):
image.png
But one day, the Discord.io framework wasn't supported anymore, so I had a redo a part of the bot, but the bot was still working, even today is still working, so I postponed a lot before redoing the bot.

In the same time, I saw other Discord bot for DCS, for examples https://github.com/DCS-gRPC/Custodian or https://github.com/Special-K-s-Flightsim-Bots/DCSServerBot , but it wasn't the same language (remember, I basically choose NodeJS) and it wasn't the functional possibilities I was looking for. I don't really want to manage my DCS server, I prefer to create more "social" interactions between the DCS server and the Discord server.

The last months, I finally re-did the entire bot to migrate from Discord.io to Discord.js and I also redid the lua part.

Now, the current bot is sharing more data, and I called it :

DIGITAL BOT SIMULATOR

DBS.png

image.png

The server automatically says when the DCS server is OFF:
image.png
And I also create a channel to follow what's happening in the mission, as you can see, I can share lot of events :
image.png
During a dogfight we can see:
image.png
And sometimes an accident:
image.png

For now, I share almost everything, but I'll make an easy true/false panel to let the admin chooses what he wants to share on the Discord.

I'm also trying to find a solution to talk from the Discord channel to the in-game DCS chat.
I already did something working with the old bot, still also working:
image.png
But the technical solution wasn't very clean, so I prefer to investigate and see if I can do something better.

If you want to see the bot running, you can have a look on my Discord server: https://discord.gg/ZUZdMzQ .

For now I'm still working on it, but yes :
I plan to make it available pushing it to Github with a guide for any admins to download it and use it on it's own server.
I just don't know when.

If you have any questions, please, do it in a public place (on this topic or in a public channel on a Discord, you can also find me on the official DCS Discord server or on the modding hub Discord server) ). I don't want to answer in private because your question(s) could interests other players. 🙂 

See you soon

Asta☠

  • Like 7

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

Ok, I've now a better solution for the link between the ingame chat and the the Discord channel 🙂
image.png

I'm gonna push it to a friend for test purpose, if everything is fine, I'll write a guide and I'll publish it 🙂

  • Like 5

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

  • 2 weeks later...

Hello DCS servers admins

Today is the day, I just released my bot!

You'll find here the instructions and the files to download it:

https://github.com/frasta/DCS-Discord-bot

I hope you'll enjoy it

see ya

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

Hey, awesome work...I've followed the steps on GitHub, but stuck here...where do I download?

  • Shutdown your DCS server - Done
  • Install node.js link (tested and working well with 18.14.0 and 19.6.0) - Done 
  • Create folder where the bot will be installed and go inside using the Windows Command Prompt (CMD) - Done
  • When inside, type npm init - Done 
  • Install node plugins npm install discord.js - Done
  • Download and unzip the .zip file - I'M STUCK HERE, where do I go to download?

Edited by NatoAviator
Link to comment
Share on other sites

1 hour ago, NatoAviator said:

Hey, awesome work...I've followed the steps on GitHub, but stuck here...where do I download?

  • Shutdown your DCS server - Done
  • Install node.js link (tested and working well with 18.14.0 and 19.6.0) - Done 
  • Create folder where the bot will be installed and go inside using the Windows Command Prompt (CMD) - Done
  • When inside, type npm init - Done 
  • Install node plugins npm install discord.js - Done
  • Download and unzip the .zip file - I'M STUCK HERE, where do I go to download?

 

Hey,
The best away is to click the "release" button link and download the zip (as for the A4 mod and SRS)
image.png

you can also hit the green "< > Code" button to download the project.

See ya 🙂

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

On 2/25/2023 at 6:25 PM, Snoopy said:

Was starting the install and a lot of the reference images in Github are no longer loading.

 

Hi @Snoopy, I just uploaded all the images directly on Github, it will be fine now 🙂

  • Like 1

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

  • 3 weeks later...
2 hours ago, Padinn said:

Mine was working well and then today on start up I am getting an error. Any idea whats up?

null

image.png

I'm not using this scripts, but it looks like there is another process that is using the port 14802, and the program can't start since it's unable to use it.

Try to restart the system, should fix the problem.

  • Like 1

FlighRIG => CPU: RyZen 5900x | RAM: 64GB Corsair 3000Mhz | GPU: nVIDIA RTX 4090 FE | OS Storage: SSD NVMe Samsung 850 Pro 512GB, DCS Storage: SSD NVMe Sabrent 1TB | Device: Multipurpose-UFC, VirPil T-50, TM WARTHOG Throttle, TrackHat, MFD Cougar with screen.

Our Servers => [ITA] Banshee | Krasnodar - PvE | PersianConquest PvE Live Map&Stats | Syria Liberation PvE Conquest

Support us on twitch subscribing with amazon prime account linked, it's free!

Link to comment
Share on other sites

Ohh thats neat! Im trying it right now.
Can you clarify which ID goes to which "line"? I understood it that we have 4 IDs: Bot itseslf, broadcastchannel, textchannel, and whats the 4th? The Token?

And to which const goes which ID? Thats unclear to me.

-Ive put the bot token to the config.json
-ive put the broadcastchannel-id to channelLiveID
-textchannel-id to messageLiveID
-bot-id to botID

whats the 4th: channelTchatID?

 

Thanks for the work!!


Edited by MarkP

Main-Module: F-16C, AH-64D

Maps: Syria, Persian Gulf, South Atlantic, Caucasus, 1944 Normandy, NTTR

Hardware: VKB Gunfighter mk.2 Pro, WinWing Orion F16, VKB T-Rudder, HP Reverb G2

PC Specs: Intel 13900K, ASUS ROG STRIX Z790-E, 64GB DDR5-5800 RAM, GeForce RTX 4090, Win 11x64

Link to comment
Share on other sites

1 minute ago, MarkP said:

Ohh thats neat! Im trying it right now.
Can you clarify which ID goes to which "line"? I understood it that we have 4 IDs: Bot itseslf, broadcastchannel, textchannel, and whats the 4th? The Token?

And to which const goes which ID? Thats unclear to me.

 

Thanks for the work!!

Hi,

With this screen it should help:

IDs.JPG

Blue: ID of the Discord channel "live" (where you have the technical info' from your server)
Yellow: ID of the message in the channel "live" (you need to make it appears first using !init)
Purple: ID of the channel "tchat" (where you can talk between Discord and the DCS ingame tchat and also see the events (connections, slot, takeoff, ...))
Green: ID of the bot.

 

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

hey, yea. Just saw it down below x) i was confused since in the first screenshot in the howto there were already all 4 columns filled. Thanks.

 

I just got it working. Man. Thanks! Its awesome!!

 

edit: two questions.

1. The IP of my server is static and i have a DNS record for it. Is there any way to set the IP in the config to be the dns record? 
2. Is there a way to provide a autostart?


 


Edited by MarkP
  • Like 1

Main-Module: F-16C, AH-64D

Maps: Syria, Persian Gulf, South Atlantic, Caucasus, 1944 Normandy, NTTR

Hardware: VKB Gunfighter mk.2 Pro, WinWing Orion F16, VKB T-Rudder, HP Reverb G2

PC Specs: Intel 13900K, ASUS ROG STRIX Z790-E, 64GB DDR5-5800 RAM, GeForce RTX 4090, Win 11x64

Link to comment
Share on other sites

On 3/17/2023 at 11:49 AM, MarkP said:

hey, yea. Just saw it down below x) i was confused since in the first screenshot in the howto there were already all 4 columns filled. Thanks.

 

I just got it working. Man. Thanks! Its awesome!!

 

edit: two questions.

1. The IP of my server is static and i have a DNS record for it. Is there any way to set the IP in the config to be the dns record? 
2. Is there a way to provide a autostart?


 

 

Hey, just saw your edit messages
1) Yes, you can "hard code/write" the IP adress with the bot, line 196, or close, at this line:

messageToShow += str_DCSip+"**"+myIP+":"+linesDCSConf[i].split("[\"port\"] = ")[1].split(",")[0]+"**\n";

you can replace the variable "myIP" by an IP adress (for example here: 123.123.123.123):

messageToShow += str_DCSip+"**"+"123.123.123.123"+":"+linesDCSConf[i].split("[\"port\"] = ")[1].split(",")[0]+"**\n";

 

2) Sure, I'm doing it myself, I use Windows task scheduler to run a script starting the bot, I recommend you to have a look here:

See ya

  • Like 1

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

  • 1 month later...

hi, Asta!
i have tried many  times, but no matter what i do, the result is this.
i know this BOT is so great, but i'm sad that i can't make it work on my multi server.
any idea what might be causing this?
スクリーンショット (1).png(sorry my poor ENGLISH. i'm Japanese.)

Link to comment
Share on other sites

3 hours ago, Nishiyandcs4 said:

hi, Asta!
i have tried many  times, but no matter what i do, the result is this.
i know this BOT is so great, but i'm sad that i can't make it work on my multi server.
any idea what might be causing this?
スクリーンショット (1).png(sorry my poor ENGLISH. i'm Japanese.)

Kon'nichiwa @Nishiyandcs4,
Don't worry, your english is more than good enough (and I'm really not perfect neither 🙂 )

I read "Unknown Message" and a 404 status.
It means you made an error on an ID.
Can you re-check your IDs according to this draw?

IDs.JPG

BotID (green) : ID of the bot
channelTchatID (pink) : ID of the channel where you are connected with events (and in-game tchat) of the simulator.
channelLiveID (blue) : ID of the channel where the bot will display the data about the server (name, password, players online, version, etc....)
messageLiveID (yellow) : ID of the message of the bot after your made "!init" for the bot to get his message 🙂

If those 4 IDs are correct, it will work 🙂


Oh, and @Snoopy
tested the bot with several DCS instances, it's working! Thank you again for the test
You "just" need to duplicate the number of bot and redo the same.
 
Enjoy

  • Thanks 1

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

Hi, Asta, thanks for the quick response! !
Yes, I have set it up as you said, but the result is the same no matter how many times I run it.
In rare cases, "Server Offline" is displayed on the channel set as "Message Live ID", but it is the same display on the CMD prompt screen.

Also, sometimes I get an error like "unable to send".
It looks like the bot is trying to access channels with these IDs, but for some reason it is unable to access these channels.

When I tried CTRL + click on the URL of the screen where the error is displayed, it will be displayed as

{"Mesage": "401: Unauthorized", "code": 0}.

Is this correct?

Link to comment
Share on other sites

6 hours ago, Nishiyandcs4 said:

Hi, Asta, thanks for the quick response! !
Yes, I have set it up as you said, but the result is the same no matter how many times I run it.
In rare cases, "Server Offline" is displayed on the channel set as "Message Live ID", but it is the same display on the CMD prompt screen.

Also, sometimes I get an error like "unable to send".
It looks like the bot is trying to access channels with these IDs, but for some reason it is unable to access these channels.

When I tried CTRL + click on the URL of the screen where the error is displayed, it will be displayed as

{"Mesage": "401: Unauthorized", "code": 0}.

Is this correct?

If the bot it started, you can't run it again until it's stopped.

unable to send => Are you sure about the rights of the bot? On the Discord and on the channels?

I gave you URL from Github, weird, here is the same screen from Discord =>

https://cdn.discordapp.com/attachments/559138601573548052/1103554191584149536/image.png

Keep us in touch 🙂

See ya

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

Hi Asta!
I didn't want to waste my time with too many issues, so I really started over to sort things out.
(Including Bot installation, node download, other settings, etc.)
Then, mysteriously, the problem was solved all at once, and the Bot started talking 'very very very lively' inside my server.
I don't know much about Bots and programming like this, so I still don't know what caused it,,,,, but I learned a lot in many ways.
Thank you for this wonderful bot including your response!🤘

  • Like 1
Link to comment
Share on other sites

Hello! Asta.

The DBS bot on my server is speaking very well!!

but...
I have another question,

1)  Why doesn't "Server Offline" show up when the server is terminated?
Even if the server is terminated, the live channel display will remain intact. Any special settings in index.js or BDSGameGUI.lua?

2)  Is the "Started since" display of the live channel not updated unless there is an event such as someone connecting while the server is running? Is it possible to have the display refreshed somewhat automatically (e.g. once every 5 minutes)?

3)  Only the file name is displayed when the server is started, but if you change the mission file, the file path without .Miz will be displayed in the "Mission" display of the live channel. I'm running a dedicated server and the files get rebooted every 4-5 hours. Also, players in the server can arbitrarily change the file. In any case, the file path is displayed except at startup.

It would be helpful if you could tell me if you have time.

Thank you.


Edited by Nishiyandcs4
Link to comment
Share on other sites

6 hours ago, Nishiyandcs4 said:

Hello! Asta.

The DBS bot on my server is speaking very well!!

but...
I have another question,

1)  Why doesn't "Server Offline" show up when the server is terminated?
Even if the server is terminated, the live channel display will remain intact. Any special settings in index.js or BDSGameGUI.lua?

2)  Is the "Started since" display of the live channel not updated unless there is an event such as someone connecting while the server is running? Is it possible to have the display refreshed somewhat automatically (e.g. once every 5 minutes)?

3)  Only the file name is displayed when the server is started, but if you change the mission file, the file path without .Miz will be displayed in the "Mission" display of the live channel. I'm running a dedicated server and the files get rebooted every 4-5 hours. Also, players in the server can arbitrarily change the file. In any case, the file path is displayed except at startup.

It would be helpful if you could tell me if you have time.

Thank you.

 

Hi,

Let's answer.

1) What I use on my side, is a windows script which is shutting down, the bot, DCS, SRS, restart the bot (to have the offline info) and then shutdown the server

TASKKILL /F /IM SR-Server.exe
TASKKILL /F /IM node.exe
timeout /t 10
TASKKILL /F /IM DCS_server.exe
timeout /t 15
cd "C:\botDBS"
pm2 start index.js
timeout /t 10
shutdown -s -f -t 3

More info' here:

 

2) It shows the mission time since the mission started. What you ask is technically possible but I didn't want to have a loop/while check if there is nothing new on the server, to avoid the bot to spam the Discord API.
What I do on my server, I keep only the server "resume when client connected".

3) I don't understand the problem. The problem is sometimes you see the path? If yes, it's not a big issue.
The problem is the mission name is not changing when you change mission? It changes for me.

 

 

 

 

 

 

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

  • 2 months later...

I'm noticing an error in the log:

2023-07-11 13:51:55.116 ERROR   LuaHooks (Main): [string "C:\Users\Carmen\Saved Games\DCS.openbeta_server\Scripts\Hooks\DBSGameGUI.lua"]:232: bad argument #1 to 'gsub' (string expected, got nil)

 

Seems related to the code that cleans up strings. Any thoughts? 

Link to comment
Share on other sites

18 minutes ago, Padinn said:

I'm noticing an error in the log:

2023-07-11 13:51:55.116 ERROR   LuaHooks (Main): [string "C:\Users\Carmen\Saved Games\DCS.openbeta_server\Scripts\Hooks\DBSGameGUI.lua"]:232: bad argument #1 to 'gsub' (string expected, got nil)

 

Seems related to the code that cleans up strings. Any thoughts? 

I need to have the log before to see what's going on.
Probably a problem of special character? (?!/\|'&"...)  Tell me when you find it and I'll see to correct it 🙂

My DCS contributions:
- My mods/skins: here
- My server/missions scripts: there
- My Discord bot:
this place
If you want to thank me buying a coffee☕/beer🍺, feel free:
https://www.buymeacoffee.com/Astazou

Link to comment
Share on other sites

  • 4 months later...

C:\ServerBot\bot>node index.js
Listining to  Address:  0.0.0.0 Port:  14802
Listining to  Address:  0.0.0.0 Port:  14803
Ready!
My public IP address is: 104.183.201.147
C:\ServerBot\bot\index.js:301
                chanelTchat.send(str_serverOFFshort);
                            ^

TypeError: Cannot read properties of undefined (reading 'send')
    at updateLiveData (C:\ServerBot\bot\index.js:301:15)
    at C:\ServerBot\bot\index.js:113:4

Node.js v21.2.0

Can you help with this error?

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...