mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Fixed compiled version
Downgraded babel until a working solution found
This commit is contained in:
@@ -4,8 +4,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 Equality = require("../Util/Equality.js");
|
||||
@@ -19,19 +17,16 @@ var Channel = (function (_Equality) {
|
||||
function Channel(data, client) {
|
||||
_classCallCheck(this, Channel);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Channel).call(this));
|
||||
|
||||
_this.id = data.id;
|
||||
_this.client = client;
|
||||
return _this;
|
||||
_Equality.call(this);
|
||||
this.id = data.id;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
Channel.prototype["delete"] = function _delete() {
|
||||
return this.client.deleteChannel.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
_createClass(Channel, [{
|
||||
key: "delete",
|
||||
value: function _delete() {
|
||||
return this.client.deleteChannel.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "isPrivate",
|
||||
get: function get() {
|
||||
return !!this.server;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"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; }; })();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Permissions = require("../Constants.js").Permissions;
|
||||
@@ -13,68 +11,63 @@ var ChannelPermissions = (function () {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
_createClass(ChannelPermissions, [{
|
||||
key: "serialise",
|
||||
value: function serialise(explicit) {
|
||||
var _this = this;
|
||||
ChannelPermissions.prototype.serialise = function serialise(explicit) {
|
||||
var _this = this;
|
||||
|
||||
var hp = function hp(perm) {
|
||||
return _this.hasPermission(perm, explicit);
|
||||
};
|
||||
var hp = function hp(perm) {
|
||||
return _this.hasPermission(perm, explicit);
|
||||
};
|
||||
|
||||
return {
|
||||
// general
|
||||
createInstantInvite: hp(Permissions.createInstantInvite),
|
||||
kickMembers: hp(Permissions.kickMembers),
|
||||
banMembers: hp(Permissions.banMembers),
|
||||
managePermissions: hp(Permissions.managePermissions),
|
||||
manageChannel: hp(Permissions.manageChannel),
|
||||
manageServer: hp(Permissions.manageServer),
|
||||
// text
|
||||
readMessages: hp(Permissions.readMessages),
|
||||
sendMessages: hp(Permissions.sendMessages),
|
||||
sendTTSMessages: hp(Permissions.sendTTSMessages),
|
||||
manageMessages: hp(Permissions.manageMessages),
|
||||
embedLinks: hp(Permissions.embedLinks),
|
||||
attachFiles: hp(Permissions.attachFiles),
|
||||
readMessageHistory: hp(Permissions.readMessageHistory),
|
||||
mentionEveryone: hp(Permissions.mentionEveryone),
|
||||
// voice
|
||||
voiceConnect: hp(Permissions.voiceConnect),
|
||||
voiceSpeak: hp(Permissions.voiceSpeak),
|
||||
voiceMuteMembers: hp(Permissions.voiceMuteMembers),
|
||||
voiceDeafenMembers: hp(Permissions.voiceDeafenMembers),
|
||||
voiceMoveMembers: hp(Permissions.voiceMoveMembers),
|
||||
voiceUseVAD: hp(Permissions.voiceUseVAD)
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "serialize",
|
||||
value: function serialize() {
|
||||
// ;n;
|
||||
return this.serialise();
|
||||
}
|
||||
}, {
|
||||
key: "hasPermission",
|
||||
value: function hasPermission(perm) {
|
||||
var explicit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
|
||||
return {
|
||||
// general
|
||||
createInstantInvite: hp(Permissions.createInstantInvite),
|
||||
kickMembers: hp(Permissions.kickMembers),
|
||||
banMembers: hp(Permissions.banMembers),
|
||||
managePermissions: hp(Permissions.managePermissions),
|
||||
manageChannel: hp(Permissions.manageChannel),
|
||||
manageServer: hp(Permissions.manageServer),
|
||||
// text
|
||||
readMessages: hp(Permissions.readMessages),
|
||||
sendMessages: hp(Permissions.sendMessages),
|
||||
sendTTSMessages: hp(Permissions.sendTTSMessages),
|
||||
manageMessages: hp(Permissions.manageMessages),
|
||||
embedLinks: hp(Permissions.embedLinks),
|
||||
attachFiles: hp(Permissions.attachFiles),
|
||||
readMessageHistory: hp(Permissions.readMessageHistory),
|
||||
mentionEveryone: hp(Permissions.mentionEveryone),
|
||||
// voice
|
||||
voiceConnect: hp(Permissions.voiceConnect),
|
||||
voiceSpeak: hp(Permissions.voiceSpeak),
|
||||
voiceMuteMembers: hp(Permissions.voiceMuteMembers),
|
||||
voiceDeafenMembers: hp(Permissions.voiceDeafenMembers),
|
||||
voiceMoveMembers: hp(Permissions.voiceMoveMembers),
|
||||
voiceUseVAD: hp(Permissions.voiceUseVAD)
|
||||
};
|
||||
};
|
||||
|
||||
if (perm instanceof String || typeof perm === "string") {
|
||||
perm = Permissions[perm];
|
||||
}
|
||||
if (!perm) {
|
||||
return false;
|
||||
}
|
||||
if (!explicit) {
|
||||
// implicit permissions allowed
|
||||
if (!!(this.permissions & Permissions.manageRoles)) {
|
||||
// manageRoles allowed, they have all permissions
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !!(this.permissions & perm);
|
||||
ChannelPermissions.prototype.serialize = function serialize() {
|
||||
// ;n;
|
||||
return this.serialise();
|
||||
};
|
||||
|
||||
ChannelPermissions.prototype.hasPermission = function hasPermission(perm) {
|
||||
var explicit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
|
||||
|
||||
if (perm instanceof String || typeof perm === "string") {
|
||||
perm = Permissions[perm];
|
||||
}
|
||||
}]);
|
||||
if (!perm) {
|
||||
return false;
|
||||
}
|
||||
if (!explicit) {
|
||||
// implicit permissions allowed
|
||||
if (!!(this.permissions & Permissions.manageRoles)) {
|
||||
// manageRoles allowed, they have all permissions
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !!(this.permissions & perm);
|
||||
};
|
||||
|
||||
return ChannelPermissions;
|
||||
})();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"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; }; })();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Server = require("./Server.js");
|
||||
@@ -24,12 +22,9 @@ var Invite = (function () {
|
||||
this.xkcd = data.xkcdpass;
|
||||
}
|
||||
|
||||
_createClass(Invite, [{
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return "https://discord.gg/" + this.code;
|
||||
}
|
||||
}]);
|
||||
Invite.prototype.toString = function toString() {
|
||||
return "https://discord.gg/" + this.code;
|
||||
};
|
||||
|
||||
return Invite;
|
||||
})();
|
||||
|
||||
@@ -4,8 +4,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 Cache = require("../Util/Cache.js");
|
||||
@@ -17,26 +15,27 @@ var Message = (function (_Equality) {
|
||||
_inherits(Message, _Equality);
|
||||
|
||||
function Message(data, channel, client) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, Message);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Message).call(this));
|
||||
_Equality.call(this);
|
||||
this.channel = channel;
|
||||
this.client = client;
|
||||
this.nonce = data.nonce;
|
||||
this.attachments = data.attachments;
|
||||
this.tts = data.tts;
|
||||
this.embeds = data.embeds;
|
||||
this.timestamp = Date.parse(data.timestamp);
|
||||
this.everyoneMentioned = data.mention_everyone;
|
||||
this.id = data.id;
|
||||
|
||||
_this.channel = channel;
|
||||
_this.client = client;
|
||||
_this.nonce = data.nonce;
|
||||
_this.attachments = data.attachments;
|
||||
_this.tts = data.tts;
|
||||
_this.embeds = data.embeds;
|
||||
_this.timestamp = Date.parse(data.timestamp);
|
||||
_this.everyoneMentioned = data.mention_everyone;
|
||||
_this.id = data.id;
|
||||
if (data.edited_timestamp) this.editedTimestamp = Date.parse(data.edited_timestamp);
|
||||
|
||||
if (data.edited_timestamp) _this.editedTimestamp = Date.parse(data.edited_timestamp);
|
||||
if (data.author instanceof User) this.author = data.author;else this.author = client.internal.users.add(new User(data.author, client));
|
||||
|
||||
if (data.author instanceof User) _this.author = data.author;else _this.author = client.internal.users.add(new User(data.author, client));
|
||||
|
||||
_this.content = data.content;
|
||||
_this.mentions = new Cache();
|
||||
this.content = data.content;
|
||||
this.mentions = new Cache();
|
||||
|
||||
data.mentions.forEach(function (mention) {
|
||||
// this is .add and not .get because it allows the bot to cache
|
||||
@@ -44,45 +43,38 @@ var Message = (function (_Equality) {
|
||||
// not previously cached.
|
||||
if (mention instanceof User) _this.mentions.push(mention);else _this.mentions.add(client.internal.users.add(new User(mention, client)));
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
Message.prototype.isMentioned = function isMentioned(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
if (user) {
|
||||
return this.mentions.has("id", user.id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Message.prototype.toString = function toString() {
|
||||
return this.content;
|
||||
};
|
||||
|
||||
Message.prototype["delete"] = function _delete() {
|
||||
return this.client.deleteMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
Message.prototype.update = function update() {
|
||||
return this.client.updateMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
Message.prototype.reply = function reply() {
|
||||
return this.client.reply.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
Message.prototype.replyTTS = function replyTTS() {
|
||||
return this.client.replyTTS.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
_createClass(Message, [{
|
||||
key: "isMentioned",
|
||||
value: function isMentioned(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
if (user) {
|
||||
return this.mentions.has("id", user.id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return this.content;
|
||||
}
|
||||
}, {
|
||||
key: "delete",
|
||||
value: function _delete() {
|
||||
return this.client.deleteMessage.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "update",
|
||||
value: function update() {
|
||||
return this.client.updateMessage.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "reply",
|
||||
value: function reply() {
|
||||
return this.client.reply.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "replyTTS",
|
||||
value: function replyTTS() {
|
||||
return this.client.replyTTS.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "sender",
|
||||
get: function get() {
|
||||
return this.author;
|
||||
|
||||
@@ -4,8 +4,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 Channel = require("./Channel.js");
|
||||
@@ -20,33 +18,29 @@ var PMChannel = (function (_Channel) {
|
||||
function PMChannel(data, client) {
|
||||
_classCallCheck(this, PMChannel);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(PMChannel).call(this, data, client));
|
||||
_Channel.call(this, data, client);
|
||||
|
||||
_this.type = data.type || "text";
|
||||
_this.lastMessageId = data.last_message_id;
|
||||
_this.messages = new Cache("id", 1000);
|
||||
_this.recipient = _this.client.internal.users.add(new User(data.recipient, _this.client));
|
||||
return _this;
|
||||
this.type = data.type || "text";
|
||||
this.lastMessageId = data.last_message_id;
|
||||
this.messages = new Cache("id", 1000);
|
||||
this.recipient = this.client.internal.users.add(new User(data.recipient, this.client));
|
||||
}
|
||||
|
||||
/* warning! may return null */
|
||||
|
||||
PMChannel.prototype.toString = function toString() {
|
||||
return this.recipient.toString();
|
||||
};
|
||||
|
||||
PMChannel.prototype.sendMessage = function sendMessage() {
|
||||
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
PMChannel.prototype.sendTTSMessage = function sendTTSMessage() {
|
||||
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
_createClass(PMChannel, [{
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return this.recipient.toString();
|
||||
}
|
||||
}, {
|
||||
key: "sendMessage",
|
||||
value: function sendMessage() {
|
||||
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "sendTTSMessage",
|
||||
value: function sendTTSMessage() {
|
||||
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "lastMessage",
|
||||
get: function get() {
|
||||
return this.messages.get("id", this.lastMessageID);
|
||||
|
||||
@@ -18,35 +18,33 @@ var PermissionOverwrite = (function () {
|
||||
|
||||
// returns an array of allowed permissions
|
||||
|
||||
PermissionOverwrite.prototype.setAllowed = function setAllowed(allowedArray) {
|
||||
var _this = this;
|
||||
|
||||
allowedArray.forEach(function (permission) {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
_this.allow |= 1 << permission;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
PermissionOverwrite.prototype.setDenied = function setDenied(deniedArray) {
|
||||
var _this2 = this;
|
||||
|
||||
deniedArray.forEach(function (permission) {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
_this2.deny |= 1 << permission;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
_createClass(PermissionOverwrite, [{
|
||||
key: "setAllowed",
|
||||
value: function setAllowed(allowedArray) {
|
||||
var _this = this;
|
||||
|
||||
allowedArray.forEach(function (permission) {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
_this.allow |= 1 << permission;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "setDenied",
|
||||
value: function setDenied(deniedArray) {
|
||||
var _this2 = this;
|
||||
|
||||
deniedArray.forEach(function (permission) {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
_this2.deny |= 1 << permission;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "allowed",
|
||||
get: function get() {
|
||||
var allowed = [];
|
||||
@@ -64,7 +62,6 @@ var PermissionOverwrite = (function () {
|
||||
}
|
||||
|
||||
// returns an array of denied permissions
|
||||
|
||||
}, {
|
||||
key: "denied",
|
||||
get: function get() {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"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; }; })();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Permissions = require("../Constants.js").Permissions;
|
||||
@@ -37,111 +35,103 @@ var Role = (function () {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
_createClass(Role, [{
|
||||
key: "serialise",
|
||||
value: function serialise(explicit) {
|
||||
var _this = this;
|
||||
Role.prototype.serialise = function serialise(explicit) {
|
||||
var _this = this;
|
||||
|
||||
var hp = function hp(perm) {
|
||||
return _this.hasPermission(perm, explicit);
|
||||
};
|
||||
var hp = function hp(perm) {
|
||||
return _this.hasPermission(perm, explicit);
|
||||
};
|
||||
|
||||
return {
|
||||
// general
|
||||
createInstantInvite: hp(Permissions.createInstantInvite),
|
||||
kickMembers: hp(Permissions.kickMembers),
|
||||
banMembers: hp(Permissions.banMembers),
|
||||
manageRoles: hp(Permissions.manageRoles),
|
||||
manageChannels: hp(Permissions.manageChannels),
|
||||
manageServer: hp(Permissions.manageServer),
|
||||
// text
|
||||
readMessages: hp(Permissions.readMessages),
|
||||
sendMessages: hp(Permissions.sendMessages),
|
||||
sendTTSMessages: hp(Permissions.sendTTSMessages),
|
||||
manageMessages: hp(Permissions.manageMessages),
|
||||
embedLinks: hp(Permissions.embedLinks),
|
||||
attachFiles: hp(Permissions.attachFiles),
|
||||
readMessageHistory: hp(Permissions.readMessageHistory),
|
||||
mentionEveryone: hp(Permissions.mentionEveryone),
|
||||
// voice
|
||||
voiceConnect: hp(Permissions.voiceConnect),
|
||||
voiceSpeak: hp(Permissions.voiceSpeak),
|
||||
voiceMuteMembers: hp(Permissions.voiceMuteMembers),
|
||||
voiceDeafenMembers: hp(Permissions.voiceDeafenMembers),
|
||||
voiceMoveMembers: hp(Permissions.voiceMoveMembers),
|
||||
voiceUseVAD: hp(Permissions.voiceUseVAD)
|
||||
};
|
||||
return {
|
||||
// general
|
||||
createInstantInvite: hp(Permissions.createInstantInvite),
|
||||
kickMembers: hp(Permissions.kickMembers),
|
||||
banMembers: hp(Permissions.banMembers),
|
||||
manageRoles: hp(Permissions.manageRoles),
|
||||
manageChannels: hp(Permissions.manageChannels),
|
||||
manageServer: hp(Permissions.manageServer),
|
||||
// text
|
||||
readMessages: hp(Permissions.readMessages),
|
||||
sendMessages: hp(Permissions.sendMessages),
|
||||
sendTTSMessages: hp(Permissions.sendTTSMessages),
|
||||
manageMessages: hp(Permissions.manageMessages),
|
||||
embedLinks: hp(Permissions.embedLinks),
|
||||
attachFiles: hp(Permissions.attachFiles),
|
||||
readMessageHistory: hp(Permissions.readMessageHistory),
|
||||
mentionEveryone: hp(Permissions.mentionEveryone),
|
||||
// voice
|
||||
voiceConnect: hp(Permissions.voiceConnect),
|
||||
voiceSpeak: hp(Permissions.voiceSpeak),
|
||||
voiceMuteMembers: hp(Permissions.voiceMuteMembers),
|
||||
voiceDeafenMembers: hp(Permissions.voiceDeafenMembers),
|
||||
voiceMoveMembers: hp(Permissions.voiceMoveMembers),
|
||||
voiceUseVAD: hp(Permissions.voiceUseVAD)
|
||||
};
|
||||
};
|
||||
|
||||
Role.prototype.serialize = function serialize() {
|
||||
// ;n;
|
||||
return this.serialise();
|
||||
};
|
||||
|
||||
Role.prototype.hasPermission = function hasPermission(perm) {
|
||||
var explicit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
|
||||
|
||||
if (perm instanceof String || typeof perm === "string") {
|
||||
perm = Permissions[perm];
|
||||
}
|
||||
}, {
|
||||
key: "serialize",
|
||||
value: function serialize() {
|
||||
// ;n;
|
||||
return this.serialise();
|
||||
if (!perm) {
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
key: "hasPermission",
|
||||
value: function hasPermission(perm) {
|
||||
var explicit = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
|
||||
|
||||
if (perm instanceof String || typeof perm === "string") {
|
||||
perm = Permissions[perm];
|
||||
if (!explicit) {
|
||||
// implicit permissions allowed
|
||||
if (!!(this.permissions & Permissions.manageRoles)) {
|
||||
// manageRoles allowed, they have all permissions
|
||||
return true;
|
||||
}
|
||||
if (!perm) {
|
||||
return false;
|
||||
}
|
||||
if (!explicit) {
|
||||
// implicit permissions allowed
|
||||
if (!!(this.permissions & Permissions.manageRoles)) {
|
||||
// manageRoles allowed, they have all permissions
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// e.g.
|
||||
// !!(36953089 & Permissions.manageRoles) = not allowed to manage roles
|
||||
// !!(36953089 & (1 << 21)) = voice speak allowed
|
||||
|
||||
return !!(this.permissions & perm);
|
||||
}
|
||||
}, {
|
||||
key: "setPermission",
|
||||
value: function setPermission(permission, value) {
|
||||
// e.g.
|
||||
// !!(36953089 & Permissions.manageRoles) = not allowed to manage roles
|
||||
// !!(36953089 & (1 << 21)) = voice speak allowed
|
||||
|
||||
return !!(this.permissions & perm);
|
||||
};
|
||||
|
||||
Role.prototype.setPermission = function setPermission(permission, value) {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
// valid permission
|
||||
if (value) {
|
||||
this.permissions |= permission;
|
||||
} else {
|
||||
this.permissions &= ~permission;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Role.prototype.setPermissions = function setPermissions(obj) {
|
||||
var _this2 = this;
|
||||
|
||||
obj.forEach(function (value, permission) {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
// valid permission
|
||||
if (value) {
|
||||
this.permissions |= permission;
|
||||
} else {
|
||||
this.permissions &= ~permission;
|
||||
}
|
||||
_this2.setPermission(permission, value);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "setPermissions",
|
||||
value: function setPermissions(obj) {
|
||||
var _this2 = this;
|
||||
});
|
||||
};
|
||||
|
||||
obj.forEach(function (value, permission) {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
// valid permission
|
||||
_this2.setPermission(permission, value);
|
||||
}
|
||||
});
|
||||
Role.prototype.colorAsHex = function colorAsHex() {
|
||||
var val = this.color.toString();
|
||||
while (val.length < 6) {
|
||||
val = "0" + val;
|
||||
}
|
||||
}, {
|
||||
key: "colorAsHex",
|
||||
value: function colorAsHex() {
|
||||
var val = this.color.toString();
|
||||
while (val.length < 6) {
|
||||
val = "0" + val;
|
||||
}
|
||||
return "#" + val;
|
||||
}
|
||||
}]);
|
||||
return "#" + val;
|
||||
};
|
||||
|
||||
return Role;
|
||||
})();
|
||||
|
||||
@@ -4,8 +4,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 Equality = require("../Util/Equality.js");
|
||||
@@ -22,26 +20,28 @@ var Server = (function (_Equality) {
|
||||
_inherits(Server, _Equality);
|
||||
|
||||
function Server(data, client) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, Server);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Server).call(this));
|
||||
_Equality.call(this);
|
||||
|
||||
var self = _this;
|
||||
_this.client = client;
|
||||
var self = this;
|
||||
this.client = client;
|
||||
|
||||
_this.region = data.region;
|
||||
_this.ownerID = data.owner_id;
|
||||
_this.name = data.name;
|
||||
_this.id = data.id;
|
||||
_this.members = new Cache();
|
||||
_this.channels = new Cache();
|
||||
_this.roles = new Cache();
|
||||
_this.icon = data.icon;
|
||||
_this.afkTimeout = data.afkTimeout;
|
||||
_this.afkChannelID = data.afk_channel_id;
|
||||
_this.memberMap = {};
|
||||
this.region = data.region;
|
||||
this.ownerID = data.owner_id;
|
||||
this.name = data.name;
|
||||
this.id = data.id;
|
||||
this.members = new Cache();
|
||||
this.channels = new Cache();
|
||||
this.roles = new Cache();
|
||||
this.icon = data.icon;
|
||||
this.afkTimeout = data.afkTimeout;
|
||||
this.afkChannelID = data.afk_channel_id;
|
||||
this.memberMap = {};
|
||||
|
||||
var self = _this;
|
||||
var self = this;
|
||||
|
||||
data.roles.forEach(function (dataRole) {
|
||||
_this.roles.add(new Role(dataRole, _this, client));
|
||||
@@ -71,94 +71,73 @@ var Server = (function (_Equality) {
|
||||
});
|
||||
|
||||
if (data.presences) {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
for (var _iterator = data.presences, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
try {
|
||||
for (var _iterator = data.presences[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var presence = _step.value;
|
||||
|
||||
var user = client.internal.users.get("id", presence.user.id);
|
||||
if (user) {
|
||||
user.status = presence.status;
|
||||
user.gameID = presence.game_id;
|
||||
}
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
|
||||
var presence = _ref;
|
||||
|
||||
var user = client.internal.users.get("id", presence.user.id);
|
||||
if (user) {
|
||||
user.status = presence.status;
|
||||
user.gameID = presence.game_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Server, [{
|
||||
key: "rolesOfUser",
|
||||
value: function rolesOfUser(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
if (user) {
|
||||
return this.memberMap[user.id] ? this.memberMap[user.id].roles : [];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
Server.prototype.rolesOfUser = function rolesOfUser(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
if (user) {
|
||||
return this.memberMap[user.id] ? this.memberMap[user.id].roles : [];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "rolesOf",
|
||||
value: function rolesOf(user) {
|
||||
return this.rolesOfUser(user);
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return this.name;
|
||||
}
|
||||
}, {
|
||||
key: "equalsStrict",
|
||||
value: function equalsStrict(obj) {
|
||||
if (obj instanceof Server) {
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
};
|
||||
|
||||
try {
|
||||
for (var _iterator2 = strictKeys[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var key = _step2.value;
|
||||
Server.prototype.rolesOf = function rolesOf(user) {
|
||||
return this.rolesOfUser(user);
|
||||
};
|
||||
|
||||
if (obj[key] !== this[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
Server.prototype.toString = function toString() {
|
||||
return this.name;
|
||||
};
|
||||
|
||||
Server.prototype.equalsStrict = function equalsStrict(obj) {
|
||||
if (obj instanceof Server) {
|
||||
for (var _iterator2 = strictKeys, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
||||
var _ref2;
|
||||
|
||||
if (_isArray2) {
|
||||
if (_i2 >= _iterator2.length) break;
|
||||
_ref2 = _iterator2[_i2++];
|
||||
} else {
|
||||
_i2 = _iterator2.next();
|
||||
if (_i2.done) break;
|
||||
_ref2 = _i2.value;
|
||||
}
|
||||
|
||||
var key = _ref2;
|
||||
|
||||
if (obj[key] !== this[key]) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
return true;
|
||||
};
|
||||
|
||||
_createClass(Server, [{
|
||||
key: "iconURL",
|
||||
get: function get() {
|
||||
if (!this.icon) {
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
"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; }; })();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 Channel = require("./Channel.js");
|
||||
@@ -18,125 +14,102 @@ var ServerChannel = (function (_Channel) {
|
||||
_inherits(ServerChannel, _Channel);
|
||||
|
||||
function ServerChannel(data, client, server) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, ServerChannel);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ServerChannel).call(this, data, client));
|
||||
|
||||
_this.name = data.name;
|
||||
_this.type = data.type;
|
||||
_this.position = data.position;
|
||||
_this.permissionOverwrites = new Cache();
|
||||
_this.server = server;
|
||||
_Channel.call(this, data, client);
|
||||
this.name = data.name;
|
||||
this.type = data.type;
|
||||
this.position = data.position;
|
||||
this.permissionOverwrites = new Cache();
|
||||
this.server = server;
|
||||
data.permission_overwrites.forEach(function (permission) {
|
||||
_this.permissionOverwrites.add(new PermissionOverwrite(permission));
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(ServerChannel, [{
|
||||
key: "permissionsOf",
|
||||
value: function permissionsOf(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
if (user) {
|
||||
if (this.server.owner.equals(user)) {
|
||||
return new ChannelPermissions(4294967295);
|
||||
}
|
||||
var everyoneRole = this.server.roles.get("name", "@everyone");
|
||||
|
||||
var userRoles = [everyoneRole].concat(this.server.rolesOf(user) || []);
|
||||
var userRolesID = userRoles.map(function (v) {
|
||||
return v.id;
|
||||
});
|
||||
var roleOverwrites = [],
|
||||
memberOverwrites = [];
|
||||
|
||||
this.permissionOverwrites.forEach(function (overwrite) {
|
||||
if (overwrite.type === "member" && overwrite.id === user.id) {
|
||||
memberOverwrites.push(overwrite);
|
||||
} else if (overwrite.type === "role" && overwrite.id in userRolesID) {
|
||||
roleOverwrites.push(overwrite);
|
||||
}
|
||||
});
|
||||
|
||||
var permissions = 0;
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = userRoles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var serverRole = _step.value;
|
||||
|
||||
permissions |= serverRole.permissions;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = roleOverwrites.concat(memberOverwrites)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var overwrite = _step2.value;
|
||||
|
||||
permissions = permissions & ~overwrite.deny;
|
||||
permissions = permissions | overwrite.allow;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ChannelPermissions(permissions);
|
||||
} else {
|
||||
return null;
|
||||
ServerChannel.prototype.permissionsOf = function permissionsOf(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
if (user) {
|
||||
if (this.server.owner.equals(user)) {
|
||||
return new ChannelPermissions(4294967295);
|
||||
}
|
||||
var everyoneRole = this.server.roles.get("name", "@everyone");
|
||||
|
||||
var userRoles = [everyoneRole].concat(this.server.rolesOf(user) || []);
|
||||
var userRolesID = userRoles.map(function (v) {
|
||||
return v.id;
|
||||
});
|
||||
var roleOverwrites = [],
|
||||
memberOverwrites = [];
|
||||
|
||||
this.permissionOverwrites.forEach(function (overwrite) {
|
||||
if (overwrite.type === "member" && overwrite.id === user.id) {
|
||||
memberOverwrites.push(overwrite);
|
||||
} else if (overwrite.type === "role" && overwrite.id in userRolesID) {
|
||||
roleOverwrites.push(overwrite);
|
||||
}
|
||||
});
|
||||
|
||||
var permissions = 0;
|
||||
|
||||
for (var _iterator = userRoles, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var serverRole = _ref;
|
||||
|
||||
permissions |= serverRole.permissions;
|
||||
}
|
||||
|
||||
for (var _iterator2 = roleOverwrites.concat(memberOverwrites), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
||||
var _ref2;
|
||||
|
||||
if (_isArray2) {
|
||||
if (_i2 >= _iterator2.length) break;
|
||||
_ref2 = _iterator2[_i2++];
|
||||
} else {
|
||||
_i2 = _iterator2.next();
|
||||
if (_i2.done) break;
|
||||
_ref2 = _i2.value;
|
||||
}
|
||||
|
||||
var overwrite = _ref2;
|
||||
|
||||
permissions = permissions & ~overwrite.deny;
|
||||
permissions = permissions | overwrite.allow;
|
||||
}
|
||||
|
||||
return new ChannelPermissions(permissions);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}, {
|
||||
key: "permsOf",
|
||||
value: function permsOf(user) {
|
||||
return this.permissionsOf(user);
|
||||
}
|
||||
}, {
|
||||
key: "mention",
|
||||
value: function mention() {
|
||||
return "<#" + this.id + ">";
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return this.mention();
|
||||
}
|
||||
}, {
|
||||
key: "setName",
|
||||
value: function setName() {
|
||||
return this.client.setChannelName.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}]);
|
||||
};
|
||||
|
||||
ServerChannel.prototype.permsOf = function permsOf(user) {
|
||||
return this.permissionsOf(user);
|
||||
};
|
||||
|
||||
ServerChannel.prototype.mention = function mention() {
|
||||
return "<#" + this.id + ">";
|
||||
};
|
||||
|
||||
ServerChannel.prototype.toString = function toString() {
|
||||
return this.mention();
|
||||
};
|
||||
|
||||
ServerChannel.prototype.setName = function setName() {
|
||||
return this.client.setChannelName.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
return ServerChannel;
|
||||
})(Channel);
|
||||
|
||||
@@ -4,8 +4,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 ServerChannel = require("./ServerChannel.js");
|
||||
@@ -18,42 +16,36 @@ var TextChannel = (function (_ServerChannel) {
|
||||
function TextChannel(data, client, server) {
|
||||
_classCallCheck(this, TextChannel);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(TextChannel).call(this, data, client, server));
|
||||
_ServerChannel.call(this, data, client, server);
|
||||
|
||||
_this.topic = data.topic;
|
||||
_this.lastMessageID = data.last_message_id;
|
||||
_this.messages = new Cache("id", client.options.maximumMessages);
|
||||
return _this;
|
||||
this.topic = data.topic;
|
||||
this.lastMessageID = data.last_message_id;
|
||||
this.messages = new Cache("id", client.options.maximumMessages);
|
||||
}
|
||||
|
||||
/* warning! may return null */
|
||||
|
||||
TextChannel.prototype.setTopic = function setTopic() {
|
||||
return this.client.setTopic.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
TextChannel.prototype.setNameAndTopic = function setNameAndTopic() {
|
||||
return this.client.setChannelNameAndTopic.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
TextChannel.prototype.update = function update() {
|
||||
return this.client.updateChannel.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
TextChannel.prototype.sendMessage = function sendMessage() {
|
||||
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
TextChannel.prototype.sendTTSMessage = function sendTTSMessage() {
|
||||
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
_createClass(TextChannel, [{
|
||||
key: "setTopic",
|
||||
value: function setTopic() {
|
||||
return this.client.setTopic.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "setNameAndTopic",
|
||||
value: function setNameAndTopic() {
|
||||
return this.client.setChannelNameAndTopic.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "update",
|
||||
value: function update() {
|
||||
return this.client.updateChannel.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "sendMessage",
|
||||
value: function sendMessage() {
|
||||
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "sendTTSMessage",
|
||||
value: function sendTTSMessage() {
|
||||
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
||||
}
|
||||
}, {
|
||||
key: "lastMessage",
|
||||
get: function get() {
|
||||
return this.messages.get("id", this.lastMessageID);
|
||||
|
||||
@@ -4,8 +4,6 @@ var _createClass = (function () { function defineProperties(target, props) { for
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 Equality = require("../Util/Equality.js");
|
||||
@@ -17,38 +15,33 @@ var User = (function (_Equality) {
|
||||
function User(data, client) {
|
||||
_classCallCheck(this, User);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(User).call(this));
|
||||
|
||||
_this.client = client;
|
||||
_this.username = data.username;
|
||||
_this.discriminator = data.discriminator;
|
||||
_this.id = data.id;
|
||||
_this.avatar = data.avatar;
|
||||
_this.status = data.status || "offline";
|
||||
_this.gameID = data.game_id || null;
|
||||
_this.typing = {
|
||||
_Equality.call(this);
|
||||
this.client = client;
|
||||
this.username = data.username;
|
||||
this.discriminator = data.discriminator;
|
||||
this.id = data.id;
|
||||
this.avatar = data.avatar;
|
||||
this.status = data.status || "offline";
|
||||
this.gameID = data.game_id || null;
|
||||
this.typing = {
|
||||
since: null,
|
||||
channel: null
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
User.prototype.mention = function mention() {
|
||||
return "<@" + this.id + ">";
|
||||
};
|
||||
|
||||
User.prototype.toString = function toString() {
|
||||
return this.mention();
|
||||
};
|
||||
|
||||
User.prototype.equalsStrict = function equalsStrict(obj) {
|
||||
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && this.gameID === obj.gameID;else return false;
|
||||
};
|
||||
|
||||
_createClass(User, [{
|
||||
key: "mention",
|
||||
value: function mention() {
|
||||
return "<@" + this.id + ">";
|
||||
}
|
||||
}, {
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return this.mention();
|
||||
}
|
||||
}, {
|
||||
key: "equalsStrict",
|
||||
value: function equalsStrict(obj) {
|
||||
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && this.gameID === obj.gameID;else return false;
|
||||
}
|
||||
}, {
|
||||
key: "avatarURL",
|
||||
get: function get() {
|
||||
if (!this.avatar) {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
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 ServerChannel = require("./ServerChannel.js");
|
||||
@@ -14,7 +12,7 @@ var VoiceChannel = (function (_ServerChannel) {
|
||||
function VoiceChannel(data, client, server) {
|
||||
_classCallCheck(this, VoiceChannel);
|
||||
|
||||
return _possibleConstructorReturn(this, Object.getPrototypeOf(VoiceChannel).call(this, data, client, server));
|
||||
_ServerChannel.call(this, data, client, server);
|
||||
}
|
||||
|
||||
return VoiceChannel;
|
||||
|
||||
Reference in New Issue
Block a user