So, im working on a thing with webhooks sending a embed to discord, but i cant seem to get the thumbnail working, getting the player avatars headshot picture on the embed
heres the code-
local HttpService = game:GetService('HttpService')
local url = "https://discord.com/api/webhooks/..."
local PictureUrl = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
local data =
{
["embeds"] = {{
["title"] = player.Name,
["color"] = tonumber(0xffffff),
["thumbnail"] = PictureUrl,
["fields"] = {
{
["name"] = "Mesage",
["value"] = text,
},
}
}}
}
local newdata = HttpService:JSONEncode(data)
HttpService:PostAsync(url, newdata)
it throws an error - HTTP 400 (Bad Request)
any help would be appreciated
This answer may help you. I think you are missing the correct formatting for sending a discord webhook.
There’s also this module if you want to use it!
You need to use the roblox API to get the link to the image itself, I used a proxy (roproxy) since roblox forbids using its api in the game.
Example:
local HttpService = game:GetService('HttpService')
local url = "https://discord.com/api/webhooks/..."
local s, PictureUrl = pcall(function()
return HttpService:JSONDecode(HttpService:GetAsync("https://thumbnails.roproxy.com/v1/users/avatar-headshot?userIds="..player.UserId.."&size=150x150&format=Png")) --use api and proxy to get LINK, you can change size
end)
if s and PictureUrl then
PictureUrl=PictureUrl.data[1].imageUrl
else
PictureUrl="https://t3.rbxcdn.com/9fc30fe577bf95e045c9a3d4abaca05d" --link if can't get player headshot (default img)
end
local data =
{
["embeds"] = {
["title"] = player.Name,
["color"] = tonumber(0xffffff),
["thumbnail"] = {
["url"] = PictureUrl
},
["fields"] = {
{
["name"] = "Message",
["value"] = text,
},
}
}
}
local newdata = HttpService:JSONEncode(data)
HttpService:PostAsync(url, newdata)