I’m trying to unpack some tables that have many tables and print them in “Fields” on Discord Webhook.
If it has only 1, it works as well.
But if it has more than one, it shows only the first, so the second didn’t show anything.
How to Fix It
Some Code :
local function Embed_Fields(name:string, value:string, inline:boolean)
local Fields = {name, value, inline}
return Fields
end
local Final_Embed = {}
local Final_Fields = {}
if Setting.Device.Enable then
table.insert(Final_Embed, Embed_Fields("Device", Device__(), true))
end
if Setting.RunService.Enable then
table.insert(Final_Embed, Embed_Fields("RunService", RunService__(), true))
end
for i, v in pairs(Final_Embed) do
table.insert(Final_Fields, {
["name"] = tostring(v[1]),
["value"] = tostring(v[2]),
["inline"] = v[3]
})
end
print("Final_Fields :", Final_Fields)
print("table.unpack(Final_Fields) :", table.unpack(Final_Fields))
The issue is that in the Final_Fields tables have 2 tables right but when I unpack and make it log on "Discord Webhook Fields", it shows only the first, so where is the second one?
Follow the image, i can print each of Final_Fields as Final_Fields [1] and Final_Fields[2], but I just want it to be automatic because it can setting that Enable or not, so I can’t predict the future.
So I need to unpack it and show all the results.