I have this script for chat log for Discord, it is working fine but the problem is that i want the username to be put with the message. Right now, the username is being put as the Bots name - i dont mind keeping it like that, i just want the username also in the discord message along with the roblox message. For example, The message i would want the bot to send could be e.g) Roblox: Hi instead of just Hi or e.g) Roblox Hi
Any help is appreciated.
(Also I removed the web hook link for the sake of the post and im fine with completely swapping this code with a different one if it does what im asking for)
local https = game:GetService("HttpService")
local webhook = "PUT WEBHOOK LINK HERE"
function sendDiscordMessage(message, name, picture)
local info = {
content = message,
username = name,
avatar_url = picture
}
local encoded = https:JSONEncode(info)
https:PostAsync(webhook, encoded)
end
game.Players.PlayerAdded:Connect(function(player)
local name = player.DisplayName .. " (@" .. player.Name .. ")"
local imageUrl = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&Type=AvatarHeadShot&userId=" .. player.UserId
player.Chatted:Connect(function(message)
sendDiscordMessage(message, name, imageUrl)
end)
end)

1 comment
Thank you! It works great :)