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

WolferyScripting / WolferyJS / #16

29 Aug 2025 04:49PM UTC coverage: 59.799% (-0.03%) from 59.833%
#16

push

DonovanDMC
Fix forcefully keeping BaseCollectionModel instances due to internal `change` listeners
WolferyScripting/resclient-ts@1786b91c7

93 of 247 branches covered (37.65%)

Branch coverage included in aggregate %.

32 of 58 new or added lines in 15 files covered. (55.17%)

7 existing lines in 1 file now uncovered.

5027 of 8315 relevant lines covered (60.46%)

1.48 hits per line

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

61.29
/lib/models/BotUser.ts
1
import BaseModel from "./BaseModel.js";
1✔
2
import type ControlledCharacter from "./ControlledCharacter.js";
1✔
3
import type WolferyJS from "../WolferyJS.js";
1✔
4
import type { BotUserProperties } from "../generated/models/types.js";
1✔
5
import { BotUserDefinition } from "../generated/models/definitions.js";
1✔
6
import type { ResClient } from "resclient-ts";
1✔
7

1✔
8
declare interface BotUser extends BaseModel, BotUserProperties {}
1✔
9
// do not edit the first line of the class comment
1✔
10
/**
1✔
11
 * The user when logged in with a bot token.
1✔
12
 * @resourceID {@link ResourceIDs.BOT_USER | BOT_USER}
1✔
13
 */
1✔
14
class BotUser extends BaseModel {
1✔
15
    constructor(client: WolferyJS, api: ResClient, rid: string) {
1✔
16
        super(client, api, rid, { definition: BotUserDefinition });
×
17
    }
×
18

1✔
19
    protected override async _listen(on: boolean): Promise<void> {
1✔
20
        await super._listen(on);
×
21
        const m = on ? "resourceOn" : "resourceOff";
×
22
        this[m]("unsubscribe", this.client.onUnsubscribe);
×
23
    }
×
24

1✔
25
    get id(): string {
1✔
26
        return this.char.id;
×
27
    }
×
28

1✔
29
    /**
1✔
30
     * Control the character associated with this BotUser.
1✔
31
     * @param force Ignore the character already being controlled.
1✔
32
     * @returns The owned character instance associated with this BotUser.
1✔
33
     */
1✔
34
    async controlChar(force = true): Promise<ControlledCharacter> {
1✔
35
        if (force && this.controlled !== null) return this.controlled;
×
UNCOV
36
        return this.call<ControlledCharacter>("controlChar");
×
UNCOV
37
    }
×
38

1✔
39
    async release(): Promise<ControlledCharacter | null> {
1✔
40
        if (this.controlled === null) return null;
×
UNCOV
41
        return this.controlled.release();
×
UNCOV
42
    }
×
43

1✔
44
    /**
1✔
45
     * Wake up the character associated with this BotUser.
1✔
46
     * @param hidden If the character should be hidden from the awake list.
1✔
47
     * @param force Ignore the character already being awake.
1✔
48
     */
1✔
49
    async wakeup(hidden?: boolean, force = true): Promise<ControlledCharacter> {
1✔
50
        if (this.controlled !== null) {
×
51
            if (this.controlled.state === "awake" && force) {
×
52
                return this.controlled;
×
53
            }
×
54
            await this.controlled.wakeup(hidden, force);
×
55
            return this.controlled;
×
56
        }
×
UNCOV
57
        return this.controlChar(force)
×
UNCOV
58
            .then(char => char.wakeup(hidden, force).then(() => char));
×
UNCOV
59
    }
×
60
}
1✔
61

1✔
62
export default BotUser;
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