When I execute this script! Its the pcall function prints the error “HTTO 400 (Bad Request)”.
Can someone please help?
Thank you.
local function send(player, text, serverId)
local HS = game:GetService("HttpService")
local WebhookLink = "https://discordapp.com/api/webhooks/........"
local tempdata = {
["content"] = "",
["embeds"] = {{
["title"] = ":bangbang: New Modcall :bangbang:",
["type"] = "rich",
["color"] = tonumber(0xf44336),
["fields"] = {
{
["name"] = "**Player**",
["value"] = string.format("%s | %s", player.Name, player.UserId)
},
{
["name"] = "**Reason**",
["value"] = text,
},
{
["name"] = "**Server ID**",
["value"] = serverId,
}
}
}}
}
local jsonData = HS:JSONEncode(tempdata)
local Success, Failure = pcall(function()
HS:PostAsync(WebhookLink, jsonData)
end)
if not Success then
warn(Failure)
end
end
game.ReplicatedStorage.ModCall.sendEmbed.OnServerEvent:Connect(send)
1 Like
MMCraftin
(MMCraftin)
May 14, 2021, 5:42pm
#2
The code here should be working can I see the client script that is firing the remote?
There are a lot of similar topics to this, Maybe you could find an answer here.
I’ve seen people implemented this Webhook from Discord. seems useful to me. But I got this error stated as the title of this topic. did search it on this forum most of them are due to their own mistakes which is not the same as mine… please help, i cant identify the problem…
Edit: Just in case some may asked, I did try to print every variables that i throw in the webhook. All of them works.
local data = {
{
["embeds"]= {
["title"] = "Big Test",
["description"] = player.Name ..…
whatever I do, it doesn’t work anyway, I checked everything about 30 times and it still shows me an HTML 400 error.
Code:
local HttpData = {
embeds = {
{
title = "A Secret weapon was earned!",
color = 16720621,
fields = {
{
name = "Player",
value = "1",
inline = true
},
{
name = "Weapon",
value = "2",
inline = true
},
{
name = "Rarity",
value = "3",
inline = true
}
},
thumbnail = {
…
so this webhook fires when a player redeems a valid code.
[image]
here’s the code redeeming script (Local), it works.
[image]
and this is where the error is: (server script in sss)
local https = game:GetService("HttpService")
local WebHook = --LINK--
local Event = game.ReplicatedStorage.Reward
local codeReward = 50
Event.OnServerEvent:Connect(function(player, code)
print("Code Worked!")
player.Settingsfolder.credits.Value += codeReward
player.PlayerGui.Menus.Credits.ShopBG.creditsval…
I would suggest trying to make everything a string, except if its a bool.
1 Like
Sure:
script.Parent.modcall.TextButton.MouseButton1Click:Connect(function()
local text = ""..script.Parent.modcall.TextBox.Text
local serverId = nil
if RS:IsStudio() then
serverId = "N/A (Sent from Roblox Studio)"
else
serverId = tostring(game.JobId)
end
game.ReplicatedStorage.ModCall.sendEmbed:FireServer(Player, serverId, text)
end)
heII_ish
(heII_ish)
May 16, 2021, 5:12pm
#5
The Player argument is automatically included on the server, you don’t need to pass it in FireServer. Also your order of parameters is messed up, on the client you have serverId, text
and on the server you have text, serverId
1 Like