HTTP 400 (Bad Request) Discord API

This script basically logs every player data in the server to a discord channel over (player amount x 30 seconds) for every (5 minutes + (player amount x 30 seconds)). For some reason, I keep getting the error and I am not sure how to fix it. I already tried changing the webhooks and URL. Please help. Thanks!

SCRIPT:

local hs = game:GetService("HttpService")
local url = "https://discord.com/api/webhooks/839604836215029831/A-CI9gpPo8QeHgWpHxGDQk69Xs9EpDe27s06JsRESYKEzsr9kdzXjIivtGRDTdK1f5ER" -- THIS WEBHOOK URL IS ALREADY DELETED
local function StatsLogger(Plr)
	local Msg = string.format("**User `%s (%i)` | Lvl `%s` | EXP `%i` | Coin `%i` | Diamond `%i`**",
		Plr.Name,
		Plr.UserId,
		Plr.Status2.Lvl.Value,
		Plr.Status2.EXP.Value,
		Plr.Status2.Coin.Value,
		Plr.Status2.Diamond.Value
	)
	local embeds = {{fields = {}, author = {name = "Go to profile", url = "https://roblox.com/users/"..Plr.UserId.."/profile"}}}
	local current = embeds[1].fields
	for _, Item in pairs(Plr.Items:GetChildren()) do
		local field = {name = Item.Name, value = tostring(Item.Value), inline = true}
		if #current == 25 then
			if #embeds == 10 then
				Msg = Msg.."\n**ERROR ERROR ERROR ERROR ERROR ERROR**"
				break
			else
				embeds[#embeds + 1] = {fields = {}}
				current = embeds[#embeds].fields
			end
		end
		current[#current + 1] = field
	end
	local myTable = {
		content = Msg,
		username = Plr.Name .. " (" .. Plr.UserId .. ")",
		avatar_url = game:GetService("Players"):GetUserThumbnailAsync(Plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100),
		embeds = embeds
	}
	hs:PostAsync(url, hs:JSONEncode(myTable))
	current = nil
	embeds = nil
end

math.randomseed(tick())
while wait(300) do
	for _, child in pairs(game.Players:GetPlayers()) do
		StatsLogger(child)
        wait(30)
	end
end
1 Like

Can anyone please help with this? Bump.

GetUserThumbnailAsync returns a rbxthumb:// content type which only roblox recognizes. You would probably need to use the thumbnail api to get the web thumbnail url

1 Like