summaryrefslogtreecommitdiff
path: root/desktop/node_modules/@xhayper/discord-rpc/dist/structures/User.js
blob: 8e313cb2e51c02fb4da3e054cbbe10d561cdd7bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = void 0;
const Base_1 = require("./Base");
class User extends Base_1.Base {
    /**
     * the user's id
     */
    id;
    /**
     * the user's username, not unique across the platform
     */
    username;
    /**
     * the user's 4-digit discord-tag
     */
    discriminator;
    /**
     * the user's [avatar hash](https://discord.com/developers/docs/reference#image-formatting)
     */
    avatar;
    /**
     * the [flags](https://discord.com/developers/docs/resources/user#user-object-user-flags) on a user's account
     */
    flags;
    /**
     * the [type of Nitro subscription](https://discord.com/developers/docs/resources/user#user-object-premium-types) on a user's account
     */
    premium_type;
    /**
     * the public [flags](https://discord.com/developers/docs/resources/user#user-object-user-flags) on a user's account
     */
    public_flags;
    /**
     * user's rich presence
     */
    presence;
    avatar_decoration;
    constructor(client, props) {
        super(client);
        Object.assign(this, props);
        // word can't explains how much i hate this
        this.id = props.id;
        this.username = props.username;
        this.discriminator = props.discriminator;
        this.avatar = props.avatar;
    }
    /**
     * The URL to the user's avatar.
     */
    get avatarUrl() {
        const isAnimated = this.avatar && this.avatar.startsWith("a_");
        return this.avatar
            ? `${this.client.cdnHost}/avatars/${this.id}/${this.avatar}${isAnimated ? ".gif" : ".png"}`
            : this.defaultAvatarUrl;
    }
    /**
     * The URL to the user's default avatar. (avatar that is used when user have no avatar)
     */
    get defaultAvatarUrl() {
        return `${this.client.cdnHost}/embed/avatars/${parseInt(this.discriminator.substring(1)) % 5}.png`;
    }
    /**
     * User's tag
     */
    get tag() {
        return `${this.username}#${this.discriminator}`;
    }
}
exports.User = User;