The error im getting is:
https://roblox.com/thumbnail/avatar-headshot/?userId=PlayerUserId: Trust check failed
Is there any way to fix that? It supposed to get roblox avatar for discord webhook.
The error im getting is:
https://roblox.com/thumbnail/avatar-headshot/?userId=PlayerUserId: Trust check failed
Is there any way to fix that? It supposed to get roblox avatar for discord webhook.
You can’t use httpservice to make requests to roblox. Use this:
https://developer.roblox.com/en-us/api-reference/function/Players/GetUserThumbnailAsync
Using this way causes HTTP error 400 (Bad Request)
It works for me, can you show me the code? 400 is a user error.
local message = ""
local Username = ""
local avatar_url = ""
if msg == nil then
return
else
message = filter(msg, plr)
end
if plr == nil then
return
else
Username = plr.DisplayName.." (@"..plr.Name..")"
avatar_url = "https://roblox.com/thumbnail/avatar-headshot/?userId="..plr.UserId
end
local data = {
["embeds"] = {
{
["title"] = plr.DisplayName.." ( @"..plr.Name.." )";
["description"] = message;
["thumbnail"] = avatar_url
}
};
["name"] = "Logger";
}
print(data)
local dat = http:JSONEncode(data)
return dat
There’s no http requests in the code you showed. The error is happening at line 46.
if script.Parent.Toggle.Value == true then
local topost = createmsg(msg, plr)
http:PostAsync(webhook, topost)
end
Without thumbnail part it works perfectly. but with UserGetThumbnailAsync and roblox.com/thumbnail it shows this error
Can you just show the whole script, but obviously remove the webhook. From the code that you’ve sent I can’t see exactly what’s wrong. I think it’s because discord expects an object for a thumbnail and “username” instead of “name”, so try this:
local data = {
["embeds"] = {
{
["title"] = plr.DisplayName.." ( @"..plr.Name.." )";
["description"] = message;
["thumbnail"] = {
["url"]=avatar_url
}
}
};
["username"] = "Logger";
}
local webhook = “Something”
local http = game:GetService(“HttpService”)
function filter(msg, plr)
local filterd = game.Chat:FilterStringForBroadcast(msg, plr)
return filterd
end
function createmsg(msg, plr)
local message = “”
local Username = “”
local avatar_url = “”
if msg == nil then
return
else
message = filter(msg, plr)
end
if plr == nil then
return
else
Username = plr.DisplayName.." (@"..plr.Name..")"
avatar_url = "https://roblox.com/thumbnail/avatar-headshot/?userId="..plr.UserId
end
local data = {
["embeds"] = {
{
["title"] = plr.DisplayName.." ( @"..plr.Name.." )";
["description"] = message;
["thumbnail"] = {
["url"] = avatar_url
}
}
};
["name"] = "Logger";
}
print(data)
local dat = http:JSONEncode(data)
return dat
end
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if script.Parent.Toggle.Value == true then
local topost = createmsg(msg, plr)
http:PostAsync(webhook, topost)
end
end)
end)
Discord blocked roblox webhooks, that is why.
I CAN send messages by webhook, but it shows an error with avatar url
That is due to roblox studio using your engine.
Try playing on the actual game.
Here try this:
local webhook = "Something"
local http = game:GetService("HttpService")
function filter(msg, plr)
local filterd = game.Chat:FilterStringForBroadcast(msg, plr)
return filterd
end
function createmsg(msg, plr)
local message = ""
local Username = ""
local avatar_url = ""
if msg == nil then
return
else
message = filter(msg, plr)
end
if plr == nil then
return
else
Username = plr.DisplayName .. " (@" .. plr.Name .. ")"
avatar_url = "https://www.roblox.com/headshot-thumbnail/image?userId="..plr.UserId.."&width=150&height=150&format=png"
end
local data = {
["embeds"] = {
{
["title"] = plr.DisplayName .. " ( @" .. plr.Name .. " )",
["description"] = message,
["thumbnail"] = {
["url"] = avatar_url
}
}
},
["username"] = "Logger"
}
print(data)
local dat = http:JSONEncode(data)
return dat
end
game.Players.PlayerAdded:Connect(
function(plr)
plr.Chatted:Connect(
function(msg)
if script.Parent.Toggle.Value == true then
local topost = createmsg(msg, plr)
http:PostAsync(webhook, topost)
end
end
)
end
)
Also while what morning said is true you can’t post to webhooks directly from roblox, but you can use a proxy.
Thanks, it works but is there any way to move avatar icon to right in embed?