Webhook Discord embed wont work

function filteringFunction.OnServerInvoke(player, msg)
	local payload = HTTP:JSONEncode({
		--content = CHAT:FilterStringForBroadcast(msg,player),
		--username = player.Name.." - (#"..player.UserId..")"
		data =
			{
				["content"] = '',
				["embeds"] = {{
					["title"] = "Feedback:",
					["description"] = msg,
					["type"] = "rich",
					["color"] = tonumber(0xffffff),
					["fields"] = {
						{
							["name"] = "Username: "..player.Name,
							["value"] = "Player ID: "..player.UserId,
							["inline"] = true
						}
					}
				}}
			}
		})
	
	HTTP:PostAsync(webhook, payload)
	return "Feedback recieved!"
end

I get a HTTP 400 bad request when I do this, I don’t know what I’m doing wrong, I don’t work with HTTP much.

4 Likes

remove content Discord Developer Portal — Documentation — Webhook

1 Like

I tried it and it still gave the same error

1 Like

why are nesting tables like that?

try to make it simpler to read, i cant understand it that well
get a youtube video and remake the webhook
the reason its http 400 bad request is possibly because the data isnt formatted correctly

function filteringFunction.OnServerInvoke(player, msg)
	local payload = HTTP:JSONEncode({
				["content"] = 'some',
				["embeds"] = {{
					["title"] = "Feedback:",
					["description"] = msg,
					["type"] = "rich",
					["color"] = tonumber(0xffffff),
					["fields"] = {
						{
							["name"] = "Username: "..player.Name,
							["value"] = "Player ID: "..player.UserId,
							["inline"] = true
						}
					}
				}}
		})
	
	HTTP:PostAsync(webhook, payload)
	return "Feedback recieved!"
end

try that

This is the exact same code from multiple different tutorials Like this

im working on a piece of code that will fix the problem, standby :slight_smile:

That doesn’t work either.

Extra characters

have you tried that Webhook Discord embed wont work - #6 by polloarrosto01

:white_check_mark: should be solved! :white_check_mark:
try this this code below!

:roblox_light: my first devforum solution :roblox_light:

function filteringFunction.OnServerInvoke(player, msg)
	local data = {
		["embeds"] = {{
			["title"] = "Feedback:",
			["description"] = msg,
			["type"] = "rich",
			["color"] = tonumber(0xffffff),
			["fields"] = {
				{
					["name"] = "Username: "..player.Name,
					["value"] = "Player ID: "..player.UserId,
					["inline"] = true
				}
			}
			local finalize = HTTP:JSONEncode(data)
			HTTP:PostAsync(webhook, finalize)
			return "GG, feedback received!"
end

it isn’t because you have to close ["embeds"] table with the nested table

well, all I did was simplify it. i did it my way which always succeeds