Hi, I’m trying to get an image from a badge and turn the webhook to the image of the badge. I’m using discord for this and I’m not having a lot of luck. Here’s the current script:
local url = "test" --- I didn't want to leak the webhook
local h = game:GetService("HttpService")
while true do
local badge = math.random(2124451678, 2124451678) ---Insert Random Numbers Here
local data = {
['embeds'] = {{
['title'] = "Badge Bot",
['description'] = "https://roblox.com/badges/"..badge,
['color'] = 6008455,
}}
}
local finaldata = h:JSONEncode(data)
h:PostAsync(url, finaldata)
wait(100)
end
I’m currently aware that discord in the past blocked requests from Roblox. If you know how please tell me, thanks.
As stated in the Discord api-reference for webhooks, there’s a avatar_url field. Simply assign that field to a string containing a url of the badge’s icon.
ie.
local badge_icon_id = 1;
local data = {
username = "ReturnedTrue",
avatar_url = "https://www.roblox.com/asset?id=" .. badge_icon_id,
embeds = {{
title = "Special Message",
description = "Hello, World!",
color = 6008455
}}
};
Note that the rbxassetid:// protocol will not work outside of Roblox, hence the website API must be utilised.
FYI: if you find issues with getting the badge’s icon id, see GetBadgeInfoAsync.
local url = "webhook"
local h = game:GetService("HttpService")
while true do
local badge = math.random(2124449010, 2124459010) ---Insert Random Numbers Here
local icon = game:GetService("BadgeService"):GetBadgeInfoAsync(badge).IconImageId
local data = {
['embeds'] = {{
['title'] = "Badge Bot",
['description'] = 'https://roblox.com/badges/'..badge..'',
['avatar_url'] = "https://www.roblox.com/asset?id="..icon,
}}
}
local finaldata = h:JSONEncode(data)
h:PostAsync(url, finaldata)
wait(30)
end
Did I do anything wrong here? It still won’t change the avatar profile image
local data = {
['avatar_url'] = "https://www.roblox.com/asset?id="..icon,
['embeds'] = {{
['title'] = "Badge Bot",
['description'] = 'https://roblox.com/badges/'..badge..'',
}}
}
Full script:
local url = "webhook"
local h = game:GetService("HttpService")
while true do
local badge = math.random(2124449010, 2124459010) ---Insert Random Numbers Here
local icon = game:GetService("BadgeService"):GetBadgeInfoAsync(badge).IconImageId
local data = {
['avatar_url'] = "https://www.roblox.com/asset?id="..icon,
['embeds'] = {{
['title'] = "Badge Bot",
['description'] = 'https://roblox.com/badges/'..badge..'',
}}
}
local finaldata = h:JSONEncode(data)
h:PostAsync(url, finaldata)
wait(30)
end
Yes, most definitely! However, you must use a proxy (ie. rprxy.xyz) since you’ll be sending a request to a Roblox domain.
All you need to do is send a GET request to the thumbnail web API and it’ll return a response with a JSON body (as a string) which can be decoded into a Lua table via JSONDecode. The table will include a data array which includes all the badge thumbnails requested.
For example:
local http_service = game:GetService("HttpService");
local badge_id = 2124449010;
local response = http_service:RequestAsync({
Url = "https://thumbnails.rprxy.xyz/v1/badges/icons?badgeIds=" .. badge_id .. "&size=150x150&format=Png&isCircular=true",
Method = "GET",
Headers = {
Accept = "application/json" --// You want JSON data
}
});
if (response.Success) then --// Occasionally can fail
local body = http_service:JSONDecode(response.Body);
local thumbnail = body.data[1].imageUrl;
--// Code
else
--// Handle for issues
end