使用 Lua 向 Discord Webhook 发送消息

所以我尝试在 Lua 中向 Discord Webhook 发送消息。

目前我的代码是这样的:

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

local payload = [[ {"username":"用户名","avatar_url":"","content":"消息内容"} ]]

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),
}

我在这里找到了这个代码:http://forum.micasaverde.com/index.php?topic=32035.0

但是消息从未到达。我做错了什么?

编辑:我进行了一些测试,当我将此消息发送到 Discord Webhook 时,似乎我得到了一个 301 错误代码。

点赞