Implement /ban command
This commit is contained in:
parent
3649681f9f
commit
590236cbfa
17
src/commands/ban.ts
Normal file
17
src/commands/ban.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import Logger from "../util/Logger";
|
||||||
|
import Interface, { Command } from "./Interface";
|
||||||
|
const c = new Logger("/ban", "blue");
|
||||||
|
|
||||||
|
export default async function handle(command: Command) {
|
||||||
|
if (!Interface.target) {
|
||||||
|
c.log("No target specified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const banStatus = Interface.target.player.db.banned;
|
||||||
|
Interface.target.player.db.banned = !banStatus;
|
||||||
|
Interface.target.player.save();
|
||||||
|
Interface.target.kick();
|
||||||
|
|
||||||
|
c.log(`${banStatus ? "Banned" : "Unbanned"} ${Interface.target.account.name}`);
|
||||||
|
}
|
@ -102,7 +102,7 @@ export default class Session {
|
|||||||
const packet = Packet.fromEncodedBuffer(Buffer.from(encodedBuffer), typeName);
|
const packet = Packet.fromEncodedBuffer(Buffer.from(encodedBuffer), typeName);
|
||||||
this.c.verbL(data);
|
this.c.verbL(data);
|
||||||
this.c.verbH(encodedBuffer);
|
this.c.verbH(encodedBuffer);
|
||||||
if(!encodedBuffer) console.log("sad!")
|
if (!encodedBuffer) this.c.error("encodedBuffer is undefined");
|
||||||
if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(typeName);
|
if (Logger.VERBOSE_LEVEL >= VerboseLevel.WARNS) this.c.log(typeName);
|
||||||
//todo: might want to regen the ts-proto types with env = node
|
//todo: might want to regen the ts-proto types with env = node
|
||||||
this.kcpobj.send(packet);
|
this.kcpobj.send(packet);
|
||||||
@ -112,6 +112,7 @@ export default class Session {
|
|||||||
public kick(hard: boolean = true) {
|
public kick(hard: boolean = true) {
|
||||||
SRServer.getInstance().sessions.delete(this.id);
|
SRServer.getInstance().sessions.delete(this.id);
|
||||||
this.kicked = true;
|
this.kicked = true;
|
||||||
|
|
||||||
if (hard) this.send(PlayerKickOutScNotify, {
|
if (hard) this.send(PlayerKickOutScNotify, {
|
||||||
kickType: PlayerKickOutScNotify_KickType.KICK_BLACK,
|
kickType: PlayerKickOutScNotify_KickType.KICK_BLACK,
|
||||||
blackInfo: {
|
blackInfo: {
|
||||||
|
Loading…
Reference in New Issue
Block a user