• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

WolferyScripting / WolferyJS / #18

01 Sep 2025 09:19PM UTC coverage: 63.335% (+3.5%) from 59.833%
#18

push

DonovanDMC
0.0.6

95 of 253 branches covered (37.55%)

Branch coverage included in aggregate %.

7592 of 11884 relevant lines covered (63.88%)

1.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.05
/lib/models/RoomScript.ts
1
import BaseModel from "./BaseModel.js";
1✔
2
import type RoomScriptDetails from "./RoomScriptDetails.js";
1✔
3
import type ControlledCharacter from "./ControlledCharacter.js";
1✔
4
import type Room from "./Room.js";
1✔
5
import type RoomDetails from "./RoomDetails.js";
1✔
6
import type WolferyJS from "../WolferyJS.js";
1✔
7
import ResourceIDs from "../generated/ResourceIDs.js";
1✔
8
import type { RoomScriptProperties } from "../generated/models/types.js";
1✔
9
import { RoomScriptDefinition } from "../generated/models/definitions.js";
1✔
10
import { type KeyBasicResponse } from "../util/types.js";
1✔
11
import type Commands from "../util/commands.js";
1✔
12
import type { ResClient } from "resclient-ts";
1✔
13

1✔
14
declare interface RoomScript extends BaseModel, RoomScriptProperties {}
1✔
15
// do not edit the first line of the class comment
1✔
16
/**
1✔
17
 * A room script.
1✔
18
 * @resourceID {@link ResourceIDs.ROOM_SCRIPT | ROOM_SCRIPT}
1✔
19
 */
1✔
20
class RoomScript extends BaseModel implements RoomScriptProperties {
1✔
21
    constructor(client: WolferyJS, api: ResClient, rid: string) {
1✔
22
        super(client, api, rid, { definition: RoomScriptDefinition });
×
23
    }
×
24

1✔
25
    /**
1✔
26
     * Delete the room script. The controlled character that owns the room must be in the room.
1✔
27
     * @roomOwnershipRequired
1✔
28
     * @calls {@link getCtrl} > {@link ControlledCharacter.deleteRoomScript}
1✔
29
     */
1✔
30
    async delete(): Promise<KeyBasicResponse> {
1✔
31
        const ctrl = await this.getCtrl();
×
32
        return ctrl.deleteRoomScript(this.id);
×
33
    }
×
34

1✔
35
    /**
1✔
36
     * Get the controlled character in the room containing this script.
1✔
37
     * @calls {@link WolferyJS.findControlledCharacter}
1✔
38
     * @throws {@link NoControlledError} If a controlled character cannot be found.
1✔
39
     */
1✔
40
    async getCtrl(): Promise<ControlledCharacter> {
1✔
41
        return this.client.findControlledCharacter(async c => c.inRoom.owner.id === c.id && (await c.inRoom.getScripts()).hasKey(this.id), true);
×
42
    }
×
43

1✔
44
    /**
1✔
45
     * Get the room script details.
1✔
46
     * @calls {@link ResClient.get}
1✔
47
     */
1✔
48
    async getDetails(): Promise<RoomScriptDetails> {
1✔
49
        return this.api.get<RoomScriptDetails>(ResourceIDs.ROOM_SCRIPT_DETAILS({ id: this.id }));
×
50
    }
×
51

1✔
52
    /**
1✔
53
     * Get the room for the room profile. A controlled character must be in the room.
1✔
54
     * @calls {@link getCtrl} > {@link ResClient.get}
1✔
55
     */
1✔
56
    async getRoom(): Promise<Room> {
1✔
57
        const ctrl = await this.getCtrl();
×
58
        return this.api.get<Room>(ResourceIDs.ROOM({ id: ctrl.inRoom.id }));
×
59
    }
×
60

1✔
61
    /**
1✔
62
     * Get the detailed room for the room profile. A controlled character must be in the room.
1✔
63
     * @calls {@link getCtrl}
1✔
64
     */
1✔
65
    async getRoomDetails(): Promise<RoomDetails> {
1✔
66
        const ctrl = await this.getCtrl();
×
67
        return ctrl.inRoom;
×
68
    }
×
69

1✔
70
    /**
1✔
71
     * Set options for this room script. The controlled character that owns the room must be in the room.
1✔
72
     * @param options The options to set.
1✔
73
     * @roomOwnershipRequired
1✔
74
     * @calls {@link getCtrl} > {@link ControlledCharacter.setRoomScript}
1✔
75
     */
1✔
76
    async set(options: Commands.Controlled.SetRoomScriptOptions): Promise<{ room: Room; script: RoomScriptDetails; }> {
1✔
77
        const ctrl = await this.getCtrl();
×
78
        return ctrl.setRoomScript(this.id, options);
×
79
    }
×
80
}
1✔
81

1✔
82
export default RoomScript;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc