Clone TextLabels into my discord embed

So I have a scrolling frame that has the username of a certain person in the frame as a text label. So I want to send everyone’s username that is in the frame to a webhook. For example, if there were a few people with a different name in the frame, it would have sent their username as a discord embed, but how do I code that? My webhook works perfectly fine.

			local enddata = 
				{
					["embeds"] = {{
						["title"]= "Shift Ended",
						["description"] = ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.Host.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.ServerVisits.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.StaffCount.Text,
						["footer"] = {
							["text"] = group.Name .. " • Shift System";
						};
						["type"]= "rich",
						["color"]= tonumber(0x2f3136),
					}
					}
				}

			http:PostAsync(ShiftChannelWebhook.Value,http:JSONEncode(enddata))

Loop through all the items in the list and add the text of the textlabel to a table.

This is what I did, It’s still not working…

				local items = {}
				
				for itemName, amount in pairs(ShiftBoard.Main.Screen.SurfaceGui.Hosting.Staff:GetChildren()) do
					if amount:IsA("TextLabel") then
						table.insert(items)
					end
				end
				
				local enddata = 
					{
						["embeds"] = {{
							["title"]= "Shift Ended",
							["description"] = ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.Host.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.ServerVisits.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.StaffCount.Text .. "\n\n Staff Attendance: \n" .. items,
							["footer"] = {
								["text"] = group.Name .. " • Shift System";
							};
							["type"]= "rich",
							["color"]= tonumber(0x2f3136),
						}
						}
					}

				http:PostAsync(ShiftChannelWebhook,http:JSONEncode(enddata))

You forgot to pass a parameter to table.insert

In this case it would be amount.Text so

table.insert(items, amount.Text)

Now it shows this error:

That is a different line. it is this line: [“description”] =

Yes. --------------------------

You are attempting to add a table to a string. Loop through the table called items and make it a string then concatenate it to the description line. Also beware of the 2000 character limit. Also discord webhook requests are blocked from roblox i believe.

I use a proxy :wink: I know that they are blocked, xd

1 Like

What do you mean by that? --------

You can not add a table to a string. Not without json encode you cant. You can however loop through the table and add it to a string which you then add to the description. Also a proxy is limited to 30 requests an hour. Just make a bot that will handle it then send the message. I believe that bots now have 4000 character limit.

So how should I loop through the table, never used tables in my life. Yeh but everything is on the embed and the embed will not be spammed because of debouncing.

The end code could look like this.

local items = {} 				 		
for itemName, amount in pairs(ShiftBoard.Main.Screen.SurfaceGui.Hosting.Staff:GetChildren()) do 
if amount:IsA("TextLabel") then 						
table.insert(items) 					
end 	
end
local itemstr = '';
for _,a in next,items do 
itemstr = ('%s%s\n'):format(itemstr,a);
end; 		
local enddata = { 						
["embeds"] = {{ 	
["title"]= "Shift Ended", 	
["description"] = ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.Host.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.ServerVisits.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.StaffCount.Text .. "\n\n Staff Attendance: \n" .. itemstr, 
["footer"] = { 
["text"] = group.Name .. " • Shift System"; 	
}; 	
["type"]= "rich", 	
["color"]= tonumber(0x2f3136), 						
} 						
} 					
} 				
http:PostAsync(ShiftChannelWebhook,http:JSONEncode(enddata))

Ignore the bad formating i am on my phone rn.

Now it says this error:

Bruh i forgot to add the change i mentioned earlier.

The end code could look like this.

local items = {} 				 		
for itemName, amount in pairs(ShiftBoard.Main.Screen.SurfaceGui.Hosting.Staff:GetChildren()) do 
if amount:IsA("TextLabel") then 						
table.insert(items,amount.Text) 					
end 	
end
local itemstr = '';
for _,a in next,items do 
itemstr = ('%s%s\n'):format(itemstr,a);
end; 		
local enddata = { 						
["embeds"] = {{ 	
["title"]= "Shift Ended", 	
["description"] = ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.Host.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.ServerVisits.Text .. "\n" .. ShiftBoard.Main.Screen.SurfaceGui.Hosting.Info.StaffCount.Text .. "\n\n Staff Attendance: \n" .. itemstr, 
["footer"] = { 
["text"] = group.Name .. " • Shift System"; 	
}; 	
["type"]= "rich", 	
["color"]= tonumber(0x2f3136), 						
} 						
} 					
} 				
http:PostAsync(ShiftChannelWebhook,http:JSONEncode(enddata))

Ignore the bad formating i am on my phone rn.

This right? Or is it something else

Yes i added it in the new reply.

So I got the message, let me try bringing an alt.
image

@Harry_TheKing1 Thank you so much for helping me!

1 Like