Hello, I am trying to implement a simple system that send data to a Discord webhook using HTTP service, I made a queue system that send data every 10 sec (if there is any data), it work perfectly fine in studio but in live servers it keep telling me “HTTP 429 (Too many requests)”, I am barely sending a request once in a day, it doesn’t always happen but it’s about 90% of the time when I try in live servers.
I read Discord documentation about their API rate limit and it’s apparently about 50 request per second. Here is the part of my code that send the POST request :
local LuaJSON = {
content = nil,
embeds = {
{
title = PlrUser.." ("..PlrDisplay..")".." has sent a feedback!",
description = Message,
color = 8182527,
author = {
url = "https://www.roblox.com/users/"..Player.UserId.."/profile",
name = PlrUser,
icon_url = ThumbnailURl
},
timestamp = get_utc_timestamp()
}
},
attachments = {}
}
local Success, Result = pcall(function()
HTTP:PostAsync(WebhookURL, HTTP:JSONEncode(LuaJSON), Enum.HttpContentType.ApplicationJson)
end)
if not Success then
warn(Result)
end
I don’t get it, if anyone is able to help me, I’d be very thankful!
In my opinion this just seems way too overcomplicated, no need to make a queue and check it every 10 seconds, Just send the data straight away without putting into a queue.
If this is hooked up to some feedback system for players (which this looks like it is) you could also add rate limiting to stop players spamming the webhook.
Hey, this might sound a bit strange but, you can use RequestAsync instead of PostAsync to get around this.
Here’s how your code would look:
local LuaJSON = {
content = nil,
embeds = {
{
title = PlrUser.." ("..PlrDisplay..")".." has sent a feedback!",
description = Message,
color = 8182527,
author = {
url = "https://www.roblox.com/users/"..Player.UserId.."/profile",
name = PlrUser,
icon_url = ThumbnailURl
},
timestamp = get_utc_timestamp()
}
},
attachments = {}
}
local requestData = {
Url = WebhookURL,
Method = "POST",
Headers = {
["Content-Type"] = "application/json"
},
Body = HTTP:JsonEncode(LuaJSON)
}
local Success, Result = pcall(function()
HTTP:RequestAsync(requestData)
end)
if not Success then
warn(Result)
end
This is the solution that worked for a project I contributed to, and I was hitting Roblox’s rate limits first before Discord sent a 429 after switching over to RequestAsync. Let me know if this solves your issue.
Basically it put every message in a queue and send them every X seconds (In my case I put 10), the player can only send a request every 2 second (however this can be exploited since it’s handled on client, the webhook is entirely handled on server with sanity checks)