I get HTTP 400 (Bad Request) error with this script:
local url = "webhook_url"
local http = game:GetService('HttpService')
local MarketplaceService = game:GetService("MarketplaceService")
local event = game.ReplicatedStorage.logEvent
game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)
local players = game:GetService("Players")
local data = {
['username'] = plr.Name.." | "..MarketplaceService:GetProductInfo(game.PlaceId).Name,
["avatar_url"] = game:GetService("Players"):GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150),
['content'] = msg
}
local newdata = http:JSONEncode(data)
http:PostAsync(url,newdata)
end)
end)
Any solutions?
(It’s connected to a discord webhook)
Did you activate the HTTP thing in game settings?
1 Like
kozak456pl
(FranciscoGranco)
April 5, 2021, 8:17pm
#3
I think its problem with formating message. Check this link
https://embed.discord.website/
1 Like
Loryonix
(Loryy)
April 5, 2021, 8:49pm
#4
Discord have a limit for webhooks.
30 messages for every minute maybe because that is not working.
1 Like
kozak456pl
(FranciscoGranco)
April 6, 2021, 7:36am
#5
I was testing it alone and it was showing still error .I think it just wrong format of message
1 Like
There’s gotta be something wrong with the formatting, check the formatting and make sure it’s right.
1 Like
Alright, I checked everything and it seems to work without the avatar_url variable. Any ideas on how to fix that?
heII_ish
(heII_ish)
April 8, 2021, 11:25pm
#8
The issue is that GetUserThumbnailAsync
returns a rbxthumb://
content type, which is only usable in roblox. The solution would be to use the https://
link that roblox uses to fetch user thumbnails
string.format("https://www.roblox.com/headshot-thumbnail/image?userId=%s&width=150&height=150&format=png", plr.UserId)
1 Like