Skip to content

Commit

Permalink
feat: Add room.kick
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup3rFire committed Mar 29, 2024
1 parent faeece0 commit ba3841c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ export default class Room extends EventEmitter {
this.ws.send({ command: "room.start" });
}

public setConfig(
config: { index: string; value: any }[] | Record<string, any>
) {
public setConfig(config: { index: string; value: any }[] | Record<string, any>) {
if (!Array.isArray(config)) {
this.ws.send({
command: "room.setconfig",
Expand All @@ -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;
Expand All @@ -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 = {
Expand Down
27 changes: 27 additions & 0 deletions src/ws/commands/room.kick.ts
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit ba3841c

Please sign in to comment.