discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.36k stars 3.97k forks source link

Presence Typing Missing in ClientUser #6460

Closed AurelicButter closed 3 years ago

AurelicButter commented 3 years ago

Please describe the problem you are having in as much detail as possible:

When trying to get the current presence for my bot through the client, the TSLint errors with a Property 'presence' does not exist on type 'ClientUser'. ts(2339) message. image

However, if I suppress the error with a ts-ignore comment, I can get the presence during runtime with the same code. image

Include a reproducible code sample here, if possible:

export function presenceHelper(
    client: Client,
    name: string,
    type = "play",
    status: PresenceStatusData = "online"
): void {
    // Snip non-relevant code

    let presenceStatus = null;
    if (client.user.presence.activities[0].name !== null) {
        presenceStatus = client.user.presence.activities[0].name;
    }
    // Snip non-relevant code
}

Further details: This is a part of my code for v12 and only ran into this when updating to v13. I can't say if this typing issue is recent or older as I'm converting my codebase into TypeScript from JavaScript at the same time. The v13 documentation also lists presence as a read-only property for ClientUser.

xMooddyy commented 3 years ago

Pending fix in PR #6450

AurelicButter commented 3 years ago

Pending fix in PR #6450

Correct me if I'm reading this wrong, but that PR doesn't seem to fix what I was reporting on. The PR only targets Client.presence and not ClientUser.presence. It is also marked as private so it would be not accessible outside of the class functions.

ImRodry commented 3 years ago

That PR does indeed only fix the missing declarations for client. I'll add this as well since it's still in the scope of the PR, thanks!