HTTP 400 (Bad Request)?

I’m attempting to try and log the bans for my admin gui, why is this error happening?

-- self explanatory, bans the player
function BanModule:BanPlayer(player, reason, staff)	
	local success, result = pcall(function()
		return Players:GetUserIdFromNameAsync(tostring(player))
	end)
	
	if success then
		local PlayerToBan = Players:GetPlayerByUserId(result)
		local data = StatsManager:GetData(PlayerToBan)
		
		if data.IsBanned == false then
			data.IsBanned = true
			data.BanReason = reason
			data.BannedByWho = staff.Name
			PlayerToBan:Kick(string.format("\n\nYou've been banned for the reason: \n\n" .. data.BanReason))
		
			local AvatarThumbnail = string.format(Format, result)
			local TimeFormat = os.date("%I:%M | %x")
			local data = {
				["embeds"] = {
					["author"] = {
						["name"] = PlayerToBan.Name;
						["icon_url"] = AvatarThumbnail
					};

					["title"] = "A player has been banned.";
					["description"] = PlayerToBan.Name .. " has been banned.";
					["type"] = "rich";
					["fields"] = {
						{
							["name"] = "Username";
							["value"] = "[Click to visit player profile](https://www.roblox.com/users/" .. result .. "/profile)";
							["inline"] = true
						};
						
						{
							["name"] = "UserID";
							["value"] = result;
							["inline"] = true
						};
						
						{
							["name"] = "Time";
							["value"] = TimeFormat;
							["inline"] = true
						}
					}
				}
			}
			
			local FinalizedData = HttpService:JSONEncode(data)
			HttpService:PostAsync(Webhook, FinalizedData)
		else
			return false
		end
	else
		error("There was an error fetching the UserId from a user's username: " .. result)
	end
end

Because roblox got blocked by cloudflare (discord uses cloudflare which helps in making the website safe from DDoS, it basically blocks the IP that is sending alot of requests.)
You can use proxy.

local webhookUrl = "https://discord.com/api/webhooks/952195912/lalalwfjwoaifjwa"
webhookUrl = webhookUrl:gsub("discord.com","hooks.hyra.io")

-- Code here
1 Like

I’ve used the proxy that you’ve provided but it’s still giving me the same error HTTP 400 (Bad Request)

I’ve found the problem myself. Apparently you had to add another table inside ["embeds] like this:

local data = {
				["embeds"] = {
					{
						["author"] = {
							["name"] = PlayerToBan.Name;
							["icon_url"] = AvatarThumbnail
						};

						["title"] = "A player has been banned.";
						["description"] = PlayerToBan.Name .. " has been banned.";
						["type"] = "rich";
						["fields"] = {
							{
								["name"] = "Username";
								["value"] = "[Click to visit player profile](https://www.roblox.com/users/" .. result .. "/profile)";
								["inline"] = true
							};

							{
								["name"] = "UserID";
								["value"] = result;
								["inline"] = true
							};

							{
								["name"] = "Time";
								["value"] = TimeFormat;
								["inline"] = true
							};

							{
								["name"] = "Banned by";
								["value"] = data.BannedByWho;
								["inline"] = true
							}
						}
					}
				}
			}