So I’m creating an application center which holds multiple applications. It currently uses webhooks to send the applications to a Discord. The issue I’m having is inserting fields to the embed corresponding to the number of questions.
Here’s the current script:
local http = game:GetService("HttpService")
local webhookurl = "Private"
game.ReplicatedStorage.Events.MD.OnServerEvent:Connect(function(player, Results)
local data1 = {
["embeds"] = {{
["title"] = "Level 2 Application From: " .. player.Name .. "",
["description"] = "Profile: https://www.roblox.com/users/" .. player.UserId .. "/profile\nAccount Age: " .. player.AccountAge .. " Days",
["author"] = {["name"] = "📝 NEW APPLICATION",},
["type"] = "rich",
["color"] = tonumber(0xffffff),
--["thumbnail"] = {url = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)},
}}
}
local fieldsQ = {}
for i, v in pairs(Results) do
table.insert(fieldsQ, #fieldsQ+1, {
["name"] = tostring(v[1]),
["value"] = tostring(v[2]),
["inline"] = false
})
end
print(fieldsQ)
local data2 = {
["embeds"] = {{
["type"] = "rich",
["color"] = tonumber(0xffffff),
["fields"] = {
fieldsQ
}
}}
}
local newdata1 = http:JSONEncode(data1)
http:PostAsync(webhookurl, newdata1)
wait(1)
local newdata2 = http:JSONEncode(data2)
http:PostAsync(webhookurl, newdata2)
end)
This is what the Results the script receives is:
the issue is that using table.insert
inserts it so it would look like this:
[3] = {
["inline"] = false,
["name"] = "What does the Medical Department do?",
["value"] = "sssss"
},
When it needs to look like this for webhooks to work:
{
["inline"] = false,
["name"] = "What does the Medical Department do?",
["value"] = "sssss"
},
The difference is that it removes the [3] part. How would I do this?
basically I want to get rid of the index
Thanks in advance!