Skip to content

Commit fb5e78c

Browse files
committed
finish client modularization
... to be rewritten some day
1 parent ac5bfad commit fb5e78c

File tree

8 files changed

+1274
-1284
lines changed

8 files changed

+1274
-1284
lines changed

src/Client/Client/Modules/Admins.luau

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
--// pyxfluff 2025
2+
3+
local Modules = script.Parent
4+
local Libs = script.Parent.Parent.Libraries
5+
6+
local Frontend = require(Modules.Frontend)
7+
local Utilities = require(Modules.Utilities)
8+
local Var = require(Modules.Variables)
9+
10+
local Admins = {}
11+
local Connections: { RBXScriptConnection } = {}
12+
13+
local RanksFrame = Var.MainFrame.Configuration.Admins.Container.Ranks.Content
14+
15+
--// TODO: OPTIMIZE THIS
16+
function Admins.Load(): ()
17+
for _, Item in RanksFrame:GetChildren() do
18+
if Item:IsA("Frame") and Item.Name ~= "Template" then Item:Destroy() end
19+
end
20+
21+
for _, Item in Var.MainFrame.Configuration.Admins.Container.Admins.Content:GetChildren() do
22+
if Item:IsA("Frame") and Item.Name ~= "Template" then Item:Destroy() end
23+
end
24+
25+
for _, Connection in Connections do
26+
Connection:Disconnect()
27+
end
28+
29+
Connections = {}
30+
31+
local Shimmer1 = Libs.Shime.new(Var.MainFrame.Configuration.Admins.Container.Ranks)
32+
local Shimmer2 = Libs.Shime.new(Var.MainFrame.Configuration.Admins.Container.Admins)
33+
34+
Shimmer1:Play()
35+
Shimmer2:Play()
36+
37+
task.defer(function()
38+
local List = Var.Remotes.GetRanks:InvokeServer("LegacyAdmins")
39+
40+
for i, User in List do
41+
if User["MemberType"] == "User" then
42+
local AdminPageTemplate = RanksFrame.Parent.Parent.Admins.Content.Template:Clone()
43+
44+
local Suc, Err = pcall(function()
45+
AdminPageTemplate.PFP.Image = tostring(
46+
Var.Services.Players:GetUserThumbnailAsync(
47+
tonumber(User["ID"]),
48+
Enum.ThumbnailType.HeadShot,
49+
Enum.ThumbnailSize.Size180x180
50+
)
51+
)
52+
AdminPageTemplate.Info.Text = `AdminID Override`
53+
54+
AdminPageTemplate.Metadata.Text =
55+
`This user is in the override module, as such we don't have any information.`
56+
AdminPageTemplate.PlayerName.Text = `@{Var.Services.Players:GetNameFromUserIdAsync(User["ID"])}`
57+
58+
AdminPageTemplate.Visible = true
59+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
60+
AdminPageTemplate.Name = User["ID"]
61+
end)
62+
63+
if not Suc then
64+
print(Err)
65+
AdminPageTemplate.PFP.Image = ""
66+
AdminPageTemplate.Metadata.Text = `AdminID Override`
67+
68+
AdminPageTemplate.Info.Text =
69+
`This user is in the override module, as such we don't have any information.`
70+
AdminPageTemplate.PlayerName.Text = `(user not found) all ranks`
71+
72+
AdminPageTemplate.Visible = true
73+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
74+
end
75+
else
76+
local AdminPageTemplate = RanksFrame.Parent.Parent.Admins.Content.Template:Clone()
77+
78+
local _, GroupInfo = pcall(function()
79+
return game:GetService("GroupService"):GetGroupInfoAsync(User["ID"])
80+
end)
81+
82+
local Suc, Err = pcall(function()
83+
AdminPageTemplate.PFP.Image = GroupInfo["EmblemUrl"]
84+
AdminPageTemplate.Metadata.Text = `AdminID Override`
85+
86+
AdminPageTemplate.Info.Text =
87+
`This user is in the override module, as such we don't have any information.`
88+
AdminPageTemplate.PlayerName.Text = `{GroupInfo["Name"]} (all ranks)`
89+
90+
AdminPageTemplate.Visible = true
91+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
92+
AdminPageTemplate.Name = User["ID"]
93+
end)
94+
95+
if not Suc then
96+
print(Err)
97+
AdminPageTemplate.PFP.Image = ""
98+
AdminPageTemplate.Info.Text = `AdminID Override`
99+
100+
AdminPageTemplate.Metadata.Text =
101+
`This user is in the override module, as such we don't have any information.`
102+
AdminPageTemplate.PlayerName.Text = `(group not found) all ranks`
103+
104+
AdminPageTemplate.Visible = true
105+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
106+
end
107+
end
108+
end
109+
end)
110+
111+
local List = Var.Remotes.GetRanks:InvokeServer()
112+
113+
if typeof(List) == "string" then
114+
warn(debug.traceback(`Failed: {List}`))
115+
116+
return "Something went wrong"
117+
else
118+
for i, v in List do
119+
local Template = RanksFrame.Template:Clone()
120+
121+
Template.Name = v["RankName"]
122+
Template.RankName.Text = v["RankName"]
123+
Template.Info.Text =
124+
`Rank {v["RankID"]} • {v["PagesCode"] == "/" and #v["AllowedPages"] .. " pages" or "Full access"} • {#v["Members"]} member{#v["Members"] == 1 and "" or "s"} {v["Protected"] and "• Protected" or ""} • {v["Reason"]}`
125+
126+
if #v["AllowedPages"] == 6 then --// im so confused
127+
for k, _ in v["AllowedPages"] do
128+
local App = Template.Pages.Frame:Clone()
129+
130+
App.Visible = true
131+
App.AppName.Text = v["AllowedPages"][k]["DisplayName"]
132+
App.ImageLabel.Image = v["AllowedPages"][k]["Icon"]
133+
App.Parent = Template.Pages
134+
end
135+
elseif #v["AllowedPages"] > 6 then
136+
for j = 1, 5 do
137+
local App = Template.Pages.Frame:Clone()
138+
139+
App.Visible = true
140+
App.AppName.Text = v["AllowedPages"][j]["DisplayName"]
141+
App.ImageLabel.Image = v["AllowedPages"][j]["Icon"]
142+
App.Parent = Template.Pages
143+
end
144+
145+
local App = Template.Pages.Frame:Clone()
146+
App.Visible = true
147+
App.AppName.Text = `{#v["AllowedPages"] - 5} others...`
148+
App.Parent = Template.Pages
149+
else
150+
for k, _ in v["AllowedPages"] do
151+
local App = Template.Pages.Frame:Clone()
152+
153+
App.Visible = true
154+
App.AppName.Text = v["AllowedPages"][k]["DisplayName"]
155+
App.ImageLabel.Image = v["AllowedPages"][k]["Icon"]
156+
App.Parent = Template.Pages
157+
end
158+
end
159+
160+
Template.Parent = RanksFrame
161+
Template.Visible = true
162+
163+
for _, User in v["Members"] do
164+
if not tonumber(User["ID"]) then
165+
warn(`Bad admin ID? ({User["ID"]} was not of type number)`)
166+
continue
167+
end
168+
169+
if User["MemberType"] == "User" then
170+
local AdminPageTemplate = RanksFrame.Parent.Parent.Admins.Content.Template:Clone()
171+
172+
local Suc, Err = pcall(function()
173+
AdminPageTemplate.PFP.Image = tostring(
174+
game.Var.Services.Players:GetUserThumbnailAsync(
175+
tonumber(User["ID"]),
176+
Enum.ThumbnailType.HeadShot,
177+
Enum.ThumbnailSize.Size180x180
178+
)
179+
)
180+
AdminPageTemplate.Info.Text = `{v["RankName"]} (Rank {i})`
181+
--// "Created by" replacement to prevent any name mistakes ("Created by AddedUsername" not "Created by CreatedUsermame")
182+
AdminPageTemplate.Metadata.Text =
183+
`{string.gsub(v["Reason"], "Created by", "Added by")} <b>{Utilities.FormatRelativeTime(
184+
v["ModifiedUnix"]
185+
)}</b>`
186+
AdminPageTemplate.PlayerName.Text = `@{Var.Services.Players:GetNameFromUserIdAsync(User["ID"])}`
187+
188+
AdminPageTemplate.Visible = true
189+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
190+
AdminPageTemplate.Name = User["ID"]
191+
end)
192+
193+
if not Suc then
194+
print(Err)
195+
AdminPageTemplate.PFP.Image = ""
196+
AdminPageTemplate.Info.Text = `{v["RankName"]} (Rank {i})`
197+
AdminPageTemplate.Metadata.Text =
198+
`{v["Reason"]} <b>{Utilities.FormatRelativeTime(v["ModifiedUnix"])}</b>`
199+
AdminPageTemplate.PlayerName.Text = `Deleted ({User["ID"]})`
200+
201+
AdminPageTemplate.Visible = true
202+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
203+
AdminPageTemplate.Name = User["ID"]
204+
end
205+
else
206+
local AdminPageTemplate = RanksFrame.Parent.Parent.Admins.Content.Template:Clone()
207+
208+
local _, GroupInfo = pcall(function()
209+
return game:GetService("GroupService"):GetGroupInfoAsync(User["ID"])
210+
end)
211+
212+
local Suc, Err = pcall(function()
213+
AdminPageTemplate.PFP.Image = GroupInfo["EmblemUrl"]
214+
AdminPageTemplate.Info.Text = `{v["RankName"]} (Rank {i})`
215+
--// "Created by" replacement to prevent any name mistakes ("Created by AddedUsername" not "Created by CreatedUsermame")
216+
AdminPageTemplate.Metadata.Text =
217+
`{string.gsub(v["Reason"], "Created by", "Added by")} <b>{Utilities.FormatRelativeTime(
218+
v["ModifiedUnix"]
219+
)}</b>`
220+
AdminPageTemplate.PlayerName.Text =
221+
`{GroupInfo["Name"]} ({(User["GroupRank"] or 0) == 0 and "all ranks" or User["GroupRank"]})`
222+
223+
AdminPageTemplate.Visible = true
224+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
225+
AdminPageTemplate.Name = User["ID"]
226+
end)
227+
228+
if not Suc then
229+
print(Err)
230+
AdminPageTemplate.PFP.Image = ""
231+
AdminPageTemplate.Info.Text = `{v["RankName"]} (Rank {i})`
232+
AdminPageTemplate.Metadata.Text =
233+
`{v["Reason"]} <b>{Utilities.FormatRelativeTime(v["ModifiedUnix"])}</b>`
234+
AdminPageTemplate.PlayerName.Text = `Deleted ({User["ID"]})`
235+
236+
AdminPageTemplate.Visible = true
237+
AdminPageTemplate.Parent = RanksFrame.Parent.Parent.Admins.Content
238+
AdminPageTemplate.Name = User["ID"]
239+
end
240+
end
241+
end
242+
end
243+
end
244+
245+
Shimmer1:Pause()
246+
Shimmer2:Pause()
247+
Shimmer1:GetFrame():Destroy()
248+
Shimmer2:GetFrame():Destroy()
249+
end
250+
251+
return Admins

0 commit comments

Comments
 (0)