rebuilt files

This commit is contained in:
Amish Shah
2015-11-22 15:01:42 +00:00
parent cf33df18cf
commit 68b60c5464
27 changed files with 1023 additions and 1746 deletions

View File

@@ -1,7 +1,5 @@
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Permissions = require("../Constants.js").Permissions;
/*
@@ -16,14 +14,10 @@ example data
color: 0 }
*/
var DefaultRole = [Permissions.createInstantInvite, Permissions.readMessages, Permissions.readMessageHistory, Permissions.sendMessages, Permissions.sendTTSMessages, Permissions.embedLinks, Permissions.attachFiles, Permissions.readMessageHistory, Permissions.mentionEveryone, Permissions.voiceConnect, Permissions.voiceSpeak, Permissions.voiceUseVAD].reduce(function (previous, current) {
return previous | current;
}, 0);
var Role = (function () {
function Role(data, server, client) {
_classCallCheck(this, Role);
const DefaultRole = [Permissions.createInstantInvite, Permissions.readMessages, Permissions.readMessageHistory, Permissions.sendMessages, Permissions.sendTTSMessages, Permissions.embedLinks, Permissions.attachFiles, Permissions.readMessageHistory, Permissions.mentionEveryone, Permissions.voiceConnect, Permissions.voiceSpeak, Permissions.voiceUseVAD].reduce((previous, current) => previous | current, 0);
class Role {
constructor(data, server, client) {
this.position = data.position || -1;
this.permissions = data.permissions || (data.name === "@everyone" ? DefaultRole : 0);
this.name = data.name || "@everyone";
@@ -35,12 +29,9 @@ var Role = (function () {
this.client = client;
}
Role.prototype.serialise = function serialise(explicit) {
var _this = this;
serialise(explicit) {
var hp = function hp(perm) {
return _this.hasPermission(perm, explicit);
};
var hp = perm => this.hasPermission(perm, explicit);
return {
// general
@@ -67,16 +58,14 @@ var Role = (function () {
voiceMoveMembers: hp(Permissions.voiceMoveMembers),
voiceUseVAD: hp(Permissions.voiceUseVAD)
};
};
}
Role.prototype.serialize = function serialize() {
serialize() {
// ;n;
return this.serialise();
};
Role.prototype.hasPermission = function hasPermission(perm) {
var explicit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
}
hasPermission(perm, explicit = false) {
if (perm instanceof String || typeof perm === "string") {
perm = Permissions[perm];
}
@@ -95,9 +84,9 @@ var Role = (function () {
// !!(36953089 & (1 << 21)) = voice speak allowed
return !!(this.permissions & perm);
};
}
Role.prototype.setPermission = function setPermission(permission, value) {
setPermission(permission, value) {
if (permission instanceof String || typeof permission === "string") {
permission = Permissions[permission];
}
@@ -109,31 +98,27 @@ var Role = (function () {
this.permissions &= ~permission;
}
}
};
}
Role.prototype.setPermissions = function setPermissions(obj) {
var _this2 = this;
obj.forEach(function (value, permission) {
setPermissions(obj) {
obj.forEach((value, permission) => {
if (permission instanceof String || typeof permission === "string") {
permission = Permissions[permission];
}
if (permission) {
// valid permission
_this2.setPermission(permission, value);
this.setPermission(permission, value);
}
});
};
}
Role.prototype.colorAsHex = function colorAsHex() {
colorAsHex() {
var val = this.color.toString();
while (val.length < 6) {
val = "0" + val;
}
return "#" + val;
};
return Role;
})();
}
}
module.exports = Role;