Discord Webhook Not Working

So, I’m trying to make a button that makes a discord webhook send a message but it’s not working.

local deebee = false
script.Parent.MouseButton1Click:Connect(function()
	if deebee == false then
		deebee = true
		local webhookUrl = "https://discordapp.com/api/webhooks/Your Webhook"
		local contentData = {
			["content"] = script.Parent.Parent.Parent.Parent.Title.SurfaceGui.Text.Text.."\n"..script.Parent.Parent.Parent.Parent.Desc.SurfaceGui.TextBox.Text,
		}
		local http = game:GetService("HttpService")
		local sentData = http:JSONEncode(contentData)
		http:PostAsync(webhookUrl, sentData)
		wait(100)
		deebee = false
	end
end)

The error you get is HTTP 400 (Bad Request)

2 Likes

image
This is the screenshot. (By the way, the script is OPS)

Discord blocks Roblox requests. I don’t exactly know why, but don’t go for any work arounds like using another website’s webhook, since using their’s can be dangerous. There is no way to get communication from your game to you unless you somehow make your own secure website which can take a while to learn.

they blocked roblox requests for a few reasons, one of which is webhook abuse I believe, such as using discord as an error logger

Are you sure that the string in the “content” parameter is not empty? Discord doesn’t allow empty messages to be sent.

And 400 means bad request which is a status code to tell that the data you provided is invalid and not that you do not have authorization, in the second case it would either be 401 or 403

When I fill it in it still errors.

You can’t send http requests to discord’s servers on Roblox since it is blocked. Instead set up a proxy or using a pre-existing proxy.

Can I have an example from you? I am confused.

You can host your own proxy using proxyservice.

Or you can use a pre-existing one, like hooks.hyra.io. which i do not recommend solely because the former is a better choice.

2 Likes

Thank you so much! This is really helpful.