discord.js
Advanced tools
Comparing version 8.0.0 to 8.1.0
@@ -21,3 +21,3 @@ "use strict";exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _InternalClient=require("./InternalClient");var _InternalClient2=_interopRequireDefault(_InternalClient);var _events=require("events");var _events2=_interopRequireDefault(_events);var _StructuresPMChannel=require("../Structures/PMChannel");var _StructuresPMChannel2=_interopRequireDefault(_StructuresPMChannel); // This utility function creates an anonymous error handling wrapper function | ||
* @type {ClientOptions} | ||
*/this.options = options || {};this.options.compress = options.compress || !process.browser;this.options.autoReconnect = options.autoReconnect || false;this.options.rateLimitAsError = options.rateLimitAsError || false;this.options.largeThreshold = options.largeThreshold || 250;this.options.maxCachedMessages = options.maxCachedMessages || 1000;this.options.guildCreateTimeout = options.guildCreateTimeout || 1000;this.options.shardId = options.shardId || 0;this.options.shardCount = options.shardCount || 0;this.options.disableEveryone = options.disableEveryone || false;if(typeof options.shardCount === "number" && typeof options.shardId === "number" && options.shardCount > 0){this.options.shard = [options.shardId,options.shardCount];} /** | ||
*/this.options = options || {};this.options.compress = options.compress || !process.browser;this.options.autoReconnect = options.autoReconnect || true;this.options.rateLimitAsError = options.rateLimitAsError || false;this.options.largeThreshold = options.largeThreshold || 250;this.options.maxCachedMessages = options.maxCachedMessages || 1000;this.options.guildCreateTimeout = options.guildCreateTimeout || 1000;this.options.shardId = options.shardId || 0;this.options.shardCount = options.shardCount || 0;this.options.disableEveryone = options.disableEveryone || false;if(typeof options.shardCount === "number" && typeof options.shardId === "number" && options.shardCount > 0){this.options.shard = [options.shardId,options.shardCount];} /** | ||
* Internal Client that the Client wraps around. | ||
@@ -292,2 +292,87 @@ * @readonly | ||
callback = limit;limit = 50;}return this.internal.getChannelLogs(where,limit,options).then(dataCallback(callback),errorCallback(callback));}; /** | ||
* Gets a single message of a server | ||
* @param {ChannelResolvable} channel to get the message from | ||
* @param {function(err: Error, msg: Message} [callback] callback to the method | ||
* @returns {Promise<Message, Error>} Resolves with a message if the request was successful, otherwise rejects with an error. | ||
* @example | ||
* // get message object off a snowflake and log its content - callback | ||
* client.getMessage(channel, '192696158886428672', function(err, msg) { | ||
* if(!err) { | ||
* console.log(msg.content); | ||
* } else { | ||
* console.log("couldn't get the message"); | ||
* } | ||
* } | ||
* @example | ||
* //get message object off a snowflake and log its content - promise | ||
* client.getMessage(channel, '192696158886428672') | ||
* .then(msg => { | ||
* console.log(msg.content); | ||
* }) | ||
* .catch(err => console.log("couldn't get the message")); | ||
*/Client.prototype.getMessage = function getMessage(channel,messageID){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, msg*/{}:arguments[2];return this.internal.getMessage(channel,messageID).then(dataCallback(callback),errorCallback(callback));}; /** | ||
* Pins a message to a channel. | ||
* @param {MessageResolvable} message to pin. | ||
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error. | ||
* @example | ||
* // pin message - callback | ||
* client.pinMessage(msg, (err) => { | ||
* if(!err) { | ||
* console.log("Successfully pinned message") | ||
* } else { | ||
* console.log("Couldn't pin the message: " + err); | ||
* } | ||
* }); | ||
* @example | ||
* // pin message - promise | ||
* client.pinMessage(msg) | ||
* .then(() => { | ||
* console.log("Successfully pinned message"); | ||
* }) | ||
* .catch(err => console.log("Couldn't pin the message: " + err)); | ||
*/Client.prototype.pinMessage = function pinMessage(msg){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err*/{}:arguments[1];return this.internal.pinMessage(msg).then(dataCallback(callback),errorCallback(callback));}; /** | ||
* Unpins a message to a server. | ||
* @param {MessageResolvable} message to unpin. | ||
* @returns {Promise<null, Error>} resolves null if successful, otherwise rejects with an error. | ||
* @example | ||
* // unpin message - callback | ||
* client.unpinMessage(msg, (err) => { | ||
* if(!err) { | ||
* console.log("Successfully unpinned message") | ||
* } else { | ||
* console.log("Couldn't pin the message: " + err); | ||
* } | ||
* }); | ||
* @example | ||
* // unpin message - promise | ||
* client.unpinMessage(msg) | ||
* .then(() => { | ||
* console.log("Successfully unpinned message"); | ||
* }) | ||
* .catch(err => console.log("Couldn't unpin the message: " + err)); | ||
*/Client.prototype.unpinMessage = function unpinMessage(msg){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err*/{}:arguments[1];return this.internal.unpinMessage(msg).then(dataCallback(callback),errorCallback(callback));}; /** | ||
* Gets all pinned messages of a channel. | ||
* @param {TextChannelResolvable} where to get the pins from. | ||
* @returns {Promise<Array<Message>, Error>} Resolves with an array of messages if successful, otherwise rejects with an error. | ||
* @example | ||
* // log all pinned messages - callback | ||
* client.getPinnedMessages(channel, (err, messages) => { | ||
* if(!err) { | ||
* for(var message of messages) { | ||
* console.log(message.content); | ||
* } | ||
* } else { | ||
* console.log("Couldn't fetch pins: " + err); | ||
* } | ||
* }); | ||
* @example | ||
* // log all pinned messages - promise | ||
* client.getPinnedMessages(channel) | ||
* .then(messages => { | ||
* for(var message of messages) { | ||
* console.log(message.content); | ||
* } | ||
* }) | ||
* .catch(err => console.log("Couldn't fetch pins: " + err)); | ||
*/Client.prototype.getPinnedMessages = function getPinnedMessages(channel){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, messages*/{}:arguments[1];return this.internal.getPinnedMessages(channel).then(dataCallback(callback),errorCallback(callback));}; /** | ||
* Gets the banned users of a server (if the client has permission to) | ||
@@ -399,3 +484,4 @@ * @param {ServerResolvable} server server to get banned users of | ||
Client.prototype.setNickname = function setNickname(server,nick,user){var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];if(typeof user === "function"){ // user is the callback | ||
callback = user;user = null;}if(!user){user = this.user;}return this.internal.setNickname(server,nick,user).then(dataCallback(callback),errorCallback(callback));}; // def createRole | ||
callback = user;user = null;}if(!user){user = this.user;}return this.internal.setNickname(server,nick,user).then(dataCallback(callback),errorCallback(callback));}; // def setNote | ||
Client.prototype.setNote = function setNote(user,note){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setNote(user,note).then(dataCallback(callback),errorCallback(callback));}; // def createRole | ||
Client.prototype.createRole = function createRole(server){var data=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, role*/{}:arguments[2];if(typeof data === "function"){ // data is the callback | ||
@@ -423,4 +509,3 @@ callback = data;data = null;}return this.internal.createRole(server,data).then(dataCallback(callback),errorCallback(callback));}; // def updateRole | ||
Client.prototype.setChannelTopic = function setChannelTopic(channel,topic){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelTopic(channel,topic).then(dataCallback(callback),errorCallback(callback));}; // def setChannelName | ||
Client.prototype.setChannelName = function setChannelName(channel,name){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelName(channel,name).then(dataCallback(callback),errorCallback(callback));}; // def setChannelNameAndTopic | ||
Client.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(channel,name,topic){var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, {}*/{}:arguments[3];return this.internal.setChannelNameAndTopic(channel,name,topic).then(dataCallback(callback),errorCallback(callback));}; // def setChannelPosition | ||
Client.prototype.setChannelName = function setChannelName(channel,name){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelName(channel,name).then(dataCallback(callback),errorCallback(callback));}; // def setChannelPosition | ||
Client.prototype.setChannelPosition = function setChannelPosition(channel,position){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelPosition(channel,position).then(dataCallback(callback),errorCallback(callback));}; // def setChannelUserLimit | ||
@@ -438,3 +523,5 @@ Client.prototype.setChannelUserLimit = function setChannelUserLimit(channel,limit){var callback=arguments.length <= 2 || arguments[2] === undefined?function() /*err, {}*/{}:arguments[2];return this.internal.setChannelUserLimit(channel,limit).then(dataCallback(callback),errorCallback(callback));}; // def setChannelBitrate | ||
Client.prototype.addFriend = function addFriend(user){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.addFriend(user).then(dataCallback(callback),errorCallback(callback));}; // def removeFriend | ||
Client.prototype.removeFriend = function removeFriend(user){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.removeFriend(user).then(dataCallback(callback),errorCallback(callback));}; // def awaitResponse | ||
Client.prototype.removeFriend = function removeFriend(user){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, {}*/{}:arguments[1];return this.internal.removeFriend(user).then(dataCallback(callback),errorCallback(callback));}; // def getOAuthApplication | ||
Client.prototype.getOAuthApplication = function getOAuthApplication(appID){var callback=arguments.length <= 1 || arguments[1] === undefined?function() /*err, bans*/{}:arguments[1];if(typeof appID === "function"){ // appID is the callback | ||
callback = appID;appID = null;}return this.internal.getOAuthApplication(appID).then(dataCallback(callback),errorCallback(callback));}; // def awaitResponse | ||
Client.prototype.awaitResponse = function awaitResponse(msg){var toSend=arguments.length <= 1 || arguments[1] === undefined?null:arguments[1];var _this2=this;var options=arguments.length <= 2 || arguments[2] === undefined?null:arguments[2];var callback=arguments.length <= 3 || arguments[3] === undefined?function() /*err, newMsg*/{}:arguments[3];var ret;if(toSend){if(typeof toSend === "function"){ // (msg, callback) | ||
@@ -441,0 +528,0 @@ callback = toSend;toSend = null;options = null;}else { // (msg, toSend, ...) |
@@ -1,8 +0,8 @@ | ||
"use strict";exports.__esModule = true;var API="https://discordapp.com/api";exports.API = API;var Endpoints={ // general endpoints | ||
LOGIN:API + "/auth/login",LOGOUT:API + "/auth/logout",ME:API + "/users/@me",ME_CHANNELS:API + "/users/@me/channels",ME_SERVER:function ME_SERVER(serverID){return Endpoints.ME + "/guilds/" + serverID;},GATEWAY:API + "/gateway",AVATAR:function AVATAR(userID,avatar){return API + "/users/" + userID + "/avatars/" + avatar + ".jpg";},INVITE:function INVITE(id){return API + "/invite/" + id;}, // servers | ||
"use strict";exports.__esModule = true;var Constants={};var API=Constants.API = "https://discordapp.com/api";var Endpoints=Constants.Endpoints = { // general endpoints | ||
LOGIN:API + "/auth/login",LOGOUT:API + "/auth/logout",ME:API + "/users/@me",ME_CHANNELS:API + "/users/@me/channels",ME_SERVER:function ME_SERVER(serverID){return Endpoints.ME + "/guilds/" + serverID;},OAUTH2_APPLICATION:function OAUTH2_APPLICATION(appID){return API + "/oauth2/applications/" + appID;},ME_NOTES:API + "/users/@me/notes",GATEWAY:API + "/gateway",AVATAR:function AVATAR(userID,avatar){return API + "/users/" + userID + "/avatars/" + avatar + ".jpg";},INVITE:function INVITE(id){return API + "/invite/" + id;}, // servers | ||
SERVERS:API + "/guilds",SERVER:function SERVER(serverID){return Endpoints.SERVERS + "/" + serverID;},SERVER_ICON:function SERVER_ICON(serverID,hash){return Endpoints.SERVER(serverID) + "/icons/" + hash + ".jpg";},SERVER_PRUNE:function SERVER_PRUNE(serverID){return Endpoints.SERVER(serverID) + "/prune";},SERVER_EMBED:function SERVER_EMBED(serverID){return Endpoints.SERVER(serverID) + "/embed";},SERVER_INVITES:function SERVER_INVITES(serverID){return Endpoints.SERVER(serverID) + "/invites";},SERVER_ROLES:function SERVER_ROLES(serverID){return Endpoints.SERVER(serverID) + "/roles";},SERVER_BANS:function SERVER_BANS(serverID){return Endpoints.SERVER(serverID) + "/bans";},SERVER_INTEGRATIONS:function SERVER_INTEGRATIONS(serverID){return Endpoints.SERVER(serverID) + "/integrations";},SERVER_MEMBERS:function SERVER_MEMBERS(serverID){return Endpoints.SERVER(serverID) + "/members";},SERVER_CHANNELS:function SERVER_CHANNELS(serverID){return Endpoints.SERVER(serverID) + "/channels";}, // channels | ||
CHANNELS:API + "/channels",CHANNEL:function CHANNEL(channelID){return Endpoints.CHANNELS + "/" + channelID;},CHANNEL_MESSAGES:function CHANNEL_MESSAGES(channelID){return Endpoints.CHANNEL(channelID) + "/messages";},CHANNEL_INVITES:function CHANNEL_INVITES(channelID){return Endpoints.CHANNEL(channelID) + "/invites";},CHANNEL_TYPING:function CHANNEL_TYPING(channelID){return Endpoints.CHANNEL(channelID) + "/typing";},CHANNEL_PERMISSIONS:function CHANNEL_PERMISSIONS(channelID){return Endpoints.CHANNEL(channelID) + "/permissions";},CHANNEL_MESSAGE:function CHANNEL_MESSAGE(channelID,messageID){return Endpoints.CHANNEL_MESSAGES(channelID) + "/" + messageID;}, // friends | ||
FRIENDS:API + "/users/@me/relationships"};exports.Endpoints = Endpoints;var Permissions={ // general | ||
CHANNELS:API + "/channels",CHANNEL:function CHANNEL(channelID){return Endpoints.CHANNELS + "/" + channelID;},CHANNEL_MESSAGES:function CHANNEL_MESSAGES(channelID){return Endpoints.CHANNEL(channelID) + "/messages";},CHANNEL_INVITES:function CHANNEL_INVITES(channelID){return Endpoints.CHANNEL(channelID) + "/invites";},CHANNEL_TYPING:function CHANNEL_TYPING(channelID){return Endpoints.CHANNEL(channelID) + "/typing";},CHANNEL_PERMISSIONS:function CHANNEL_PERMISSIONS(channelID){return Endpoints.CHANNEL(channelID) + "/permissions";},CHANNEL_MESSAGE:function CHANNEL_MESSAGE(channelID,messageID){return Endpoints.CHANNEL_MESSAGES(channelID) + "/" + messageID;},CHANNEL_PINS:function CHANNEL_PINS(channelID){return Endpoints.CHANNEL(channelID) + "/pins";},CHANNEL_PIN:function CHANNEL_PIN(channelID,messageID){return Endpoints.CHANNEL_PINS(channelID) + "/" + messageID;}, // friends | ||
FRIENDS:API + "/users/@me/relationships"};Constants.Permissions = { // general | ||
createInstantInvite:1 << 0,kickMembers:1 << 1,banMembers:1 << 2,administrator:1 << 3,manageChannels:1 << 4,manageChannel:1 << 4,manageServer:1 << 5,changeNickname:1 << 26,manageNicknames:1 << 27,manageRoles:1 << 28,managePermissions:1 << 28, // text | ||
readMessages:1 << 10,sendMessages:1 << 11,sendTTSMessages:1 << 12,manageMessages:1 << 13,embedLinks:1 << 14,attachFiles:1 << 15,readMessageHistory:1 << 16,mentionEveryone:1 << 17, // voice | ||
voiceConnect:1 << 20,voiceSpeak:1 << 21,voiceMuteMembers:1 << 22,voiceDeafenMembers:1 << 23,voiceMoveMembers:1 << 24,voiceUseVAD:1 << 25};exports.Permissions = Permissions;var PacketType={CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",READY:"READY",SERVER_BAN_ADD:"GUILD_BAN_ADD",SERVER_BAN_REMOVE:"GUILD_BAN_REMOVE",SERVER_CREATE:"GUILD_CREATE",SERVER_DELETE:"GUILD_DELETE",SERVER_MEMBER_ADD:"GUILD_MEMBER_ADD",SERVER_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",SERVER_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",SERVER_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",SERVER_ROLE_CREATE:"GUILD_ROLE_CREATE",SERVER_ROLE_DELETE:"GUILD_ROLE_DELETE",SERVER_ROLE_UPDATE:"GUILD_ROLE_UPDATE",SERVER_UPDATE:"GUILD_UPDATE",TYPING:"TYPING_START",USER_UPDATE:"USER_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",FRIEND_ADD:"RELATIONSHIP_ADD",FRIEND_REMOVE:"RELATIONSHIP_REMOVE"};exports.PacketType = PacketType; | ||
voiceConnect:1 << 20,voiceSpeak:1 << 21,voiceMuteMembers:1 << 22,voiceDeafenMembers:1 << 23,voiceMoveMembers:1 << 24,voiceUseVAD:1 << 25};Constants.PacketType = {CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",READY:"READY",SERVER_BAN_ADD:"GUILD_BAN_ADD",SERVER_BAN_REMOVE:"GUILD_BAN_REMOVE",SERVER_CREATE:"GUILD_CREATE",SERVER_DELETE:"GUILD_DELETE",SERVER_MEMBER_ADD:"GUILD_MEMBER_ADD",SERVER_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",SERVER_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",SERVER_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",SERVER_ROLE_CREATE:"GUILD_ROLE_CREATE",SERVER_ROLE_DELETE:"GUILD_ROLE_DELETE",SERVER_ROLE_UPDATE:"GUILD_ROLE_UPDATE",SERVER_UPDATE:"GUILD_UPDATE",TYPING:"TYPING_START",USER_UPDATE:"USER_UPDATE",USER_NOTE_UPDATE:"USER_NOTE_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",FRIEND_ADD:"RELATIONSHIP_ADD",FRIEND_REMOVE:"RELATIONSHIP_REMOVE"};exports["default"] = Constants;module.exports = exports["default"]; |
@@ -5,5 +5,5 @@ "use strict"; /** | ||
* @property {boolean} [tts=false] Whether or not the message should be sent as text-to-speech. | ||
*/exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var Message=(function(_Equality){_inherits(Message,_Equality);function Message(data,channel,client){var _this=this;_classCallCheck(this,Message);_Equality.call(this);this.channel = channel;this.server = channel.server;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 || data.everyoneMentioned;this.id = data.id;if(data.edited_timestamp){this.editedTimestamp = Date.parse(data.edited_timestamp);}if(data.author instanceof _User2["default"]){this.author = data.author;}else if(data.author){this.author = client.internal.users.add(new _User2["default"](data.author,client));}this.content = data.content;var mentionData=client.internal.resolver.resolveMentions(data.content,channel);this.cleanContent = mentionData[1];this.mentions = [];mentionData[0].forEach(function(mention){ // this is .add and not .get because it allows the bot to cache | ||
*/exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var Message=(function(_Equality){_inherits(Message,_Equality);function Message(data,channel,client){var _this=this;_classCallCheck(this,Message);_Equality.call(this);this.channel = channel;this.server = channel.server;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 || data.everyoneMentioned;this.pinned = data.pinned;this.id = data.id;if(data.edited_timestamp){this.editedTimestamp = Date.parse(data.edited_timestamp);}if(data.author instanceof _User2["default"]){this.author = data.author;}else if(data.author){this.author = client.internal.users.add(new _User2["default"](data.author,client));}this.content = data.content;var mentionData=client.internal.resolver.resolveMentions(data.content,channel);this.cleanContent = mentionData[1];this.mentions = [];mentionData[0].forEach(function(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 _User2["default"]){_this.mentions.push(mention);}else {_this.mentions.push(client.internal.users.add(new _User2["default"](mention,client)));}});}Message.prototype.isMentioned = function isMentioned(user){user = this.client.internal.resolver.resolveUser(user);if(!user){return false;}for(var _iterator=this.mentions,_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 mention=_ref;if(mention.id == user.id){return true;}}return false;};Message.prototype.toString = function toString(){return this.content;};Message.prototype["delete"] = function _delete(){return this.client.deleteMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.update = function update(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.edit = function edit(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.reply = function reply(){return this.client.reply.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.replyTTS = function replyTTS(){return this.client.replyTTS.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(Message,[{key:"sender",get:function get(){return this.author;}}]);return Message;})(_UtilEquality2["default"]);exports["default"] = Message;module.exports = exports["default"]; | ||
if(mention instanceof _User2["default"]){_this.mentions.push(mention);}else {_this.mentions.push(client.internal.users.add(new _User2["default"](mention,client)));}});}Message.prototype.isMentioned = function isMentioned(user){user = this.client.internal.resolver.resolveUser(user);if(!user){return false;}for(var _iterator=this.mentions,_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 mention=_ref;if(mention.id == user.id){return true;}}return false;};Message.prototype.toString = function toString(){return this.content;};Message.prototype["delete"] = function _delete(){return this.client.deleteMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.update = function update(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.edit = function edit(){return this.client.updateMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.reply = function reply(){return this.client.reply.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.replyTTS = function replyTTS(){return this.client.replyTTS.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.pin = function pin(){return this.client.pinMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Message.prototype.unpin = function unpin(){return this.client.unpinMessage.apply(this.client,req(this,arguments));};_createClass(Message,[{key:"sender",get:function get(){return this.author;}}]);return Message;})(_UtilEquality2["default"]);exports["default"] = Message;module.exports = exports["default"]; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _Channel2=require("./Channel");var _Channel3=_interopRequireDefault(_Channel2);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var PMChannel=(function(_Channel){_inherits(PMChannel,_Channel);function PMChannel(data,client){_classCallCheck(this,PMChannel);_Channel.call(this,data,client);this.type = data.type || "text";this.lastMessageID = data.last_message_id || data.lastMessageID;this.messages = new _UtilCache2["default"]("id",client.options.maxCachedMessages);this.recipient = this.client.internal.users.add(new _User2["default"](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,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(PMChannel,[{key:"lastMessage",get:function get(){return this.messages.get("id",this.lastMessageID);}}]);return PMChannel;})(_Channel3["default"]);exports["default"] = PMChannel;module.exports = exports["default"]; | ||
"use strict";exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _Channel2=require("./Channel");var _Channel3=_interopRequireDefault(_Channel2);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var PMChannel=(function(_Channel){_inherits(PMChannel,_Channel);function PMChannel(data,client){_classCallCheck(this,PMChannel);_Channel.call(this,data,client);this.type = data.type || "text";this.lastMessageID = data.last_message_id || data.lastMessageID;this.messages = new _UtilCache2["default"]("id",client.options.maxCachedMessages);this.recipient = this.client.internal.users.add(new _User2["default"](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,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};PMChannel.prototype.getMessage = function getMessage(){return this.client.getMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(PMChannel,[{key:"lastMessage",get:function get(){return this.messages.get("id",this.lastMessageID);}}]);return PMChannel;})(_Channel3["default"]);exports["default"] = PMChannel;module.exports = exports["default"]; |
"use strict"; /** | ||
* Types of region for a server, include: `us-west`, `us-east`, `us-south`, `us-central`, `singapore`, `london`, `sydney`, `amsterdam` and `frankfurt` | ||
* @typedef {(string)} region | ||
*/exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var _Constants=require("../Constants");var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _TextChannel=require("./TextChannel");var _TextChannel2=_interopRequireDefault(_TextChannel);var _VoiceChannel=require("./VoiceChannel");var _VoiceChannel2=_interopRequireDefault(_VoiceChannel);var _Role=require("./Role");var _Role2=_interopRequireDefault(_Role);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var strictKeys=["region","ownerID","name","id","icon","afkTimeout","afkChannelID"];var Server=(function(_Equality){_inherits(Server,_Equality);function Server(data,client){var _this=this;_classCallCheck(this,Server);_Equality.call(this);var self=this;this.client = client;this.region = data.region;this.ownerID = data.owner_id || data.ownerID;this.name = data.name;this.id = data.id;this.members = new _UtilCache2["default"]();this.channels = new _UtilCache2["default"]();this.roles = new _UtilCache2["default"]();this.icon = data.icon;this.afkTimeout = data.afk_timeout;this.afkChannelID = data.afk_channel_id || data.afkChannelID;this.memberMap = data.memberMap || {};this.memberCount = data.member_count || data.memberCount;this.large = data.large || this.memberCount > 250;var self=this;if(data.roles instanceof _UtilCache2["default"]){data.roles.forEach(function(role){return _this.roles.add(role);});}else {data.roles.forEach(function(dataRole){_this.roles.add(new _Role2["default"](dataRole,_this,client));});}if(data.members instanceof _UtilCache2["default"]){data.members.forEach(function(member){return _this.members.add(member);});}else {data.members.forEach(function(dataUser){_this.memberMap[dataUser.user.id] = {roles:dataUser.roles,mute:dataUser.mute,selfMute:dataUser.self_mute,deaf:dataUser.deaf,selfDeaf:dataUser.self_deaf,joinedAt:Date.parse(dataUser.joined_at),nick:dataUser.nick || null};_this.members.add(client.internal.users.add(new _User2["default"](dataUser.user,client)));});}if(data.channels instanceof _UtilCache2["default"]){data.channels.forEach(function(channel){return _this.channels.add(channel);});}else {data.channels.forEach(function(dataChannel){if(dataChannel.type === "text"){_this.channels.add(client.internal.channels.add(new _TextChannel2["default"](dataChannel,client,_this)));}else {_this.channels.add(client.internal.channels.add(new _VoiceChannel2["default"](dataChannel,client,_this)));}});}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;var user=client.internal.users.get("id",presence.user.id);if(user){user.status = presence.status;user.game = presence.game;}}}if(data.voice_states){for(var _iterator2=data.voice_states,_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 voiceState=_ref2;var _user=this.members.get("id",voiceState.user_id);if(_user){this.memberMap[_user.id] = this.memberMap[_user.id] || {};this.memberMap[_user.id].mute = voiceState.mute || this.memberMap[_user.id].mute;this.memberMap[_user.id].selfMute = voiceState.self_mute === undefined?this.memberMap[_user.id].selfMute:voiceState.self_mute;this.memberMap[_user.id].deaf = voiceState.deaf || this.memberMap[_user.id].deaf;this.memberMap[_user.id].selfDeaf = voiceState.self_deaf === undefined?this.memberMap[_user.id].selfDeaf:voiceState.self_deaf;var channel=this.channels.get("id",voiceState.channel_id);if(channel){this.eventVoiceJoin(_user,channel);}else {this.client.emit("warn","channel doesn't exist even though READY expects them to");}}else {this.client.emit("warn","user doesn't exist even though READY expects them to");}}}}Server.prototype.detailsOf = function detailsOf(user){var _this2=this;user = this.client.internal.resolver.resolveUser(user);if(user){var result=this.memberMap[user.id] || {};if(result && result.roles){result.roles = result.roles.map(function(pid){return _this2.roles.get("id",pid) || pid;});}return result;}else {return {};}};Server.prototype.detailsOfUser = function detailsOfUser(user){return this.detailsOf(user);};Server.prototype.detailsOfMember = function detailsOfMember(user){return this.detailsOf(user);};Server.prototype.details = function details(user){return this.detailsOf(user);};Server.prototype.rolesOfUser = function rolesOfUser(user){return this.detailsOf(user).roles || [];};Server.prototype.rolesOfMember = function rolesOfMember(member){return this.rolesOfUser(member);};Server.prototype.rolesOf = function rolesOf(user){return this.rolesOfUser(user);};Server.prototype.toString = function toString(){return this.name;};Server.prototype.eventVoiceJoin = function eventVoiceJoin(user,channel){ // removes from other speaking channels first | ||
var oldChannel=this.eventVoiceLeave(user);channel.members.add(user);user.voiceChannel = channel;if(oldChannel.id){this.client.emit("voiceLeave",oldChannel,user);this.client.emit("voiceSwitch",oldChannel,channel,user);}this.client.emit("voiceJoin",channel,user);};Server.prototype.eventVoiceStateUpdate = function eventVoiceStateUpdate(channel,user,data){if(!user.voiceChannel || user.voiceChannel.id !== channel.id){return this.eventVoiceJoin(user,channel);}if(!this.memberMap[user.id]){this.memberMap[user.id] = {};}var oldState={mute:this.memberMap[user.id].mute,selfMute:this.memberMap[user.id].self_mute,deaf:this.memberMap[user.id].deaf,selfDeaf:this.memberMap[user.id].self_deaf};this.memberMap[user.id].mute = data.mute;this.memberMap[user.id].selfMute = data.self_mute;this.memberMap[user.id].deaf = data.deaf;this.memberMap[user.id].selfDeaf = data.self_deaf;if(oldState.mute !== undefined && (oldState.mute != data.mute || oldState.self_mute != data.self_mute || oldState.deaf != data.deaf || oldState.self_deaf != data.self_deaf)){this.client.emit("voiceStateUpdate",channel,user,oldState,this.memberMap[user.id]);}else {this.eventVoiceJoin(user,channel);}};Server.prototype.eventVoiceLeave = function eventVoiceLeave(user){for(var _iterator3=this.channels.getAll("type","voice"),_isArray3=Array.isArray(_iterator3),_i3=0,_iterator3=_isArray3?_iterator3:_iterator3[Symbol.iterator]();;) {var _ref3;if(_isArray3){if(_i3 >= _iterator3.length)break;_ref3 = _iterator3[_i3++];}else {_i3 = _iterator3.next();if(_i3.done)break;_ref3 = _i3.value;}var chan=_ref3;if(chan.members.has(user)){chan.members.remove(user);user.voiceChannel = null;return chan;}}return {server:this};};Server.prototype.equalsStrict = function equalsStrict(obj){if(obj instanceof Server){for(var _iterator4=strictKeys,_isArray4=Array.isArray(_iterator4),_i4=0,_iterator4=_isArray4?_iterator4:_iterator4[Symbol.iterator]();;) {var _ref4;if(_isArray4){if(_i4 >= _iterator4.length)break;_ref4 = _iterator4[_i4++];}else {_i4 = _iterator4.next();if(_i4.done)break;_ref4 = _i4.value;}var key=_ref4;if(obj[key] !== this[key]){return false;}}}else {return false;}return true;};Server.prototype.leave = function leave(){return this.client.leaveServer.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype["delete"] = function _delete(){return this.client.leaveServer.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.createInvite = function createInvite(){return this.client.createInvite.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.createRole = function createRole(){return this.client.createRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.banMember = function banMember(user,tlength,callback){return this.client.banMember.apply(this.client,[user,this,tlength,callback]);};Server.prototype.banUser = function banUser(user,tlength,callback){return this.client.banMember.apply(this.client,[user,this,tlength,callback]);};Server.prototype.ban = function ban(user,tlength,callback){return this.client.banMember.apply(this.client,[user,this,tlength,callback]);};Server.prototype.unbanMember = function unbanMember(user,callback){return this.client.unbanMember.apply(this.client,[user,this,callback]);};Server.prototype.unbanUser = function unbanUser(user,callback){return this.client.unbanMember.apply(this.client,[user,this,callback]);};Server.prototype.unban = function unban(user,callback){return this.client.unbanMember.apply(this.client,[user,this,callback]);};Server.prototype.kickMember = function kickMember(user,callback){return this.client.kickMember.apply(this.client,[user,this,callback]);};Server.prototype.kickUser = function kickUser(user,callback){return this.client.kickMember.apply(this.client,[user,this,callback]);};Server.prototype.kick = function kick(user,callback){return this.client.kickMember.apply(this.client,[user,this,callback]);};Server.prototype.getBans = function getBans(){return this.client.getBans.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.createChannel = function createChannel(){return this.client.createChannel.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.setNickname = function setNickname(){return this.client.setNickname.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.membersWithRole = function membersWithRole(role){return this.members.filter(function(m){return m.hasRole(role);});};Server.prototype.usersWithRole = function usersWithRole(role){return this.membersWithRole(role);};_createClass(Server,[{key:"createdAt",get:function get(){return new Date(+this.id / 4194304 + 1420070400000);}},{key:"iconURL",get:function get(){if(!this.icon){return null;}else {return _Constants.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:"generalChannel",get:function get(){return this.defaultChannel;}},{key:"general",get:function get(){return this.defaultChannel;}},{key:"owner",get:function get(){return this.members.get("id",this.ownerID);}}]);return Server;})(_UtilEquality2["default"]);exports["default"] = Server;module.exports = exports["default"]; | ||
*/exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _UtilBucket=require("../Util/Bucket");var _UtilBucket2=_interopRequireDefault(_UtilBucket);var _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var _Constants=require("../Constants");var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _TextChannel=require("./TextChannel");var _TextChannel2=_interopRequireDefault(_TextChannel);var _VoiceChannel=require("./VoiceChannel");var _VoiceChannel2=_interopRequireDefault(_VoiceChannel);var _Role=require("./Role");var _Role2=_interopRequireDefault(_Role);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var strictKeys=["region","ownerID","name","id","icon","afkTimeout","afkChannelID"];var Server=(function(_Equality){_inherits(Server,_Equality);function Server(data,client){var _this=this;_classCallCheck(this,Server);_Equality.call(this);this.client = client;this.id = data.id;if(data.owner_id){ // new server data | ||
client.internal.buckets["bot:msg:guild:" + this.id] = new _UtilBucket2["default"](5,5000);client.internal.buckets["dmsg:" + this.id] = new _UtilBucket2["default"](5,1000);client.internal.buckets["bdmsg:" + this.id] = new _UtilBucket2["default"](1,1000);client.internal.buckets["guild_member:" + this.id] = new _UtilBucket2["default"](10,10000);client.internal.buckets["guild_member_nick:" + this.id] = new _UtilBucket2["default"](1,1000);}this.region = data.region;this.ownerID = data.owner_id || data.ownerID;this.name = data.name;this.members = new _UtilCache2["default"]();this.channels = new _UtilCache2["default"]();this.roles = new _UtilCache2["default"]();this.icon = data.icon;this.afkTimeout = data.afk_timeout;this.afkChannelID = data.afk_channel_id || data.afkChannelID;this.memberMap = data.memberMap || {};this.memberCount = data.member_count || data.memberCount;this.large = data.large || this.memberCount > 250;if(data.roles instanceof _UtilCache2["default"]){data.roles.forEach(function(role){return _this.roles.add(role);});}else {data.roles.forEach(function(dataRole){_this.roles.add(new _Role2["default"](dataRole,_this,client));});}if(data.members instanceof _UtilCache2["default"]){data.members.forEach(function(member){return _this.members.add(member);});}else {data.members.forEach(function(dataUser){_this.memberMap[dataUser.user.id] = {roles:dataUser.roles,mute:dataUser.mute,selfMute:dataUser.self_mute,deaf:dataUser.deaf,selfDeaf:dataUser.self_deaf,joinedAt:Date.parse(dataUser.joined_at),nick:dataUser.nick || null};_this.members.add(client.internal.users.add(new _User2["default"](dataUser.user,client)));});}if(data.channels instanceof _UtilCache2["default"]){data.channels.forEach(function(channel){return _this.channels.add(channel);});}else {data.channels.forEach(function(dataChannel){if(dataChannel.type === "text"){_this.channels.add(client.internal.channels.add(new _TextChannel2["default"](dataChannel,client,_this)));}else {_this.channels.add(client.internal.channels.add(new _VoiceChannel2["default"](dataChannel,client,_this)));}});}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;var user=client.internal.users.get("id",presence.user.id);if(user){user.status = presence.status;user.game = presence.game;}}}if(data.voice_states){for(var _iterator2=data.voice_states,_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 voiceState=_ref2;var _user=this.members.get("id",voiceState.user_id);if(_user){this.memberMap[_user.id] = this.memberMap[_user.id] || {};this.memberMap[_user.id].mute = voiceState.mute || this.memberMap[_user.id].mute;this.memberMap[_user.id].selfMute = voiceState.self_mute === undefined?this.memberMap[_user.id].selfMute:voiceState.self_mute;this.memberMap[_user.id].deaf = voiceState.deaf || this.memberMap[_user.id].deaf;this.memberMap[_user.id].selfDeaf = voiceState.self_deaf === undefined?this.memberMap[_user.id].selfDeaf:voiceState.self_deaf;var channel=this.channels.get("id",voiceState.channel_id);if(channel){this.eventVoiceJoin(_user,channel);}else {this.client.emit("warn","channel doesn't exist even though READY expects them to");}}else {this.client.emit("warn","user doesn't exist even though READY expects them to");}}}}Server.prototype.detailsOf = function detailsOf(user){var _this2=this;user = this.client.internal.resolver.resolveUser(user);if(user){var result=this.memberMap[user.id] || {};if(result && result.roles){result.roles = result.roles.map(function(pid){return _this2.roles.get("id",pid) || pid;});}return result;}else {return {};}};Server.prototype.detailsOfUser = function detailsOfUser(user){return this.detailsOf(user);};Server.prototype.detailsOfMember = function detailsOfMember(user){return this.detailsOf(user);};Server.prototype.details = function details(user){return this.detailsOf(user);};Server.prototype.rolesOfUser = function rolesOfUser(user){return this.detailsOf(user).roles || [];};Server.prototype.rolesOfMember = function rolesOfMember(member){return this.rolesOfUser(member);};Server.prototype.rolesOf = function rolesOf(user){return this.rolesOfUser(user);};Server.prototype.toString = function toString(){return this.name;};Server.prototype.eventVoiceJoin = function eventVoiceJoin(user,channel){ // removes from other speaking channels first | ||
var oldChannel=this.eventVoiceLeave(user);channel.members.add(user);user.voiceChannel = channel;if(oldChannel.id && channel.id !== oldChannel.id){this.client.emit("voiceLeave",oldChannel,user);this.client.emit("voiceSwitch",oldChannel,channel,user);}this.client.emit("voiceJoin",channel,user);};Server.prototype.eventVoiceStateUpdate = function eventVoiceStateUpdate(channel,user,data){if(!user.voiceChannel || user.voiceChannel.id !== channel.id){return this.eventVoiceJoin(user,channel);}if(!this.memberMap[user.id]){this.memberMap[user.id] = {};}var oldState={mute:this.memberMap[user.id].mute,selfMute:this.memberMap[user.id].self_mute,deaf:this.memberMap[user.id].deaf,selfDeaf:this.memberMap[user.id].self_deaf};this.memberMap[user.id].mute = data.mute;this.memberMap[user.id].selfMute = data.self_mute;this.memberMap[user.id].deaf = data.deaf;this.memberMap[user.id].selfDeaf = data.self_deaf;if(oldState.mute !== undefined && (oldState.mute != data.mute || oldState.self_mute != data.self_mute || oldState.deaf != data.deaf || oldState.self_deaf != data.self_deaf)){this.client.emit("voiceStateUpdate",channel,user,oldState,this.memberMap[user.id]);}else {this.eventVoiceJoin(user,channel);}};Server.prototype.eventVoiceLeave = function eventVoiceLeave(user){for(var _iterator3=this.channels.getAll("type","voice"),_isArray3=Array.isArray(_iterator3),_i3=0,_iterator3=_isArray3?_iterator3:_iterator3[Symbol.iterator]();;) {var _ref3;if(_isArray3){if(_i3 >= _iterator3.length)break;_ref3 = _iterator3[_i3++];}else {_i3 = _iterator3.next();if(_i3.done)break;_ref3 = _i3.value;}var chan=_ref3;if(chan.members.has("id",user.id)){chan.members.remove(user);user.voiceChannel = null;return chan;}}return {server:this};};Server.prototype.equalsStrict = function equalsStrict(obj){if(obj instanceof Server){for(var _iterator4=strictKeys,_isArray4=Array.isArray(_iterator4),_i4=0,_iterator4=_isArray4?_iterator4:_iterator4[Symbol.iterator]();;) {var _ref4;if(_isArray4){if(_i4 >= _iterator4.length)break;_ref4 = _iterator4[_i4++];}else {_i4 = _iterator4.next();if(_i4.done)break;_ref4 = _i4.value;}var key=_ref4;if(obj[key] !== this[key]){return false;}}}else {return false;}return true;};Server.prototype.leave = function leave(){return this.client.leaveServer.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype["delete"] = function _delete(){return this.client.leaveServer.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.createInvite = function createInvite(){return this.client.createInvite.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.createRole = function createRole(){return this.client.createRole.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.banMember = function banMember(user,tlength,callback){return this.client.banMember.apply(this.client,[user,this,tlength,callback]);};Server.prototype.banUser = function banUser(user,tlength,callback){return this.client.banMember.apply(this.client,[user,this,tlength,callback]);};Server.prototype.ban = function ban(user,tlength,callback){return this.client.banMember.apply(this.client,[user,this,tlength,callback]);};Server.prototype.unbanMember = function unbanMember(user,callback){return this.client.unbanMember.apply(this.client,[user,this,callback]);};Server.prototype.unbanUser = function unbanUser(user,callback){return this.client.unbanMember.apply(this.client,[user,this,callback]);};Server.prototype.unban = function unban(user,callback){return this.client.unbanMember.apply(this.client,[user,this,callback]);};Server.prototype.kickMember = function kickMember(user,callback){return this.client.kickMember.apply(this.client,[user,this,callback]);};Server.prototype.kickUser = function kickUser(user,callback){return this.client.kickMember.apply(this.client,[user,this,callback]);};Server.prototype.kick = function kick(user,callback){return this.client.kickMember.apply(this.client,[user,this,callback]);};Server.prototype.getBans = function getBans(){return this.client.getBans.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.createChannel = function createChannel(){return this.client.createChannel.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.setNickname = function setNickname(){return this.client.setNickname.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};Server.prototype.membersWithRole = function membersWithRole(role){return this.members.filter(function(m){return m.hasRole(role);});};Server.prototype.usersWithRole = function usersWithRole(role){return this.membersWithRole(role);};_createClass(Server,[{key:"createdAt",get:function get(){return new Date(+this.id / 4194304 + 1420070400000);}},{key:"iconURL",get:function get(){if(!this.icon){return null;}else {return _Constants.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:"generalChannel",get:function get(){return this.defaultChannel;}},{key:"general",get:function get(){return this.defaultChannel;}},{key:"owner",get:function get(){return this.members.get("id",this.ownerID);}}]);return Server;})(_UtilEquality2["default"]);exports["default"] = Server;module.exports = exports["default"]; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _ServerChannel2=require("./ServerChannel");var _ServerChannel3=_interopRequireDefault(_ServerChannel2);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var TextChannel=(function(_ServerChannel){_inherits(TextChannel,_ServerChannel);function TextChannel(data,client,server){_classCallCheck(this,TextChannel);_ServerChannel.call(this,data,client,server);this.topic = data.topic;this.lastMessageID = data.last_message_id || data.lastMessageID;this.messages = new _UtilCache2["default"]("id",client.options.maxCachedMessages);} /* warning! may return null */TextChannel.prototype.setTopic = function setTopic(){return this.client.setChannelTopic.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.setNameAndTopic = function setNameAndTopic(){return this.client.setChannelNameAndTopic.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(TextChannel,[{key:"lastMessage",get:function get(){return this.messages.get("id",this.lastMessageID);}}]);return TextChannel;})(_ServerChannel3["default"]);exports["default"] = TextChannel;module.exports = exports["default"]; | ||
"use strict";exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _ServerChannel2=require("./ServerChannel");var _ServerChannel3=_interopRequireDefault(_ServerChannel2);var _UtilCache=require("../Util/Cache");var _UtilCache2=_interopRequireDefault(_UtilCache);var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var TextChannel=(function(_ServerChannel){_inherits(TextChannel,_ServerChannel);function TextChannel(data,client,server){_classCallCheck(this,TextChannel);_ServerChannel.call(this,data,client,server);this.topic = data.topic;this.lastMessageID = data.last_message_id || data.lastMessageID;this.messages = new _UtilCache2["default"]("id",client.options.maxCachedMessages);} /* warning! may return null */TextChannel.prototype.setTopic = function setTopic(){return this.client.setChannelTopic.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.getMessage = function getMessage(){return this.client.getMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};TextChannel.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};_createClass(TextChannel,[{key:"lastMessage",get:function get(){return this.messages.get("id",this.lastMessageID);}}]);return TextChannel;})(_ServerChannel3["default"]);exports["default"] = TextChannel;module.exports = exports["default"]; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var _Constants=require("../Constants");var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var User=(function(_Equality){_inherits(User,_Equality);function User(data,client){_classCallCheck(this,User);_Equality.call(this);this.client = client;this.username = data.username;this.discriminator = data.discriminator;this.id = data.id;this.avatar = data.avatar;this.bot = !!data.bot;this.status = data.status || "offline";this.game = data.game || null;this.typing = {since:null,channel:null};this.voiceChannel = null;this.voiceState = {};}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.game === obj.game || this.game && obj.game && this.game.name === obj.game.name);else return false;};User.prototype.equals = function equals(obj){if(obj instanceof User)return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar;else return false;};User.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.addTo = function addTo(role,callback){return this.client.addMemberToRole.apply(this.client,[this,role,callback]);};User.prototype.removeFrom = function removeFrom(role,callback){return this.client.removeMemberFromRole.apply(this.client,[this,role,callback]);};User.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.hasRole = function hasRole(role){return this.client.memberHasRole.apply(this.client,[this,role]);};_createClass(User,[{key:"createdAt",get:function get(){return new Date(+this.id / 4194304 + 1420070400000);}},{key:"avatarURL",get:function get(){if(!this.avatar){return null;}else {return _Constants.Endpoints.AVATAR(this.id,this.avatar);}}},{key:"name",get:function get(){return this.username;}}]);return User;})(_UtilEquality2["default"]);exports["default"] = User;module.exports = exports["default"]; | ||
"use strict";exports.__esModule = true;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 _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}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 _UtilEquality=require("../Util/Equality");var _UtilEquality2=_interopRequireDefault(_UtilEquality);var _Constants=require("../Constants");var _UtilArgumentRegulariser=require("../Util/ArgumentRegulariser");var User=(function(_Equality){_inherits(User,_Equality);function User(data,client){_classCallCheck(this,User);_Equality.call(this);this.client = client;this.username = data.username;this.discriminator = data.discriminator;this.id = data.id;this.avatar = data.avatar;this.bot = !!data.bot;this.status = data.status || "offline";this.game = data.game || null;this.typing = {since:null,channel:null};this.note = data.note || null;this.voiceChannel = null;this.voiceState = {};this.speaking = false;}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.game === obj.game || this.game && obj.game && this.game.name === obj.game.name);else return false;};User.prototype.equals = function equals(obj){if(obj instanceof User)return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar;else return false;};User.prototype.sendMessage = function sendMessage(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.send = function send(){return this.client.sendMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendTTSMessage = function sendTTSMessage(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendTTS = function sendTTS(){return this.client.sendTTSMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.sendFile = function sendFile(){return this.client.sendFile.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.startTyping = function startTyping(){return this.client.startTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.stopTyping = function stopTyping(){return this.client.stopTyping.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.addTo = function addTo(role,callback){return this.client.addMemberToRole.apply(this.client,[this,role,callback]);};User.prototype.removeFrom = function removeFrom(role,callback){return this.client.removeMemberFromRole.apply(this.client,[this,role,callback]);};User.prototype.getLogs = function getLogs(){return this.client.getChannelLogs.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.getMessage = function getMessage(){return this.client.getMessage.apply(this.client,_UtilArgumentRegulariser.reg(this,arguments));};User.prototype.hasRole = function hasRole(role){return this.client.memberHasRole.apply(this.client,[this,role]);};_createClass(User,[{key:"createdAt",get:function get(){return new Date(+this.id / 4194304 + 1420070400000);}},{key:"avatarURL",get:function get(){if(!this.avatar){return null;}else {return _Constants.Endpoints.AVATAR(this.id,this.avatar);}}},{key:"name",get:function get(){return this.username;}}]);return User;})(_UtilEquality2["default"]);exports["default"] = User;module.exports = exports["default"]; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule = true;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 discrimS=Symbol();var discrimCacheS=Symbol();var Cache=(function(_Array){_inherits(Cache,_Array);function Cache(discrim,limit){_classCallCheck(this,Cache);_Array.call(this);this[discrimS] = discrim || "id";this[discrimCacheS] = {};this.limit = limit;}Cache.prototype.get = function get(key,value){if(typeof key === 'function'){var valid=key;key = null;}else if(key === this[discrimS] && typeof value === "string"){return this[discrimCacheS][value] || null;}else if(value && value.constructor.name === 'RegExp'){var valid=function valid(item){return value.test(item);};}else if(typeof value !== 'function'){var valid=function valid(item){return item == value;};}for(var _iterator=this,_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 item=_ref;if(valid(key == null?item:item[key])){return item;}}return null;};Cache.prototype.has = function has(key,value){return !!this.get(key,value);};Cache.prototype.getAll = function getAll(key,value){var found=new Cache(this[discrimS]);if(typeof key === 'function'){var valid=key;key = null;}else if(value && value.constructor.name === 'RegExp'){var valid=function valid(item){return value.test(item);};}else if(typeof value !== 'function'){var valid=function valid(item){return item == value;};}for(var _iterator2=this,_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 item=_ref2;if(valid(key == null?item:item[key])){found.add(item);}}return found;};Cache.prototype.add = function add(data){var cacheKey=data[this[discrimS]];if(this[discrimCacheS][cacheKey]){return this[discrimCacheS][cacheKey];}if(this.limit && this.length >= this.limit){this.splice(0,1);}this.push(data);this[discrimCacheS][cacheKey] = data;return data;};Cache.prototype.update = function update(old,data){var obj=this[discrimCacheS][old[this[discrimS]]];if(obj){for(var key in data) {if(data.hasOwnProperty(key)){obj[key] = data[key];}}return obj;}return false;};Cache.prototype.random = function random(){return this[Math.floor(Math.random() * this.length)];};Cache.prototype.remove = function remove(data){delete this[discrimCacheS][data[this[discrimS]]];for(var i in this) {if(this[i] && this[i][this[discrimS]] === data[this[discrimS]]){this.splice(i,1);return true;}}return false;};return Cache;})(Array);exports["default"] = Cache;module.exports = exports["default"]; | ||
"use strict";exports.__esModule = true;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 discrimS=Symbol();var discrimCacheS=Symbol();var Cache=(function(_Array){_inherits(Cache,_Array);function Cache(discrim,limit){_classCallCheck(this,Cache);_Array.call(this);this[discrimS] = discrim || "id";this[discrimCacheS] = {};this.limit = limit;}Cache.prototype.get = function get(key,value){if(typeof key === 'function'){var valid=key;key = null;}else if(key && !value){return this[discrimCacheS][key] || null;}else if(key === this[discrimS] && typeof value === "string"){return this[discrimCacheS][value] || null;}else if(value && value.constructor.name === 'RegExp'){var valid=function valid(item){return value.test(item);};}else if(typeof value !== 'function'){var valid=function valid(item){return item == value;};}for(var _iterator=this,_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 item=_ref;if(valid(key == null?item:item[key])){return item;}}return null;};Cache.prototype.has = function has(key,value){return !!this.get(key,value);};Cache.prototype.getAll = function getAll(key,value){var found=new Cache(this[discrimS]);if(typeof key === 'function'){var valid=key;key = null;}else if(value && value.constructor.name === 'RegExp'){var valid=function valid(item){return value.test(item);};}else if(typeof value !== 'function'){var valid=function valid(item){return item == value;};}for(var _iterator2=this,_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 item=_ref2;if(valid(key == null?item:item[key])){found.add(item);}}return found;};Cache.prototype.add = function add(data){var cacheKey=data[this[discrimS]];if(this[discrimCacheS][cacheKey]){return this[discrimCacheS][cacheKey];}if(this.limit && this.length >= this.limit){this.splice(0,1);}this.push(data);this[discrimCacheS][cacheKey] = data;return data;};Cache.prototype.update = function update(old,data){var obj=this[discrimCacheS][old[this[discrimS]]];if(obj){for(var key in data) {if(data.hasOwnProperty(key)){obj[key] = data[key];}}return obj;}return false;};Cache.prototype.random = function random(){return this[Math.floor(Math.random() * this.length)];};Cache.prototype.remove = function remove(data){if(!this[discrimCacheS][data[this[discrimS]]])return false;delete this[discrimCacheS][data[this[discrimS]]];for(var i in this) {if(this[i] && this[i][this[discrimS]] === data[this[discrimS]]){this.splice(i,1);return true;}}return false;};return Cache;})(Array);exports["default"] = Cache;module.exports = exports["default"]; |
"use strict";exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var _child_process=require("child_process");var _child_process2=_interopRequireDefault(_child_process); // no opus! | ||
var _VolumeTransformer=require("./VolumeTransformer");var _VolumeTransformer2=_interopRequireDefault(_VolumeTransformer);var opus;try{opus = require("node-opus");}catch(e) {}var AudioEncoder=(function(){function AudioEncoder(){_classCallCheck(this,AudioEncoder);if(opus){this.opus = new opus.OpusEncoder(48000,2);}this.choice = false;this.sanityCheckPassed = undefined;}AudioEncoder.prototype.sanityCheck = function sanityCheck(){var _opus=this.opus;var encodeZeroes=function encodeZeroes(){try{var zeroes=new Buffer(1920);zeroes.fill(0);return _opus.encode(zeroes,1920).readUIntBE(0,3);}catch(err) {return false;}};if(this.sanityCheckPassed === undefined)this.sanityCheckPassed = encodeZeroes() === 16056318;return this.sanityCheckPassed;};AudioEncoder.prototype.opusBuffer = function opusBuffer(buffer){return this.opus.encode(buffer,1920);};AudioEncoder.prototype.getCommand = function getCommand(force){if(this.choice && force)return choice;var choices=["avconv","ffmpeg"];for(var _iterator=choices,_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 choice=_ref;var p=_child_process2["default"].spawnSync(choice);if(!p.error){this.choice = choice;return choice;}}return "help";};AudioEncoder.prototype.encodeStream = function encodeStream(stream,options){var _this=this;return new Promise(function(resolve,reject){_this.volume = new _VolumeTransformer2["default"](options.volume);var enc=_child_process2["default"].spawn(_this.getCommand(),['-i','-','-f','s16le','-ar','48000','-ss',options.seek || 0,'-ac',2,'pipe:1']);stream.pipe(enc.stdin);_this.hookEncodingProcess(resolve,reject,enc,stream);});};AudioEncoder.prototype.encodeFile = function encodeFile(file,options){var _this2=this;return new Promise(function(resolve,reject){_this2.volume = new _VolumeTransformer2["default"](options.volume);var enc=_child_process2["default"].spawn(_this2.getCommand(),['-i',file,'-f','s16le','-ar','48000','-ss',options.seek || 0,'-ac',2,'pipe:1']);_this2.hookEncodingProcess(resolve,reject,enc);});};AudioEncoder.prototype.encodeArbitraryFFmpeg = function encodeArbitraryFFmpeg(ffmpegOptions,volume){var _this3=this;return new Promise(function(resolve,reject){_this3.volume = new _VolumeTransformer2["default"](volume); // add options discord.js needs | ||
var _VolumeTransformer=require("./VolumeTransformer");var _VolumeTransformer2=_interopRequireDefault(_VolumeTransformer);var opus;try{opus = require("node-opus");}catch(e) {}var AudioEncoder=(function(){function AudioEncoder(){_classCallCheck(this,AudioEncoder);if(opus){this.opus = new opus.OpusEncoder(48000,2);}this.choice = false;this.sanityCheckPassed = undefined;}AudioEncoder.prototype.sanityCheck = function sanityCheck(){var _opus=this.opus;var encodeZeroes=function encodeZeroes(){try{var zeroes=new Buffer(1920);zeroes.fill(0);return _opus.encode(zeroes,1920).readUIntBE(0,3);}catch(err) {return false;}};if(this.sanityCheckPassed === undefined)this.sanityCheckPassed = encodeZeroes() === 16056318;return this.sanityCheckPassed;};AudioEncoder.prototype.opusBuffer = function opusBuffer(buffer){return this.opus.encode(buffer,1920);};AudioEncoder.prototype.getCommand = function getCommand(force){if(this.choice && force)return choice;var choices=["avconv","ffmpeg"];for(var _iterator=choices,_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 choice=_ref;var p=_child_process2["default"].spawnSync(choice);if(!p.error){this.choice = choice;return choice;}}return "help";};AudioEncoder.prototype.encodeStream = function encodeStream(stream,options){var _this=this;return new Promise(function(resolve,reject){_this.volume = new _VolumeTransformer2["default"](options.volume);var enc=_child_process2["default"].spawn(_this.getCommand(),['-i','-','-f','s16le','-ar','48000','-ss',options.seek || 0,'-ac',2,'pipe:1']);var dest=stream.pipe(enc.stdin);dest.on('unpipe',function(){return dest.destroy();});dest.on('error',function(err){return dest.destroy();});_this.hookEncodingProcess(resolve,reject,enc,stream);});};AudioEncoder.prototype.encodeFile = function encodeFile(file,options){var _this2=this;return new Promise(function(resolve,reject){_this2.volume = new _VolumeTransformer2["default"](options.volume);var enc=_child_process2["default"].spawn(_this2.getCommand(),['-i',file,'-f','s16le','-ar','48000','-ss',options.seek || 0,'-ac',2,'pipe:1']);_this2.hookEncodingProcess(resolve,reject,enc);});};AudioEncoder.prototype.encodeArbitraryFFmpeg = function encodeArbitraryFFmpeg(ffmpegOptions,volume){var _this3=this;return new Promise(function(resolve,reject){_this3.volume = new _VolumeTransformer2["default"](volume); // add options discord.js needs | ||
var options=ffmpegOptions.concat(['-f','s16le','-ar','48000','-ac',2,'pipe:1']);var enc=_child_process2["default"].spawn(_this3.getCommand(),options);_this3.hookEncodingProcess(resolve,reject,enc);});};AudioEncoder.prototype.hookEncodingProcess = function hookEncodingProcess(resolve,reject,enc,stream){var _this4=this;var processKilled=false;function killProcess(cause){if(processKilled)return;enc.stdin.pause();enc.kill("SIGKILL");processKilled = true;reject(cause);}var ffmpegErrors="";enc.stdout.pipe(this.volume);enc.stderr.on("data",function(data){ffmpegErrors += "\n" + new Buffer(data).toString().trim();});enc.stdout.once("end",function(){killProcess("end");});enc.stdout.once("error",function(){enc.stdout.emit("end");});enc.once("exit",function(code,signal){if(code){reject(new Error("FFMPEG: " + ffmpegErrors));}});this.volume.once("readable",function(){var data={proc:enc,stream:_this4.volume,channels:2};if(stream){data.instream = stream;}resolve(data);});this.volume.once("end",function(){killProcess("end");});this.volume.once("error",function(){killProcess("end");});this.volume.on("end",function(){killProcess("end");});this.volume.on("close",function(){killProcess("close");});};return AudioEncoder;})();exports["default"] = AudioEncoder;module.exports = exports["default"]; |
@@ -14,2 +14,2 @@ "use strict"; /* | ||
callback = options;}if(typeof options !== "object"){options = {};}options.volume = options.volume !== undefined?options.volume:this.getVolume();return new Promise(function(resolve,reject){_this2.encoder.encodeStream(stream,options)["catch"](error).then(function(data){self.streamProc = data.proc;self.instream = data.instream;var intent=self.playStream(data.stream);resolve(intent);callback(null,intent);});function error(){var e=arguments.length <= 0 || arguments[0] === undefined?true:arguments[0];reject(e);callback(e);}});};VoiceConnection.prototype.playArbitraryFFmpeg = function playArbitraryFFmpeg(ffmpegOptions,volume){var _this3=this;var callback=arguments.length <= 2 || arguments[2] === undefined?function(err,str){}:arguments[2];var self=this;self.stopPlaying();if(typeof volume === "function"){ // volume is the callback | ||
callback = volume;}if(!ffmpegOptions instanceof Array){ffmpegOptions = [];}var volume=volume !== undefined?volume:this.getVolume();return new Promise(function(resolve,reject){_this3.encoder.encodeArbitraryFFmpeg(ffmpegOptions,volume)["catch"](error).then(function(data){self.streamProc = data.proc;self.instream = data.instream;var intent=self.playStream(data.stream);resolve(intent);callback(null,intent);});function error(){var e=arguments.length <= 0 || arguments[0] === undefined?true:arguments[0];reject(e);callback(e);}});};VoiceConnection.prototype.init = function init(){var _this4=this;var self=this;_dns2["default"].lookup(this.endpoint,function(err,address,family){var vWS=self.vWS = new _ws2["default"]("wss://" + _this4.endpoint,null,{rejectUnauthorized:false});_this4.endpoint = address;var udpClient=self.udp = _dgram2["default"].createSocket("udp4");var firstPacket=true;var discordIP="",discordPort="";udpClient.bind({exclusive:true});udpClient.on('message',function(msg,rinfo){var buffArr=JSON.parse(JSON.stringify(msg)).data;if(firstPacket === true){for(var i=4;i < buffArr.indexOf(0,i);i++) {discordIP += String.fromCharCode(buffArr[i]);}discordPort = msg.readUIntLE(msg.length - 2,2).toString(10);var modes=self.vWSData.modes;var mode=MODE_xsalsa20_poly1305;if(modes.indexOf(MODE_xsalsa20_poly1305) < 0){mode = MODE_plain;self.client.emit("debug","Encrypted mode not reported as supported by the server, using 'plain'");}vWS.send(JSON.stringify({"op":1,"d":{"protocol":"udp","data":{"address":discordIP,"port":Number(discordPort),"mode":mode}}}));firstPacket = false;}});vWS.on("open",function(){vWS.send(JSON.stringify({op:0,d:{server_id:self.server.id,user_id:self.client.internal.user.id,session_id:self.session,token:self.token}}));});var KAI;vWS.on("message",function(msg){var data=JSON.parse(msg);switch(data.op){case 2:self.vWSData = data.d;self.KAI = KAI = self.client.internal.intervals.misc["voiceKAI"] = setInterval(function(){if(vWS && vWS.readyState === _ws2["default"].OPEN)vWS.send(JSON.stringify({op:3,d:null}));},data.d.heartbeat_interval);var udpPacket=new Buffer(70);udpPacket.writeUIntBE(data.d.ssrc,0,4);udpClient.send(udpPacket,0,udpPacket.length,data.d.port,self.endpoint,function(err){if(err)self.emit("error",err);});break;case 4:if(data.d.secret_key && data.d.secret_key.length > 0){var buffer=new ArrayBuffer(data.d.secret_key.length);self.secret = new Uint8Array(buffer);for(var i=0;i < _this4.secret.length;i++) {self.secret[i] = data.d.secret_key[i];}}self.ready = true;self.mode = data.d.mode;self.emit("ready",self);break;}});vWS.on("error",function(err,msg){self.emit("error",err,msg);});vWS.on("close",function(code){self.emit("close",code);});});};VoiceConnection.prototype.wrapVolume = function wrapVolume(stream){stream.pipe(this.volume);return this.volume;};VoiceConnection.prototype.setVolume = function setVolume(volume){this.volume.set(volume);};VoiceConnection.prototype.getVolume = function getVolume(){return this.volume.get();};VoiceConnection.prototype.mute = function mute(){this.lastVolume = this.volume.get();this.setVolume(0);};VoiceConnection.prototype.unmute = function unmute(){this.setVolume(this.lastVolume);this.lastVolume = undefined;};VoiceConnection.prototype.pause = function pause(){this.paused = true;this.setSpeaking(false);this.playingIntent.emit("pause");};VoiceConnection.prototype.resume = function resume(){this.paused = false;this.setSpeaking(true);this.playingIntent.emit("resume");};return VoiceConnection;})(_events2["default"]);exports["default"] = VoiceConnection;module.exports = exports["default"]; | ||
callback = volume;}if(!ffmpegOptions instanceof Array){ffmpegOptions = [];}var volume=volume !== undefined?volume:this.getVolume();return new Promise(function(resolve,reject){_this3.encoder.encodeArbitraryFFmpeg(ffmpegOptions,volume)["catch"](error).then(function(data){self.streamProc = data.proc;self.instream = data.instream;var intent=self.playStream(data.stream);resolve(intent);callback(null,intent);});function error(){var e=arguments.length <= 0 || arguments[0] === undefined?true:arguments[0];reject(e);callback(e);}});};VoiceConnection.prototype.init = function init(){var _this4=this;var self=this;_dns2["default"].lookup(this.endpoint,function(err,address,family){var vWS=self.vWS = new _ws2["default"]("wss://" + _this4.endpoint,null,{rejectUnauthorized:false});_this4.endpoint = address;var udpClient=self.udp = _dgram2["default"].createSocket("udp4");var firstPacket=true;var discordIP="",discordPort="";udpClient.bind({exclusive:true});udpClient.on('message',function(msg,rinfo){var buffArr=JSON.parse(JSON.stringify(msg)).data;if(firstPacket === true){for(var i=4;i < buffArr.indexOf(0,i);i++) {discordIP += String.fromCharCode(buffArr[i]);}discordPort = msg.readUIntLE(msg.length - 2,2).toString(10);var modes=self.vWSData.modes;var mode=MODE_xsalsa20_poly1305;if(modes.indexOf(MODE_xsalsa20_poly1305) < 0){mode = MODE_plain;self.client.emit("debug","Encrypted mode not reported as supported by the server, using 'plain'");}vWS.send(JSON.stringify({"op":1,"d":{"protocol":"udp","data":{"address":discordIP,"port":Number(discordPort),"mode":mode}}}));firstPacket = false;}});vWS.on("open",function(){vWS.send(JSON.stringify({op:0,d:{server_id:self.server.id,user_id:self.client.internal.user.id,session_id:self.session,token:self.token}}));});var KAI;vWS.on("message",function(msg){var data=JSON.parse(msg);switch(data.op){case 2:self.vWSData = data.d;self.KAI = KAI = self.client.internal.intervals.misc["voiceKAI"] = setInterval(function(){if(vWS && vWS.readyState === _ws2["default"].OPEN)vWS.send(JSON.stringify({op:3,d:null}));},data.d.heartbeat_interval);var udpPacket=new Buffer(70);udpPacket.writeUIntBE(data.d.ssrc,0,4);udpClient.send(udpPacket,0,udpPacket.length,data.d.port,self.endpoint,function(err){if(err)self.emit("error",err);});break;case 4:if(data.d.secret_key && data.d.secret_key.length > 0){var buffer=new ArrayBuffer(data.d.secret_key.length);self.secret = new Uint8Array(buffer);for(var i=0;i < _this4.secret.length;i++) {self.secret[i] = data.d.secret_key[i];}}self.ready = true;self.mode = data.d.mode;self.emit("ready",self);break;case 5:var user=self.server.members.get("id",data.d.user_id);if(user){var speaking=data.d.speaking;var channel=user.voiceChannel;if(channel){user.speaking = speaking;self.client.emit("voiceSpeaking",channel,user);}else {self.client.emit("warn","channel doesn't exist even though SPEAKING expects them to");}}else {self.client.emit("warn","user doesn't exist even though SPEAKING expects them to");}break;}});vWS.on("error",function(err,msg){self.emit("error",err,msg);});vWS.on("close",function(code){self.emit("close",code);});});};VoiceConnection.prototype.wrapVolume = function wrapVolume(stream){stream.pipe(this.volume);return this.volume;};VoiceConnection.prototype.setVolume = function setVolume(volume){this.volume.set(volume);};VoiceConnection.prototype.getVolume = function getVolume(){return this.volume.get();};VoiceConnection.prototype.mute = function mute(){this.lastVolume = this.volume.get();this.setVolume(0);};VoiceConnection.prototype.unmute = function unmute(){this.setVolume(this.lastVolume);this.lastVolume = undefined;};VoiceConnection.prototype.pause = function pause(){this.paused = true;this.setSpeaking(false);this.playingIntent.emit("pause");};VoiceConnection.prototype.resume = function resume(){this.paused = false;this.setSpeaking(true);this.playingIntent.emit("resume");};return VoiceConnection;})(_events2["default"]);exports["default"] = VoiceConnection;module.exports = exports["default"]; |
{ | ||
"name": "discord.js", | ||
"version": "8.0.0", | ||
"version": "8.1.0", | ||
"description": "A way to interface with the Discord API", | ||
@@ -28,5 +28,5 @@ "main": "./entrypoint.js", | ||
"dependencies": { | ||
"superagent": "^1.8.3", | ||
"superagent": "^2.1.0", | ||
"unpipe": "^1.0.0", | ||
"ws": "^1.1.0" | ||
"ws": "^1.1.1" | ||
}, | ||
@@ -44,3 +44,3 @@ "devDependencies": { | ||
"optionalDependencies": { | ||
"node-opus": "^0.2.0", | ||
"node-opus": "^0.2.1", | ||
"tweetnacl": "^0.14.3" | ||
@@ -54,3 +54,4 @@ }, | ||
"./lib/Util/TokenCacher.js": "./lib/Util/TokenCacher-shim.js" | ||
} | ||
}, | ||
"tonicExampleFilename": "./examples/tonicdev.js" | ||
} |
@@ -109,13 +109,24 @@ /* global describe */ | ||
client.setChannelNameAndTopic(channel, "testing", "a testing channel - temporary").then(() => { | ||
client.setChannelName(channel, "testing").then(() => { | ||
if (channel.name !== "testing" || channel.topic !== "a testing channel - temporary") { | ||
err("channel not updated"); | ||
if (channel.name !== "testing") { | ||
err("channel name not updated"); | ||
return; | ||
} | ||
pass("channel name and topic updated"); | ||
pass("channel name updated"); | ||
sendMsg(); | ||
client.setChannelTopic(channel, "a testing channel - temporary").then(() => { | ||
if (channel.topic !== "a testing channel - temporary"){ | ||
err("channel topic not updated"); | ||
return; | ||
} | ||
pass("channel topic updated"); | ||
sendMsg(); | ||
}); | ||
}).catch(e => { | ||
@@ -122,0 +133,0 @@ err("error editting channel: " + e); |
Sorry, the diff of this file is too big to display
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
268164
44
1968
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcookiejar@2.1.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedform-data@1.0.0-rc4(transitive)
+ Addedformidable@1.2.6(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.3.0(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedobject-inspect@1.13.4(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedqs@6.14.0(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedsuperagent@2.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedcomponent-emitter@1.2.1(transitive)
- Removedcookiejar@2.0.6(transitive)
- Removedextend@3.0.0(transitive)
- Removedform-data@1.0.0-rc3(transitive)
- Removedformidable@1.0.17(transitive)
- Removedisarray@0.0.1(transitive)
- Removedmime@1.3.4(transitive)
- Removedqs@2.3.3(transitive)
- Removedreadable-stream@1.0.27-1(transitive)
- Removedreduce-component@1.0.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedsuperagent@1.8.5(transitive)
Updatedsuperagent@^2.1.0
Updatedws@^1.1.1