• 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

64.86
/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 ResourceIDs from "../generated/ResourceIDs.js";
1✔
7
import type { ResClient } from "resclient-ts";
1✔
8

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

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

1✔
26
    /** The character id. */
1✔
27
    get charId(): string {
1✔
28
        return this.char.id;
×
29
    }
×
30

1✔
31
    /** The user id. */
1✔
32
    get id(): string {
1✔
33
        return ResourceIDs.BOT_USER.parts(this.rid).id;
×
34
    }
×
35

1✔
36
    /**
1✔
37
     * Control the character associated with this BotUser.
1✔
38
     * @param force Ignore the character already being controlled.
1✔
39
     * @calls {@link MiscCommands.controlCharBot}
1✔
40
     */
1✔
41
    async controlChar(force = true): Promise<ControlledCharacter> {
1✔
42
        if (force && this.controlled !== null) return this.controlled;
×
43
        return this.client.commands.misc.controlCharBot(this);
×
44
    }
×
45

1✔
46
    /**
1✔
47
     * Release control of the character associated with this BotUser.
1✔
48
     * @calls {@link ControlledCharacter.release}
1✔
49
     */
1✔
50
    async release(): Promise<ControlledCharacter | null> {
1✔
51
        if (this.controlled === null) return null;
×
52
        return this.controlled.release();
×
53
    }
×
54

1✔
55
    /**
1✔
56
     * Wake up the character associated with this BotUser.
1✔
57
     * @param hidden If the character should be hidden from the awake list.
1✔
58
     * @param force Ignore the character already being awake.
1✔
59
     * @calls {@link ControlledCharacter.wakeup}, {@link controlChar} > {@link ControlledCharacter.wakeup}
1✔
60
     */
1✔
61
    async wakeup(hidden?: boolean, force = true): Promise<ControlledCharacter> {
1✔
62
        if (this.controlled !== null) {
×
63
            if (this.controlled.state === "awake" && force) {
×
64
                return this.controlled;
×
65
            }
×
66
            await this.controlled.wakeup(hidden, force);
×
67
            return this.controlled;
×
68
        }
×
69
        return this.controlChar(force)
×
70
            .then(char => char.wakeup(hidden, force).then(() => char));
×
71
    }
×
72
}
1✔
73

1✔
74
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