Why isn't my Roblox -> Discord Webhook working?

Hi!

I’ve been attempting to create a logging system for my in-game anti-exploit. My goal is to send each log to discord using a webhook, but for some reason it isn’t working. It isn’t showing any error messages either.

Here is my script, obviously I censored the webhook URL.

local http = game:GetService("HttpService")

game.ReplicatedStorage.AE.OnServerEvent:Connect(function(plr, gen, reason)
   local Data = {
   	["content"] = "**Anti-Exploit report from"..game.Name;
   	["embed"] = {
   		["Title"] = "__Anti-Exploit Report__";
   		["Description"] = "An AE report has been received on"..game.Name.."today.";
   		["type"] = "rich";
   		["color"] = tonumber(0xb40000);
   		["fields"] = {
   			{
   				["name"] = "**Reported User: **",
   				["value"] = plr.Name,
   				["inline"] = true
   			},
   			{
   				["name"] = "**Time: **",
   				["value"] = os.time(),
   				["inline"] = true
   			},
   			{
   				["name"] = "**Reason: **",
   				["value"] = reason,
   				["inline"] = true
   			},
   			{
   				["name"] = "**Report ID: **",
   				["value"] = gen,
   				["inline"] = true
   			},
   			}
   	}
   }
   	Data = http:JSONEncode(Data)

   http:PostAsync("WEBHOOK HERE", Data)

end)

If you require any other information or scripts, please comment and let me know.

Any help is appreciated, thanks!

1 Like

Your fields are incorrect. “embed” should be “embeds”, also “embeds” should be an array of embed objects (tables) with the embed information. “Title” and “Description” should be lowercase

local Data = {
	["content"] = "**Anti-Exploit report from " .. game.Name;
	["embeds"] = {
		{
			["title"] = "__Anti-Exploit Report__";
			["description"] = "An AE report has been received on " .. game.Name .. " today.";
			["type"] = "rich";
			["color"] = tonumber(0xb40000);
			["fields"] = {
				{
					["name"] = "**Reported User: **",
					["value"] = plr.Name,
					["inline"] = true
				},
				{
					["name"] = "**Time: **",
					["value"] = os.time(),
					["inline"] = true
				},
				{
					["name"] = "**Reason: **",
					["value"] = reason,
					["inline"] = true
				},
				{
					["name"] = "**Report ID: **",
					["value"] = gen,
					["inline"] = true
				},
			}
		},
	}
}

image

2 Likes

This worked, but I’ve been receiving “Error 429” after.
The AE report’s purpose was an auto-clicker, I believe that’s the reason why I’m getting the error.
Here’s the script that fires the Remote Event:

	local plr = game.Players.LocalPlayer
		local reason = "Usage of Auto-Clicker"
		
		game.ReplicatedStorage.AE:FireServer(gen, reason)
		game.Players.LocalPlayer:Kick("Reason Removed for space")

What can I add to this script to prevent the error code?

You should add a cooldown. Error 429 means you’re getting rate-limited by discord

I’ve tried this but it didn’t work:

if tick() - last <= 0.1 then
		local plr = game.Players.LocalPlayer
		local reason = "Usage of Auto-Clicker"
		wait(1)
		game.ReplicatedStorage.AE:FireServer(gen, reason)
		game.Players.LocalPlayer:Kick("")

Any ideas?

local last = 0
AE.OnServerEvent:Connect(function()
    if tick() - last > 1 then
        last = tick()
        -- run your code
    end
end)
1 Like

Just a tip, you shouldn’t run this on the client. They can easily exploit and get around it.