Application Center Script

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:

image

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!

4 Likes

Try this:

table.insert(fieldsQ,{
		["name"] = tostring(v[1]),
		["value"] = tostring(v[2]),
		["inline"] = false
	})

Let me know if thats help

No luck. Same thing shows up.

Try:

table["name"] = "smthn",
table["value"] = "helo i am under the water",
table["inline"] = true,

That would work for one, not multiple as it would override the others.

It works for me with indexes

maybe try to do this:

["fields"] = fieldsQ

because there are 2 tables and webhook wants only 1 with fields with indexes

["fields"] = {
fieldsQ
}

Let me know if that helps!