summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/structures/PermissionOverwrites.js
blob: ebb78fb289b5a31df415cc74a771026d80c45e76 (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
59
60
61
62
63
64
65
66
67
68
69
const Permissions = require('../util/Permissions');

/**
 * Represents a permission overwrite for a role or member in a guild channel.
 */
class PermissionOverwrites {
  constructor(guildChannel, data) {
    /**
     * The GuildChannel this overwrite is for
     * @name PermissionOverwrites#channel
     * @type {GuildChannel}
     * @readonly
     */
    Object.defineProperty(this, 'channel', { value: guildChannel });

    if (data) this.setup(data);
  }

  setup(data) {
    /**
     * The ID of this overwrite, either a user ID or a role ID
     * @type {Snowflake}
     */
    this.id = data.id;

    /**
     * The type of this overwrite
     * @type {string}
     */
    this.type = data.type;

    /**
     * The permissions that are denied for the user or role as a bitfield.
     * @type {number}
     */
    this.deny = data.deny;

    /**
     * The permissions that are allowed for the user or role as a bitfield.
     * @type {number}
     */
    this.allow = data.allow;

    /**
     * The permissions that are denied for the user or role.
     * @type {Permissions}
     * @deprecated
     */
    this.denied = new Permissions(data.deny).freeze();

    /**
     * The permissions that are allowed for the user or role.
     * @type {Permissions}
     * @deprecated
     */
    this.allowed = new Permissions(data.allow).freeze();
  }

  /**
   * Delete this Permission Overwrite.
   * @param {string} [reason] Reason for deleting this overwrite
   * @returns {Promise<PermissionOverwrites>}
   */
  delete(reason) {
    return this.channel.client.rest.methods.deletePermissionOverwrites(this, reason);
  }
}

module.exports = PermissionOverwrites;