mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
rebuilt files
This commit is contained in:
@@ -1,39 +1,26 @@
|
||||
"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 _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");
|
||||
var Cache = require("../Util/Cache.js");
|
||||
var PermissionOverwrite = require("./PermissionOverwrite.js");
|
||||
var reg = require("../Util/ArgumentRegulariser.js").reg;
|
||||
|
||||
var Channel = (function (_Equality) {
|
||||
_inherits(Channel, _Equality);
|
||||
class Channel extends Equality {
|
||||
|
||||
function Channel(data, client) {
|
||||
_classCallCheck(this, Channel);
|
||||
|
||||
_Equality.call(this);
|
||||
constructor(data, client) {
|
||||
super();
|
||||
this.id = data.id;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
Channel.prototype["delete"] = function _delete() {
|
||||
get isPrivate() {
|
||||
return !!this.server;
|
||||
}
|
||||
|
||||
delete() {
|
||||
return this.client.deleteChannel.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
_createClass(Channel, [{
|
||||
key: "isPrivate",
|
||||
get: function get() {
|
||||
return !!this.server;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Channel;
|
||||
})(Equality);
|
||||
}
|
||||
|
||||
module.exports = Channel;
|
||||
@@ -1,22 +1,15 @@
|
||||
"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;
|
||||
|
||||
var ChannelPermissions = (function () {
|
||||
function ChannelPermissions(permissions) {
|
||||
_classCallCheck(this, ChannelPermissions);
|
||||
|
||||
class ChannelPermissions {
|
||||
constructor(permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
ChannelPermissions.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
|
||||
@@ -43,16 +36,14 @@ var ChannelPermissions = (function () {
|
||||
voiceMoveMembers: hp(Permissions.voiceMoveMembers),
|
||||
voiceUseVAD: hp(Permissions.voiceUseVAD)
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
ChannelPermissions.prototype.serialize = function serialize() {
|
||||
serialize() {
|
||||
// ;n;
|
||||
return this.serialise();
|
||||
};
|
||||
|
||||
ChannelPermissions.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];
|
||||
}
|
||||
@@ -67,9 +58,7 @@ var ChannelPermissions = (function () {
|
||||
}
|
||||
}
|
||||
return !!(this.permissions & perm);
|
||||
};
|
||||
|
||||
return ChannelPermissions;
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ChannelPermissions;
|
||||
@@ -1,32 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Server = require("./Server.js");
|
||||
var ServerChannel = require("./ServerChannel.js");
|
||||
|
||||
var Invite = (function () {
|
||||
function Invite(data, chan, client) {
|
||||
_classCallCheck(this, Invite);
|
||||
class Invite {
|
||||
constructor(data, chan, client) {
|
||||
this.maxAge = data.max_age;
|
||||
this.code = data.code;
|
||||
this.server = chan.server;
|
||||
this.channel = chan;
|
||||
this.revoked = data.revoked;
|
||||
this.createdAt = Date.parse(data.created_at);
|
||||
this.temporary = data.temporary;
|
||||
this.uses = data.uses;
|
||||
this.maxUses = data.uses;
|
||||
this.inviter = client.internal.users.get("id", data.inviter.id);
|
||||
this.xkcd = data.xkcdpass;
|
||||
}
|
||||
|
||||
this.maxAge = data.max_age;
|
||||
this.code = data.code;
|
||||
this.server = chan.server;
|
||||
this.channel = chan;
|
||||
this.revoked = data.revoked;
|
||||
this.createdAt = Date.parse(data.created_at);
|
||||
this.temporary = data.temporary;
|
||||
this.uses = data.uses;
|
||||
this.maxUses = data.uses;
|
||||
this.inviter = client.internal.users.get("id", data.inviter.id);
|
||||
this.xkcd = data.xkcdpass;
|
||||
}
|
||||
|
||||
Invite.prototype.toString = function toString() {
|
||||
return "https://discord.gg/" + this.code;
|
||||
};
|
||||
|
||||
return Invite;
|
||||
})();
|
||||
toString() {
|
||||
return `https://discord.gg/${ this.code }`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Invite;
|
||||
@@ -1,25 +1,13 @@
|
||||
"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 _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");
|
||||
var User = require("./User.js");
|
||||
var reg = require("../Util/ArgumentRegulariser.js").reg;
|
||||
var Equality = require("../Util/Equality");
|
||||
|
||||
var Message = (function (_Equality) {
|
||||
_inherits(Message, _Equality);
|
||||
|
||||
function Message(data, channel, client) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, Message);
|
||||
|
||||
_Equality.call(this);
|
||||
class Message extends Equality {
|
||||
constructor(data, channel, client) {
|
||||
super();
|
||||
this.channel = channel;
|
||||
this.client = client;
|
||||
this.nonce = data.nonce;
|
||||
@@ -37,51 +25,46 @@ var Message = (function (_Equality) {
|
||||
this.content = data.content;
|
||||
this.mentions = new Cache();
|
||||
|
||||
data.mentions.forEach(function (mention) {
|
||||
data.mentions.forEach(mention => {
|
||||
// this is .add and not .get because it allows the bot to cache
|
||||
// users from messages from logs who may have left the server and were
|
||||
// not previously cached.
|
||||
if (mention instanceof User) _this.mentions.push(mention);else _this.mentions.add(client.internal.users.add(new User(mention, client)));
|
||||
if (mention instanceof User) this.mentions.push(mention);else this.mentions.add(client.internal.users.add(new User(mention, client)));
|
||||
});
|
||||
}
|
||||
|
||||
Message.prototype.isMentioned = function isMentioned(user) {
|
||||
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() {
|
||||
toString() {
|
||||
return this.content;
|
||||
};
|
||||
}
|
||||
|
||||
Message.prototype["delete"] = function _delete() {
|
||||
delete() {
|
||||
return this.client.deleteMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
Message.prototype.update = function update() {
|
||||
update() {
|
||||
return this.client.updateMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
Message.prototype.reply = function reply() {
|
||||
reply() {
|
||||
return this.client.reply.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
Message.prototype.replyTTS = function replyTTS() {
|
||||
replyTTS() {
|
||||
return this.client.replyTTS.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
_createClass(Message, [{
|
||||
key: "sender",
|
||||
get: function get() {
|
||||
return this.author;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Message;
|
||||
})(Equality);
|
||||
get sender() {
|
||||
return this.author;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Message;
|
||||
@@ -1,24 +1,14 @@
|
||||
"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 _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");
|
||||
var User = require("./User.js");
|
||||
var Equality = require("../Util/Equality.js");
|
||||
var Cache = require("../Util/Cache.js");
|
||||
var reg = require("../Util/ArgumentRegulariser.js").reg;
|
||||
|
||||
var PMChannel = (function (_Channel) {
|
||||
_inherits(PMChannel, _Channel);
|
||||
|
||||
function PMChannel(data, client) {
|
||||
_classCallCheck(this, PMChannel);
|
||||
|
||||
_Channel.call(this, data, client);
|
||||
class PMChannel extends Channel {
|
||||
constructor(data, client) {
|
||||
super(data, client);
|
||||
|
||||
this.type = data.type || "text";
|
||||
this.lastMessageId = data.last_message_id;
|
||||
@@ -27,27 +17,21 @@ var PMChannel = (function (_Channel) {
|
||||
}
|
||||
|
||||
/* warning! may return null */
|
||||
get lastMessage() {
|
||||
return this.messages.get("id", this.lastMessageID);
|
||||
}
|
||||
|
||||
PMChannel.prototype.toString = function toString() {
|
||||
toString() {
|
||||
return this.recipient.toString();
|
||||
};
|
||||
}
|
||||
|
||||
PMChannel.prototype.sendMessage = function sendMessage() {
|
||||
sendMessage() {
|
||||
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
PMChannel.prototype.sendTTSMessage = function sendTTSMessage() {
|
||||
sendTTSMessage() {
|
||||
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
_createClass(PMChannel, [{
|
||||
key: "lastMessage",
|
||||
get: function get() {
|
||||
return this.messages.get("id", this.lastMessageID);
|
||||
}
|
||||
}]);
|
||||
|
||||
return PMChannel;
|
||||
})(Channel);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PMChannel;
|
||||
@@ -1,15 +1,10 @@
|
||||
"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;
|
||||
|
||||
var PermissionOverwrite = (function () {
|
||||
function PermissionOverwrite(data) {
|
||||
_classCallCheck(this, PermissionOverwrite);
|
||||
class PermissionOverwrite {
|
||||
|
||||
constructor(data) {
|
||||
this.id = data.id;
|
||||
this.type = data.type; // member or role
|
||||
this.deny = data.deny;
|
||||
@@ -17,70 +12,59 @@ var PermissionOverwrite = (function () {
|
||||
}
|
||||
|
||||
// returns an array of allowed permissions
|
||||
get allowed() {
|
||||
var allowed = [];
|
||||
for (var permName in Permissions) {
|
||||
if (permName === "manageRoles" || permName === "manageChannels") {
|
||||
// these permissions do not exist in overwrites.
|
||||
continue;
|
||||
}
|
||||
|
||||
PermissionOverwrite.prototype.setAllowed = function setAllowed(allowedArray) {
|
||||
var _this = this;
|
||||
if (!!(this.allow & Permissions[permName])) {
|
||||
allowed.push(permName);
|
||||
}
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
allowedArray.forEach(function (permission) {
|
||||
// returns an array of denied permissions
|
||||
get denied() {
|
||||
var denied = [];
|
||||
for (var permName in Permissions) {
|
||||
if (permName === "manageRoles" || permName === "manageChannels") {
|
||||
// these permissions do not exist in overwrites.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!!(this.deny & Permissions[permName])) {
|
||||
denied.push(permName);
|
||||
}
|
||||
}
|
||||
return denied;
|
||||
}
|
||||
|
||||
setAllowed(allowedArray) {
|
||||
allowedArray.forEach(permission => {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
_this.allow |= 1 << permission;
|
||||
this.allow |= 1 << permission;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
PermissionOverwrite.prototype.setDenied = function setDenied(deniedArray) {
|
||||
var _this2 = this;
|
||||
|
||||
deniedArray.forEach(function (permission) {
|
||||
setDenied(deniedArray) {
|
||||
deniedArray.forEach(permission => {
|
||||
if (permission instanceof String || typeof permission === "string") {
|
||||
permission = Permissions[permission];
|
||||
}
|
||||
if (permission) {
|
||||
_this2.deny |= 1 << permission;
|
||||
this.deny |= 1 << permission;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
_createClass(PermissionOverwrite, [{
|
||||
key: "allowed",
|
||||
get: function get() {
|
||||
var allowed = [];
|
||||
for (var permName in Permissions) {
|
||||
if (permName === "manageRoles" || permName === "manageChannels") {
|
||||
// these permissions do not exist in overwrites.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!!(this.allow & Permissions[permName])) {
|
||||
allowed.push(permName);
|
||||
}
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
// returns an array of denied permissions
|
||||
}, {
|
||||
key: "denied",
|
||||
get: function get() {
|
||||
var denied = [];
|
||||
for (var permName in Permissions) {
|
||||
if (permName === "manageRoles" || permName === "manageChannels") {
|
||||
// these permissions do not exist in overwrites.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!!(this.deny & Permissions[permName])) {
|
||||
denied.push(permName);
|
||||
}
|
||||
}
|
||||
return denied;
|
||||
}
|
||||
}]);
|
||||
|
||||
return PermissionOverwrite;
|
||||
})();
|
||||
}
|
||||
|
||||
module.exports = PermissionOverwrite;
|
||||
@@ -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;
|
||||
@@ -1,11 +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"); } }
|
||||
|
||||
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");
|
||||
var Endpoints = require("../Constants.js").Endpoints;
|
||||
var Cache = require("../Util/Cache.js");
|
||||
@@ -16,15 +10,10 @@ var Role = require("./Role.js");
|
||||
|
||||
var strictKeys = ["region", "ownerID", "name", "id", "icon", "afkTimeout", "afkChannelID"];
|
||||
|
||||
var Server = (function (_Equality) {
|
||||
_inherits(Server, _Equality);
|
||||
class Server extends Equality {
|
||||
constructor(data, client) {
|
||||
|
||||
function Server(data, client) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, Server);
|
||||
|
||||
_Equality.call(this);
|
||||
super();
|
||||
|
||||
var self = this;
|
||||
this.client = client;
|
||||
@@ -43,48 +32,33 @@ var Server = (function (_Equality) {
|
||||
|
||||
var self = this;
|
||||
|
||||
data.roles.forEach(function (dataRole) {
|
||||
_this.roles.add(new Role(dataRole, _this, client));
|
||||
data.roles.forEach(dataRole => {
|
||||
this.roles.add(new Role(dataRole, this, client));
|
||||
});
|
||||
|
||||
data.members.forEach(function (dataUser) {
|
||||
_this.memberMap[dataUser.user.id] = {
|
||||
roles: dataUser.roles.map(function (pid) {
|
||||
return self.roles.get("id", pid);
|
||||
}),
|
||||
data.members.forEach(dataUser => {
|
||||
this.memberMap[dataUser.user.id] = {
|
||||
roles: dataUser.roles.map(pid => self.roles.get("id", pid)),
|
||||
mute: dataUser.mute,
|
||||
deaf: dataUser.deaf,
|
||||
joinedAt: Date.parse(dataUser.joined_at)
|
||||
};
|
||||
var user = client.internal.users.add(new User(dataUser.user, client));
|
||||
_this.members.add(user);
|
||||
this.members.add(user);
|
||||
});
|
||||
|
||||
data.channels.forEach(function (dataChannel) {
|
||||
data.channels.forEach(dataChannel => {
|
||||
if (dataChannel.type === "text") {
|
||||
var channel = client.internal.channels.add(new TextChannel(dataChannel, client, _this));
|
||||
_this.channels.add(channel);
|
||||
var channel = client.internal.channels.add(new TextChannel(dataChannel, client, this));
|
||||
this.channels.add(channel);
|
||||
} else {
|
||||
var channel = client.internal.channels.add(new VoiceChannel(dataChannel, client, _this));
|
||||
_this.channels.add(channel);
|
||||
var channel = client.internal.channels.add(new VoiceChannel(dataChannel, client, this));
|
||||
this.channels.add(channel);
|
||||
}
|
||||
});
|
||||
|
||||
if (data.presences) {
|
||||
for (var _iterator = data.presences, _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 presence = _ref;
|
||||
|
||||
for (var presence of data.presences) {
|
||||
var user = client.internal.users.get("id", presence.user.id);
|
||||
if (user) {
|
||||
user.status = presence.status;
|
||||
@@ -94,39 +68,46 @@ var Server = (function (_Equality) {
|
||||
}
|
||||
}
|
||||
|
||||
Server.prototype.rolesOfUser = function rolesOfUser(user) {
|
||||
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.rolesOf = function rolesOf(user) {
|
||||
rolesOf(user) {
|
||||
return this.rolesOfUser(user);
|
||||
};
|
||||
}
|
||||
|
||||
Server.prototype.toString = function toString() {
|
||||
get iconURL() {
|
||||
if (!this.icon) {
|
||||
return null;
|
||||
} else {
|
||||
return Endpoints.SERVER_ICON(this.id, this.icon);
|
||||
}
|
||||
}
|
||||
|
||||
get afkChannel() {
|
||||
return this.channels.get("id", this.afkChannelID);
|
||||
}
|
||||
|
||||
get defaultChannel() {
|
||||
return this.channels.get("id", this.id);
|
||||
}
|
||||
|
||||
get owner() {
|
||||
return this.members.get("id", this.ownerID);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.name;
|
||||
};
|
||||
}
|
||||
|
||||
Server.prototype.equalsStrict = function equalsStrict(obj) {
|
||||
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;
|
||||
|
||||
for (var key of strictKeys) {
|
||||
if (obj[key] !== this[key]) {
|
||||
return false;
|
||||
}
|
||||
@@ -135,35 +116,8 @@ var Server = (function (_Equality) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
_createClass(Server, [{
|
||||
key: "iconURL",
|
||||
get: function get() {
|
||||
if (!this.icon) {
|
||||
return null;
|
||||
} else {
|
||||
return Endpoints.SERVER_ICON(this.id, this.icon);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "afkChannel",
|
||||
get: function get() {
|
||||
return this.channels.get("id", this.afkChannelID);
|
||||
}
|
||||
}, {
|
||||
key: "defaultChannel",
|
||||
get: function get() {
|
||||
return this.channels.get("id", this.id);
|
||||
}
|
||||
}, {
|
||||
key: "owner",
|
||||
get: function get() {
|
||||
return this.members.get("id", this.ownerID);
|
||||
}
|
||||
}]);
|
||||
|
||||
return Server;
|
||||
})(Equality);
|
||||
}
|
||||
|
||||
module.exports = Server;
|
||||
@@ -1,35 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
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 Channel = require("./Channel.js");
|
||||
var Cache = require("../Util/Cache.js");
|
||||
var PermissionOverwrite = require("./PermissionOverwrite.js");
|
||||
var ChannelPermissions = require("./ChannelPermissions.js");
|
||||
var reg = require("../Util/ArgumentRegulariser.js").reg;
|
||||
|
||||
var ServerChannel = (function (_Channel) {
|
||||
_inherits(ServerChannel, _Channel);
|
||||
|
||||
function ServerChannel(data, client, server) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, ServerChannel);
|
||||
|
||||
_Channel.call(this, data, client);
|
||||
class ServerChannel extends Channel {
|
||||
constructor(data, client, server) {
|
||||
super(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));
|
||||
data.permission_overwrites.forEach(permission => {
|
||||
this.permissionOverwrites.add(new PermissionOverwrite(permission));
|
||||
});
|
||||
}
|
||||
|
||||
ServerChannel.prototype.permissionsOf = function permissionsOf(user) {
|
||||
permissionsOf(user) {
|
||||
user = this.client.internal.resolver.resolveUser(user);
|
||||
if (user) {
|
||||
if (this.server.owner.equals(user)) {
|
||||
@@ -38,13 +28,11 @@ var ServerChannel = (function (_Channel) {
|
||||
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 userRolesID = userRoles.map(v => v.id);
|
||||
var roleOverwrites = [],
|
||||
memberOverwrites = [];
|
||||
|
||||
this.permissionOverwrites.forEach(function (overwrite) {
|
||||
this.permissionOverwrites.forEach(overwrite => {
|
||||
if (overwrite.type === "member" && overwrite.id === user.id) {
|
||||
memberOverwrites.push(overwrite);
|
||||
} else if (overwrite.type === "role" && overwrite.id in userRolesID) {
|
||||
@@ -54,37 +42,11 @@ var ServerChannel = (function (_Channel) {
|
||||
|
||||
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;
|
||||
|
||||
for (var serverRole of userRoles) {
|
||||
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;
|
||||
|
||||
for (var overwrite of roleOverwrites.concat(memberOverwrites)) {
|
||||
permissions = permissions & ~overwrite.deny;
|
||||
permissions = permissions | overwrite.allow;
|
||||
}
|
||||
@@ -93,25 +55,23 @@ var ServerChannel = (function (_Channel) {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ServerChannel.prototype.permsOf = function permsOf(user) {
|
||||
permsOf(user) {
|
||||
return this.permissionsOf(user);
|
||||
};
|
||||
}
|
||||
|
||||
ServerChannel.prototype.mention = function mention() {
|
||||
return "<#" + this.id + ">";
|
||||
};
|
||||
mention() {
|
||||
return `<#${ this.id }>`;
|
||||
}
|
||||
|
||||
ServerChannel.prototype.toString = function toString() {
|
||||
toString() {
|
||||
return this.mention();
|
||||
};
|
||||
}
|
||||
|
||||
ServerChannel.prototype.setName = function setName() {
|
||||
setName() {
|
||||
return this.client.setChannelName.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
return ServerChannel;
|
||||
})(Channel);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ServerChannel;
|
||||
@@ -1,22 +1,12 @@
|
||||
"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 _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");
|
||||
var Cache = require("../Util/Cache.js");
|
||||
var reg = require("../Util/ArgumentRegulariser.js").reg;
|
||||
|
||||
var TextChannel = (function (_ServerChannel) {
|
||||
_inherits(TextChannel, _ServerChannel);
|
||||
|
||||
function TextChannel(data, client, server) {
|
||||
_classCallCheck(this, TextChannel);
|
||||
|
||||
_ServerChannel.call(this, data, client, server);
|
||||
class TextChannel extends ServerChannel {
|
||||
constructor(data, client, server) {
|
||||
super(data, client, server);
|
||||
|
||||
this.topic = data.topic;
|
||||
this.lastMessageID = data.last_message_id;
|
||||
@@ -24,35 +14,29 @@ var TextChannel = (function (_ServerChannel) {
|
||||
}
|
||||
|
||||
/* warning! may return null */
|
||||
get lastMessage() {
|
||||
return this.messages.get("id", this.lastMessageID);
|
||||
}
|
||||
|
||||
TextChannel.prototype.setTopic = function setTopic() {
|
||||
setTopic() {
|
||||
return this.client.setTopic.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
TextChannel.prototype.setNameAndTopic = function setNameAndTopic() {
|
||||
setNameAndTopic() {
|
||||
return this.client.setChannelNameAndTopic.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
TextChannel.prototype.update = function update() {
|
||||
update() {
|
||||
return this.client.updateChannel.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
TextChannel.prototype.sendMessage = function sendMessage() {
|
||||
sendMessage() {
|
||||
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
}
|
||||
|
||||
TextChannel.prototype.sendTTSMessage = function sendTTSMessage() {
|
||||
sendTTSMessage() {
|
||||
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
||||
};
|
||||
|
||||
_createClass(TextChannel, [{
|
||||
key: "lastMessage",
|
||||
get: function get() {
|
||||
return this.messages.get("id", this.lastMessageID);
|
||||
}
|
||||
}]);
|
||||
|
||||
return TextChannel;
|
||||
})(ServerChannel);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TextChannel;
|
||||
@@ -1,21 +1,11 @@
|
||||
"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 _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");
|
||||
var Endpoints = require("../Constants.js").Endpoints;
|
||||
|
||||
var User = (function (_Equality) {
|
||||
_inherits(User, _Equality);
|
||||
|
||||
function User(data, client) {
|
||||
_classCallCheck(this, User);
|
||||
|
||||
_Equality.call(this);
|
||||
class User extends Equality {
|
||||
constructor(data, client) {
|
||||
super();
|
||||
this.client = client;
|
||||
this.username = data.username;
|
||||
this.discriminator = data.discriminator;
|
||||
@@ -29,30 +19,25 @@ var User = (function (_Equality) {
|
||||
};
|
||||
}
|
||||
|
||||
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: "avatarURL",
|
||||
get: function get() {
|
||||
if (!this.avatar) {
|
||||
return null;
|
||||
} else {
|
||||
return Endpoints.AVATAR(this.id, this.avatar);
|
||||
}
|
||||
get avatarURL() {
|
||||
if (!this.avatar) {
|
||||
return null;
|
||||
} else {
|
||||
return Endpoints.AVATAR(this.id, this.avatar);
|
||||
}
|
||||
}]);
|
||||
}
|
||||
|
||||
return User;
|
||||
})(Equality);
|
||||
mention() {
|
||||
return `<@${ this.id }>`;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.mention();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = User;
|
||||
@@ -1,21 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
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 ServerChannel = require("./ServerChannel.js");
|
||||
|
||||
var VoiceChannel = (function (_ServerChannel) {
|
||||
_inherits(VoiceChannel, _ServerChannel);
|
||||
|
||||
function VoiceChannel(data, client, server) {
|
||||
_classCallCheck(this, VoiceChannel);
|
||||
|
||||
_ServerChannel.call(this, data, client, server);
|
||||
class VoiceChannel extends ServerChannel {
|
||||
constructor(data, client, server) {
|
||||
super(data, client, server);
|
||||
}
|
||||
|
||||
return VoiceChannel;
|
||||
})(ServerChannel);
|
||||
}
|
||||
|
||||
module.exports = VoiceChannel;
|
||||
Reference in New Issue
Block a user