Hey! I am attempting to make a feedback system that sends a message to a channel in a Discord server when a user presses a button in game. I have my webhook set up and managed to send a message to the server via a server script. However I’m having trouble when sending a message to the server by pressing a text button.
What I am doing is firing a remote event from the client to the server that contains the link key thing for the webhook and then the message to send. Whenever I press the button, I get the error “Trust check failed.”
Here is my local script code: (in the text button)
local http = game:GetService("HttpService")
local Data = {
["content"] = "Hey! This is a message sent from roblox!"
}
Data = http:JSONEncode(Data)
game:GetService("ReplicatedStorage").sendFb:FireServer("<webhook key>", Data)
My server script code:
local http = game:GetService("HttpService")
game:GetService("ReplicatedStorage").sendFb.OnServerEvent:Connect(key, data)
http:PostAsync(key, data)
end)
Sorry if I made any typos, or misspelled anything. I rewrote my code from memory on a device, but I’m pretty positive I got it right.
UPDATE
I’m still getting the error despite changing the Discord link to the proxy version.
Are you sending directly to Discord’s url? Unless they’ve changed it recently, the Roblox user-agent is blocked by Discord because of continual rate limit abuse. You’ll have to use a proxy.
Well I did this from a serverscript and it worked:
local http = game:GetService("HttpService")
local Data = {
["content"] = "This is a test message"
}
Data = http:JSONEncode(Data)
http:PostAsync("<key>", Data)
You probably ran your code in studio (which has a different UserAgent than live roblox servers) which is probably why it worked. Discord blocked roblox’s UserAgent, not roblox studio’s user agent. You’ll definitely need to use a proxy.
I personally wouldn’t recommend a feedback system from Discord primarily because that’s grounds for potential misusage. There’s the issue of Roblox potentially cracking down on you if you do not filter messages sent to Discord, as well as Discord being unhappy with your use of webhooks.
Your remotes are also relatively insecure. The only thing the client should be sending is text input. The server should be validating (and filtering) text input from the client, then sending it over.
And, to parrot several other people who posted this repeatedly for whatever reason (seriously, only one person needs to say it…), you will need to use a proxy server if you wish to use Discord webhooks, as Roblox’s UserAgent is blocked. The one Quaration replied with should work just fine for your use case (assuming that’s discord.osyr.is, I didn’t check the post).