How can I make this an embed into a Discord webhook?

I’m trying to make the chatlogs here embedded, I’m trying to edit it to embeds, so users can’t abuse pings. I’m trying to set it so the webhook avatar is the user avatar, description the message from the player and the username as the user’s username and ID.
I couldn’t find how to do this fully anywhere, users are abusing the eveyone and here pings throuh the webhook.
I’ve tried editing to a different code, though it always errors out. This code isn’t mine, I got it from a tutorial video.

-- Variables Prep --

local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
local disabled = false -- Do not touch else the script won't work
local DiscordCommand = false -- restricts the command being sent to discord
local groupid = 0-- put your own if you'd like to use the group function
local grouprank = 0 -- needed for group function
local group = true -- Enable this to use groupid and grouprank in code
local webhook = "https://discordapp.com/api/webhooks/*********" -- webhook goes here
local allowed = {"Player1","Player2","Player3"} -- if group is set to false, use this to allow some players to use the command
local enablecommand = ";chatlogs on" -- can be changed
local enablecommand2 = "/e ;chatlogs on" -- can be changed but keep the /e in it
local disablecommand = ";chatlogs off" -- can be changed
local disablecommand2 = "/e ;chatlogs off"-- can be changed but keep the /e in it

-- Actual Code --

function contains(plrname)
    for _, v in pairs(allowed) do
        if v == plrname then return true end
    end
    return false
end

Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if disabled == false then
            if DiscordCommand == false then
                local data = {
                    content = msg;
                    username = plr.Name .. " - (#" .. plr.UserId .. ")";
                    avatar_url = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userId="..plr.UserId
                }
                HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
            elseif DiscordCommand == true then
                if msg ~= enablecommand and msg ~= enablecommand2 and msg ~= disablecommand and msg ~= disablecommand2 then
                local data = {
                    content = msg;
                    username = plr.Name .. " - (#" .. plr.UserId .. ")";
                    avatar_url = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userId="..plr.UserId
                }
                HttpService:PostAsync(webhook, HttpService:JSONEncode(data))
                end
            end
        end
    end)
end)

Players.PlayerAdded:connect(function(Player)
    if group == true then
        if Player:GetRankInGroup(groupid) >= grouprank then
            Player.Chatted:Connect(function(msg)
                if msg:lower() == enablecommand or msg:lower() == enablecommand2 then
                    disabled = false
                    print("Chat logs activated")
                end
                if msg:lower() == disablecommand or msg:lower() == disablecommand2 then
                    disabled = true
                    print("Chat logs deactivated")
                end    
            end)
        end
    elseif group == false then
        if contains(Player.Name) then
            Player.Chatted:Connect(function(msg)
                if msg:lower() == enablecommand or msg:lower() == enablecommand2 then
                    disabled = false
                    print("Chat logs activated")
                end
                if msg:lower() == disablecommand or msg:lower() == disablecommand2 then
                    disabled = true
                    print("Chat logs deactivated")
                end    
            end)
        end
    end
end)



-- END --

Anything helps, thanks!

2 Likes

Just a little bump here, been quiet! :eyes:

This post should solve your problem