Jump to content

LUA Script Creation for Discord Webhook Integration Help


Raptor6872

Recommended Posts

Greetings All,

 

I've been working to try and create a LUA script that I can run in order to send data from the game to a Discord "webhook". I do not have a lot of knowledge on the topic but have been trying to learn more. It seems that LUASocket and JSON are all integrated in DCS thankfully, but I am not sure how to exactly make this work. So far I've come up with the following, but it does not work, any ideas?

 

Just a post to provoke thought and ideas since I've not found any decent resources.

 

(e.g. Have a trigger cause a msg. to send to Discord WebHook)

 

-------------------------------------------------------

-- Discord Bot (Hook) Test -------------------------

-------------------------------------------------------

package.path = package.path..";.\\LuaSocket\\?.lua;"

package.cpath = package.cpath..";.\\LuaSocket\\?.dll;"

 

local JSON = loadfile("Scripts\\JSON.lua")()

 

local http = require("http")

 

local siteurl = "YourWebHookURL"

local payload = "Test"

local respback = { }

local res, code, response_headers, status = http.request

{

url = siteurl,

method = "POST",

headers =

{

["Content-Type"] = "application/json",

["Content-Length"] = payload:len()

},

source = ltn12.source.string(payload),

sink = ltn12.sink.table(respback)

}

-------------------------------------------------------

DRAGON 1-3 | Raptor [i7-7700K OC 5 GHz CPU | 32 GB DDR4 RAM | RTX 2070S GPU w/ 4GB]

Link to comment
Share on other sites

Thanks Pikey, interesting. Gives me ideas ^^

Zip - VEAF :pilotfly:

 

If you want to learn, talk and fly with french-speaking friends, the Virtual European Air Force is here for you ! Meet us on our Discord and our forum

If you're a mission creator, you may want to check the VEAF Mission Creation Tools (and its GitHub repository) a set of open-source scripts and tools that make creating a dynamic mission a breeze !

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

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