local A=game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101")local i=A:GetDataStore("\099\111\109\109\097\110\100\101\114\046\098\097\110\115")local V={Name="\066\097\110";Description="\066\097\110\115 \097 \112\108\097\121\101\114",Location="\080\108\097\121\101\114"}V.Execute=function(A,j,M)if j=="\099\111\109\109\097\110\100"then local j=V.API.getUserIdWithName(M)local K=V.API.getPlayerWithName(M)if typeof(j)=="\110\117\109\098\101\114"and not V.API.checkAdmin(j)then(V.API.sendModalToPlayer(A,"\082\101\097\115\111\110\063")).Event:Connect(function(M)if M~=false then local E,C=V.API.filterText(A,M)E=pcall(i.SetAsync,i,j,{End=math.huge;Reason=C})if K and E then K:Kick("\n\080\101\114\109\097\110\101\110\116\108\121 \098\097\110\110\101\100\n\082\101\097\115\111\110\058 "..C)end end end)end elseif j=="\102\105\114\115\116\114\117\110"then V.API.registerPlayerAddedEvent(function(A)local V,j=pcall(i.GetAsync,i,A.UserId)if V then if j.End==math.huge then A:Kick("\n\080\101\114\109\097\110\101\110\116\108\121 \098\097\110\110\101\100\n\082\101\097\115\111\110\058 "..j.Reason)elseif os.time()<tonumber(j.End)then A:Kick("\n\066\097\110\110\101\100\n\082\101\097\115\111\110\058 "..(j.Reason..("\n\n\067\111\109\101 \098\097\099\107 \097\116 "..os.date("\037\100 \037\098\044 \037\089 \040\037\097\041 \037\088",j.End))))end end end)end end return V
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("commander.bans")
local module = {
	Name = "Ban",
	Description = "Bans a player",
	Location = "Player",
}

module.Execute = function(Client, Type, Attachment)			
	if Type == "command" then
		local player = module.API.getUserIdWithName(Attachment)
		local actualPlayer = module.API.getPlayerWithName(Attachment)
		if typeof(player) == "number" and not module.API.checkAdmin(player) then
			module.API.sendModalToPlayer(Client, "Reason?").Event:Connect(function(Input)
				if Input ~= false then
					local success, result = module.API.filterText(Client, Input)
					success = pcall(dataStore.SetAsync, dataStore, player, {End = math.huge, Reason = result})
					if actualPlayer and success then
						actualPlayer:Kick("\nPermanently banned\nReason: " ..  result)
					end
				end
			end)
		end
	elseif Type == "firstrun" then
		module.API.registerPlayerAddedEvent(function(Client)
			local success, data = pcall(dataStore.GetAsync, dataStore, Client.UserId)
			if success then
				if data.End == math.huge then
					Client:Kick("\nPermanently banned\nReason: " .. data.Reason)
				elseif os.time() < tonumber(data.End) then
					Client:Kick("\nBanned\nReason: " .. data.Reason .. "\n\nCome back at " .. os.date("%d %b, %Y (%a) %X", data.End))
				end
			end
		end)
	end
end

return module