Gandhi20
(DaRealGandhi20)
March 1, 2022, 2:27am
#1
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))
jufdnhf
(jufdnhf)
March 1, 2022, 8:02am
#2
Loop through all the items in the list and add the text of the textlabel to a table.
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:13pm
#3
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)
That is a different line. it is this line: [“description”] =
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:24pm
#7
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.
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:26pm
#9
Harry_TheKing1:
b
I use a proxy I know that they are blocked, xd
1 Like
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:27pm
#10
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.
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:32pm
#12
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.
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.
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:39pm
#17
This right? Or is it something else
Yes i added it in the new reply.
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:41pm
#19
So I got the message, let me try bringing an alt.
Gandhi20
(DaRealGandhi20)
March 1, 2022, 1:47pm
#20
@Harry_TheKing1 Thank you so much for helping me!
1 Like