summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/structures/BaseGuildEmoji.js
blob: d3665271cd51d7713f49d95f00deeff883fd4aa9 (plain) (blame)
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
'use strict';

const Emoji = require('./Emoji');

/**
 * Parent class for {@link GuildEmoji} and {@link GuildPreviewEmoji}.
 * @extends {Emoji}
 */
class BaseGuildEmoji extends Emoji {
  constructor(client, data, guild) {
    super(client, data);

    /**
     * The guild this emoji is a part of
     * @type {Guild|GuildPreview}
     */
    this.guild = guild;

    /**
     * Array of role ids this emoji is active for
     * @name BaseGuildEmoji#_roles
     * @type {Snowflake[]}
     * @private
     */
    Object.defineProperty(this, '_roles', { value: [], writable: true });

    this._patch(data);
  }

  _patch(data) {
    if (data.name) this.name = data.name;

    /**
     * Whether or not this emoji requires colons surrounding it
     * @type {boolean}
     * @name GuildEmoji#requiresColons
     */
    if (typeof data.require_colons !== 'undefined') this.requiresColons = data.require_colons;

    /**
     * Whether this emoji is managed by an external service
     * @type {boolean}
     * @name GuildEmoji#managed
     */
    if (typeof data.managed !== 'undefined') this.managed = data.managed;

    /**
     * Whether this emoji is available
     * @type {boolean}
     * @name GuildEmoji#available
     */
    if (typeof data.available !== 'undefined') this.available = data.available;

    if (data.roles) this._roles = data.roles;
  }
}

module.exports = BaseGuildEmoji;