summary refs log tree commit diff
path: root/commands/ban.js
blob: 584b4d0bbaa301badb2220c135784ea5ea73725a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import fs from "node: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));
    },
};