diff --git a/src/room/Room.ts b/src/room/Room.ts index 79ae7d5..8510b4c 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -230,9 +230,7 @@ export default class Room extends EventEmitter { this.ws.send({ command: "room.start" }); } - public setConfig( - config: { index: string; value: any }[] | Record - ) { + public setConfig(config: { index: string; value: any }[] | Record) { if (!Array.isArray(config)) { this.ws.send({ command: "room.setconfig", @@ -254,11 +252,11 @@ export default interface Room extends EventEmitter { /** Emitted when a player joins the room. */ on(eventName: "join", listener: (player: Member) => void): this; + /** Emitted when the the client gets kicked or banned from the room. */ + on(eventName: "kick", listener: (type: string) => void): this; + /** Emitted when a player sends a message. */ - on( - eventName: "chat", - listener: (message: { content: string; author: Member }) => void - ): this; + on(eventName: "chat", listener: (message: { content: string; author: Member }) => void): this; /** Emitted when a player leaves the room. */ on(eventName: "leave", listener: (player: User) => void): this; @@ -270,10 +268,7 @@ export default interface Room extends EventEmitter { on(eventName: "start", listener: (game: Game) => void): this; /** Emitted when the game ends. */ - on( - eventName: "end", - listener: (leaderboard: Leaderboard[], victor: Player) => void - ): this; + on(eventName: "end", listener: (leaderboard: Leaderboard[], victor: Player) => void): this; } export type Member = { diff --git a/src/ws/commands/room.kick.ts b/src/ws/commands/room.kick.ts new file mode 100644 index 0000000..d71ee49 --- /dev/null +++ b/src/ws/commands/room.kick.ts @@ -0,0 +1,27 @@ +import WebSocketManager from "../WebSocketManager"; + +export default async function ({ client: { room } }: WebSocketManager, { data }: any) { + room.id = undefined; + room.name = undefined; + room.nameSafe = undefined; + room.type = undefined; + room.owner = undefined; + room.creator = undefined; + room.state = undefined; + room.topic = undefined; + room.auto = undefined; + room.options = undefined; + room.userLimit = undefined; + room.autoStart = undefined; + room.allowAnonymous = undefined; + room.allowUnranked = undefined; + room.allowBots = undefined; + room.userRankLimit = undefined; + room.useBestRankAsLimit = undefined; + room.forceRequireXPToChat = undefined; + room.bgm = undefined; + room.match = undefined; + room.players = undefined; + + room.emit("kick", data); +}