Hey! I have been recently trying to send Discord embed messages, by using Discord webhooks. However, I have come to 2 problems.
My first problem:
game.Players.LocalPlayer.Name gives a nil value, instead of actually giving the player’s name.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.CarbonEvents.SendWebhook.OnClientEvent:Connect(function(target, tj, tr)
ReplicatedStorage.ArrestWebhook:FireServer(
"SendWebhook", {
game.Players.LocalPlayer.Name;
target.Name;
tr;
target.UserId;
tj;
}
)
end)
My second problem:
The embed doesn’t load player’s Roblox thumbnailImage.
["icon_url"] = "https://www.roblox.com/headshot-thumbnail/image?userId="..Players:GetUserIdFromNameAsync(tostring(contentTable[1])).."&width=150&height=150&format=png"
ModuleScript for the Discord embed:
local module = {}
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local ServerStorage = game:GetService("ServerStorage")
local URL = YOU DONT NEED THIS
-- content table 4 = arrested user, content table 2 = arrester
module.SendWebhook = function(contentTable)
if not tostring(contentTable[3]) then return end
local data = {
["content"] = ":shield: __**New arrest log**__";
["embeds"] = {{
["author"] = {
["name"] = tostring(contentTable[1]);
["icon_url"] = "https://www.roblox.com/headshot-thumbnail/image?userId="..Players:GetUserIdFromNameAsync(tostring(contentTable[1])).."&width=150&height=150&format=png"
};
["description"] = "**A player has been arrested!**";
["color"] = tonumber(0xffffff);
["fields"] = {
{
["name"] = "Arrested User";
["value"] = tostring(contentTable[2]);
["inline"] = true;
};
{
["name"] = "Reason";
["value"] = tostring(contentTable[3]);
["inline"] = true;
};
{
["name"] = "Duration";
["value"] = tonumber(contentTable[5]).." seconds";
["inline"] = true;
};
{
["name"] = "Arrested User ID";
["value"] = tostring(contentTable[4]);
["inline"] = true;
};
{
["name"] = "Arrested By";
["value"] = tostring(contentTable[1]);
["inline"] = true;
};
{
["name"] = "User ID";
["value"] = Players:GetUserIdFromNameAsync(tostring(contentTable[1]));
["inline"] = true;
};
{
["name"] = "Server ID";
["value"] = tostring(ServerStorage.JoinCode.Value);
["inline"] = true;
};
};
["footer"] = {
["icon_url"] = "https://game-icons.net/images/project_papper.png";
["text"] = "FBI Arrest Logs"
}
}}
}
HttpService:PostAsync(URL, HttpService:JSONEncode(data))
end
return module