Issue with my player report command

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i want it to send the report to the webhook on the discord server
  2. What is the issue? Include screenshots / videos if possible!
    I’m having an issue getting my report player command working that well send a webhook with the reason the player was reported for but I’m getting an error saying Number of requests exceeded the limit Hers my script I take out the webhook URL because that’s private
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")

local webhookUrl = ""  
local reportCooldown = 60 
local cooldowns = {}

local function sendReportToDiscord(reporter, reportedUsername, reason)
    local data = {
        ["content"] = "",  
        ["embeds"] = {{
            ["title"] = "Player Report",
            ["description"] = "**Reporter:** " .. reporter.Name .. "\n**Reported Player:** " .. reportedUsername .. "\n**Reason:** " .. reason,
            ["color"] = 16711680,  
        }}
    }

    local headers = {
        ["Content-Type"] = "application/json"
    }

    local request = {
        Url = webhookUrl,
        Method = "POST",
        Headers = headers,
        Body = HttpService:JSONEncode(data)
    }

    HttpService:RequestAsync(request)
end

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        local args = message:split(" ")
        if args[1] == "!report" then
            local currentTime = tick()
            if cooldowns[player.UserId] and currentTime - cooldowns[player.UserId] < reportCooldown then
                player:SendNotification({
                    Title = "Cooldown Active",
                    Text = "Please wait before sending another report.",
                    Duration = 5
                })
                return
            end

            if #args >= 3 then
                local reportedUsername = args[2]
                local reason = table.concat(args, " ", 3)

                sendReportToDiscord(player, reportedUsername, reason)
                cooldowns[player.UserId] = tick()
                player:SendNotification({
                    Title = "Report Sent",
                    Text = "Your report has been sent to the staff.",
                    Duration = 5
                })
            else
                player:SendNotification({
                    Title = "Invalid Command",
                    Text = "Usage: !report <username> <reason>",
                    Duration = 5
                })
            end
        end
    end)
end)

What’s the webhook URL look like? (You can remove the actual UUID part of it, but what is the domain and stuff?)

Here is what it looks like (https://discord.com/api/webhooks/1324913084921286697/)

The issue here is very simple - Discord doesn’t directly allow requests from Roblox due to the number of requests it receives from the platform. To mitigate this, you’ll need to use a proxy so you can request the webhook URL without directly sending to Discord from Roblox.

To do this, you can use a service created by @lewisakura which is free to use - if you experience Error Code 429 during your use of the service, it means your scripts are sending too many requests to the proxy. More information on the proxy can be found here!

To use the proxy, you simply replace discord.com with webhook.lewisakura.moe - this should leave your webhook URL looking similar to the following:

https://webhook.lewisakura.moe/api/webhooks/LONGSTRINGOFINTEGERS/

Discord blocks all calls to its apis from Roblox servers, so you need to instead make use of a proxy.

so it made it work a few times then it went back to giving the same error

That means you’re making too many calls. In this case you must add a pcall to prevent errors and you should try minimising the amount of reports being made.