2019-12-19 21:58:35 +02:00
|
|
|
local Server = require 'utils.server'
|
2019-12-19 23:47:46 +02:00
|
|
|
local Event = require 'utils.event'
|
2019-12-19 21:22:30 +02:00
|
|
|
|
2019-12-19 23:47:46 +02:00
|
|
|
local function on_console_command(event)
|
|
|
|
local cmd = event.command
|
2020-06-16 22:25:06 +02:00
|
|
|
if not event.player_index then
|
|
|
|
return
|
|
|
|
end
|
2019-12-19 23:47:46 +02:00
|
|
|
local player = game.players[event.player_index]
|
|
|
|
local reason = event.parameters
|
2020-06-16 22:25:06 +02:00
|
|
|
if not reason then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if not player.admin then
|
|
|
|
return
|
|
|
|
end
|
2019-12-19 23:47:46 +02:00
|
|
|
if cmd == 'ban' then
|
|
|
|
if player then
|
2020-06-16 22:25:06 +02:00
|
|
|
Server.to_banned_embed(table.concat {player.name .. ' banned ' .. reason})
|
2019-12-19 23:47:46 +02:00
|
|
|
return
|
|
|
|
else
|
2020-06-16 22:25:06 +02:00
|
|
|
Server.to_banned_embed(table.concat {'Server banned ' .. reason})
|
2019-12-19 23:47:46 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
elseif cmd == 'unban' then
|
|
|
|
if player then
|
2020-06-16 22:25:06 +02:00
|
|
|
Server.to_banned_embed(table.concat {player.name .. ' unbanned ' .. reason})
|
2019-12-19 23:47:46 +02:00
|
|
|
return
|
|
|
|
else
|
2020-06-16 22:25:06 +02:00
|
|
|
Server.to_banned_embed(table.concat {'Server unbanned ' .. reason})
|
2019-12-19 23:47:46 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Event.add(defines.events.on_console_command, on_console_command)
|