mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
The Client now SHOULD add roles properly to members, as they leave it up to the Server class.
62 lines
No EOL
3.1 KiB
JavaScript
62 lines
No EOL
3.1 KiB
JavaScript
"use strict";
|
|
|
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
|
|
|
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
|
|
var User = require("./user.js");
|
|
|
|
var Member = (function (_User) {
|
|
_inherits(Member, _User);
|
|
|
|
function Member(user, server, roles) {
|
|
_classCallCheck(this, Member);
|
|
|
|
_get(Object.getPrototypeOf(Member.prototype), "constructor", this).call(this, user); // should work, we are basically creating a Member that has the same properties as user and a few more
|
|
this.server = server;
|
|
this.rawRoles = roles;
|
|
}
|
|
|
|
_createClass(Member, [{
|
|
key: "roles",
|
|
get: function get() {
|
|
|
|
var ufRoles = [];
|
|
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
|
|
try {
|
|
for (var _iterator = this.rawRoles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
var rawRole = _step.value;
|
|
|
|
ufRoles.push(this.server.getRole(rawRole));
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator["return"]) {
|
|
_iterator["return"]();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
|
|
return ufRoles;
|
|
}
|
|
}]);
|
|
|
|
return Member;
|
|
})(User);
|
|
|
|
module.exports = Member; |