I’m attempting to build up a webhook for Discord, but I’m unable to get any player’s headshot link.
I tried using the Roblox API, but it simply gives me an error. I tried using GetUserThumbnailAsync, but it just gives me a rbxthumb link. I searched the developer forum but came up with nothing.
I’ve heard that node.js servers and proxies can be used to access the Roblox API, but I’m not sure how to set them up.
Assuming that you’ve already got a proxy set up since you’re sending requests to Discord’s /webhooks/{webhook.id}/{webhook.token} endpoint, you can use that proxy to also get thumbnails from Roblox’s API.
-- You can change the size query to that of your choosing, as long as Roblox
-- supports it.
local HeadshotThumbnailUrl = "https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds=%d&size=150x150&format=Png&isCircular=false"
-- The "Proxy" value is assumed to be an instance of your proxy, and its
-- :Get() method used for executing GET requests.
-- Assume we have a Player instance from somewhere.
local response = Proxy:Get(HeadshotThumbnailUrl:format(player.UserId))
-- { data: [ { imageUrl: string } ] }
local headshotUrl = HttpService:JSONDecode(response).data[1].imageUrl
print(headshotUrl)
local httpService = game:GetService("HttpService")
local URL = "https://thumbnails.roproxy.com/v1/users/avatar-headshot?userIds=%s&size=150x150&format=Png&isCircular=false"
local userID = 0000
local response
local data
local success, err = pcall(function()
response = httpService:GetAsync(URL:format(userID))
end)
if not success then
print(err)
else
data = httpService:JSONDecode(response).data[1].imageUrl
print(data)
end