Sending a message to discord webhook with lua

Viewed 6179

So I am trying to send a message to a discord webhook in Lua.
Currently I have this code:

local http = require("socket.http")
ltn12 = require("ltn12")

local payload = [[ {"username":"NAME","avatar_url":"","content":"MESSAGE"} ]]

http.request
{
    url = "https://discordapp.com/api/webhooks/<redacted>",
    method = "POST",
    headers =
    {
        ["Content-Type"] = "application/json",
        ["Content-Length"] = payload:len()
    },
    source = ltn12.source.string(payload),
}

That I found here: http://forum.micasaverde.com/index.php?topic=32035.0
But the message never arrives. What am I doing wrong?

Edit: I tested a bit and it seems like I get a 301 error code when I send this to the discord webhook.

0 Answers
Related