Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Not able to send variables through PostAsync Discord webhook?

Asked by 3 years ago
Edited 3 years ago

This is my code. I have no idea why it ain't working.

local main = script.Parent.Parent

script.Parent.MouseButton1Down:Connect(function()
    local http = game:GetService("HttpService")
    local rank = main.First.Rank.Text
    local username
    local priority = tostring(main.Priority.Value)
    local number = tostring(main.Second.Num.Text)
    local reason = tostring(main.Second.Rea.Text)
    local Data = {
        username..", "..rank.." has sent a priority "..priority.." back-up request. "..number.." personnel members are requested for the following reason: "..reason;
    }

    Data = http:JSONEncode(Data)
    http:PostAsync("https://discordapp.com/api/webhooks/...", Data)
end)
0
is this a local script? You must post requests on the server, not on the client. Use RemoteEvents for communication. Your [Data] also makes no sense, you need to send what discord requires for it's embed, in your case you need to specify [content] inside of the table, not just send a string. imKirda 4491 — 3y
0
Take a look here: https://discord.com/developers/docs/resources/webhook, scroll down to [Execute] method, it shows exactly what discord webhook requires. imKirda 4491 — 3y
0
@imKirda No, it is a serverscript. I still cannot figure out how that works. Would you help me? Fixer1987 95 — 3y

1 answer

Log in to vote
0
Answered by
LuiOG 0
3 years ago

do something like

local Data = {
    ["content"] = "msg content",
    ["title"] = "msg title"
}
Data = http:JSONEncode(Data)
http:PostAsync("webhook url", Data)

etc

this should work

0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
View all comments (9 more)
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
0
It didn't, the content still won't read my variables. Fixer1987 95 — 3y
Ad

Answer this question