Need help with discord api

i have an error : HTTP 400 (Bad Request) and really i don’t know how to fix it
I’ve been blowing my brains out for 3 hours already, but I really can’t find the mistake, could someone help me?

http = game:GetService("HttpService")

game.ReplicatedStorage.ReportEvent.OnServerEvent:Connect(function(executor)


local Data = {
	    {
        ["content"] = "",
        ["embeds"] = {{
            ["author"] = {
	            ["name"] = "By YaK Studio",
	            ["icon_url"] = "https://i.imgur.com/HnwY5lx.png",
	            ["image"] = "https://i.imgur.com/HnwY5lx.png",
        	 },

            ["title"] = "PSS - Report Log",
            ["description"] = "**A player got reported**",
            ["type"] = "rich",
            ["color"] = tonumber(11675437),
            
            ["fields"] = {
                {
                  ["name"] = "Field 1",
                  ["value"] = "Field 1",
                  ["inline"] = false
                },
                {
                 ["name"] ="**By Who**",
                ["value"]= executor.Name.." / ".."https://www.roblox.com/users/"..executor.UserId.."/profile",
                ["inline"] = false
               },
                {
                  ["name"] ="**Game Name**",
                  ["value"] = "GameName",
                  ["inline"] = false
                },
                {
                  ["name"]= "**ServerId**",
                  ["value"] = "game.JobId,
                  ["inline"] = false
                },
                {
                  ["name"] = "Date",
                  ["value"] = "after",
                  ["inline"] = false
                }
            },
          ["thumbnail"] = {
               ["url"] = "https://i.imgur.com/HnwY5lx.png",
           }
        }},
       ["username"] = "Test",
        ["avatar_url"] = "https://i.imgur.com/HnwY5lx.png",
    }
}

Data = http:JSONEncode(Data)

http:PostAsync("my webhook", Data)
end)

thanks

2 Likes

First you forgot an apostrophe on the 4th field:

                {
                  ["name"]= "**ServerId**",
                  ["value"] = "game.JobId,
                  ["inline"] = false
                },
1 Like

Wow…i think i didn’t saw it because i’m too tired

and thank you

2 Likes

Na it’s still don’t work

same error same line

at the line : http:PostAsync(“webhook”, Data)

but i checked and there is no error at this line

It means when you encode it, there is some lines that is invalid to JSON. You can print the encoded data first and see if something is missing.

ok, really i saw nothing wrong, do you think i did a very small error?

print the json at the line before it’s posted and check if it’s formatted correctly.

Also, What is the exact error outputted?

EDIT: Looking back over your code, im not sure if this could be the issue, however, This line might be breaking it.

[“color”] = tonumber(11675437),

It’s already a number so i don’t see the need of using the “tonumber” api for it either.

tonumber works on numbers, too, it’s just redundant.
image

2 Likes

I know, i was just thinking it could mess it up during encoding to JSON

@Yuna_Bikusen your Discord account can be terminated if you use
webhook with roblox, Discord do not like it, you can ask to Discord admin

i found the error it come from “game.JobId”

Really? Why, exactly? I didn’t know about this… Well the thing that Discord is for +13 years I knew, but that you can lose an account by doing so… Why exactly if it is possible to explain (from your point of view)?

Make sure Http requests are enabled in settings and your [‘content’] cannot be an empty string

Na you can lose if :

  • You send a webhook when a user join

  • with hight trafic on your game

2 Likes

Don’t worry i fixed the problem^^ :smile:

Oh OK good thing you fixed the problem and I have to write 30 chars