diff options
author | WlodekM <[email protected]> | 2024-09-09 20:38:31 +0300 |
---|---|---|
committer | WlodekM <[email protected]> | 2024-09-09 20:38:31 +0300 |
commit | 0d841c1c4d6853bd43eb575c55a57f3de675f88b (patch) | |
tree | 36e34574f682e09e88797b46254abf2b0c398258 /commands/ban.js | |
parent | d952979c5ab76a572da7cf9eede76095be0dbb88 (diff) |
ipban measures
Diffstat (limited to 'commands/ban.js')
-rw-r--r-- | commands/ban.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/commands/ban.js b/commands/ban.js new file mode 100644 index 0000000..db681d1 --- /dev/null +++ b/commands/ban.js @@ -0,0 +1,17 @@ +import fs from "fs"; + +export default { + name: "ban", + aliases: [], + command: function ({ user, server, args }) { + if(!user.admin) return user.socket.send("You are not admin"); + if(!server.accounts.checkAccount(args[0])) return user.socket.send("Account not found"); + let theUser = Object.values(server.users).find(a => a.username == args[0]); + theUser.socket.send('you were kicked because you were banned, L'); + let ipBanList = JSON.parse(String(fs.readFileSync("db/bannedIps.json"))); + ipBanList[theUser.ip] = args[1] ?? 'reason'; + ipBanList['account:'+args[0]] = args[1] ?? 'reason'; + theUser.socket.close(1003, "Kicked"); + fs.writeFileSync('db/bannedIps.json', JSON.stringify(ipBanList)); + }, +}; |