- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAdminModuleCommandHandler.lua
More file actions
Latest commit
113 lines (96 loc) · 3.49 KB
/
Copy pathAdminModuleCommandHandler.lua
File metadata and controls
113 lines (96 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--[[
Written by Begi.
Listens for commands, checks permissions, and executes the appropriate functions from AdminModule.
--]]
localAdminModule=require(game:GetService("ReplicatedStorage"):WaitForChild("AdminModule"))
localConfig=require(game:GetService("ReplicatedStorage"):WaitForChild("AdminModule"):WaitForChild("Config"))
-- Services
localPlayers=game:GetService("Players")
-- Function to check if a player is an admin
localfunctionisAdmin(player)
returntable.find(Config.AdminUserIds, player.UserId) ~=nil
end
-- Function to process commands
localfunctionprocessCommand(player, message)
-- Split the message into command and arguments
localargs=message:split("")
localcommand=table.remove(args, 1):lower()
ifcommand==Config.CommandPrefix.."ban" then
ifisAdmin(player) then
localtargetID=tonumber(args[1])
localduration=args[2]
localdurationParsed=AdminModule.parseDuration(duration)
localreason
ifdurationParsedthen
reason=table.concat(args, "", 3)
else
duration="-1"
reason=table.concat(args, "", 2)
end
iftargetIDthen
AdminModule.BanPlayer(targetID, duration, reason, player)
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "Player not found.")
end
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "You do not have permission to use this command.")
end
elseifcommand==Config.CommandPrefix.."unban" then
ifisAdmin(player) then
localtargetID=tonumber(args[1])
iftargetIDthen
AdminModule.UnbanPlayer(targetID, player)
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "Player not found.")
end
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "You do not have permission to use this command.")
end
elseifcommand==Config.CommandPrefix.."checkhistory" then
ifisAdmin(player) then
localtargetID=tonumber(args[1])
iftargetIDthen
AdminModule.CheckPlayerHistory(targetID, player)
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "Player not found.")
end
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "You do not have permission to use this command.")
end
elseifcommand==Config.CommandPrefix.."getid" then
ifisAdmin(player) then
localtargetUsername=args[1]
AdminModule.GetPlayerID(targetUsername, player)
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "You do not have permission to use this command.")
end
else
Config.Remotes.CommandFeedbackEvent:FireClient(player, "Unknown command.")
end
end
-- Listen for player chats
Players.PlayerAdded:Connect(function(player)
ifisAdmin(player) then
Config.Remotes.CommandFeedbackEvent:FireClient(player, "AdminModule is activated for you. Toggle menu: "..tostring(Config.ToggleKey))
end
player.Chatted:Connect(function(message)
ifmessage:sub(1, #Config.CommandPrefix) ==Config.CommandPrefixthen
processCommand(player, message)
end
end)
end)
Config.Remotes.CommandsFromUI.OnServerEvent:Connect(function(player, command, parameter)
ifcommand=="GetID" then
localusername=parameter
AdminModule.GetPlayerID(username, player)
elseifcommand=="Unban" then
localid=parameter
AdminModule.UnbanPlayer(id, player)
elseifcommand=="CheckHistory" then
localid=parameter
AdminModule.CheckPlayerHistory(id, player)
end
end)
Config.Remotes.BanFromUI.OnServerEvent:Connect(function(player, id, duration, reason)
AdminModule.BanPlayer(id, duration, reason, player)
end)