How do I send images on webhooks?
local data = {
['embeds'] = {{
['title'] = "" .. plr.Name .. "",
['description'] = plr.Name .. " Has joined our games.",
["color"] = tonumber(0xFFFAFA),
['fields'] = {
{
['name'] = plr.Name .. " Account Age",
["value"] = "Account Age: " .. plr.AccountAge,
['inline'] = true
},
{
['name'] = plr.Name .. " User ID",
['value'] = plr.UserId,
['inline'] = true
}
}
}}
}
local finaldata = http:JSONEncode(data)
http:PostAsync(url, finaldata)
5 Likes
What type of image are you trying to send?
Can you be more specific? What are you trying to achieve?
A image of the players face. Like a headshot. using player:GetUserThumbnail
A image of the players face. Like a headshot. using player:GetUserThumbnail
When I was making a webhook to Discord for an application center I made it set the icon of the bot to the player’s character using this:
["avatar_url"] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username="..User.Name
Hopefully this is what you’re looking for and it works for you. If you don’t want to set the icon and you want it to be part of the embed you can just create a new field with it as the value.
You can use plr:GetUserThumbnailAsync as well if you want something more specific like a headshot.
local data = {
['embeds'] = {{
['title'] = "" .. plr.Name .. "",
['description'] = plr.Name .. " Has joined our games.",
["color"] = tonumber(0xFFFAFA),
['fields'] = {
{
['name'] = plr.Name .. " Account Age",
["value"] = "Account Age: " .. plr.AccountAge,
['inline'] = true
},
{
['name'] = plr.Name .. " User ID",
['value'] = plr.UserId,
['inline'] = true
}
},
}},
['avatar_url'] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username="..plr.Name
}
local finaldata = http:JSONEncode(data)
http:PostAsync(url, finaldata)
2 Likes
I just tried this and it didnt work
no errors or nothing
edit: this worked but im trying to just add a image in the acc webhook not the avater url
Looks similar to this one
1 Like
would this code work? we are trying to test it nothing happens.
local data = {
['embeds'] = {{
['title'] = "" .. player.Name .. "",
['description'] = player.Name .. " Has been kicked for Hitbox Extension.",
["color"] = tonumber(0xFFFAFA),
['fields'] = {
{
['name'] = player.Name .. " Account Age",
["value"] = "Account Age: " .. player.AccountAge,
['inline'] = true
},
{
['name'] = player.Name .. " User ID",
['value'] = player.UserId,
['inline'] = true
},
{
['url'] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=" .. player.Name,
}
},
}},
['avatar_url'] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=" .. player.Name,
}
you have to set it up as an image like
["image"] = {
["url"] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=" .. player.Name
}
Where will I add this may you inform me
You add it outside of the fields.
local data = {
['embeds'] = {{
['title'] = "" .. player.Name .. "",
['description'] = player.Name .. " Has been kicked for Hitbox Extension.",
["color"] = tonumber(0xFFFAFA),
['fields'] = {
{
['name'] = player.Name .. " Account Age",
["value"] = "Account Age: " .. player.AccountAge,
['inline'] = true
},
{
['name'] = player.Name .. " User ID",
['value'] = player.UserId,
['inline'] = true
},
},
["image"] = {
['url'] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=" .. player.Name,
}
}},
['avatar_url'] = "https://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=" .. player.Name,
}
Tried to customize it to what I think you were looking for.
Something like this?
Hope this helps
local data = {
["embeds"] = {{
["author"] = {
["name"] = player.Name,
["icon_url"] = game:GetService("Players"):GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150),
},
["description"] = "Kicked for hitbox extension",
["color"] = tonumber(0xFFFAFA),
["fields"] = {
{
["name"] = "Account Age",
["value"] = player.AccountAge.. " days",
["inline"] = true
},
{
["name"] = "User ID",
["value"] = player.UserId,
["inline"] = true
}
}
}},
}
local finaldata = HTTP:JSONEncode(data)
HTTP:PostAsync(HookURL, finaldata)
12 Likes
Luacrative:
local data = { [“embeds”] = {{ [“author”] = { [“name”] = player.Name, [“icon_url”] = game:GetService(“Players”):GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150), }, [“description”] = “Kicked for hitbox extension”, [“color”] = tonumber(0xFFFAFA), [“fields”] = { { [“name”] = “Account Age”, [“value”] = player.AccountAge… " days", [“inline”] = true }, { [“name”] = “User ID”, [“value”] = player.UserId, [“inline”] = true } } }}, } local finaldata = HTTP:JSONEncode(data) HTTP:PostAsync(HookURL, finaldata)
Thanks helped a lot I will be sure to use this information a lot
3 Likes
Hey there, today was my first day scripting webhooks, I tried using that code and it turns out that it doesn’t work. Do I need to change something in the “author” variable?
EDIT: changed the author thing to my discord tag and it worked, but it does not show the image. Here’s my code:
local HTTP = game:GetService("HttpService")
game.Players.PlayerAdded:Connect(function(player)
local data = {
["embeds"] = {{
["DeveloperAnirudh#0001"] = {
["name"] = player.Name,
["icon_url"] = game:GetService("Players"):GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150),
},
["description"] = "Player joined the game!",
["color"] = tonumber(0xFFFAFA),
["fields"] = {
{
["name"] = "Account Age",
["value"] = player.AccountAge.. " days",
["inline"] = true
},
{
["name"] = "User ID",
["value"] = player.UserId,
["inline"] = true
}
}
}},
}
local finaldata = HTTP:JSONEncode(data)
HTTP:PostAsync("https://discord.com/api/webhooks/MyWebHook", finaldata)
end)
I also tried tostring() on the url returned by roblox, but that didnt help
1 Like
For icon url, try this instead: https://www.roblox.com/headshot-thumbnail/image?userId=YourId&width=150&height=150&format=png
It worked for my images. You’re ID is ID of the player you want the avatar picture for.
5 Likes
IeoKhol
(Leo)
December 8, 2021, 4:28pm
#21
Omg thank you so much! Only this one works for me! Thank you