summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/structures/ClientUserChannelOverride.js
blob: 93efa45ff9580eef19647b4c362c21fdf8a1d72e (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
const Constants = require('../util/Constants');

/**
 * A wrapper around the ClientUser's channel overrides.
 */
class ClientUserChannelOverride {
  constructor(data) {
    this.patch(data);
  }

  /**
   * Patch the data contained in this class with new partial data.
   * @param {Object} data Data to patch this with
   * @returns {void}
   * @private
   */
  patch(data) {
    for (const key of Object.keys(Constants.UserChannelOverrideMap)) {
      const value = Constants.UserChannelOverrideMap[key];
      if (!data.hasOwnProperty(key)) continue;
      if (typeof value === 'function') {
        this[value.name] = value(data[key]);
      } else {
        this[value] = data[key];
      }
    }
  }
}

module.exports = ClientUserChannelOverride;