Discord Webhook error

local module = {}
local httpService = game:GetService("HttpService")

module.sendMessage = function(webhook, message)
    local post = {["content"] = message}
	httpService:PostAsync(webhook,httpService:JSONEncode(post))
end

Can you show Line 13 which is where the error is occuring?

thats this line

httpService:PostAsync(webhook,httpService:JSONEncode(post))

Are you using a proxy of some sort?

In the module script:

local module = {}
local httpService = game:GetService("HttpService")

module.Webhooks = {
	Development = "https://hooks.hyra.io/api/webhooks/xxxxxxxxxxxxxxx/xxxxxxxxxxxxxx";
}


module.sendMessage = function(webhook, message)
	local post = {["content"] = message}
	httpService:PostAsync(webhook,httpService:JSONEncode(post))
end

return module

in the normal script:

webhookService:sendMessage(webhookService.Webhooks.Development, "tekst")

This works perfectly fine for me.
image

Are HTTP requests on in your game settings?

Yes this is on. I am stuck with it.

Are you using require() properly in the server script?

local module = require(game.ReplicatedStorage.ModuleScript)

I’ve just searched up this error and basically, it’s that “you have to specify that you’re using an external resource”. In your case it might be replacing https:// by http://

Yes. Because he run the code until the :PostAsync, then a get the error.

I’ve found the issue, replace the : in the server script with a . when calling sendMessage.

module.sendMessage(module.Webhooks.Development, "Testing!") 

I tried still get the error.
It’s weard.

I tried this to. I still get the same error over and over again.

Wrap this in a pcall() like this and tell if you get any errors.

module.sendMessage = function(webhook, message)
	local post = {["content"] = message}
	
	local success, err = pcall(function()
		httpService:PostAsync(webhook,httpService:JSONEncode(post))
	end)
	
	if success then
		print("success")
	else
		print(err)
	end
end

I get the error HttpService is not allowed to access ROBLOX resources.

Could you try replacing your current proxy with webhook.newstargeted.com? You should give it a shot and check other webhooks and if they work.

Still getting the same error. I changed the webhook, still not work.

function module.Send(webhook, message:string)
	local toSend = {["content"] = message}
	print(toSend)
	
	local data = httpService:JSONEncode(toSend)
	
	local success, err = pcall(function()
		httpService:PostAsync(webhook, data)
	end)
end

If this fails, it must be the proxy or the webhook is inputted incorrectly.

It works, thank you! Thank you all for you’re time. :heart:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.