diff --git a/discord.master.js b/discord.master.js index 84095660..e95de566 100644 --- a/discord.master.js +++ b/discord.master.js @@ -70,7 +70,7 @@ /* 0 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(process) {exports.Package = __webpack_require__(28); +/* WEBPACK VAR INJECTION */(function(process) {exports.Package = __webpack_require__(29); /** * Options for a Client. @@ -937,6 +937,18 @@ class Collection extends Map { return testVal !== value || (testVal === undefined && !collection.has(key)); }); } + + /** + * The sort() method sorts the elements of a collection in place and returns the collection. + * The sort is not necessarily stable. The default sort order is according to string Unicode code points. + * @param {Function} [compareFunction] Specifies a function that defines the sort order. + * if omitted, the collection is sorted according to each character's Unicode code point value, + * according to the string conversion of each element. + * @returns {Collection} + */ + sort(compareFunction = (x, y) => +(x > y) || +(x === y) - 1) { + return new Collection(Array.from(this.entries()).sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]))); + } } module.exports = Collection; @@ -946,7 +958,7 @@ module.exports = Collection; /* 4 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {const superagent = __webpack_require__(25); +/* WEBPACK VAR INJECTION */(function(Buffer) {const superagent = __webpack_require__(26); const Constants = __webpack_require__(0); /** @@ -1166,7 +1178,7 @@ module.exports = Util; /* 5 */ /***/ (function(module, exports, __webpack_require__) { -const Long = __webpack_require__(42); +const Long = __webpack_require__(24); // Discord epoch (2015-01-01T00:00:00.000Z) const EPOCH = 1420070400000; @@ -1673,9 +1685,9 @@ module.exports = Channel; /* 9 */ /***/ (function(module, exports, __webpack_require__) { -const Attachment = __webpack_require__(32); -const Embed = __webpack_require__(34); -const MessageReaction = __webpack_require__(35); +const Attachment = __webpack_require__(33); +const Embed = __webpack_require__(35); +const MessageReaction = __webpack_require__(36); const Util = __webpack_require__(4); const Collection = __webpack_require__(3); const Constants = __webpack_require__(0); @@ -2349,9 +2361,8 @@ class Role { * @type {number} */ get calculatedPosition() { - const sorted = this.guild.roles.array() - .sort((r1, r2) => r1.position !== r2.position ? r1.position - r2.position : r1.id - r2.id); - return sorted.indexOf(sorted.find(r => r.id === this.id)); + const sorted = this.guild._sortedRoles(); + return sorted.array().indexOf(sorted.get(this.id)); } /** @@ -3563,9 +3574,9 @@ module.exports = GuildMember; /* 14 */ /***/ (function(module, exports, __webpack_require__) { -const path = __webpack_require__(24); +const path = __webpack_require__(25); const Message = __webpack_require__(9); -const MessageCollector = __webpack_require__(33); +const MessageCollector = __webpack_require__(34); const Collection = __webpack_require__(3); /** @@ -4095,6 +4106,7 @@ exports.EOL = '\n'; /* 16 */ /***/ (function(module, exports, __webpack_require__) { +const Long = __webpack_require__(24); const User = __webpack_require__(11); const Role = __webpack_require__(10); const Emoji = __webpack_require__(12); @@ -4392,6 +4404,15 @@ class Guild { return this.roles.get(this.id); } + /** + * Fetches a collection of roles in the current guild sorted by position. + * @type {Collection} + * @readonly + */ + get _sortedRoles() { + return this._sortPositionWithID(this.roles); + } + /** * Returns the GuildMember form of a User object, if the user is present in the guild. * @param {UserResolvable} user The user that you want to obtain the GuildMember of @@ -4784,31 +4805,6 @@ class Guild { return this.client.rest.methods.createGuildRole(this, data); } - /** - * Set the position of a role in this guild - * @param {Role|Snowflake} role the role to edit, can be a role object or a role ID. - * @param {number} position the new position of the role - * @param {boolean} [relative=false] Position moves the role relative to its current position - * @returns {Promise} - */ - setRolePosition(role, position, relative = false) { - if (typeof role === 'string') { - role = this.roles.get(role); - if (!role) return Promise.reject(new Error('Supplied role is not a role or string.')); - } - - position = Number(position); - if (isNaN(position)) return Promise.reject(new Error('Supplied position is not a number.')); - - let updatedRoles = Object.assign([], this.roles.array() - .sort((r1, r2) => r1.position !== r2.position ? r1.position - r2.position : r1.id - r2.id)); - - Util.moveElementInArray(updatedRoles, role, position, relative); - - updatedRoles = updatedRoles.map((r, i) => ({ id: r.id, position: i })); - return this.client.rest.methods.setRolePositions(this.id, updatedRoles); - } - /** * Creates a new custom emoji in the guild. * @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji. @@ -5016,6 +5012,81 @@ class Guild { } this.presences.set(id, new Presence(presence)); } + + /** + * Set the position of a role in this guild + * @param {string|Role} role The role to edit, can be a role object or a role ID. + * @param {number} position The new position of the role + * @param {boolean} [relative=false] Position Moves the role relative to its current position + * @returns {Promise} + */ + setRolePosition(role, position, relative = false) { + if (typeof role === 'string') { + role = this.roles.get(role); + if (!role) return Promise.reject(new Error('Supplied role is not a role or snowflake.')); + } + + position = Number(position); + if (isNaN(position)) return Promise.reject(new Error('Supplied position is not a number.')); + + let updatedRoles = this._sortedRoles().array(); + + Util.moveElementInArray(updatedRoles, role, position, relative); + + updatedRoles = updatedRoles.map((r, i) => ({ id: r.id, position: i })); + return this.client.rest.methods.setRolePositions(this.id, updatedRoles); + } + + /** + * Set the position of a channel in this guild + * @param {string|GuildChannel} channel The channel to edit, can be a channel object or a channel ID. + * @param {number} position The new position of the channel + * @param {boolean} [relative=false] Position Moves the channel relative to its current position + * @returns {Promise} + */ + setChannelPosition(channel, position, relative = false) { + if (typeof channel === 'string') { + channel = this.channels.get(channel); + if (!channel) return Promise.reject(new Error('Supplied channel is not a channel or snowflake.')); + } + + position = Number(position); + if (isNaN(position)) return Promise.reject(new Error('Supplied position is not a number.')); + + let updatedChannels = this._sortedChannels(channel.type).array(); + + Util.moveElementInArray(updatedChannels, channel, position, relative); + + updatedChannels = updatedChannels.map((r, i) => ({ id: r.id, position: i })); + return this.client.rest.methods.setChannelPositions(this.id, updatedChannels); + } + + /** + * Fetches a collection of channels in the current guild sorted by position. + * @param {string} type Channel type + * @returns {Collection} + */ + _sortedChannels(type) { + return this._sortPositionWithID(this.channels.filter(c => { + if (type === 'voice' && c.type === 'voice') return true; + else if (type !== 'voice' && c.type !== 'voice') return true; + else return type === c.type; + })); + } + + /** + * Sorts a collection by object position or ID if the positions are equivalent. + * Intended to be identical to Discord's sorting method. + * @param {Collection} collection The collection to sort + * @returns {Collection} + */ + _sortPositionWithID(collection) { + return collection.sort((a, b) => + a.position !== b.position ? + a.position - b.position : + Long.fromString(a.id).sub(Long.fromString(b.id)).toNumber() + ); + } } module.exports = Guild; @@ -5027,7 +5098,7 @@ module.exports = Guild; const Channel = __webpack_require__(8); const Role = __webpack_require__(10); -const PermissionOverwrites = __webpack_require__(39); +const PermissionOverwrites = __webpack_require__(40); const Permissions = __webpack_require__(6); const Collection = __webpack_require__(3); @@ -5073,6 +5144,15 @@ class GuildChannel extends Channel { } } + /** + * The position of the channel + * @type {number} + */ + get calculatedPosition() { + const sorted = this.guild._sortedChannels(this.type); + return sorted.array().indexOf(sorted.get(this.id)); + } + /** * Gets the overall set of permissions for a user in this channel, taking into account roles and permission * overwrites. @@ -5247,6 +5327,7 @@ class GuildChannel extends Channel { /** * Set a new position for the guild channel * @param {number} position The new position for the guild channel + * @param {boolean} [relative=false] Move the position relative to its current value * @returns {Promise} * @example * // set a new channel position @@ -5254,8 +5335,8 @@ class GuildChannel extends Channel { * .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`)) * .catch(console.error); */ - setPosition(position) { - return this.client.rest.methods.updateChannel(this, { position }); + setPosition(position, relative) { + return this.guild.setChannelPosition(this, position, relative).then(() => this); } /** @@ -5787,7 +5868,7 @@ module.exports = ReactionEmoji; /* 21 */ /***/ (function(module, exports, __webpack_require__) { -const path = __webpack_require__(24); +const path = __webpack_require__(25); /** * Represents a webhook @@ -8113,3451 +8194,6 @@ function isUndefined(arg) { /* 24 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length - 1; i >= 0; i--) { - var last = parts[i]; - if (last === '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Split a filename into [root, dir, basename, ext], unix version -// 'root' is just a slash, or nothing. -var splitPathRe = - /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; -var splitPath = function(filename) { - return splitPathRe.exec(filename).slice(1); -}; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { - var resolvedPath = '', - resolvedAbsolute = false; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) ? arguments[i] : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string') { - throw new TypeError('Arguments to path.resolve must be strings'); - } else if (!path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { - var isAbsolute = exports.isAbsolute(path), - trailingSlash = substr(path, -1) === '/'; - - // Normalize the path - path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - -// posix version -exports.isAbsolute = function(path) { - return path.charAt(0) === '/'; -}; - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - if (typeof p !== 'string') { - throw new TypeError('Arguments to path.join must be strings'); - } - return p; - }).join('/')); -}; - - -// path.relative(from, to) -// posix version -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); - - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; - } - - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; - } - - if (start > end) return []; - return arr.slice(start, end - start + 1); - } - - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); - - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } - - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } - - outputParts = outputParts.concat(toParts.slice(samePartsLength)); - - return outputParts.join('/'); -}; - -exports.sep = '/'; -exports.delimiter = ':'; - -exports.dirname = function(path) { - var result = splitPath(path), - root = result[0], - dir = result[1]; - - if (!root && !dir) { - // No dirname whatsoever - return '.'; - } - - if (dir) { - // It has a dirname, strip trailing slash - dir = dir.substr(0, dir.length - 1); - } - - return root + dir; -}; - - -exports.basename = function(path, ext) { - var f = splitPath(path)[2]; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPath(path)[3]; -}; - -function filter (xs, f) { - if (xs.filter) return xs.filter(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - if (f(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// String.prototype.substr - negative index don't work in IE8 -var substr = 'ab'.substr(-1) === 'b' - ? function (str, start, len) { return str.substr(start, len) } - : function (str, start, len) { - if (start < 0) start = str.length + start; - return str.substr(start, len); - } -; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18))) - -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * Root reference for iframes. - */ - -var root; -if (typeof window !== 'undefined') { // Browser window - root = window; -} else if (typeof self !== 'undefined') { // Web Worker - root = self; -} else { // Other environments - console.warn("Using browser-only version of superagent in non-browser environment"); - root = this; -} - -var Emitter = __webpack_require__(53); -var RequestBase = __webpack_require__(60); -var isObject = __webpack_require__(26); -var isFunction = __webpack_require__(59); -var ResponseBase = __webpack_require__(61); -var shouldRetry = __webpack_require__(62); - -/** - * Noop. - */ - -function noop(){}; - -/** - * Expose `request`. - */ - -var request = exports = module.exports = function(method, url) { - // callback - if ('function' == typeof url) { - return new exports.Request('GET', method).end(url); - } - - // url first - if (1 == arguments.length) { - return new exports.Request('GET', method); - } - - return new exports.Request(method, url); -} - -exports.Request = Request; - -/** - * Determine XHR. - */ - -request.getXHR = function () { - if (root.XMLHttpRequest - && (!root.location || 'file:' != root.location.protocol - || !root.ActiveXObject)) { - return new XMLHttpRequest; - } else { - try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} - try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {} - try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {} - try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {} - } - throw Error("Browser-only verison of superagent could not find XHR"); -}; - -/** - * Removes leading and trailing whitespace, added to support IE. - * - * @param {String} s - * @return {String} - * @api private - */ - -var trim = ''.trim - ? function(s) { return s.trim(); } - : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); }; - -/** - * Serialize the given `obj`. - * - * @param {Object} obj - * @return {String} - * @api private - */ - -function serialize(obj) { - if (!isObject(obj)) return obj; - var pairs = []; - for (var key in obj) { - pushEncodedKeyValuePair(pairs, key, obj[key]); - } - return pairs.join('&'); -} - -/** - * Helps 'serialize' with serializing arrays. - * Mutates the pairs array. - * - * @param {Array} pairs - * @param {String} key - * @param {Mixed} val - */ - -function pushEncodedKeyValuePair(pairs, key, val) { - if (val != null) { - if (Array.isArray(val)) { - val.forEach(function(v) { - pushEncodedKeyValuePair(pairs, key, v); - }); - } else if (isObject(val)) { - for(var subkey in val) { - pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]); - } - } else { - pairs.push(encodeURIComponent(key) - + '=' + encodeURIComponent(val)); - } - } else if (val === null) { - pairs.push(encodeURIComponent(key)); - } -} - -/** - * Expose serialization method. - */ - - request.serializeObject = serialize; - - /** - * Parse the given x-www-form-urlencoded `str`. - * - * @param {String} str - * @return {Object} - * @api private - */ - -function parseString(str) { - var obj = {}; - var pairs = str.split('&'); - var pair; - var pos; - - for (var i = 0, len = pairs.length; i < len; ++i) { - pair = pairs[i]; - pos = pair.indexOf('='); - if (pos == -1) { - obj[decodeURIComponent(pair)] = ''; - } else { - obj[decodeURIComponent(pair.slice(0, pos))] = - decodeURIComponent(pair.slice(pos + 1)); - } - } - - return obj; -} - -/** - * Expose parser. - */ - -request.parseString = parseString; - -/** - * Default MIME type map. - * - * superagent.types.xml = 'application/xml'; - * - */ - -request.types = { - html: 'text/html', - json: 'application/json', - xml: 'application/xml', - urlencoded: 'application/x-www-form-urlencoded', - 'form': 'application/x-www-form-urlencoded', - 'form-data': 'application/x-www-form-urlencoded' -}; - -/** - * Default serialization map. - * - * superagent.serialize['application/xml'] = function(obj){ - * return 'generated xml here'; - * }; - * - */ - - request.serialize = { - 'application/x-www-form-urlencoded': serialize, - 'application/json': JSON.stringify - }; - - /** - * Default parsers. - * - * superagent.parse['application/xml'] = function(str){ - * return { object parsed from str }; - * }; - * - */ - -request.parse = { - 'application/x-www-form-urlencoded': parseString, - 'application/json': JSON.parse -}; - -/** - * Parse the given header `str` into - * an object containing the mapped fields. - * - * @param {String} str - * @return {Object} - * @api private - */ - -function parseHeader(str) { - var lines = str.split(/\r?\n/); - var fields = {}; - var index; - var line; - var field; - var val; - - lines.pop(); // trailing CRLF - - for (var i = 0, len = lines.length; i < len; ++i) { - line = lines[i]; - index = line.indexOf(':'); - field = line.slice(0, index).toLowerCase(); - val = trim(line.slice(index + 1)); - fields[field] = val; - } - - return fields; -} - -/** - * Check if `mime` is json or has +json structured syntax suffix. - * - * @param {String} mime - * @return {Boolean} - * @api private - */ - -function isJSON(mime) { - return /[\/+]json\b/.test(mime); -} - -/** - * Initialize a new `Response` with the given `xhr`. - * - * - set flags (.ok, .error, etc) - * - parse header - * - * Examples: - * - * Aliasing `superagent` as `request` is nice: - * - * request = superagent; - * - * We can use the promise-like API, or pass callbacks: - * - * request.get('/').end(function(res){}); - * request.get('/', function(res){}); - * - * Sending data can be chained: - * - * request - * .post('/user') - * .send({ name: 'tj' }) - * .end(function(res){}); - * - * Or passed to `.send()`: - * - * request - * .post('/user') - * .send({ name: 'tj' }, function(res){}); - * - * Or passed to `.post()`: - * - * request - * .post('/user', { name: 'tj' }) - * .end(function(res){}); - * - * Or further reduced to a single call for simple cases: - * - * request - * .post('/user', { name: 'tj' }, function(res){}); - * - * @param {XMLHTTPRequest} xhr - * @param {Object} options - * @api private - */ - -function Response(req) { - this.req = req; - this.xhr = this.req.xhr; - // responseText is accessible only if responseType is '' or 'text' and on older browsers - this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined') - ? this.xhr.responseText - : null; - this.statusText = this.req.xhr.statusText; - var status = this.xhr.status; - // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request - if (status === 1223) { - status = 204; - } - this._setStatusProperties(status); - this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders()); - // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but - // getResponseHeader still works. so we get content-type even if getting - // other headers fails. - this.header['content-type'] = this.xhr.getResponseHeader('content-type'); - this._setHeaderProperties(this.header); - - if (null === this.text && req._responseType) { - this.body = this.xhr.response; - } else { - this.body = this.req.method != 'HEAD' - ? this._parseBody(this.text ? this.text : this.xhr.response) - : null; - } -} - -ResponseBase(Response.prototype); - -/** - * Parse the given body `str`. - * - * Used for auto-parsing of bodies. Parsers - * are defined on the `superagent.parse` object. - * - * @param {String} str - * @return {Mixed} - * @api private - */ - -Response.prototype._parseBody = function(str){ - var parse = request.parse[this.type]; - if(this.req._parser) { - return this.req._parser(this, str); - } - if (!parse && isJSON(this.type)) { - parse = request.parse['application/json']; - } - return parse && str && (str.length || str instanceof Object) - ? parse(str) - : null; -}; - -/** - * Return an `Error` representative of this response. - * - * @return {Error} - * @api public - */ - -Response.prototype.toError = function(){ - var req = this.req; - var method = req.method; - var url = req.url; - - var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')'; - var err = new Error(msg); - err.status = this.status; - err.method = method; - err.url = url; - - return err; -}; - -/** - * Expose `Response`. - */ - -request.Response = Response; - -/** - * Initialize a new `Request` with the given `method` and `url`. - * - * @param {String} method - * @param {String} url - * @api public - */ - -function Request(method, url) { - var self = this; - this._query = this._query || []; - this.method = method; - this.url = url; - this.header = {}; // preserves header name case - this._header = {}; // coerces header names to lowercase - this.on('end', function(){ - var err = null; - var res = null; - - try { - res = new Response(self); - } catch(e) { - err = new Error('Parser is unable to parse the response'); - err.parse = true; - err.original = e; - // issue #675: return the raw response if the response parsing fails - if (self.xhr) { - // ie9 doesn't have 'response' property - err.rawResponse = typeof self.xhr.responseType == 'undefined' ? self.xhr.responseText : self.xhr.response; - // issue #876: return the http status code if the response parsing fails - err.status = self.xhr.status ? self.xhr.status : null; - err.statusCode = err.status; // backwards-compat only - } else { - err.rawResponse = null; - err.status = null; - } - - return self.callback(err); - } - - self.emit('response', res); - - var new_err; - try { - if (!self._isResponseOK(res)) { - new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); - new_err.original = err; - new_err.response = res; - new_err.status = res.status; - } - } catch(e) { - new_err = e; // #985 touching res may cause INVALID_STATE_ERR on old Android - } - - // #1000 don't catch errors from the callback to avoid double calling it - if (new_err) { - self.callback(new_err, res); - } else { - self.callback(null, res); - } - }); -} - -/** - * Mixin `Emitter` and `RequestBase`. - */ - -Emitter(Request.prototype); -RequestBase(Request.prototype); - -/** - * Set Content-Type to `type`, mapping values from `request.types`. - * - * Examples: - * - * superagent.types.xml = 'application/xml'; - * - * request.post('/') - * .type('xml') - * .send(xmlstring) - * .end(callback); - * - * request.post('/') - * .type('application/xml') - * .send(xmlstring) - * .end(callback); - * - * @param {String} type - * @return {Request} for chaining - * @api public - */ - -Request.prototype.type = function(type){ - this.set('Content-Type', request.types[type] || type); - return this; -}; - -/** - * Set Accept to `type`, mapping values from `request.types`. - * - * Examples: - * - * superagent.types.json = 'application/json'; - * - * request.get('/agent') - * .accept('json') - * .end(callback); - * - * request.get('/agent') - * .accept('application/json') - * .end(callback); - * - * @param {String} accept - * @return {Request} for chaining - * @api public - */ - -Request.prototype.accept = function(type){ - this.set('Accept', request.types[type] || type); - return this; -}; - -/** - * Set Authorization field value with `user` and `pass`. - * - * @param {String} user - * @param {String} pass - * @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic') - * @return {Request} for chaining - * @api public - */ - -Request.prototype.auth = function(user, pass, options){ - if (!options) { - options = { - type: 'function' === typeof btoa ? 'basic' : 'auto', - } - } - - switch (options.type) { - case 'basic': - this.set('Authorization', 'Basic ' + btoa(user + ':' + pass)); - break; - - case 'auto': - this.username = user; - this.password = pass; - break; - } - return this; -}; - -/** - * Add query-string `val`. - * - * Examples: - * - * request.get('/shoes') - * .query('size=10') - * .query({ color: 'blue' }) - * - * @param {Object|String} val - * @return {Request} for chaining - * @api public - */ - -Request.prototype.query = function(val){ - if ('string' != typeof val) val = serialize(val); - if (val) this._query.push(val); - return this; -}; - -/** - * Queue the given `file` as an attachment to the specified `field`, - * with optional `options` (or filename). - * - * ``` js - * request.post('/upload') - * .attach('content', new Blob(['hey!'], { type: "text/html"})) - * .end(callback); - * ``` - * - * @param {String} field - * @param {Blob|File} file - * @param {String|Object} options - * @return {Request} for chaining - * @api public - */ - -Request.prototype.attach = function(field, file, options){ - if (this._data) { - throw Error("superagent can't mix .send() and .attach()"); - } - - this._getFormData().append(field, file, options || file.name); - return this; -}; - -Request.prototype._getFormData = function(){ - if (!this._formData) { - this._formData = new root.FormData(); - } - return this._formData; -}; - -/** - * Invoke the callback with `err` and `res` - * and handle arity check. - * - * @param {Error} err - * @param {Response} res - * @api private - */ - -Request.prototype.callback = function(err, res){ - // console.log(this._retries, this._maxRetries) - if (this._maxRetries && this._retries++ < this._maxRetries && shouldRetry(err, res)) { - return this._retry(); - } - - var fn = this._callback; - this.clearTimeout(); - - if (err) { - if (this._maxRetries) err.retries = this._retries - 1; - this.emit('error', err); - } - - fn(err, res); -}; - -/** - * Invoke callback with x-domain error. - * - * @api private - */ - -Request.prototype.crossDomainError = function(){ - var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'); - err.crossDomain = true; - - err.status = this.status; - err.method = this.method; - err.url = this.url; - - this.callback(err); -}; - -// This only warns, because the request is still likely to work -Request.prototype.buffer = Request.prototype.ca = Request.prototype.agent = function(){ - console.warn("This is not supported in browser version of superagent"); - return this; -}; - -// This throws, because it can't send/receive data as expected -Request.prototype.pipe = Request.prototype.write = function(){ - throw Error("Streaming is not supported in browser version of superagent"); -}; - -/** - * Compose querystring to append to req.url - * - * @api private - */ - -Request.prototype._appendQueryString = function(){ - var query = this._query.join('&'); - if (query) { - this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query; - } - - if (this._sort) { - var index = this.url.indexOf('?'); - if (index >= 0) { - var queryArr = this.url.substring(index + 1).split('&'); - if (isFunction(this._sort)) { - queryArr.sort(this._sort); - } else { - queryArr.sort(); - } - this.url = this.url.substring(0, index) + '?' + queryArr.join('&'); - } - } -}; - -/** - * Check if `obj` is a host object, - * we don't want to serialize these :) - * - * @param {Object} obj - * @return {Boolean} - * @api private - */ -Request.prototype._isHost = function _isHost(obj) { - // Native objects stringify to [object File], [object Blob], [object FormData], etc. - return obj && 'object' === typeof obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]'; -} - -/** - * Initiate request, invoking callback `fn(res)` - * with an instanceof `Response`. - * - * @param {Function} fn - * @return {Request} for chaining - * @api public - */ - -Request.prototype.end = function(fn){ - if (this._endCalled) { - console.warn("Warning: .end() was called twice. This is not supported in superagent"); - } - this._endCalled = true; - - // store callback - this._callback = fn || noop; - - // querystring - this._appendQueryString(); - - return this._end(); -}; - -Request.prototype._end = function() { - var self = this; - var xhr = this.xhr = request.getXHR(); - var data = this._formData || this._data; - - this._setTimeouts(); - - // state change - xhr.onreadystatechange = function(){ - var readyState = xhr.readyState; - if (readyState >= 2 && self._responseTimeoutTimer) { - clearTimeout(self._responseTimeoutTimer); - } - if (4 != readyState) { - return; - } - - // In IE9, reads to any property (e.g. status) off of an aborted XHR will - // result in the error "Could not complete the operation due to error c00c023f" - var status; - try { status = xhr.status } catch(e) { status = 0; } - - if (!status) { - if (self.timedout || self._aborted) return; - return self.crossDomainError(); - } - self.emit('end'); - }; - - // progress - var handleProgress = function(direction, e) { - if (e.total > 0) { - e.percent = e.loaded / e.total * 100; - } - e.direction = direction; - self.emit('progress', e); - } - if (this.hasListeners('progress')) { - try { - xhr.onprogress = handleProgress.bind(null, 'download'); - if (xhr.upload) { - xhr.upload.onprogress = handleProgress.bind(null, 'upload'); - } - } catch(e) { - // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. - // Reported here: - // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context - } - } - - // initiate request - try { - if (this.username && this.password) { - xhr.open(this.method, this.url, true, this.username, this.password); - } else { - xhr.open(this.method, this.url, true); - } - } catch (err) { - // see #1149 - return this.callback(err); - } - - // CORS - if (this._withCredentials) xhr.withCredentials = true; - - // body - if (!this._formData && 'GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) { - // serialize stuff - var contentType = this._header['content-type']; - var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : '']; - if (!serialize && isJSON(contentType)) { - serialize = request.serialize['application/json']; - } - if (serialize) data = serialize(data); - } - - // set header fields - for (var field in this.header) { - if (null == this.header[field]) continue; - xhr.setRequestHeader(field, this.header[field]); - } - - if (this._responseType) { - xhr.responseType = this._responseType; - } - - // send stuff - this.emit('request', this); - - // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing) - // We need null here if data is undefined - xhr.send(typeof data !== 'undefined' ? data : null); - return this; -}; - -/** - * GET `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} - * @api public - */ - -request.get = function(url, data, fn){ - var req = request('GET', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.query(data); - if (fn) req.end(fn); - return req; -}; - -/** - * HEAD `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} - * @api public - */ - -request.head = function(url, data, fn){ - var req = request('HEAD', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * OPTIONS query to `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} - * @api public - */ - -request.options = function(url, data, fn){ - var req = request('OPTIONS', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * DELETE `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} [data] - * @param {Function} [fn] - * @return {Request} - * @api public - */ - -function del(url, data, fn){ - var req = request('DELETE', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -request['del'] = del; -request['delete'] = del; - -/** - * PATCH `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} [data] - * @param {Function} [fn] - * @return {Request} - * @api public - */ - -request.patch = function(url, data, fn){ - var req = request('PATCH', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * POST `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} [data] - * @param {Function} [fn] - * @return {Request} - * @api public - */ - -request.post = function(url, data, fn){ - var req = request('POST', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - -/** - * PUT `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} - * @api public - */ - -request.put = function(url, data, fn){ - var req = request('PUT', url); - if ('function' == typeof data) fn = data, data = null; - if (data) req.send(data); - if (fn) req.end(fn); - return req; -}; - - -/***/ }), -/* 26 */ -/***/ (function(module, exports) { - -/** - * Check if `obj` is an object. - * - * @param {Object} obj - * @return {Boolean} - * @api private - */ - -function isObject(obj) { - return null !== obj && 'object' === typeof obj; -} - -module.exports = isObject; - - -/***/ }), -/* 27 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(24); -const fs = __webpack_require__(43); -const request = __webpack_require__(25); - -const Constants = __webpack_require__(0); -const convertToBuffer = __webpack_require__(4).convertToBuffer; -const User = __webpack_require__(11); -const Message = __webpack_require__(9); -const Guild = __webpack_require__(16); -const Channel = __webpack_require__(8); -const GuildMember = __webpack_require__(13); -const Emoji = __webpack_require__(12); -const ReactionEmoji = __webpack_require__(20); - -/** - * The DataResolver identifies different objects and tries to resolve a specific piece of information from them, e.g. - * extracting a User from a Message object. - * @private - */ -class ClientDataResolver { - /** - * @param {Client} client The client the resolver is for - */ - constructor(client) { - this.client = client; - } - - /** - * Data that resolves to give a User object. This can be: - * * A User object - * * A user ID - * * A Message object (resolves to the message author) - * * A Guild object (owner of the guild) - * * A GuildMember object - * @typedef {User|Snowflake|Message|Guild|GuildMember} UserResolvable - */ - - /** - * Resolves a UserResolvable to a User object - * @param {UserResolvable} user The UserResolvable to identify - * @returns {?User} - */ - resolveUser(user) { - if (user instanceof User) return user; - if (typeof user === 'string') return this.client.users.get(user) || null; - if (user instanceof GuildMember) return user.user; - if (user instanceof Message) return user.author; - if (user instanceof Guild) return user.owner; - return null; - } - - /** - * Resolves a UserResolvable to a user ID string - * @param {UserResolvable} user The UserResolvable to identify - * @returns {?Snowflake} - */ - resolveUserID(user) { - if (user instanceof User || user instanceof GuildMember) return user.id; - if (typeof user === 'string') return user || null; - if (user instanceof Message) return user.author.id; - if (user instanceof Guild) return user.ownerID; - return null; - } - - /** - * Data that resolves to give a Guild object. This can be: - * * A Guild object - * * A Guild ID - * @typedef {Guild|Snowflake} GuildResolvable - */ - - /** - * Resolves a GuildResolvable to a Guild object - * @param {GuildResolvable} guild The GuildResolvable to identify - * @returns {?Guild} - */ - resolveGuild(guild) { - if (guild instanceof Guild) return guild; - if (typeof guild === 'string') return this.client.guilds.get(guild) || null; - return null; - } - - /** - * Data that resolves to give a GuildMember object. This can be: - * * A GuildMember object - * * A User object - * @typedef {Guild} GuildMemberResolvable - */ - - /** - * Resolves a GuildMemberResolvable to a GuildMember object - * @param {GuildResolvable} guild The guild that the member is part of - * @param {UserResolvable} user The user that is part of the guild - * @returns {?GuildMember} - */ - resolveGuildMember(guild, user) { - if (user instanceof GuildMember) return user; - guild = this.resolveGuild(guild); - user = this.resolveUser(user); - if (!guild || !user) return null; - return guild.members.get(user.id) || null; - } - - /** - * Data that can be resolved to give a Channel object. This can be: - * * A Channel object - * * A Message object (the channel the message was sent in) - * * A Guild object (the #general channel) - * * A channel ID - * @typedef {Channel|Guild|Message|Snowflake} ChannelResolvable - */ - - /** - * Resolves a ChannelResolvable to a Channel object - * @param {ChannelResolvable} channel The channel resolvable to resolve - * @returns {?Channel} - */ - resolveChannel(channel) { - if (channel instanceof Channel) return channel; - if (typeof channel === 'string') return this.client.channels.get(channel) || null; - if (channel instanceof Message) return channel.channel; - if (channel instanceof Guild) return channel.channels.get(channel.id) || null; - return null; - } - - /** - * Resolves a ChannelResolvable to a channel ID - * @param {ChannelResolvable} channel The channel resolvable to resolve - * @returns {?Snowflake} - */ - resolveChannelID(channel) { - if (channel instanceof Channel) return channel.id; - if (typeof channel === 'string') return channel; - if (channel instanceof Message) return channel.channel.id; - if (channel instanceof Guild) return channel.defaultChannel.id; - return null; - } - - /** - * Data that can be resolved to give an invite code. This can be: - * * An invite code - * * An invite URL - * @typedef {string} InviteResolvable - */ - - /** - * Resolves InviteResolvable to an invite code - * @param {InviteResolvable} data The invite resolvable to resolve - * @returns {string} - */ - resolveInviteCode(data) { - const inviteRegex = /discord(?:app\.com\/invite|\.gg)\/([\w-]{2,255})/i; - const match = inviteRegex.exec(data); - if (match && match[1]) return match[1]; - return data; - } - - /** - * Data that can be resolved to give a string. This can be: - * * A string - * * An array (joined with a new line delimiter to give a string) - * * Any value - * @typedef {string|Array|*} StringResolvable - */ - - /** - * Resolves a StringResolvable to a string - * @param {StringResolvable} data The string resolvable to resolve - * @returns {string} - */ - resolveString(data) { - if (typeof data === 'string') return data; - if (data instanceof Array) return data.join('\n'); - return String(data); - } - - /** - * Data that resolves to give a Base64 string, typically for image uploading. This can be: - * * A Buffer - * * A base64 string - * @typedef {Buffer|string} Base64Resolvable - */ - - /** - * Resolves a Base64Resolvable to a Base 64 image - * @param {Base64Resolvable} data The base 64 resolvable you want to resolve - * @returns {?string} - */ - resolveBase64(data) { - if (data instanceof Buffer) return `data:image/jpg;base64,${data.toString('base64')}`; - return data; - } - - /** - * Data that can be resolved to give a Buffer. This can be: - * * A Buffer - * * The path to a local file - * * A URL - * @typedef {string|Buffer} BufferResolvable - */ - - /** - * Resolves a BufferResolvable to a Buffer - * @param {BufferResolvable} resource The buffer resolvable to resolve - * @returns {Promise} - */ - resolveBuffer(resource) { - if (resource instanceof Buffer) return Promise.resolve(resource); - if (this.client.browser && resource instanceof ArrayBuffer) return Promise.resolve(convertToBuffer(resource)); - - if (typeof resource === 'string') { - return new Promise((resolve, reject) => { - if (/^https?:\/\//.test(resource)) { - const req = request.get(resource).set('Content-Type', 'blob'); - if (this.client.browser) req.responseType('arraybuffer'); - req.end((err, res) => { - if (err) return reject(err); - if (this.client.browser) return resolve(convertToBuffer(res.xhr.response)); - if (!(res.body instanceof Buffer)) return reject(new TypeError('The response body isn\'t a Buffer.')); - return resolve(res.body); - }); - } else { - const file = path.resolve(resource); - fs.stat(file, (err, stats) => { - if (err) return reject(err); - if (!stats || !stats.isFile()) return reject(new Error(`The file could not be found: ${file}`)); - fs.readFile(file, (err2, data) => { - if (err2) reject(err2); else resolve(data); - }); - return null; - }); - } - }); - } - - return Promise.reject(new TypeError('The resource must be a string or Buffer.')); - } - - /** - * Data that can be resolved to give an emoji identifier. This can be: - * * A string - * * An Emoji - * * A ReactionEmoji - * @typedef {string|Emoji|ReactionEmoji} EmojiIdentifierResolvable - */ - - /** - * Resolves an EmojiResolvable to an emoji identifier - * @param {EmojiIdentifierResolvable} emoji The emoji resolvable to resolve - * @returns {string} - */ - resolveEmojiIdentifier(emoji) { - if (emoji instanceof Emoji || emoji instanceof ReactionEmoji) return emoji.identifier; - if (typeof emoji === 'string') { - if (!emoji.includes('%')) return encodeURIComponent(emoji); - } - return null; - } - - /** - * Can be a Hex Literal, Hex String, Number, RGB Array, or one of the following - * ``` - * [ - * 'DEFAULT', - * 'AQUA', - * 'GREEN', - * 'BLUE', - * 'PURPLE', - * 'GOLD', - * 'ORANGE', - * 'RED', - * 'GREY', - * 'DARKER_GREY', - * 'NAVY', - * 'DARK_AQUA', - * 'DARK_GREEN', - * 'DARK_BLUE', - * 'DARK_PURPLE', - * 'DARK_GOLD', - * 'DARK_ORANGE', - * 'DARK_RED', - * 'DARK_GREY', - * 'LIGHT_GREY', - * 'DARK_NAVY', - * 'RANDOM', - * ] - * ``` - * or something like - * ``` - * [255, 0, 255] - * ``` - * for purple - * @typedef {String|number|Array} ColorResolvable - */ - - /** - * Resolves a ColorResolvable into a color number - * @param {ColorResolvable} color Color to resolve - * @returns {number} A color - */ - static resolveColor(color) { - if (typeof color === 'string') { - if (color === 'RANDOM') return Math.floor(Math.random() * (0xFFFFFF + 1)); - color = Constants.Colors[color] || parseInt(color.replace('#', ''), 16); - } else if (color instanceof Array) { - color = (color[0] << 16) + (color[1] << 8) + color[2]; - } - - if (color < 0 || color > 0xFFFFFF) { - throw new RangeError('Color must be within the range 0 - 16777215 (0xFFFFFF).'); - } else if (color && isNaN(color)) { - throw new TypeError('Unable to convert color to a number.'); - } - - return color; - } - - /** - * @param {ColorResolvable} color Color to resolve - * @returns {number} A color - */ - resolveColor(color) { - return this.constructor.resolveColor(color); - } -} - -module.exports = ClientDataResolver; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(22).Buffer)) - -/***/ }), -/* 28 */ -/***/ (function(module, exports) { - -module.exports = { - "name": "discord.js", - "version": "11.0.0", - "description": "A powerful library for interacting with the Discord API", - "main": "./src/index", - "types": "./typings/index.d.ts", - "scripts": { - "test": "npm run lint && npm run docs:test", - "docs": "docgen --source src --custom docs/index.yml --output docs/docs.json", - "docs:test": "docgen --source src --custom docs/index.yml", - "lint": "eslint src", - "lint:fix": "eslint --fix src", - "webpack": "parallel-webpack" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/hydrabolt/discord.js.git" - }, - "keywords": [ - "discord", - "api", - "bot", - "client", - "node", - "discordapp" - ], - "author": "Amish Shah ", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/hydrabolt/discord.js/issues" - }, - "homepage": "https://github.com/hydrabolt/discord.js#readme", - "runkitExampleFilename": "./docs/examples/ping.js", - "dependencies": { - "@types/node": "^7.0.0", - "long": "^3.2.0", - "prism-media": "hydrabolt/prism-media", - "superagent": "^3.4.0", - "tweetnacl": "^0.14.0", - "ws": "^2.0.0" - }, - "peerDependencies": { - "bufferutil": "^2.0.0", - "erlpack": "hammerandchisel/erlpack", - "node-opus": "^0.2.0", - "opusscript": "^0.0.2", - "sodium": "^2.0.1", - "uws": "^0.14.1" - }, - "devDependencies": { - "discord.js-docgen": "hydrabolt/discord.js-docgen", - "eslint": "^3.17.0", - "parallel-webpack": "^1.6.0", - "uglify-js": "mishoo/UglifyJS2#harmony", - "webpack": "^2.2.0" - }, - "engines": { - "node": ">=6.0.0" - }, - "browser": { - "ws": false, - "uws": false, - "erlpack": false, - "prism-media": false, - "opusscript": false, - "node-opus": false, - "tweetnacl": false, - "sodium": false, - "src/sharding/Shard.js": false, - "src/sharding/ShardClientUtil.js": false, - "src/sharding/ShardingManager.js": false, - "src/client/voice/dispatcher/StreamDispatcher.js": false, - "src/client/voice/opus/BaseOpusEngine.js": false, - "src/client/voice/opus/NodeOpusEngine.js": false, - "src/client/voice/opus/OpusEngineList.js": false, - "src/client/voice/opus/OpusScriptEngine.js": false, - "src/client/voice/pcm/ConverterEngine.js": false, - "src/client/voice/pcm/ConverterEngineList.js": false, - "src/client/voice/pcm/FfmpegConverterEngine.js": false, - "src/client/voice/player/AudioPlayer.js": false, - "src/client/voice/receiver/VoiceReadable.js": false, - "src/client/voice/receiver/VoiceReceiver.js": false, - "src/client/voice/util/Secretbox.js": false, - "src/client/voice/util/SecretKey.js": false, - "src/client/voice/util/VolumeInterface.js": false, - "src/client/voice/ClientVoiceManager.js": false, - "src/client/voice/VoiceBroadcast.js": false, - "src/client/voice/VoiceConnection.js": false, - "src/client/voice/VoiceUDPClient.js": false, - "src/client/voice/VoiceWebSocket.js": false - } -}; - -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { - -const User = __webpack_require__(11); -const Collection = __webpack_require__(3); - -/** - * Represents the logged in client's Discord user - * @extends {User} - */ -class ClientUser extends User { - setup(data) { - super.setup(data); - - /** - * Whether or not this account has been verified - * @type {boolean} - */ - this.verified = data.verified; - - /** - * The email of this account - * @type {string} - */ - this.email = data.email; - this.localPresence = {}; - this._typing = new Map(); - - /** - * A Collection of friends for the logged in user. - * This is only filled when using a user account. - * @type {Collection} - */ - this.friends = new Collection(); - - /** - * A Collection of blocked users for the logged in user. - * This is only filled when using a user account. - * @type {Collection} - */ - this.blocked = new Collection(); - - /** - * A Collection of notes for the logged in user. - * This is only filled when using a user account. - * @type {Collection} - */ - this.notes = new Collection(); - - /** - * Discord client settings, such as guild positions - * This is only filled when using a user account. - * @type {Object} - */ - this.settings = {}; - - /** - * If the user has discord premium (nitro) - * This is only filled when using a user account. - * @type {?boolean} - */ - this.premium = typeof data.premium === 'boolean' ? data.premium : null; - - /** - * If the user has MFA enabled on their account - * This is only filled when using a user account. - * @type {?boolean} - */ - this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null; - - /** - * If the user has ever used a mobile device on discord - * This is only filled when using a user account. - * @type {?boolean} - */ - this.mobile = typeof data.mobile === 'boolean' ? data.mobile : null; - } - - edit(data) { - return this.client.rest.methods.updateCurrentUser(data); - } - - /** - * Set the username of the logged in Client. - * Changing usernames in Discord is heavily rate limited, with only 2 requests - * every hour. Use this sparingly! - * @param {string} username The new username - * @param {string} [password] Current password (only for user accounts) - * @returns {Promise} - * @example - * // set username - * client.user.setUsername('discordjs') - * .then(user => console.log(`My new username is ${user.username}`)) - * .catch(console.error); - */ - setUsername(username, password) { - return this.client.rest.methods.updateCurrentUser({ username }, password); - } - - /** - * Changes the email for the client user's account. - * This is only available when using a user account. - * @param {string} email New email to change to - * @param {string} password Current password - * @returns {Promise} - * @example - * // set email - * client.user.setEmail('bob@gmail.com', 'some amazing password 123') - * .then(user => console.log(`My new email is ${user.email}`)) - * .catch(console.error); - */ - setEmail(email, password) { - return this.client.rest.methods.updateCurrentUser({ email }, password); - } - - /** - * Changes the password for the client user's account. - * This is only available when using a user account. - * @param {string} newPassword New password to change to - * @param {string} oldPassword Current password - * @returns {Promise} - * @example - * // set password - * client.user.setPassword('some new amazing password 456', 'some amazing password 123') - * .then(user => console.log('New password set!')) - * .catch(console.error); - */ - setPassword(newPassword, oldPassword) { - return this.client.rest.methods.updateCurrentUser({ password: newPassword }, oldPassword); - } - - /** - * Set the avatar of the logged in Client. - * @param {BufferResolvable|Base64Resolvable} avatar The new avatar - * @returns {Promise} - * @example - * // set avatar - * client.user.setAvatar('./avatar.png') - * .then(user => console.log(`New avatar set!`)) - * .catch(console.error); - */ - setAvatar(avatar) { - if (typeof avatar === 'string' && avatar.startsWith('data:')) { - return this.client.rest.methods.updateCurrentUser({ avatar }); - } else { - return this.client.resolver.resolveBuffer(avatar).then(data => - this.client.rest.methods.updateCurrentUser({ avatar: data }) - ); - } - } - - /** - * Data resembling a raw Discord presence - * @typedef {Object} PresenceData - * @property {PresenceStatus} [status] Status of the user - * @property {boolean} [afk] Whether the user is AFK - * @property {Object} [game] Game the user is playing - * @property {string} [game.name] Name of the game - * @property {string} [game.url] Twitch stream URL - */ - - /** - * Sets the full presence of the client user. - * @param {PresenceData} data Data for the presence - * @returns {Promise} - */ - setPresence(data) { - // {"op":3,"d":{"status":"dnd","since":0,"game":null,"afk":false}} - return new Promise(resolve => { - let status = this.localPresence.status || this.presence.status; - let game = this.localPresence.game; - let afk = this.localPresence.afk || this.presence.afk; - - if (!game && this.presence.game) { - game = { - name: this.presence.game.name, - type: this.presence.game.type, - url: this.presence.game.url, - }; - } - - if (data.status) { - if (typeof data.status !== 'string') throw new TypeError('Status must be a string'); - status = data.status; - } - - if (data.game) { - game = data.game; - if (game.url) game.type = 1; - } - - if (data.game === null) game = null; - - if (typeof data.afk !== 'undefined') afk = data.afk; - afk = Boolean(afk); - - this.localPresence = { status, game, afk }; - this.localPresence.since = 0; - this.localPresence.game = this.localPresence.game || null; - - this.client.ws.send({ - op: 3, - d: this.localPresence, - }); - - this.client._setPresence(this.id, this.localPresence); - - resolve(this); - }); - } - - /** - * A user's status. Must be one of: - * - `online` - * - `idle` - * - `invisible` - * - `dnd` (do not disturb) - * @typedef {string} PresenceStatus - */ - - /** - * Sets the status of the client user. - * @param {PresenceStatus} status Status to change to - * @returns {Promise} - */ - setStatus(status) { - return this.setPresence({ status }); - } - - /** - * Sets the game the client user is playing. - * @param {?string} game Game being played - * @param {string} [streamingURL] Twitch stream URL - * @returns {Promise} - */ - setGame(game, streamingURL) { - if (game === null) return this.setPresence({ game }); - return this.setPresence({ game: { - name: game, - url: streamingURL, - } }); - } - - /** - * Sets/removes the AFK flag for the client user. - * @param {boolean} afk Whether or not the user is AFK - * @returns {Promise} - */ - setAFK(afk) { - return this.setPresence({ afk }); - } - - /** - * Fetches messages that mentioned the client's user - * @param {Object} [options] Options for the fetch - * @param {number} [options.limit=25] Maximum number of mentions to retrieve - * @param {boolean} [options.roles=true] Whether to include role mentions - * @param {boolean} [options.everyone=true] Whether to include everyone/here mentions - * @param {Guild|Snowflake} [options.guild] Limit the search to a specific guild - * @returns {Promise} - */ - fetchMentions(options = { limit: 25, roles: true, everyone: true, guild: null }) { - return this.client.rest.methods.fetchMentions(options); - } - - /** - * Send a friend request - * This is only available when using a user account. - * @param {UserResolvable} user The user to send the friend request to. - * @returns {Promise} The user the friend request was sent to. - */ - addFriend(user) { - user = this.client.resolver.resolveUser(user); - return this.client.rest.methods.addFriend(user); - } - - /** - * Remove a friend - * This is only available when using a user account. - * @param {UserResolvable} user The user to remove from your friends - * @returns {Promise} The user that was removed - */ - removeFriend(user) { - user = this.client.resolver.resolveUser(user); - return this.client.rest.methods.removeFriend(user); - } - - /** - * Creates a guild - * This is only available when using a user account. - * @param {string} name The name of the guild - * @param {string} region The region for the server - * @param {BufferResolvable|Base64Resolvable} [icon=null] The icon for the guild - * @returns {Promise} The guild that was created - */ - createGuild(name, region, icon = null) { - if (!icon) return this.client.rest.methods.createGuild({ name, icon, region }); - if (typeof icon === 'string' && icon.startsWith('data:')) { - return this.client.rest.methods.createGuild({ name, icon, region }); - } else { - return this.client.resolver.resolveBuffer(icon).then(data => - this.client.rest.methods.createGuild({ name, icon: data, region }) - ); - } - } - - /** - * An object containing either a user or access token, and an optional nickname - * @typedef {Object} GroupDMRecipientOptions - * @property {UserResolvable|Snowflake} [user] User to add to the group DM - * (only available if a user is creating the DM) - * @property {string} [accessToken] Access token to use to add a user to the group DM - * (only available if a bot is creating the DM) - * @property {string} [nick] Permanent nickname (only available if a bot is creating the DM) - */ - - /** - * Creates a group DM - * @param {GroupDMRecipientOptions[]} recipients The recipients - * @returns {Promise} - */ - createGroupDM(recipients) { - return this.client.rest.methods.createGroupDM({ - recipients: recipients.map(u => this.client.resolver.resolveUserID(u.user)), - accessTokens: recipients.map(u => u.accessToken), - nicks: recipients.map(u => u.nick), - }); - } - - /** - * Accepts an invite to join a guild - * This is only available when using a user account. - * @param {Invite|string} invite Invite or code to accept - * @returns {Promise} Joined guild - */ - acceptInvite(invite) { - return this.client.rest.methods.acceptInvite(invite); - } -} - -module.exports = ClientUser; - - -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { - -const Channel = __webpack_require__(8); -const TextBasedChannel = __webpack_require__(14); -const Collection = __webpack_require__(3); - -/** - * Represents a direct message channel between two users. - * @extends {Channel} - * @implements {TextBasedChannel} - */ -class DMChannel extends Channel { - constructor(client, data) { - super(client, data); - this.type = 'dm'; - this.messages = new Collection(); - this._typing = new Map(); - } - - setup(data) { - super.setup(data); - - /** - * The recipient on the other end of the DM - * @type {User} - */ - this.recipient = this.client.dataManager.newUser(data.recipients[0]); - - this.lastMessageID = data.last_message_id; - } - - /** - * When concatenated with a string, this automatically concatenates the recipient's mention instead of the - * DM channel object. - * @returns {string} - */ - toString() { - return this.recipient.toString(); - } - - // These are here only for documentation purposes - they are implemented by TextBasedChannel - /* eslint-disable no-empty-function */ - send() {} - sendMessage() {} - sendEmbed() {} - sendFile() {} - sendFiles() {} - sendCode() {} - fetchMessage() {} - fetchMessages() {} - fetchPinnedMessages() {} - search() {} - startTyping() {} - stopTyping() {} - get typing() {} - get typingCount() {} - createCollector() {} - awaitMessages() {} - // Doesn't work on DM channels; bulkDelete() {} - acknowledge() {} - _cacheMessage() {} -} - -TextBasedChannel.applyToClass(DMChannel, true, ['bulkDelete']); - -module.exports = DMChannel; - - -/***/ }), -/* 31 */ -/***/ (function(module, exports, __webpack_require__) { - -const PartialGuild = __webpack_require__(37); -const PartialGuildChannel = __webpack_require__(38); -const Constants = __webpack_require__(0); - -/* -{ max_age: 86400, - code: 'CG9A5', - guild: - { splash: null, - id: '123123123', - icon: '123123123', - name: 'name' }, - created_at: '2016-08-28T19:07:04.763368+00:00', - temporary: false, - uses: 0, - max_uses: 0, - inviter: - { username: '123', - discriminator: '4204', - bot: true, - id: '123123123', - avatar: '123123123' }, - channel: { type: 0, id: '123123', name: 'heavy-testing' } } -*/ - -/** - * Represents an invitation to a guild channel. - * The only guaranteed properties are `code`, `guild` and `channel`. Other properties can be missing. - */ -class Invite { - constructor(client, data) { - /** - * The client that instantiated the invite - * @name Invite#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - this.setup(data); - } - - setup(data) { - /** - * The guild the invite is for. If this guild is already known, this will be a Guild object. If the guild is - * unknown, this will be a PartialGuild object. - * @type {Guild|PartialGuild} - */ - this.guild = this.client.guilds.get(data.guild.id) || new PartialGuild(this.client, data.guild); - - /** - * The code for this invite - * @type {string} - */ - this.code = data.code; - - /** - * Whether or not this invite is temporary - * @type {boolean} - */ - this.temporary = data.temporary; - - /** - * The maximum age of the invite, in seconds - * @type {?number} - */ - this.maxAge = data.max_age; - - /** - * How many times this invite has been used - * @type {number} - */ - this.uses = data.uses; - - /** - * The maximum uses of this invite - * @type {number} - */ - this.maxUses = data.max_uses; - - if (data.inviter) { - /** - * The user who created this invite - * @type {User} - */ - this.inviter = this.client.dataManager.newUser(data.inviter); - } - - /** - * The channel the invite is for. If this channel is already known, this will be a GuildChannel object. - * If the channel is unknown, this will be a PartialGuildChannel object. - * @type {GuildChannel|PartialGuildChannel} - */ - this.channel = this.client.channels.get(data.channel.id) || new PartialGuildChannel(this.client, data.channel); - - /** - * The timestamp the invite was created at - * @type {number} - */ - this.createdTimestamp = new Date(data.created_at).getTime(); - } - - /** - * The time the invite was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * The timestamp the invite will expire at - * @type {number} - * @readonly - */ - get expiresTimestamp() { - return this.createdTimestamp + (this.maxAge * 1000); - } - - /** - * The time the invite will expire - * @type {Date} - * @readonly - */ - get expiresAt() { - return new Date(this.expiresTimestamp); - } - - /** - * The URL to the invite - * @type {string} - * @readonly - */ - get url() { - return Constants.Endpoints.inviteLink(this.code); - } - - /** - * Deletes this invite - * @returns {Promise} - */ - delete() { - return this.client.rest.methods.deleteInvite(this); - } - - /** - * When concatenated with a string, this automatically concatenates the invite's URL instead of the object. - * @returns {string} - * @example - * // logs: Invite: https://discord.gg/A1b2C3 - * console.log(`Invite: ${invite}`); - */ - toString() { - return this.url; - } -} - -module.exports = Invite; - - -/***/ }), -/* 32 */ -/***/ (function(module, exports) { - -/** - * Represents an attachment in a message - */ -class MessageAttachment { - constructor(message, data) { - /** - * The Client that instantiated this MessageAttachment. - * @name MessageAttachment#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: message.client }); - - /** - * The message this attachment is part of. - * @type {Message} - */ - this.message = message; - - this.setup(data); - } - - setup(data) { - /** - * The ID of this attachment - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The file name of this attachment - * @type {string} - */ - this.filename = data.filename; - - /** - * The size of this attachment in bytes - * @type {number} - */ - this.filesize = data.size; - - /** - * The URL to this attachment - * @type {string} - */ - this.url = data.url; - - /** - * The Proxy URL to this attachment - * @type {string} - */ - this.proxyURL = data.proxy_url; - - /** - * The height of this attachment (if an image) - * @type {?number} - */ - this.height = data.height; - - /** - * The width of this attachment (if an image) - * @type {?number} - */ - this.width = data.width; - } -} - -module.exports = MessageAttachment; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports, __webpack_require__) { - -const EventEmitter = __webpack_require__(23).EventEmitter; -const Collection = __webpack_require__(3); - -/** - * Collects messages based on a specified filter, then emits them. - * @extends {EventEmitter} - */ -class MessageCollector extends EventEmitter { - /** - * A function that takes a Message object and a MessageCollector and returns a boolean. - * ```js - * function(message, collector) { - * if (message.content.includes('discord')) { - * return true; // passed the filter test - * } - * return false; // failed the filter test - * } - * ``` - * @typedef {Function} CollectorFilterFunction - */ - - /** - * An object containing options used to configure a MessageCollector. All properties are optional. - * @typedef {Object} CollectorOptions - * @property {number} [time] Duration for the collector in milliseconds - * @property {number} [max] Maximum number of messages to handle - * @property {number} [maxMatches] Maximum number of successfully filtered messages to obtain - */ - - /** - * @param {Channel} channel The channel to collect messages in - * @param {CollectorFilterFunction} filter The filter function - * @param {CollectorOptions} [options] Options for the collector - */ - constructor(channel, filter, options = {}) { - super(); - - /** - * The channel this collector is operating on - * @type {Channel} - */ - this.channel = channel; - - /** - * A function used to filter messages that the collector collects. - * @type {CollectorFilterFunction} - */ - this.filter = filter; - - /** - * Options for the collecor. - * @type {CollectorOptions} - */ - this.options = options; - - /** - * Whether this collector has stopped collecting messages. - * @type {boolean} - */ - this.ended = false; - - /** - * A collection of collected messages, mapped by message ID. - * @type {Collection} - */ - this.collected = new Collection(); - - this.listener = message => this.verify(message); - this.channel.client.on('message', this.listener); - if (options.time) this.channel.client.setTimeout(() => this.stop('time'), options.time); - } - - /** - * Verifies a message against the filter and options - * @private - * @param {Message} message The message - * @returns {boolean} - */ - verify(message) { - if (this.channel ? this.channel.id !== message.channel.id : false) return false; - if (this.filter(message, this)) { - this.collected.set(message.id, message); - /** - * Emitted whenever the collector receives a message that passes the filter test. - * @param {Message} message The received message - * @param {MessageCollector} collector The collector the message passed through - * @event MessageCollector#message - */ - this.emit('message', message, this); - if (this.collected.size >= this.options.maxMatches) this.stop('matchesLimit'); - else if (this.options.max && this.collected.size === this.options.max) this.stop('limit'); - return true; - } - return false; - } - - /** - * Returns a promise that resolves when a valid message is sent. Rejects - * with collected messages if the Collector ends before receiving a message. - * @type {Promise} - * @readonly - */ - get next() { - return new Promise((resolve, reject) => { - if (this.ended) { - reject(this.collected); - return; - } - - const cleanup = () => { - this.removeListener('message', onMessage); - this.removeListener('end', onEnd); - }; - - const onMessage = (...args) => { - cleanup(); - resolve(...args); - }; - - const onEnd = (...args) => { - cleanup(); - reject(...args); // eslint-disable-line prefer-promise-reject-errors - }; - - this.once('message', onMessage); - this.once('end', onEnd); - }); - } - - /** - * Stops the collector and emits `end`. - * @param {string} [reason='user'] An optional reason for stopping the collector - */ - stop(reason = 'user') { - if (this.ended) return; - this.ended = true; - this.channel.client.removeListener('message', this.listener); - /** - * Emitted when the Collector stops collecting. - * @param {Collection} collection A collection of messages collected - * during the lifetime of the collector, mapped by the ID of the messages. - * @param {string} reason The reason for the end of the collector. If it ended because it reached the specified time - * limit, this would be `time`. If you invoke `.stop()` without specifying a reason, this would be `user`. If it - * ended because it reached its message limit, it will be `limit`. - * @event MessageCollector#end - */ - this.emit('end', this.collected, reason); - } -} - -module.exports = MessageCollector; - - -/***/ }), -/* 34 */ -/***/ (function(module, exports) { - -/** - * Represents an embed in a message (image/video preview, rich embed, etc.) - * This class is only used for *recieved* embeds. If you wish to send one, use the {@link RichEmbed} class. - */ -class MessageEmbed { - constructor(message, data) { - /** - * The client that instantiated this embed - * @name MessageEmbed#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: message.client }); - - /** - * The message this embed is part of - * @type {Message} - */ - this.message = message; - - this.setup(data); - } - - setup(data) { - /** - * The type of this embed - * @type {string} - */ - this.type = data.type; - - /** - * The title of this embed, if there is one - * @type {?string} - */ - this.title = data.title; - - /** - * The description of this embed, if there is one - * @type {?string} - */ - this.description = data.description; - - /** - * The URL of this embed - * @type {string} - */ - this.url = data.url; - - /** - * The color of the embed - * @type {number} - */ - this.color = data.color; - - /** - * The fields of this embed - * @type {MessageEmbedField[]} - */ - this.fields = []; - if (data.fields) for (const field of data.fields) this.fields.push(new MessageEmbedField(this, field)); - - /** - * The timestamp of this embed - * @type {number} - */ - this.createdTimestamp = data.timestamp; - - /** - * The thumbnail of this embed, if there is one - * @type {?MessageEmbedThumbnail} - */ - this.thumbnail = data.thumbnail ? new MessageEmbedThumbnail(this, data.thumbnail) : null; - - /** - * The image of this embed, if there is one - * @type {?MessageEmbedImage} - */ - this.image = data.image ? new MessageEmbedImage(this, data.image) : null; - - /** - * The video of this embed, if there is one - * @type {?MessageEmbedVideo} - */ - this.video = data.video ? new MessageEmbedVideo(this, data.video) : null; - - /** - * The author of this embed, if there is one - * @type {?MessageEmbedAuthor} - */ - this.author = data.author ? new MessageEmbedAuthor(this, data.author) : null; - - /** - * The provider of this embed, if there is one - * @type {?MessageEmbedProvider} - */ - this.provider = data.provider ? new MessageEmbedProvider(this, data.provider) : null; - - /** - * The footer of this embed - * @type {?MessageEmbedFooter} - */ - this.footer = data.footer ? new MessageEmbedFooter(this, data.footer) : null; - } - - /** - * The date this embed was created - * @type {Date} - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * The hexadecimal version of the embed color, with a leading hash. - * @type {string} - * @readonly - */ - get hexColor() { - let col = this.color.toString(16); - while (col.length < 6) col = `0${col}`; - return `#${col}`; - } -} - -/** - * Represents a thumbnail for a message embed - */ -class MessageEmbedThumbnail { - constructor(embed, data) { - /** - * The embed this thumbnail is part of - * @type {MessageEmbed} - */ - this.embed = embed; - - this.setup(data); - } - - setup(data) { - /** - * The URL for this thumbnail - * @type {string} - */ - this.url = data.url; - - /** - * The Proxy URL for this thumbnail - * @type {string} - */ - this.proxyURL = data.proxy_url; - - /** - * The height of the thumbnail - * @type {number} - */ - this.height = data.height; - - /** - * The width of the thumbnail - * @type {number} - */ - this.width = data.width; - } -} - -/** - * Represents an image for a message embed - */ -class MessageEmbedImage { - constructor(embed, data) { - /** - * The embed this image is part of - * @type {MessageEmbed} - */ - this.embed = embed; - - this.setup(data); - } - - setup(data) { - /** - * The URL for this image - * @type {string} - */ - this.url = data.url; - - /** - * The Proxy URL for this image - * @type {string} - */ - this.proxyURL = data.proxy_url; - - /** - * The height of the image - * @type {number} - */ - this.height = data.height; - - /** - * The width of the image - * @type {number} - */ - this.width = data.width; - } -} - -/** - * Represents a video for a message embed - */ -class MessageEmbedVideo { - constructor(embed, data) { - /** - * The embed this video is part of - * @type {MessageEmbed} - */ - this.embed = embed; - - this.setup(data); - } - - setup(data) { - /** - * The source URL for this video - * @type {string} - */ - this.url = data.url; - - /** - * The height of the video - * @type {number} - */ - this.height = data.height; - - /** - * The width of the video - * @type {number} - */ - this.width = data.width; - } -} - -/** - * Represents a provider for a message embed - */ -class MessageEmbedProvider { - constructor(embed, data) { - /** - * The embed this provider is part of - * @type {MessageEmbed} - */ - this.embed = embed; - - this.setup(data); - } - - setup(data) { - /** - * The name of this provider - * @type {string} - */ - this.name = data.name; - - /** - * The URL of this provider - * @type {string} - */ - this.url = data.url; - } -} - -/** - * Represents an author for a message embed - */ -class MessageEmbedAuthor { - constructor(embed, data) { - /** - * The embed this author is part of - * @type {MessageEmbed} - */ - this.embed = embed; - - this.setup(data); - } - - setup(data) { - /** - * The name of this author - * @type {string} - */ - this.name = data.name; - - /** - * The URL of this author - * @type {string} - */ - this.url = data.url; - - /** - * The icon URL of this author - * @type {string} - */ - this.iconURL = data.icon_url; - } -} - -/** - * Represents a field for a message embed - */ -class MessageEmbedField { - constructor(embed, data) { - /** - * The embed this footer is part of - * @type {MessageEmbed} - */ - this.embed = embed; - - this.setup(data); - } - - setup(data) { - /** - * The name of this field - * @type {string} - */ - this.name = data.name; - - /** - * The value of this field - * @type {string} - */ - this.value = data.value; - - /** - * If this field is displayed inline - * @type {boolean} - */ - this.inline = data.inline; - } -} - -/** - * Represents the footer of a message embed - */ -class MessageEmbedFooter { - constructor(embed, data) { - /** - * The embed this footer is part of - * @type {MessageEmbed} - */ - this.embed = embed; - - this.setup(data); - } - - setup(data) { - /** - * The text in this footer - * @type {string} - */ - this.text = data.text; - - /** - * The icon URL of this footer - * @type {string} - */ - this.iconURL = data.icon_url; - - /** - * The proxy icon URL of this footer - * @type {string} - */ - this.proxyIconUrl = data.proxy_icon_url; - } -} - -MessageEmbed.Thumbnail = MessageEmbedThumbnail; -MessageEmbed.Image = MessageEmbedImage; -MessageEmbed.Video = MessageEmbedVideo; -MessageEmbed.Provider = MessageEmbedProvider; -MessageEmbed.Author = MessageEmbedAuthor; -MessageEmbed.Field = MessageEmbedField; -MessageEmbed.Footer = MessageEmbedFooter; - -module.exports = MessageEmbed; - - -/***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { - -const Collection = __webpack_require__(3); -const Emoji = __webpack_require__(12); -const ReactionEmoji = __webpack_require__(20); - -/** - * Represents a reaction to a message - */ -class MessageReaction { - constructor(message, emoji, count, me) { - /** - * The message that this reaction refers to - * @type {Message} - */ - this.message = message; - - /** - * Whether the client has given this reaction - * @type {boolean} - */ - this.me = me; - - /** - * The number of people that have given the same reaction. - * @type {number} - */ - this.count = count || 0; - - /** - * The users that have given this reaction, mapped by their ID. - * @type {Collection} - */ - this.users = new Collection(); - - this._emoji = new ReactionEmoji(this, emoji.name, emoji.id); - } - - /** - * The emoji of this reaction, either an Emoji object for known custom emojis, or a ReactionEmoji - * object which has fewer properties. Whatever the prototype of the emoji, it will still have - * `name`, `id`, `identifier` and `toString()` - * @type {Emoji|ReactionEmoji} - */ - get emoji() { - if (this._emoji instanceof Emoji) return this._emoji; - // Check to see if the emoji has become known to the client - if (this._emoji.id) { - const emojis = this.message.client.emojis; - if (emojis.has(this._emoji.id)) { - const emoji = emojis.get(this._emoji.id); - this._emoji = emoji; - return emoji; - } - } - return this._emoji; - } - - /** - * Removes a user from this reaction. - * @param {UserResolvable} [user=this.message.client.user] User to remove the reaction of - * @returns {Promise} - */ - remove(user = this.message.client.user) { - const message = this.message; - user = this.message.client.resolver.resolveUserID(user); - if (!user) return Promise.reject(new Error('Couldn\'t resolve the user ID to remove from the reaction.')); - return message.client.rest.methods.removeMessageReaction( - message, this.emoji.identifier, user - ); - } - - /** - * Fetch all the users that gave this reaction. Resolves with a collection of users, mapped by their IDs. - * @param {number} [limit=100] the maximum amount of users to fetch, defaults to 100 - * @returns {Promise>} - */ - fetchUsers(limit = 100) { - const message = this.message; - return message.client.rest.methods.getMessageReactionUsers( - message, this.emoji.identifier, limit - ).then(users => { - this.users = new Collection(); - for (const rawUser of users) { - const user = this.message.client.dataManager.newUser(rawUser); - this.users.set(user.id, user); - } - this.count = this.users.size; - return this.users; - }); - } -} - -module.exports = MessageReaction; - - -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -const Snowflake = __webpack_require__(5); - -/** - * Represents an OAuth2 Application - */ -class OAuth2Application { - constructor(client, data) { - /** - * The client that instantiated the application - * @name OAuth2Application#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - this.setup(data); - } - - setup(data) { - /** - * The ID of the app - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The name of the app - * @type {string} - */ - this.name = data.name; - - /** - * The app's description - * @type {string} - */ - this.description = data.description; - - /** - * The app's icon hash - * @type {string} - */ - this.icon = data.icon; - - /** - * The app's icon URL - * @type {string} - */ - this.iconURL = `https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`; - - /** - * The app's RPC origins - * @type {?string[]} - */ - this.rpcOrigins = data.rpc_origins; - - /** - * The app's redirect URIs - * @type {string[]} - */ - this.redirectURIs = data.redirect_uris; - - /** - * If this app's bot requires a code grant when using the oauth2 flow - * @type {boolean} - */ - this.botRequireCodeGrant = data.bot_require_code_grant; - - /** - * If this app's bot is public - * @type {boolean} - */ - this.botPublic = data.bot_public; - - /** - * If this app can use rpc - * @type {boolean} - */ - this.rpcApplicationState = data.rpc_application_state; - - /** - * Object containing basic info about this app's bot - * @type {Object} - */ - this.bot = data.bot; - - /** - * Flags for the app - * @type {number} - */ - this.flags = data.flags; - - /** - * OAuth2 secret for the application - * @type {boolean} - */ - this.secret = data.secret; - } - - /** - * The timestamp the app was created at - * @type {number} - * @readonly - */ - get createdTimestamp() { - return Snowflake.deconstruct(this.id).timestamp; - } - - /** - * The time the app was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * Reset the app's secret and bot token - * @returns {OAuth2Application} - */ - reset() { - return this.client.rest.methods.resetApplication(this.id); - } - - /** - * When concatenated with a string, this automatically concatenates the app name rather than the app object. - * @returns {string} - */ - toString() { - return this.name; - } -} - -module.exports = OAuth2Application; - - -/***/ }), -/* 37 */ -/***/ (function(module, exports) { - -/* -{ splash: null, - id: '123123123', - icon: '123123123', - name: 'name' } -*/ - -/** - * Represents a guild that the client only has limited information for - e.g. from invites. - */ -class PartialGuild { - constructor(client, data) { - /** - * The Client that instantiated this PartialGuild - * @name PartialGuild#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - this.setup(data); - } - - setup(data) { - /** - * The ID of this guild - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The name of this guild - * @type {string} - */ - this.name = data.name; - - /** - * The hash of this guild's icon, or null if there is none. - * @type {?string} - */ - this.icon = data.icon; - - /** - * The hash of the guild splash image, or null if no splash (VIP only) - * @type {?string} - */ - this.splash = data.splash; - } -} - -module.exports = PartialGuild; - - -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { - -const Constants = __webpack_require__(0); - -/* -{ type: 0, id: '123123', name: 'heavy-testing' } } -*/ - -/** - * Represents a guild channel that the client only has limited information for - e.g. from invites. - */ -class PartialGuildChannel { - constructor(client, data) { - /** - * The Client that instantiated this PartialGuildChannel - * @name PartialGuildChannel#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - this.setup(data); - } - - setup(data) { - /** - * The ID of this guild channel - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The name of this guild channel - * @type {string} - */ - this.name = data.name; - - /** - * The type of this guild channel - `text` or `voice` - * @type {string} - */ - this.type = Constants.ChannelTypes.TEXT === data.type ? 'text' : 'voice'; - } -} - -module.exports = PartialGuildChannel; - - -/***/ }), -/* 39 */ -/***/ (function(module, exports) { - -/** - * Represents a permission overwrite for a role or member in a guild channel. - */ -class PermissionOverwrites { - constructor(guildChannel, data) { - /** - * The GuildChannel this overwrite is for - * @name PermissionOverwrites#channel - * @type {GuildChannel} - * @readonly - */ - Object.defineProperty(this, 'channel', { value: guildChannel }); - - if (data) this.setup(data); - } - - setup(data) { - /** - * The ID of this overwrite, either a user ID or a role ID - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The type of this overwrite - * @type {string} - */ - this.type = data.type; - - this.deny = data.deny; - this.allow = data.allow; - } - - /** - * Delete this Permission Overwrite. - * @returns {Promise} - */ - delete() { - return this.channel.client.rest.methods.deletePermissionOverwrites(this); - } -} - -module.exports = PermissionOverwrites; - - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -const GuildChannel = __webpack_require__(17); -const TextBasedChannel = __webpack_require__(14); -const Collection = __webpack_require__(3); - -/** - * Represents a guild text channel on Discord. - * @extends {GuildChannel} - * @implements {TextBasedChannel} - */ -class TextChannel extends GuildChannel { - constructor(guild, data) { - super(guild, data); - this.type = 'text'; - this.messages = new Collection(); - this._typing = new Map(); - } - - setup(data) { - super.setup(data); - - /** - * The topic of the text channel, if there is one. - * @type {?string} - */ - this.topic = data.topic; - - this.lastMessageID = data.last_message_id; - } - - /** - * A collection of members that can see this channel, mapped by their ID. - * @type {Collection} - * @readonly - */ - get members() { - const members = new Collection(); - for (const member of this.guild.members.values()) { - if (this.permissionsFor(member).hasPermission('READ_MESSAGES')) { - members.set(member.id, member); - } - } - return members; - } - - /** - * Fetch all webhooks for the channel. - * @returns {Promise>} - */ - fetchWebhooks() { - return this.client.rest.methods.getChannelWebhooks(this); - } - - /** - * Create a webhook for the channel. - * @param {string} name The name of the webhook. - * @param {BufferResolvable|Base64Resolvable} avatar The avatar for the webhook. - * @returns {Promise} webhook The created webhook. - * @example - * channel.createWebhook('Snek', 'http://snek.s3.amazonaws.com/topSnek.png') - * .then(webhook => console.log(`Created Webhook ${webhook}`)) - * .catch(console.error) - */ - createWebhook(name, avatar) { - return new Promise(resolve => { - if (typeof avatar === 'string' && avatar.startsWith('data:')) { - resolve(this.client.rest.methods.createWebhook(this, name, avatar)); - } else { - this.client.resolver.resolveBuffer(avatar).then(data => - resolve(this.client.rest.methods.createWebhook(this, name, data)) - ); - } - }); - } - - // These are here only for documentation purposes - they are implemented by TextBasedChannel - /* eslint-disable no-empty-function */ - send() {} - sendMessage() {} - sendEmbed() {} - sendFile() {} - sendFiles() {} - sendCode() {} - fetchMessage() {} - fetchMessages() {} - fetchPinnedMessages() {} - search() {} - startTyping() {} - stopTyping() {} - get typing() {} - get typingCount() {} - createCollector() {} - awaitMessages() {} - bulkDelete() {} - acknowledge() {} - _cacheMessage() {} -} - -TextBasedChannel.applyToClass(TextChannel, true); - -module.exports = TextChannel; - - -/***/ }), -/* 41 */ -/***/ (function(module, exports, __webpack_require__) { - -const GuildChannel = __webpack_require__(17); -const Collection = __webpack_require__(3); - -/** - * Represents a guild voice channel on Discord. - * @extends {GuildChannel} - */ -class VoiceChannel extends GuildChannel { - constructor(guild, data) { - super(guild, data); - - /** - * The members in this voice channel. - * @type {Collection} - */ - this.members = new Collection(); - - this.type = 'voice'; - } - - setup(data) { - super.setup(data); - - /** - * The bitrate of this voice channel - * @type {number} - */ - this.bitrate = data.bitrate; - - /** - * The maximum amount of users allowed in this channel - 0 means unlimited. - * @type {number} - */ - this.userLimit = data.user_limit; - } - - /** - * The voice connection for this voice channel, if the client is connected - * @type {?VoiceConnection} - * @readonly - */ - get connection() { - const connection = this.guild.voiceConnection; - if (connection && connection.channel.id === this.id) return connection; - return null; - } - - /** - * Checks if the voice channel is full - * @type {boolean} - */ - get full() { - return this.userLimit > 0 && this.members.size >= this.userLimit; - } - - /** - * Checks if the client has permission join the voice channel - * @type {boolean} - */ - get joinable() { - if (this.client.browser) return false; - if (!this.permissionsFor(this.client.user).hasPermission('CONNECT')) return false; - if (this.full && !this.permissionsFor(this.client.user).hasPermission('MOVE_MEMBERS')) return false; - return true; - } - - /** - * Checks if the client has permission to send audio to the voice channel - * @type {boolean} - */ - get speakable() { - return this.permissionsFor(this.client.user).hasPermission('SPEAK'); - } - - /** - * Sets the bitrate of the channel - * @param {number} bitrate The new bitrate - * @returns {Promise} - * @example - * // set the bitrate of a voice channel - * voiceChannel.setBitrate(48000) - * .then(vc => console.log(`Set bitrate to ${vc.bitrate} for ${vc.name}`)) - * .catch(console.error); - */ - setBitrate(bitrate) { - return this.edit({ bitrate }); - } - - /** - * Sets the user limit of the channel - * @param {number} userLimit The new user limit - * @returns {Promise} - * @example - * // set the user limit of a voice channel - * voiceChannel.setUserLimit(42) - * .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`)) - * .catch(console.error); - */ - setUserLimit(userLimit) { - return this.edit({ userLimit }); - } - - /** - * Attempts to join this voice channel - * @returns {Promise} - * @example - * // join a voice channel - * voiceChannel.join() - * .then(connection => console.log('Connected!')) - * .catch(console.error); - */ - join() { - if (this.client.browser) return Promise.reject(new Error('Voice connections are not available in browsers.')); - return this.client.voice.joinChannel(this); - } - - /** - * Leaves this voice channel - * @example - * // leave a voice channel - * voiceChannel.leave(); - */ - leave() { - if (this.client.browser) return; - const connection = this.client.voice.connections.get(this.guild.id); - if (connection && connection.channel.id === this.id) connection.disconnect(); - } -} - -module.exports = VoiceChannel; - - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* Copyright 2013 Daniel Wirtz Copyright 2009 The Closure Library Authors. All Rights Reserved. @@ -12772,6 +9408,3451 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ }); +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// resolves . and .. elements in a path array with directory names there +// must be no slashes, empty elements, or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length - 1; i >= 0; i--) { + var last = parts[i]; + if (last === '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Split a filename into [root, dir, basename, ext], unix version +// 'root' is just a slash, or nothing. +var splitPathRe = + /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; +var splitPath = function(filename) { + return splitPathRe.exec(filename).slice(1); +}; + +// path.resolve([from ...], to) +// posix version +exports.resolve = function() { + var resolvedPath = '', + resolvedAbsolute = false; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) ? arguments[i] : process.cwd(); + + // Skip empty and invalid entries + if (typeof path !== 'string') { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charAt(0) === '/'; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { + var isAbsolute = exports.isAbsolute(path), + trailingSlash = substr(path, -1) === '/'; + + // Normalize the path + path = normalizeArray(filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + +// posix version +exports.isAbsolute = function(path) { + return path.charAt(0) === '/'; +}; + +// posix version +exports.join = function() { + var paths = Array.prototype.slice.call(arguments, 0); + return exports.normalize(filter(paths, function(p, index) { + if (typeof p !== 'string') { + throw new TypeError('Arguments to path.join must be strings'); + } + return p; + }).join('/')); +}; + + +// path.relative(from, to) +// posix version +exports.relative = function(from, to) { + from = exports.resolve(from).substr(1); + to = exports.resolve(to).substr(1); + + function trim(arr) { + var start = 0; + for (; start < arr.length; start++) { + if (arr[start] !== '') break; + } + + var end = arr.length - 1; + for (; end >= 0; end--) { + if (arr[end] !== '') break; + } + + if (start > end) return []; + return arr.slice(start, end - start + 1); + } + + var fromParts = trim(from.split('/')); + var toParts = trim(to.split('/')); + + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + + return outputParts.join('/'); +}; + +exports.sep = '/'; +exports.delimiter = ':'; + +exports.dirname = function(path) { + var result = splitPath(path), + root = result[0], + dir = result[1]; + + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + + return root + dir; +}; + + +exports.basename = function(path, ext) { + var f = splitPath(path)[2]; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +exports.extname = function(path) { + return splitPath(path)[3]; +}; + +function filter (xs, f) { + if (xs.filter) return xs.filter(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + if (f(xs[i], i, xs)) res.push(xs[i]); + } + return res; +} + +// String.prototype.substr - negative index don't work in IE8 +var substr = 'ab'.substr(-1) === 'b' + ? function (str, start, len) { return str.substr(start, len) } + : function (str, start, len) { + if (start < 0) start = str.length + start; + return str.substr(start, len); + } +; + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(18))) + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * Root reference for iframes. + */ + +var root; +if (typeof window !== 'undefined') { // Browser window + root = window; +} else if (typeof self !== 'undefined') { // Web Worker + root = self; +} else { // Other environments + console.warn("Using browser-only version of superagent in non-browser environment"); + root = this; +} + +var Emitter = __webpack_require__(53); +var RequestBase = __webpack_require__(60); +var isObject = __webpack_require__(27); +var isFunction = __webpack_require__(59); +var ResponseBase = __webpack_require__(61); +var shouldRetry = __webpack_require__(62); + +/** + * Noop. + */ + +function noop(){}; + +/** + * Expose `request`. + */ + +var request = exports = module.exports = function(method, url) { + // callback + if ('function' == typeof url) { + return new exports.Request('GET', method).end(url); + } + + // url first + if (1 == arguments.length) { + return new exports.Request('GET', method); + } + + return new exports.Request(method, url); +} + +exports.Request = Request; + +/** + * Determine XHR. + */ + +request.getXHR = function () { + if (root.XMLHttpRequest + && (!root.location || 'file:' != root.location.protocol + || !root.ActiveXObject)) { + return new XMLHttpRequest; + } else { + try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {} + try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {} + try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {} + try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {} + } + throw Error("Browser-only verison of superagent could not find XHR"); +}; + +/** + * Removes leading and trailing whitespace, added to support IE. + * + * @param {String} s + * @return {String} + * @api private + */ + +var trim = ''.trim + ? function(s) { return s.trim(); } + : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); }; + +/** + * Serialize the given `obj`. + * + * @param {Object} obj + * @return {String} + * @api private + */ + +function serialize(obj) { + if (!isObject(obj)) return obj; + var pairs = []; + for (var key in obj) { + pushEncodedKeyValuePair(pairs, key, obj[key]); + } + return pairs.join('&'); +} + +/** + * Helps 'serialize' with serializing arrays. + * Mutates the pairs array. + * + * @param {Array} pairs + * @param {String} key + * @param {Mixed} val + */ + +function pushEncodedKeyValuePair(pairs, key, val) { + if (val != null) { + if (Array.isArray(val)) { + val.forEach(function(v) { + pushEncodedKeyValuePair(pairs, key, v); + }); + } else if (isObject(val)) { + for(var subkey in val) { + pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]); + } + } else { + pairs.push(encodeURIComponent(key) + + '=' + encodeURIComponent(val)); + } + } else if (val === null) { + pairs.push(encodeURIComponent(key)); + } +} + +/** + * Expose serialization method. + */ + + request.serializeObject = serialize; + + /** + * Parse the given x-www-form-urlencoded `str`. + * + * @param {String} str + * @return {Object} + * @api private + */ + +function parseString(str) { + var obj = {}; + var pairs = str.split('&'); + var pair; + var pos; + + for (var i = 0, len = pairs.length; i < len; ++i) { + pair = pairs[i]; + pos = pair.indexOf('='); + if (pos == -1) { + obj[decodeURIComponent(pair)] = ''; + } else { + obj[decodeURIComponent(pair.slice(0, pos))] = + decodeURIComponent(pair.slice(pos + 1)); + } + } + + return obj; +} + +/** + * Expose parser. + */ + +request.parseString = parseString; + +/** + * Default MIME type map. + * + * superagent.types.xml = 'application/xml'; + * + */ + +request.types = { + html: 'text/html', + json: 'application/json', + xml: 'application/xml', + urlencoded: 'application/x-www-form-urlencoded', + 'form': 'application/x-www-form-urlencoded', + 'form-data': 'application/x-www-form-urlencoded' +}; + +/** + * Default serialization map. + * + * superagent.serialize['application/xml'] = function(obj){ + * return 'generated xml here'; + * }; + * + */ + + request.serialize = { + 'application/x-www-form-urlencoded': serialize, + 'application/json': JSON.stringify + }; + + /** + * Default parsers. + * + * superagent.parse['application/xml'] = function(str){ + * return { object parsed from str }; + * }; + * + */ + +request.parse = { + 'application/x-www-form-urlencoded': parseString, + 'application/json': JSON.parse +}; + +/** + * Parse the given header `str` into + * an object containing the mapped fields. + * + * @param {String} str + * @return {Object} + * @api private + */ + +function parseHeader(str) { + var lines = str.split(/\r?\n/); + var fields = {}; + var index; + var line; + var field; + var val; + + lines.pop(); // trailing CRLF + + for (var i = 0, len = lines.length; i < len; ++i) { + line = lines[i]; + index = line.indexOf(':'); + field = line.slice(0, index).toLowerCase(); + val = trim(line.slice(index + 1)); + fields[field] = val; + } + + return fields; +} + +/** + * Check if `mime` is json or has +json structured syntax suffix. + * + * @param {String} mime + * @return {Boolean} + * @api private + */ + +function isJSON(mime) { + return /[\/+]json\b/.test(mime); +} + +/** + * Initialize a new `Response` with the given `xhr`. + * + * - set flags (.ok, .error, etc) + * - parse header + * + * Examples: + * + * Aliasing `superagent` as `request` is nice: + * + * request = superagent; + * + * We can use the promise-like API, or pass callbacks: + * + * request.get('/').end(function(res){}); + * request.get('/', function(res){}); + * + * Sending data can be chained: + * + * request + * .post('/user') + * .send({ name: 'tj' }) + * .end(function(res){}); + * + * Or passed to `.send()`: + * + * request + * .post('/user') + * .send({ name: 'tj' }, function(res){}); + * + * Or passed to `.post()`: + * + * request + * .post('/user', { name: 'tj' }) + * .end(function(res){}); + * + * Or further reduced to a single call for simple cases: + * + * request + * .post('/user', { name: 'tj' }, function(res){}); + * + * @param {XMLHTTPRequest} xhr + * @param {Object} options + * @api private + */ + +function Response(req) { + this.req = req; + this.xhr = this.req.xhr; + // responseText is accessible only if responseType is '' or 'text' and on older browsers + this.text = ((this.req.method !='HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text')) || typeof this.xhr.responseType === 'undefined') + ? this.xhr.responseText + : null; + this.statusText = this.req.xhr.statusText; + var status = this.xhr.status; + // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request + if (status === 1223) { + status = 204; + } + this._setStatusProperties(status); + this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders()); + // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but + // getResponseHeader still works. so we get content-type even if getting + // other headers fails. + this.header['content-type'] = this.xhr.getResponseHeader('content-type'); + this._setHeaderProperties(this.header); + + if (null === this.text && req._responseType) { + this.body = this.xhr.response; + } else { + this.body = this.req.method != 'HEAD' + ? this._parseBody(this.text ? this.text : this.xhr.response) + : null; + } +} + +ResponseBase(Response.prototype); + +/** + * Parse the given body `str`. + * + * Used for auto-parsing of bodies. Parsers + * are defined on the `superagent.parse` object. + * + * @param {String} str + * @return {Mixed} + * @api private + */ + +Response.prototype._parseBody = function(str){ + var parse = request.parse[this.type]; + if(this.req._parser) { + return this.req._parser(this, str); + } + if (!parse && isJSON(this.type)) { + parse = request.parse['application/json']; + } + return parse && str && (str.length || str instanceof Object) + ? parse(str) + : null; +}; + +/** + * Return an `Error` representative of this response. + * + * @return {Error} + * @api public + */ + +Response.prototype.toError = function(){ + var req = this.req; + var method = req.method; + var url = req.url; + + var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')'; + var err = new Error(msg); + err.status = this.status; + err.method = method; + err.url = url; + + return err; +}; + +/** + * Expose `Response`. + */ + +request.Response = Response; + +/** + * Initialize a new `Request` with the given `method` and `url`. + * + * @param {String} method + * @param {String} url + * @api public + */ + +function Request(method, url) { + var self = this; + this._query = this._query || []; + this.method = method; + this.url = url; + this.header = {}; // preserves header name case + this._header = {}; // coerces header names to lowercase + this.on('end', function(){ + var err = null; + var res = null; + + try { + res = new Response(self); + } catch(e) { + err = new Error('Parser is unable to parse the response'); + err.parse = true; + err.original = e; + // issue #675: return the raw response if the response parsing fails + if (self.xhr) { + // ie9 doesn't have 'response' property + err.rawResponse = typeof self.xhr.responseType == 'undefined' ? self.xhr.responseText : self.xhr.response; + // issue #876: return the http status code if the response parsing fails + err.status = self.xhr.status ? self.xhr.status : null; + err.statusCode = err.status; // backwards-compat only + } else { + err.rawResponse = null; + err.status = null; + } + + return self.callback(err); + } + + self.emit('response', res); + + var new_err; + try { + if (!self._isResponseOK(res)) { + new_err = new Error(res.statusText || 'Unsuccessful HTTP response'); + new_err.original = err; + new_err.response = res; + new_err.status = res.status; + } + } catch(e) { + new_err = e; // #985 touching res may cause INVALID_STATE_ERR on old Android + } + + // #1000 don't catch errors from the callback to avoid double calling it + if (new_err) { + self.callback(new_err, res); + } else { + self.callback(null, res); + } + }); +} + +/** + * Mixin `Emitter` and `RequestBase`. + */ + +Emitter(Request.prototype); +RequestBase(Request.prototype); + +/** + * Set Content-Type to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.xml = 'application/xml'; + * + * request.post('/') + * .type('xml') + * .send(xmlstring) + * .end(callback); + * + * request.post('/') + * .type('application/xml') + * .send(xmlstring) + * .end(callback); + * + * @param {String} type + * @return {Request} for chaining + * @api public + */ + +Request.prototype.type = function(type){ + this.set('Content-Type', request.types[type] || type); + return this; +}; + +/** + * Set Accept to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.json = 'application/json'; + * + * request.get('/agent') + * .accept('json') + * .end(callback); + * + * request.get('/agent') + * .accept('application/json') + * .end(callback); + * + * @param {String} accept + * @return {Request} for chaining + * @api public + */ + +Request.prototype.accept = function(type){ + this.set('Accept', request.types[type] || type); + return this; +}; + +/** + * Set Authorization field value with `user` and `pass`. + * + * @param {String} user + * @param {String} pass + * @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic') + * @return {Request} for chaining + * @api public + */ + +Request.prototype.auth = function(user, pass, options){ + if (!options) { + options = { + type: 'function' === typeof btoa ? 'basic' : 'auto', + } + } + + switch (options.type) { + case 'basic': + this.set('Authorization', 'Basic ' + btoa(user + ':' + pass)); + break; + + case 'auto': + this.username = user; + this.password = pass; + break; + } + return this; +}; + +/** + * Add query-string `val`. + * + * Examples: + * + * request.get('/shoes') + * .query('size=10') + * .query({ color: 'blue' }) + * + * @param {Object|String} val + * @return {Request} for chaining + * @api public + */ + +Request.prototype.query = function(val){ + if ('string' != typeof val) val = serialize(val); + if (val) this._query.push(val); + return this; +}; + +/** + * Queue the given `file` as an attachment to the specified `field`, + * with optional `options` (or filename). + * + * ``` js + * request.post('/upload') + * .attach('content', new Blob(['hey!'], { type: "text/html"})) + * .end(callback); + * ``` + * + * @param {String} field + * @param {Blob|File} file + * @param {String|Object} options + * @return {Request} for chaining + * @api public + */ + +Request.prototype.attach = function(field, file, options){ + if (this._data) { + throw Error("superagent can't mix .send() and .attach()"); + } + + this._getFormData().append(field, file, options || file.name); + return this; +}; + +Request.prototype._getFormData = function(){ + if (!this._formData) { + this._formData = new root.FormData(); + } + return this._formData; +}; + +/** + * Invoke the callback with `err` and `res` + * and handle arity check. + * + * @param {Error} err + * @param {Response} res + * @api private + */ + +Request.prototype.callback = function(err, res){ + // console.log(this._retries, this._maxRetries) + if (this._maxRetries && this._retries++ < this._maxRetries && shouldRetry(err, res)) { + return this._retry(); + } + + var fn = this._callback; + this.clearTimeout(); + + if (err) { + if (this._maxRetries) err.retries = this._retries - 1; + this.emit('error', err); + } + + fn(err, res); +}; + +/** + * Invoke callback with x-domain error. + * + * @api private + */ + +Request.prototype.crossDomainError = function(){ + var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'); + err.crossDomain = true; + + err.status = this.status; + err.method = this.method; + err.url = this.url; + + this.callback(err); +}; + +// This only warns, because the request is still likely to work +Request.prototype.buffer = Request.prototype.ca = Request.prototype.agent = function(){ + console.warn("This is not supported in browser version of superagent"); + return this; +}; + +// This throws, because it can't send/receive data as expected +Request.prototype.pipe = Request.prototype.write = function(){ + throw Error("Streaming is not supported in browser version of superagent"); +}; + +/** + * Compose querystring to append to req.url + * + * @api private + */ + +Request.prototype._appendQueryString = function(){ + var query = this._query.join('&'); + if (query) { + this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query; + } + + if (this._sort) { + var index = this.url.indexOf('?'); + if (index >= 0) { + var queryArr = this.url.substring(index + 1).split('&'); + if (isFunction(this._sort)) { + queryArr.sort(this._sort); + } else { + queryArr.sort(); + } + this.url = this.url.substring(0, index) + '?' + queryArr.join('&'); + } + } +}; + +/** + * Check if `obj` is a host object, + * we don't want to serialize these :) + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ +Request.prototype._isHost = function _isHost(obj) { + // Native objects stringify to [object File], [object Blob], [object FormData], etc. + return obj && 'object' === typeof obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]'; +} + +/** + * Initiate request, invoking callback `fn(res)` + * with an instanceof `Response`. + * + * @param {Function} fn + * @return {Request} for chaining + * @api public + */ + +Request.prototype.end = function(fn){ + if (this._endCalled) { + console.warn("Warning: .end() was called twice. This is not supported in superagent"); + } + this._endCalled = true; + + // store callback + this._callback = fn || noop; + + // querystring + this._appendQueryString(); + + return this._end(); +}; + +Request.prototype._end = function() { + var self = this; + var xhr = this.xhr = request.getXHR(); + var data = this._formData || this._data; + + this._setTimeouts(); + + // state change + xhr.onreadystatechange = function(){ + var readyState = xhr.readyState; + if (readyState >= 2 && self._responseTimeoutTimer) { + clearTimeout(self._responseTimeoutTimer); + } + if (4 != readyState) { + return; + } + + // In IE9, reads to any property (e.g. status) off of an aborted XHR will + // result in the error "Could not complete the operation due to error c00c023f" + var status; + try { status = xhr.status } catch(e) { status = 0; } + + if (!status) { + if (self.timedout || self._aborted) return; + return self.crossDomainError(); + } + self.emit('end'); + }; + + // progress + var handleProgress = function(direction, e) { + if (e.total > 0) { + e.percent = e.loaded / e.total * 100; + } + e.direction = direction; + self.emit('progress', e); + } + if (this.hasListeners('progress')) { + try { + xhr.onprogress = handleProgress.bind(null, 'download'); + if (xhr.upload) { + xhr.upload.onprogress = handleProgress.bind(null, 'upload'); + } + } catch(e) { + // Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. + // Reported here: + // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context + } + } + + // initiate request + try { + if (this.username && this.password) { + xhr.open(this.method, this.url, true, this.username, this.password); + } else { + xhr.open(this.method, this.url, true); + } + } catch (err) { + // see #1149 + return this.callback(err); + } + + // CORS + if (this._withCredentials) xhr.withCredentials = true; + + // body + if (!this._formData && 'GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) { + // serialize stuff + var contentType = this._header['content-type']; + var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : '']; + if (!serialize && isJSON(contentType)) { + serialize = request.serialize['application/json']; + } + if (serialize) data = serialize(data); + } + + // set header fields + for (var field in this.header) { + if (null == this.header[field]) continue; + xhr.setRequestHeader(field, this.header[field]); + } + + if (this._responseType) { + xhr.responseType = this._responseType; + } + + // send stuff + this.emit('request', this); + + // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing) + // We need null here if data is undefined + xhr.send(typeof data !== 'undefined' ? data : null); + return this; +}; + +/** + * GET `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + +request.get = function(url, data, fn){ + var req = request('GET', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.query(data); + if (fn) req.end(fn); + return req; +}; + +/** + * HEAD `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + +request.head = function(url, data, fn){ + var req = request('HEAD', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * OPTIONS query to `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + +request.options = function(url, data, fn){ + var req = request('OPTIONS', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * DELETE `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} [data] + * @param {Function} [fn] + * @return {Request} + * @api public + */ + +function del(url, data, fn){ + var req = request('DELETE', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +request['del'] = del; +request['delete'] = del; + +/** + * PATCH `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} [data] + * @param {Function} [fn] + * @return {Request} + * @api public + */ + +request.patch = function(url, data, fn){ + var req = request('PATCH', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * POST `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} [data] + * @param {Function} [fn] + * @return {Request} + * @api public + */ + +request.post = function(url, data, fn){ + var req = request('POST', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + +/** + * PUT `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + +request.put = function(url, data, fn){ + var req = request('PUT', url); + if ('function' == typeof data) fn = data, data = null; + if (data) req.send(data); + if (fn) req.end(fn); + return req; +}; + + +/***/ }), +/* 27 */ +/***/ (function(module, exports) { + +/** + * Check if `obj` is an object. + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ + +function isObject(obj) { + return null !== obj && 'object' === typeof obj; +} + +module.exports = isObject; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(25); +const fs = __webpack_require__(43); +const request = __webpack_require__(26); + +const Constants = __webpack_require__(0); +const convertToBuffer = __webpack_require__(4).convertToBuffer; +const User = __webpack_require__(11); +const Message = __webpack_require__(9); +const Guild = __webpack_require__(16); +const Channel = __webpack_require__(8); +const GuildMember = __webpack_require__(13); +const Emoji = __webpack_require__(12); +const ReactionEmoji = __webpack_require__(20); + +/** + * The DataResolver identifies different objects and tries to resolve a specific piece of information from them, e.g. + * extracting a User from a Message object. + * @private + */ +class ClientDataResolver { + /** + * @param {Client} client The client the resolver is for + */ + constructor(client) { + this.client = client; + } + + /** + * Data that resolves to give a User object. This can be: + * * A User object + * * A user ID + * * A Message object (resolves to the message author) + * * A Guild object (owner of the guild) + * * A GuildMember object + * @typedef {User|Snowflake|Message|Guild|GuildMember} UserResolvable + */ + + /** + * Resolves a UserResolvable to a User object + * @param {UserResolvable} user The UserResolvable to identify + * @returns {?User} + */ + resolveUser(user) { + if (user instanceof User) return user; + if (typeof user === 'string') return this.client.users.get(user) || null; + if (user instanceof GuildMember) return user.user; + if (user instanceof Message) return user.author; + if (user instanceof Guild) return user.owner; + return null; + } + + /** + * Resolves a UserResolvable to a user ID string + * @param {UserResolvable} user The UserResolvable to identify + * @returns {?Snowflake} + */ + resolveUserID(user) { + if (user instanceof User || user instanceof GuildMember) return user.id; + if (typeof user === 'string') return user || null; + if (user instanceof Message) return user.author.id; + if (user instanceof Guild) return user.ownerID; + return null; + } + + /** + * Data that resolves to give a Guild object. This can be: + * * A Guild object + * * A Guild ID + * @typedef {Guild|Snowflake} GuildResolvable + */ + + /** + * Resolves a GuildResolvable to a Guild object + * @param {GuildResolvable} guild The GuildResolvable to identify + * @returns {?Guild} + */ + resolveGuild(guild) { + if (guild instanceof Guild) return guild; + if (typeof guild === 'string') return this.client.guilds.get(guild) || null; + return null; + } + + /** + * Data that resolves to give a GuildMember object. This can be: + * * A GuildMember object + * * A User object + * @typedef {Guild} GuildMemberResolvable + */ + + /** + * Resolves a GuildMemberResolvable to a GuildMember object + * @param {GuildResolvable} guild The guild that the member is part of + * @param {UserResolvable} user The user that is part of the guild + * @returns {?GuildMember} + */ + resolveGuildMember(guild, user) { + if (user instanceof GuildMember) return user; + guild = this.resolveGuild(guild); + user = this.resolveUser(user); + if (!guild || !user) return null; + return guild.members.get(user.id) || null; + } + + /** + * Data that can be resolved to give a Channel object. This can be: + * * A Channel object + * * A Message object (the channel the message was sent in) + * * A Guild object (the #general channel) + * * A channel ID + * @typedef {Channel|Guild|Message|Snowflake} ChannelResolvable + */ + + /** + * Resolves a ChannelResolvable to a Channel object + * @param {ChannelResolvable} channel The channel resolvable to resolve + * @returns {?Channel} + */ + resolveChannel(channel) { + if (channel instanceof Channel) return channel; + if (typeof channel === 'string') return this.client.channels.get(channel) || null; + if (channel instanceof Message) return channel.channel; + if (channel instanceof Guild) return channel.channels.get(channel.id) || null; + return null; + } + + /** + * Resolves a ChannelResolvable to a channel ID + * @param {ChannelResolvable} channel The channel resolvable to resolve + * @returns {?Snowflake} + */ + resolveChannelID(channel) { + if (channel instanceof Channel) return channel.id; + if (typeof channel === 'string') return channel; + if (channel instanceof Message) return channel.channel.id; + if (channel instanceof Guild) return channel.defaultChannel.id; + return null; + } + + /** + * Data that can be resolved to give an invite code. This can be: + * * An invite code + * * An invite URL + * @typedef {string} InviteResolvable + */ + + /** + * Resolves InviteResolvable to an invite code + * @param {InviteResolvable} data The invite resolvable to resolve + * @returns {string} + */ + resolveInviteCode(data) { + const inviteRegex = /discord(?:app\.com\/invite|\.gg)\/([\w-]{2,255})/i; + const match = inviteRegex.exec(data); + if (match && match[1]) return match[1]; + return data; + } + + /** + * Data that can be resolved to give a string. This can be: + * * A string + * * An array (joined with a new line delimiter to give a string) + * * Any value + * @typedef {string|Array|*} StringResolvable + */ + + /** + * Resolves a StringResolvable to a string + * @param {StringResolvable} data The string resolvable to resolve + * @returns {string} + */ + resolveString(data) { + if (typeof data === 'string') return data; + if (data instanceof Array) return data.join('\n'); + return String(data); + } + + /** + * Data that resolves to give a Base64 string, typically for image uploading. This can be: + * * A Buffer + * * A base64 string + * @typedef {Buffer|string} Base64Resolvable + */ + + /** + * Resolves a Base64Resolvable to a Base 64 image + * @param {Base64Resolvable} data The base 64 resolvable you want to resolve + * @returns {?string} + */ + resolveBase64(data) { + if (data instanceof Buffer) return `data:image/jpg;base64,${data.toString('base64')}`; + return data; + } + + /** + * Data that can be resolved to give a Buffer. This can be: + * * A Buffer + * * The path to a local file + * * A URL + * @typedef {string|Buffer} BufferResolvable + */ + + /** + * Resolves a BufferResolvable to a Buffer + * @param {BufferResolvable} resource The buffer resolvable to resolve + * @returns {Promise} + */ + resolveBuffer(resource) { + if (resource instanceof Buffer) return Promise.resolve(resource); + if (this.client.browser && resource instanceof ArrayBuffer) return Promise.resolve(convertToBuffer(resource)); + + if (typeof resource === 'string') { + return new Promise((resolve, reject) => { + if (/^https?:\/\//.test(resource)) { + const req = request.get(resource).set('Content-Type', 'blob'); + if (this.client.browser) req.responseType('arraybuffer'); + req.end((err, res) => { + if (err) return reject(err); + if (this.client.browser) return resolve(convertToBuffer(res.xhr.response)); + if (!(res.body instanceof Buffer)) return reject(new TypeError('The response body isn\'t a Buffer.')); + return resolve(res.body); + }); + } else { + const file = path.resolve(resource); + fs.stat(file, (err, stats) => { + if (err) return reject(err); + if (!stats || !stats.isFile()) return reject(new Error(`The file could not be found: ${file}`)); + fs.readFile(file, (err2, data) => { + if (err2) reject(err2); else resolve(data); + }); + return null; + }); + } + }); + } + + return Promise.reject(new TypeError('The resource must be a string or Buffer.')); + } + + /** + * Data that can be resolved to give an emoji identifier. This can be: + * * A string + * * An Emoji + * * A ReactionEmoji + * @typedef {string|Emoji|ReactionEmoji} EmojiIdentifierResolvable + */ + + /** + * Resolves an EmojiResolvable to an emoji identifier + * @param {EmojiIdentifierResolvable} emoji The emoji resolvable to resolve + * @returns {string} + */ + resolveEmojiIdentifier(emoji) { + if (emoji instanceof Emoji || emoji instanceof ReactionEmoji) return emoji.identifier; + if (typeof emoji === 'string') { + if (!emoji.includes('%')) return encodeURIComponent(emoji); + } + return null; + } + + /** + * Can be a Hex Literal, Hex String, Number, RGB Array, or one of the following + * ``` + * [ + * 'DEFAULT', + * 'AQUA', + * 'GREEN', + * 'BLUE', + * 'PURPLE', + * 'GOLD', + * 'ORANGE', + * 'RED', + * 'GREY', + * 'DARKER_GREY', + * 'NAVY', + * 'DARK_AQUA', + * 'DARK_GREEN', + * 'DARK_BLUE', + * 'DARK_PURPLE', + * 'DARK_GOLD', + * 'DARK_ORANGE', + * 'DARK_RED', + * 'DARK_GREY', + * 'LIGHT_GREY', + * 'DARK_NAVY', + * 'RANDOM', + * ] + * ``` + * or something like + * ``` + * [255, 0, 255] + * ``` + * for purple + * @typedef {String|number|Array} ColorResolvable + */ + + /** + * Resolves a ColorResolvable into a color number + * @param {ColorResolvable} color Color to resolve + * @returns {number} A color + */ + static resolveColor(color) { + if (typeof color === 'string') { + if (color === 'RANDOM') return Math.floor(Math.random() * (0xFFFFFF + 1)); + color = Constants.Colors[color] || parseInt(color.replace('#', ''), 16); + } else if (color instanceof Array) { + color = (color[0] << 16) + (color[1] << 8) + color[2]; + } + + if (color < 0 || color > 0xFFFFFF) { + throw new RangeError('Color must be within the range 0 - 16777215 (0xFFFFFF).'); + } else if (color && isNaN(color)) { + throw new TypeError('Unable to convert color to a number.'); + } + + return color; + } + + /** + * @param {ColorResolvable} color Color to resolve + * @returns {number} A color + */ + resolveColor(color) { + return this.constructor.resolveColor(color); + } +} + +module.exports = ClientDataResolver; + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(22).Buffer)) + +/***/ }), +/* 29 */ +/***/ (function(module, exports) { + +module.exports = { + "name": "discord.js", + "version": "11.0.0", + "description": "A powerful library for interacting with the Discord API", + "main": "./src/index", + "types": "./typings/index.d.ts", + "scripts": { + "test": "npm run lint && npm run docs:test", + "docs": "docgen --source src --custom docs/index.yml --output docs/docs.json", + "docs:test": "docgen --source src --custom docs/index.yml", + "lint": "eslint src", + "lint:fix": "eslint --fix src", + "webpack": "parallel-webpack" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/hydrabolt/discord.js.git" + }, + "keywords": [ + "discord", + "api", + "bot", + "client", + "node", + "discordapp" + ], + "author": "Amish Shah ", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/hydrabolt/discord.js/issues" + }, + "homepage": "https://github.com/hydrabolt/discord.js#readme", + "runkitExampleFilename": "./docs/examples/ping.js", + "dependencies": { + "@types/node": "^7.0.0", + "long": "^3.2.0", + "prism-media": "hydrabolt/prism-media", + "superagent": "^3.4.0", + "tweetnacl": "^0.14.0", + "ws": "^2.0.0" + }, + "peerDependencies": { + "bufferutil": "^2.0.0", + "erlpack": "hammerandchisel/erlpack", + "node-opus": "^0.2.0", + "opusscript": "^0.0.2", + "sodium": "^2.0.1", + "uws": "^0.14.1" + }, + "devDependencies": { + "discord.js-docgen": "hydrabolt/discord.js-docgen", + "eslint": "^3.17.0", + "parallel-webpack": "^1.6.0", + "uglify-js": "mishoo/UglifyJS2#harmony", + "webpack": "^2.2.0" + }, + "engines": { + "node": ">=6.0.0" + }, + "browser": { + "ws": false, + "uws": false, + "erlpack": false, + "prism-media": false, + "opusscript": false, + "node-opus": false, + "tweetnacl": false, + "sodium": false, + "src/sharding/Shard.js": false, + "src/sharding/ShardClientUtil.js": false, + "src/sharding/ShardingManager.js": false, + "src/client/voice/dispatcher/StreamDispatcher.js": false, + "src/client/voice/opus/BaseOpusEngine.js": false, + "src/client/voice/opus/NodeOpusEngine.js": false, + "src/client/voice/opus/OpusEngineList.js": false, + "src/client/voice/opus/OpusScriptEngine.js": false, + "src/client/voice/pcm/ConverterEngine.js": false, + "src/client/voice/pcm/ConverterEngineList.js": false, + "src/client/voice/pcm/FfmpegConverterEngine.js": false, + "src/client/voice/player/AudioPlayer.js": false, + "src/client/voice/receiver/VoiceReadable.js": false, + "src/client/voice/receiver/VoiceReceiver.js": false, + "src/client/voice/util/Secretbox.js": false, + "src/client/voice/util/SecretKey.js": false, + "src/client/voice/util/VolumeInterface.js": false, + "src/client/voice/ClientVoiceManager.js": false, + "src/client/voice/VoiceBroadcast.js": false, + "src/client/voice/VoiceConnection.js": false, + "src/client/voice/VoiceUDPClient.js": false, + "src/client/voice/VoiceWebSocket.js": false + } +}; + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +const User = __webpack_require__(11); +const Collection = __webpack_require__(3); + +/** + * Represents the logged in client's Discord user + * @extends {User} + */ +class ClientUser extends User { + setup(data) { + super.setup(data); + + /** + * Whether or not this account has been verified + * @type {boolean} + */ + this.verified = data.verified; + + /** + * The email of this account + * @type {string} + */ + this.email = data.email; + this.localPresence = {}; + this._typing = new Map(); + + /** + * A Collection of friends for the logged in user. + * This is only filled when using a user account. + * @type {Collection} + */ + this.friends = new Collection(); + + /** + * A Collection of blocked users for the logged in user. + * This is only filled when using a user account. + * @type {Collection} + */ + this.blocked = new Collection(); + + /** + * A Collection of notes for the logged in user. + * This is only filled when using a user account. + * @type {Collection} + */ + this.notes = new Collection(); + + /** + * Discord client settings, such as guild positions + * This is only filled when using a user account. + * @type {Object} + */ + this.settings = {}; + + /** + * If the user has discord premium (nitro) + * This is only filled when using a user account. + * @type {?boolean} + */ + this.premium = typeof data.premium === 'boolean' ? data.premium : null; + + /** + * If the user has MFA enabled on their account + * This is only filled when using a user account. + * @type {?boolean} + */ + this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null; + + /** + * If the user has ever used a mobile device on discord + * This is only filled when using a user account. + * @type {?boolean} + */ + this.mobile = typeof data.mobile === 'boolean' ? data.mobile : null; + } + + edit(data) { + return this.client.rest.methods.updateCurrentUser(data); + } + + /** + * Set the username of the logged in Client. + * Changing usernames in Discord is heavily rate limited, with only 2 requests + * every hour. Use this sparingly! + * @param {string} username The new username + * @param {string} [password] Current password (only for user accounts) + * @returns {Promise} + * @example + * // set username + * client.user.setUsername('discordjs') + * .then(user => console.log(`My new username is ${user.username}`)) + * .catch(console.error); + */ + setUsername(username, password) { + return this.client.rest.methods.updateCurrentUser({ username }, password); + } + + /** + * Changes the email for the client user's account. + * This is only available when using a user account. + * @param {string} email New email to change to + * @param {string} password Current password + * @returns {Promise} + * @example + * // set email + * client.user.setEmail('bob@gmail.com', 'some amazing password 123') + * .then(user => console.log(`My new email is ${user.email}`)) + * .catch(console.error); + */ + setEmail(email, password) { + return this.client.rest.methods.updateCurrentUser({ email }, password); + } + + /** + * Changes the password for the client user's account. + * This is only available when using a user account. + * @param {string} newPassword New password to change to + * @param {string} oldPassword Current password + * @returns {Promise} + * @example + * // set password + * client.user.setPassword('some new amazing password 456', 'some amazing password 123') + * .then(user => console.log('New password set!')) + * .catch(console.error); + */ + setPassword(newPassword, oldPassword) { + return this.client.rest.methods.updateCurrentUser({ password: newPassword }, oldPassword); + } + + /** + * Set the avatar of the logged in Client. + * @param {BufferResolvable|Base64Resolvable} avatar The new avatar + * @returns {Promise} + * @example + * // set avatar + * client.user.setAvatar('./avatar.png') + * .then(user => console.log(`New avatar set!`)) + * .catch(console.error); + */ + setAvatar(avatar) { + if (typeof avatar === 'string' && avatar.startsWith('data:')) { + return this.client.rest.methods.updateCurrentUser({ avatar }); + } else { + return this.client.resolver.resolveBuffer(avatar).then(data => + this.client.rest.methods.updateCurrentUser({ avatar: data }) + ); + } + } + + /** + * Data resembling a raw Discord presence + * @typedef {Object} PresenceData + * @property {PresenceStatus} [status] Status of the user + * @property {boolean} [afk] Whether the user is AFK + * @property {Object} [game] Game the user is playing + * @property {string} [game.name] Name of the game + * @property {string} [game.url] Twitch stream URL + */ + + /** + * Sets the full presence of the client user. + * @param {PresenceData} data Data for the presence + * @returns {Promise} + */ + setPresence(data) { + // {"op":3,"d":{"status":"dnd","since":0,"game":null,"afk":false}} + return new Promise(resolve => { + let status = this.localPresence.status || this.presence.status; + let game = this.localPresence.game; + let afk = this.localPresence.afk || this.presence.afk; + + if (!game && this.presence.game) { + game = { + name: this.presence.game.name, + type: this.presence.game.type, + url: this.presence.game.url, + }; + } + + if (data.status) { + if (typeof data.status !== 'string') throw new TypeError('Status must be a string'); + status = data.status; + } + + if (data.game) { + game = data.game; + if (game.url) game.type = 1; + } + + if (data.game === null) game = null; + + if (typeof data.afk !== 'undefined') afk = data.afk; + afk = Boolean(afk); + + this.localPresence = { status, game, afk }; + this.localPresence.since = 0; + this.localPresence.game = this.localPresence.game || null; + + this.client.ws.send({ + op: 3, + d: this.localPresence, + }); + + this.client._setPresence(this.id, this.localPresence); + + resolve(this); + }); + } + + /** + * A user's status. Must be one of: + * - `online` + * - `idle` + * - `invisible` + * - `dnd` (do not disturb) + * @typedef {string} PresenceStatus + */ + + /** + * Sets the status of the client user. + * @param {PresenceStatus} status Status to change to + * @returns {Promise} + */ + setStatus(status) { + return this.setPresence({ status }); + } + + /** + * Sets the game the client user is playing. + * @param {?string} game Game being played + * @param {string} [streamingURL] Twitch stream URL + * @returns {Promise} + */ + setGame(game, streamingURL) { + if (game === null) return this.setPresence({ game }); + return this.setPresence({ game: { + name: game, + url: streamingURL, + } }); + } + + /** + * Sets/removes the AFK flag for the client user. + * @param {boolean} afk Whether or not the user is AFK + * @returns {Promise} + */ + setAFK(afk) { + return this.setPresence({ afk }); + } + + /** + * Fetches messages that mentioned the client's user + * @param {Object} [options] Options for the fetch + * @param {number} [options.limit=25] Maximum number of mentions to retrieve + * @param {boolean} [options.roles=true] Whether to include role mentions + * @param {boolean} [options.everyone=true] Whether to include everyone/here mentions + * @param {Guild|Snowflake} [options.guild] Limit the search to a specific guild + * @returns {Promise} + */ + fetchMentions(options = { limit: 25, roles: true, everyone: true, guild: null }) { + return this.client.rest.methods.fetchMentions(options); + } + + /** + * Send a friend request + * This is only available when using a user account. + * @param {UserResolvable} user The user to send the friend request to. + * @returns {Promise} The user the friend request was sent to. + */ + addFriend(user) { + user = this.client.resolver.resolveUser(user); + return this.client.rest.methods.addFriend(user); + } + + /** + * Remove a friend + * This is only available when using a user account. + * @param {UserResolvable} user The user to remove from your friends + * @returns {Promise} The user that was removed + */ + removeFriend(user) { + user = this.client.resolver.resolveUser(user); + return this.client.rest.methods.removeFriend(user); + } + + /** + * Creates a guild + * This is only available when using a user account. + * @param {string} name The name of the guild + * @param {string} region The region for the server + * @param {BufferResolvable|Base64Resolvable} [icon=null] The icon for the guild + * @returns {Promise} The guild that was created + */ + createGuild(name, region, icon = null) { + if (!icon) return this.client.rest.methods.createGuild({ name, icon, region }); + if (typeof icon === 'string' && icon.startsWith('data:')) { + return this.client.rest.methods.createGuild({ name, icon, region }); + } else { + return this.client.resolver.resolveBuffer(icon).then(data => + this.client.rest.methods.createGuild({ name, icon: data, region }) + ); + } + } + + /** + * An object containing either a user or access token, and an optional nickname + * @typedef {Object} GroupDMRecipientOptions + * @property {UserResolvable|Snowflake} [user] User to add to the group DM + * (only available if a user is creating the DM) + * @property {string} [accessToken] Access token to use to add a user to the group DM + * (only available if a bot is creating the DM) + * @property {string} [nick] Permanent nickname (only available if a bot is creating the DM) + */ + + /** + * Creates a group DM + * @param {GroupDMRecipientOptions[]} recipients The recipients + * @returns {Promise} + */ + createGroupDM(recipients) { + return this.client.rest.methods.createGroupDM({ + recipients: recipients.map(u => this.client.resolver.resolveUserID(u.user)), + accessTokens: recipients.map(u => u.accessToken), + nicks: recipients.map(u => u.nick), + }); + } + + /** + * Accepts an invite to join a guild + * This is only available when using a user account. + * @param {Invite|string} invite Invite or code to accept + * @returns {Promise} Joined guild + */ + acceptInvite(invite) { + return this.client.rest.methods.acceptInvite(invite); + } +} + +module.exports = ClientUser; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +const Channel = __webpack_require__(8); +const TextBasedChannel = __webpack_require__(14); +const Collection = __webpack_require__(3); + +/** + * Represents a direct message channel between two users. + * @extends {Channel} + * @implements {TextBasedChannel} + */ +class DMChannel extends Channel { + constructor(client, data) { + super(client, data); + this.type = 'dm'; + this.messages = new Collection(); + this._typing = new Map(); + } + + setup(data) { + super.setup(data); + + /** + * The recipient on the other end of the DM + * @type {User} + */ + this.recipient = this.client.dataManager.newUser(data.recipients[0]); + + this.lastMessageID = data.last_message_id; + } + + /** + * When concatenated with a string, this automatically concatenates the recipient's mention instead of the + * DM channel object. + * @returns {string} + */ + toString() { + return this.recipient.toString(); + } + + // These are here only for documentation purposes - they are implemented by TextBasedChannel + /* eslint-disable no-empty-function */ + send() {} + sendMessage() {} + sendEmbed() {} + sendFile() {} + sendFiles() {} + sendCode() {} + fetchMessage() {} + fetchMessages() {} + fetchPinnedMessages() {} + search() {} + startTyping() {} + stopTyping() {} + get typing() {} + get typingCount() {} + createCollector() {} + awaitMessages() {} + // Doesn't work on DM channels; bulkDelete() {} + acknowledge() {} + _cacheMessage() {} +} + +TextBasedChannel.applyToClass(DMChannel, true, ['bulkDelete']); + +module.exports = DMChannel; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +const PartialGuild = __webpack_require__(38); +const PartialGuildChannel = __webpack_require__(39); +const Constants = __webpack_require__(0); + +/* +{ max_age: 86400, + code: 'CG9A5', + guild: + { splash: null, + id: '123123123', + icon: '123123123', + name: 'name' }, + created_at: '2016-08-28T19:07:04.763368+00:00', + temporary: false, + uses: 0, + max_uses: 0, + inviter: + { username: '123', + discriminator: '4204', + bot: true, + id: '123123123', + avatar: '123123123' }, + channel: { type: 0, id: '123123', name: 'heavy-testing' } } +*/ + +/** + * Represents an invitation to a guild channel. + * The only guaranteed properties are `code`, `guild` and `channel`. Other properties can be missing. + */ +class Invite { + constructor(client, data) { + /** + * The client that instantiated the invite + * @name Invite#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: client }); + + this.setup(data); + } + + setup(data) { + /** + * The guild the invite is for. If this guild is already known, this will be a Guild object. If the guild is + * unknown, this will be a PartialGuild object. + * @type {Guild|PartialGuild} + */ + this.guild = this.client.guilds.get(data.guild.id) || new PartialGuild(this.client, data.guild); + + /** + * The code for this invite + * @type {string} + */ + this.code = data.code; + + /** + * Whether or not this invite is temporary + * @type {boolean} + */ + this.temporary = data.temporary; + + /** + * The maximum age of the invite, in seconds + * @type {?number} + */ + this.maxAge = data.max_age; + + /** + * How many times this invite has been used + * @type {number} + */ + this.uses = data.uses; + + /** + * The maximum uses of this invite + * @type {number} + */ + this.maxUses = data.max_uses; + + if (data.inviter) { + /** + * The user who created this invite + * @type {User} + */ + this.inviter = this.client.dataManager.newUser(data.inviter); + } + + /** + * The channel the invite is for. If this channel is already known, this will be a GuildChannel object. + * If the channel is unknown, this will be a PartialGuildChannel object. + * @type {GuildChannel|PartialGuildChannel} + */ + this.channel = this.client.channels.get(data.channel.id) || new PartialGuildChannel(this.client, data.channel); + + /** + * The timestamp the invite was created at + * @type {number} + */ + this.createdTimestamp = new Date(data.created_at).getTime(); + } + + /** + * The time the invite was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * The timestamp the invite will expire at + * @type {number} + * @readonly + */ + get expiresTimestamp() { + return this.createdTimestamp + (this.maxAge * 1000); + } + + /** + * The time the invite will expire + * @type {Date} + * @readonly + */ + get expiresAt() { + return new Date(this.expiresTimestamp); + } + + /** + * The URL to the invite + * @type {string} + * @readonly + */ + get url() { + return Constants.Endpoints.inviteLink(this.code); + } + + /** + * Deletes this invite + * @returns {Promise} + */ + delete() { + return this.client.rest.methods.deleteInvite(this); + } + + /** + * When concatenated with a string, this automatically concatenates the invite's URL instead of the object. + * @returns {string} + * @example + * // logs: Invite: https://discord.gg/A1b2C3 + * console.log(`Invite: ${invite}`); + */ + toString() { + return this.url; + } +} + +module.exports = Invite; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +/** + * Represents an attachment in a message + */ +class MessageAttachment { + constructor(message, data) { + /** + * The Client that instantiated this MessageAttachment. + * @name MessageAttachment#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: message.client }); + + /** + * The message this attachment is part of. + * @type {Message} + */ + this.message = message; + + this.setup(data); + } + + setup(data) { + /** + * The ID of this attachment + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The file name of this attachment + * @type {string} + */ + this.filename = data.filename; + + /** + * The size of this attachment in bytes + * @type {number} + */ + this.filesize = data.size; + + /** + * The URL to this attachment + * @type {string} + */ + this.url = data.url; + + /** + * The Proxy URL to this attachment + * @type {string} + */ + this.proxyURL = data.proxy_url; + + /** + * The height of this attachment (if an image) + * @type {?number} + */ + this.height = data.height; + + /** + * The width of this attachment (if an image) + * @type {?number} + */ + this.width = data.width; + } +} + +module.exports = MessageAttachment; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +const EventEmitter = __webpack_require__(23).EventEmitter; +const Collection = __webpack_require__(3); + +/** + * Collects messages based on a specified filter, then emits them. + * @extends {EventEmitter} + */ +class MessageCollector extends EventEmitter { + /** + * A function that takes a Message object and a MessageCollector and returns a boolean. + * ```js + * function(message, collector) { + * if (message.content.includes('discord')) { + * return true; // passed the filter test + * } + * return false; // failed the filter test + * } + * ``` + * @typedef {Function} CollectorFilterFunction + */ + + /** + * An object containing options used to configure a MessageCollector. All properties are optional. + * @typedef {Object} CollectorOptions + * @property {number} [time] Duration for the collector in milliseconds + * @property {number} [max] Maximum number of messages to handle + * @property {number} [maxMatches] Maximum number of successfully filtered messages to obtain + */ + + /** + * @param {Channel} channel The channel to collect messages in + * @param {CollectorFilterFunction} filter The filter function + * @param {CollectorOptions} [options] Options for the collector + */ + constructor(channel, filter, options = {}) { + super(); + + /** + * The channel this collector is operating on + * @type {Channel} + */ + this.channel = channel; + + /** + * A function used to filter messages that the collector collects. + * @type {CollectorFilterFunction} + */ + this.filter = filter; + + /** + * Options for the collecor. + * @type {CollectorOptions} + */ + this.options = options; + + /** + * Whether this collector has stopped collecting messages. + * @type {boolean} + */ + this.ended = false; + + /** + * A collection of collected messages, mapped by message ID. + * @type {Collection} + */ + this.collected = new Collection(); + + this.listener = message => this.verify(message); + this.channel.client.on('message', this.listener); + if (options.time) this.channel.client.setTimeout(() => this.stop('time'), options.time); + } + + /** + * Verifies a message against the filter and options + * @private + * @param {Message} message The message + * @returns {boolean} + */ + verify(message) { + if (this.channel ? this.channel.id !== message.channel.id : false) return false; + if (this.filter(message, this)) { + this.collected.set(message.id, message); + /** + * Emitted whenever the collector receives a message that passes the filter test. + * @param {Message} message The received message + * @param {MessageCollector} collector The collector the message passed through + * @event MessageCollector#message + */ + this.emit('message', message, this); + if (this.collected.size >= this.options.maxMatches) this.stop('matchesLimit'); + else if (this.options.max && this.collected.size === this.options.max) this.stop('limit'); + return true; + } + return false; + } + + /** + * Returns a promise that resolves when a valid message is sent. Rejects + * with collected messages if the Collector ends before receiving a message. + * @type {Promise} + * @readonly + */ + get next() { + return new Promise((resolve, reject) => { + if (this.ended) { + reject(this.collected); + return; + } + + const cleanup = () => { + this.removeListener('message', onMessage); + this.removeListener('end', onEnd); + }; + + const onMessage = (...args) => { + cleanup(); + resolve(...args); + }; + + const onEnd = (...args) => { + cleanup(); + reject(...args); // eslint-disable-line prefer-promise-reject-errors + }; + + this.once('message', onMessage); + this.once('end', onEnd); + }); + } + + /** + * Stops the collector and emits `end`. + * @param {string} [reason='user'] An optional reason for stopping the collector + */ + stop(reason = 'user') { + if (this.ended) return; + this.ended = true; + this.channel.client.removeListener('message', this.listener); + /** + * Emitted when the Collector stops collecting. + * @param {Collection} collection A collection of messages collected + * during the lifetime of the collector, mapped by the ID of the messages. + * @param {string} reason The reason for the end of the collector. If it ended because it reached the specified time + * limit, this would be `time`. If you invoke `.stop()` without specifying a reason, this would be `user`. If it + * ended because it reached its message limit, it will be `limit`. + * @event MessageCollector#end + */ + this.emit('end', this.collected, reason); + } +} + +module.exports = MessageCollector; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/** + * Represents an embed in a message (image/video preview, rich embed, etc.) + * This class is only used for *recieved* embeds. If you wish to send one, use the {@link RichEmbed} class. + */ +class MessageEmbed { + constructor(message, data) { + /** + * The client that instantiated this embed + * @name MessageEmbed#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: message.client }); + + /** + * The message this embed is part of + * @type {Message} + */ + this.message = message; + + this.setup(data); + } + + setup(data) { + /** + * The type of this embed + * @type {string} + */ + this.type = data.type; + + /** + * The title of this embed, if there is one + * @type {?string} + */ + this.title = data.title; + + /** + * The description of this embed, if there is one + * @type {?string} + */ + this.description = data.description; + + /** + * The URL of this embed + * @type {string} + */ + this.url = data.url; + + /** + * The color of the embed + * @type {number} + */ + this.color = data.color; + + /** + * The fields of this embed + * @type {MessageEmbedField[]} + */ + this.fields = []; + if (data.fields) for (const field of data.fields) this.fields.push(new MessageEmbedField(this, field)); + + /** + * The timestamp of this embed + * @type {number} + */ + this.createdTimestamp = data.timestamp; + + /** + * The thumbnail of this embed, if there is one + * @type {?MessageEmbedThumbnail} + */ + this.thumbnail = data.thumbnail ? new MessageEmbedThumbnail(this, data.thumbnail) : null; + + /** + * The image of this embed, if there is one + * @type {?MessageEmbedImage} + */ + this.image = data.image ? new MessageEmbedImage(this, data.image) : null; + + /** + * The video of this embed, if there is one + * @type {?MessageEmbedVideo} + */ + this.video = data.video ? new MessageEmbedVideo(this, data.video) : null; + + /** + * The author of this embed, if there is one + * @type {?MessageEmbedAuthor} + */ + this.author = data.author ? new MessageEmbedAuthor(this, data.author) : null; + + /** + * The provider of this embed, if there is one + * @type {?MessageEmbedProvider} + */ + this.provider = data.provider ? new MessageEmbedProvider(this, data.provider) : null; + + /** + * The footer of this embed + * @type {?MessageEmbedFooter} + */ + this.footer = data.footer ? new MessageEmbedFooter(this, data.footer) : null; + } + + /** + * The date this embed was created + * @type {Date} + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * The hexadecimal version of the embed color, with a leading hash. + * @type {string} + * @readonly + */ + get hexColor() { + let col = this.color.toString(16); + while (col.length < 6) col = `0${col}`; + return `#${col}`; + } +} + +/** + * Represents a thumbnail for a message embed + */ +class MessageEmbedThumbnail { + constructor(embed, data) { + /** + * The embed this thumbnail is part of + * @type {MessageEmbed} + */ + this.embed = embed; + + this.setup(data); + } + + setup(data) { + /** + * The URL for this thumbnail + * @type {string} + */ + this.url = data.url; + + /** + * The Proxy URL for this thumbnail + * @type {string} + */ + this.proxyURL = data.proxy_url; + + /** + * The height of the thumbnail + * @type {number} + */ + this.height = data.height; + + /** + * The width of the thumbnail + * @type {number} + */ + this.width = data.width; + } +} + +/** + * Represents an image for a message embed + */ +class MessageEmbedImage { + constructor(embed, data) { + /** + * The embed this image is part of + * @type {MessageEmbed} + */ + this.embed = embed; + + this.setup(data); + } + + setup(data) { + /** + * The URL for this image + * @type {string} + */ + this.url = data.url; + + /** + * The Proxy URL for this image + * @type {string} + */ + this.proxyURL = data.proxy_url; + + /** + * The height of the image + * @type {number} + */ + this.height = data.height; + + /** + * The width of the image + * @type {number} + */ + this.width = data.width; + } +} + +/** + * Represents a video for a message embed + */ +class MessageEmbedVideo { + constructor(embed, data) { + /** + * The embed this video is part of + * @type {MessageEmbed} + */ + this.embed = embed; + + this.setup(data); + } + + setup(data) { + /** + * The source URL for this video + * @type {string} + */ + this.url = data.url; + + /** + * The height of the video + * @type {number} + */ + this.height = data.height; + + /** + * The width of the video + * @type {number} + */ + this.width = data.width; + } +} + +/** + * Represents a provider for a message embed + */ +class MessageEmbedProvider { + constructor(embed, data) { + /** + * The embed this provider is part of + * @type {MessageEmbed} + */ + this.embed = embed; + + this.setup(data); + } + + setup(data) { + /** + * The name of this provider + * @type {string} + */ + this.name = data.name; + + /** + * The URL of this provider + * @type {string} + */ + this.url = data.url; + } +} + +/** + * Represents an author for a message embed + */ +class MessageEmbedAuthor { + constructor(embed, data) { + /** + * The embed this author is part of + * @type {MessageEmbed} + */ + this.embed = embed; + + this.setup(data); + } + + setup(data) { + /** + * The name of this author + * @type {string} + */ + this.name = data.name; + + /** + * The URL of this author + * @type {string} + */ + this.url = data.url; + + /** + * The icon URL of this author + * @type {string} + */ + this.iconURL = data.icon_url; + } +} + +/** + * Represents a field for a message embed + */ +class MessageEmbedField { + constructor(embed, data) { + /** + * The embed this footer is part of + * @type {MessageEmbed} + */ + this.embed = embed; + + this.setup(data); + } + + setup(data) { + /** + * The name of this field + * @type {string} + */ + this.name = data.name; + + /** + * The value of this field + * @type {string} + */ + this.value = data.value; + + /** + * If this field is displayed inline + * @type {boolean} + */ + this.inline = data.inline; + } +} + +/** + * Represents the footer of a message embed + */ +class MessageEmbedFooter { + constructor(embed, data) { + /** + * The embed this footer is part of + * @type {MessageEmbed} + */ + this.embed = embed; + + this.setup(data); + } + + setup(data) { + /** + * The text in this footer + * @type {string} + */ + this.text = data.text; + + /** + * The icon URL of this footer + * @type {string} + */ + this.iconURL = data.icon_url; + + /** + * The proxy icon URL of this footer + * @type {string} + */ + this.proxyIconUrl = data.proxy_icon_url; + } +} + +MessageEmbed.Thumbnail = MessageEmbedThumbnail; +MessageEmbed.Image = MessageEmbedImage; +MessageEmbed.Video = MessageEmbedVideo; +MessageEmbed.Provider = MessageEmbedProvider; +MessageEmbed.Author = MessageEmbedAuthor; +MessageEmbed.Field = MessageEmbedField; +MessageEmbed.Footer = MessageEmbedFooter; + +module.exports = MessageEmbed; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +const Collection = __webpack_require__(3); +const Emoji = __webpack_require__(12); +const ReactionEmoji = __webpack_require__(20); + +/** + * Represents a reaction to a message + */ +class MessageReaction { + constructor(message, emoji, count, me) { + /** + * The message that this reaction refers to + * @type {Message} + */ + this.message = message; + + /** + * Whether the client has given this reaction + * @type {boolean} + */ + this.me = me; + + /** + * The number of people that have given the same reaction. + * @type {number} + */ + this.count = count || 0; + + /** + * The users that have given this reaction, mapped by their ID. + * @type {Collection} + */ + this.users = new Collection(); + + this._emoji = new ReactionEmoji(this, emoji.name, emoji.id); + } + + /** + * The emoji of this reaction, either an Emoji object for known custom emojis, or a ReactionEmoji + * object which has fewer properties. Whatever the prototype of the emoji, it will still have + * `name`, `id`, `identifier` and `toString()` + * @type {Emoji|ReactionEmoji} + */ + get emoji() { + if (this._emoji instanceof Emoji) return this._emoji; + // Check to see if the emoji has become known to the client + if (this._emoji.id) { + const emojis = this.message.client.emojis; + if (emojis.has(this._emoji.id)) { + const emoji = emojis.get(this._emoji.id); + this._emoji = emoji; + return emoji; + } + } + return this._emoji; + } + + /** + * Removes a user from this reaction. + * @param {UserResolvable} [user=this.message.client.user] User to remove the reaction of + * @returns {Promise} + */ + remove(user = this.message.client.user) { + const message = this.message; + user = this.message.client.resolver.resolveUserID(user); + if (!user) return Promise.reject(new Error('Couldn\'t resolve the user ID to remove from the reaction.')); + return message.client.rest.methods.removeMessageReaction( + message, this.emoji.identifier, user + ); + } + + /** + * Fetch all the users that gave this reaction. Resolves with a collection of users, mapped by their IDs. + * @param {number} [limit=100] the maximum amount of users to fetch, defaults to 100 + * @returns {Promise>} + */ + fetchUsers(limit = 100) { + const message = this.message; + return message.client.rest.methods.getMessageReactionUsers( + message, this.emoji.identifier, limit + ).then(users => { + this.users = new Collection(); + for (const rawUser of users) { + const user = this.message.client.dataManager.newUser(rawUser); + this.users.set(user.id, user); + } + this.count = this.users.size; + return this.users; + }); + } +} + +module.exports = MessageReaction; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +const Snowflake = __webpack_require__(5); + +/** + * Represents an OAuth2 Application + */ +class OAuth2Application { + constructor(client, data) { + /** + * The client that instantiated the application + * @name OAuth2Application#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: client }); + + this.setup(data); + } + + setup(data) { + /** + * The ID of the app + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The name of the app + * @type {string} + */ + this.name = data.name; + + /** + * The app's description + * @type {string} + */ + this.description = data.description; + + /** + * The app's icon hash + * @type {string} + */ + this.icon = data.icon; + + /** + * The app's icon URL + * @type {string} + */ + this.iconURL = `https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`; + + /** + * The app's RPC origins + * @type {?string[]} + */ + this.rpcOrigins = data.rpc_origins; + + /** + * The app's redirect URIs + * @type {string[]} + */ + this.redirectURIs = data.redirect_uris; + + /** + * If this app's bot requires a code grant when using the oauth2 flow + * @type {boolean} + */ + this.botRequireCodeGrant = data.bot_require_code_grant; + + /** + * If this app's bot is public + * @type {boolean} + */ + this.botPublic = data.bot_public; + + /** + * If this app can use rpc + * @type {boolean} + */ + this.rpcApplicationState = data.rpc_application_state; + + /** + * Object containing basic info about this app's bot + * @type {Object} + */ + this.bot = data.bot; + + /** + * Flags for the app + * @type {number} + */ + this.flags = data.flags; + + /** + * OAuth2 secret for the application + * @type {boolean} + */ + this.secret = data.secret; + } + + /** + * The timestamp the app was created at + * @type {number} + * @readonly + */ + get createdTimestamp() { + return Snowflake.deconstruct(this.id).timestamp; + } + + /** + * The time the app was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * Reset the app's secret and bot token + * @returns {OAuth2Application} + */ + reset() { + return this.client.rest.methods.resetApplication(this.id); + } + + /** + * When concatenated with a string, this automatically concatenates the app name rather than the app object. + * @returns {string} + */ + toString() { + return this.name; + } +} + +module.exports = OAuth2Application; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports) { + +/* +{ splash: null, + id: '123123123', + icon: '123123123', + name: 'name' } +*/ + +/** + * Represents a guild that the client only has limited information for - e.g. from invites. + */ +class PartialGuild { + constructor(client, data) { + /** + * The Client that instantiated this PartialGuild + * @name PartialGuild#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: client }); + + this.setup(data); + } + + setup(data) { + /** + * The ID of this guild + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The name of this guild + * @type {string} + */ + this.name = data.name; + + /** + * The hash of this guild's icon, or null if there is none. + * @type {?string} + */ + this.icon = data.icon; + + /** + * The hash of the guild splash image, or null if no splash (VIP only) + * @type {?string} + */ + this.splash = data.splash; + } +} + +module.exports = PartialGuild; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +const Constants = __webpack_require__(0); + +/* +{ type: 0, id: '123123', name: 'heavy-testing' } } +*/ + +/** + * Represents a guild channel that the client only has limited information for - e.g. from invites. + */ +class PartialGuildChannel { + constructor(client, data) { + /** + * The Client that instantiated this PartialGuildChannel + * @name PartialGuildChannel#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: client }); + + this.setup(data); + } + + setup(data) { + /** + * The ID of this guild channel + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The name of this guild channel + * @type {string} + */ + this.name = data.name; + + /** + * The type of this guild channel - `text` or `voice` + * @type {string} + */ + this.type = Constants.ChannelTypes.TEXT === data.type ? 'text' : 'voice'; + } +} + +module.exports = PartialGuildChannel; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + +/** + * Represents a permission overwrite for a role or member in a guild channel. + */ +class PermissionOverwrites { + constructor(guildChannel, data) { + /** + * The GuildChannel this overwrite is for + * @name PermissionOverwrites#channel + * @type {GuildChannel} + * @readonly + */ + Object.defineProperty(this, 'channel', { value: guildChannel }); + + if (data) this.setup(data); + } + + setup(data) { + /** + * The ID of this overwrite, either a user ID or a role ID + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The type of this overwrite + * @type {string} + */ + this.type = data.type; + + this.deny = data.deny; + this.allow = data.allow; + } + + /** + * Delete this Permission Overwrite. + * @returns {Promise} + */ + delete() { + return this.channel.client.rest.methods.deletePermissionOverwrites(this); + } +} + +module.exports = PermissionOverwrites; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +const GuildChannel = __webpack_require__(17); +const TextBasedChannel = __webpack_require__(14); +const Collection = __webpack_require__(3); + +/** + * Represents a guild text channel on Discord. + * @extends {GuildChannel} + * @implements {TextBasedChannel} + */ +class TextChannel extends GuildChannel { + constructor(guild, data) { + super(guild, data); + this.type = 'text'; + this.messages = new Collection(); + this._typing = new Map(); + } + + setup(data) { + super.setup(data); + + /** + * The topic of the text channel, if there is one. + * @type {?string} + */ + this.topic = data.topic; + + this.lastMessageID = data.last_message_id; + } + + /** + * A collection of members that can see this channel, mapped by their ID. + * @type {Collection} + * @readonly + */ + get members() { + const members = new Collection(); + for (const member of this.guild.members.values()) { + if (this.permissionsFor(member).hasPermission('READ_MESSAGES')) { + members.set(member.id, member); + } + } + return members; + } + + /** + * Fetch all webhooks for the channel. + * @returns {Promise>} + */ + fetchWebhooks() { + return this.client.rest.methods.getChannelWebhooks(this); + } + + /** + * Create a webhook for the channel. + * @param {string} name The name of the webhook. + * @param {BufferResolvable|Base64Resolvable} avatar The avatar for the webhook. + * @returns {Promise} webhook The created webhook. + * @example + * channel.createWebhook('Snek', 'http://snek.s3.amazonaws.com/topSnek.png') + * .then(webhook => console.log(`Created Webhook ${webhook}`)) + * .catch(console.error) + */ + createWebhook(name, avatar) { + return new Promise(resolve => { + if (typeof avatar === 'string' && avatar.startsWith('data:')) { + resolve(this.client.rest.methods.createWebhook(this, name, avatar)); + } else { + this.client.resolver.resolveBuffer(avatar).then(data => + resolve(this.client.rest.methods.createWebhook(this, name, data)) + ); + } + }); + } + + // These are here only for documentation purposes - they are implemented by TextBasedChannel + /* eslint-disable no-empty-function */ + send() {} + sendMessage() {} + sendEmbed() {} + sendFile() {} + sendFiles() {} + sendCode() {} + fetchMessage() {} + fetchMessages() {} + fetchPinnedMessages() {} + search() {} + startTyping() {} + stopTyping() {} + get typing() {} + get typingCount() {} + createCollector() {} + awaitMessages() {} + bulkDelete() {} + acknowledge() {} + _cacheMessage() {} +} + +TextBasedChannel.applyToClass(TextChannel, true); + +module.exports = TextChannel; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +const GuildChannel = __webpack_require__(17); +const Collection = __webpack_require__(3); + +/** + * Represents a guild voice channel on Discord. + * @extends {GuildChannel} + */ +class VoiceChannel extends GuildChannel { + constructor(guild, data) { + super(guild, data); + + /** + * The members in this voice channel. + * @type {Collection} + */ + this.members = new Collection(); + + this.type = 'voice'; + } + + setup(data) { + super.setup(data); + + /** + * The bitrate of this voice channel + * @type {number} + */ + this.bitrate = data.bitrate; + + /** + * The maximum amount of users allowed in this channel - 0 means unlimited. + * @type {number} + */ + this.userLimit = data.user_limit; + } + + /** + * The voice connection for this voice channel, if the client is connected + * @type {?VoiceConnection} + * @readonly + */ + get connection() { + const connection = this.guild.voiceConnection; + if (connection && connection.channel.id === this.id) return connection; + return null; + } + + /** + * Checks if the voice channel is full + * @type {boolean} + */ + get full() { + return this.userLimit > 0 && this.members.size >= this.userLimit; + } + + /** + * Checks if the client has permission join the voice channel + * @type {boolean} + */ + get joinable() { + if (this.client.browser) return false; + if (!this.permissionsFor(this.client.user).hasPermission('CONNECT')) return false; + if (this.full && !this.permissionsFor(this.client.user).hasPermission('MOVE_MEMBERS')) return false; + return true; + } + + /** + * Checks if the client has permission to send audio to the voice channel + * @type {boolean} + */ + get speakable() { + return this.permissionsFor(this.client.user).hasPermission('SPEAK'); + } + + /** + * Sets the bitrate of the channel + * @param {number} bitrate The new bitrate + * @returns {Promise} + * @example + * // set the bitrate of a voice channel + * voiceChannel.setBitrate(48000) + * .then(vc => console.log(`Set bitrate to ${vc.bitrate} for ${vc.name}`)) + * .catch(console.error); + */ + setBitrate(bitrate) { + return this.edit({ bitrate }); + } + + /** + * Sets the user limit of the channel + * @param {number} userLimit The new user limit + * @returns {Promise} + * @example + * // set the user limit of a voice channel + * voiceChannel.setUserLimit(42) + * .then(vc => console.log(`Set user limit to ${vc.userLimit} for ${vc.name}`)) + * .catch(console.error); + */ + setUserLimit(userLimit) { + return this.edit({ userLimit }); + } + + /** + * Attempts to join this voice channel + * @returns {Promise} + * @example + * // join a voice channel + * voiceChannel.join() + * .then(connection => console.log('Connected!')) + * .catch(console.error); + */ + join() { + if (this.client.browser) return Promise.reject(new Error('Voice connections are not available in browsers.')); + return this.client.voice.joinChannel(this); + } + + /** + * Leaves this voice channel + * @example + * // leave a voice channel + * voiceChannel.leave(); + */ + leave() { + if (this.client.browser) return; + const connection = this.client.voice.connections.get(this.guild.id); + if (connection && connection.channel.id === this.id) connection.disconnect(); + } +} + +module.exports = VoiceChannel; + + /***/ }), /* 43 */ /***/ (function(module, exports) { @@ -12902,7 +12983,7 @@ const Util = __webpack_require__(4); const RESTManager = __webpack_require__(44); const ClientDataManager = __webpack_require__(65); const ClientManager = __webpack_require__(66); -const ClientDataResolver = __webpack_require__(27); +const ClientDataResolver = __webpack_require__(28); const ClientVoiceManager = __webpack_require__(140); const WebSocketManager = __webpack_require__(100); const ActionsManager = __webpack_require__(67); @@ -13448,7 +13529,7 @@ module.exports = Client; const Webhook = __webpack_require__(21); const RESTManager = __webpack_require__(44); -const ClientDataResolver = __webpack_require__(27); +const ClientDataResolver = __webpack_require__(28); const Constants = __webpack_require__(0); const Util = __webpack_require__(4); @@ -13570,7 +13651,7 @@ module.exports = WebhookClient; /* 48 */ /***/ (function(module, exports, __webpack_require__) { -const ClientDataResolver = __webpack_require__(27); +const ClientDataResolver = __webpack_require__(28); /** * A rich embed to be sent with a message with a fluent interface for creation @@ -14408,7 +14489,7 @@ exports.encode = exports.stringify = __webpack_require__(57); * @return {Boolean} * @api private */ -var isObject = __webpack_require__(26); +var isObject = __webpack_require__(27); function isFunction(fn) { var tag = isObject(fn) ? Object.prototype.toString.call(fn) : ''; @@ -14425,7 +14506,7 @@ module.exports = isFunction; /** * Module of mixed-in functions shared between node and client code */ -var isObject = __webpack_require__(26); +var isObject = __webpack_require__(27); /** * Expose `RequestBase`. @@ -15281,10 +15362,10 @@ const Constants = __webpack_require__(0); const Util = __webpack_require__(4); const Guild = __webpack_require__(16); const User = __webpack_require__(11); -const DMChannel = __webpack_require__(30); +const DMChannel = __webpack_require__(31); const Emoji = __webpack_require__(12); -const TextChannel = __webpack_require__(40); -const VoiceChannel = __webpack_require__(41); +const TextChannel = __webpack_require__(41); +const VoiceChannel = __webpack_require__(42); const GuildChannel = __webpack_require__(17); const GroupDMChannel = __webpack_require__(19); @@ -15648,27 +15729,27 @@ module.exports = GuildBanRemove; /* 72 */ /***/ (function(module, exports, __webpack_require__) { -const Action = __webpack_require__(2); - -class GuildChannelsPositionUpdate extends Action { - handle(data) { - const client = this.client; - - const guild = client.guilds.get(data.guild_id); - if (guild) { - for (const partialChannel of data.channels) { - const channel = guild.roles.get(partialChannel.id); - if (channel) channel.position = partialChannel.position; - } - } - - return { - guild, - }; - } -} - -module.exports = GuildChannelsPositionUpdate; +const Action = __webpack_require__(2); + +class GuildChannelsPositionUpdate extends Action { + handle(data) { + const client = this.client; + + const guild = client.guilds.get(data.guild_id); + if (guild) { + for (const partialChannel of data.channels) { + const channel = guild.channels.get(partialChannel.id); + if (channel) channel.position = partialChannel.position; + } + } + + return { + guild, + }; + } +} + +module.exports = GuildChannelsPositionUpdate; /***/ }), @@ -16029,9 +16110,7 @@ class GuildRolesPositionUpdate extends Action { if (guild) { for (const partialRole of data.roles) { const role = guild.roles.get(partialRole.id); - if (role) { - role.position = partialRole.position; - } + if (role) role.position = partialRole.position; } } @@ -16556,7 +16635,7 @@ module.exports = UserUpdateAction; /* 95 */ /***/ (function(module, exports, __webpack_require__) { -const request = __webpack_require__(25); +const request = __webpack_require__(26); const Constants = __webpack_require__(0); class APIRequest { @@ -16614,7 +16693,7 @@ module.exports = APIRequest; /***/ (function(module, exports, __webpack_require__) { const querystring = __webpack_require__(58); -const long = __webpack_require__(42); +const long = __webpack_require__(24); const Permissions = __webpack_require__(6); const Constants = __webpack_require__(0); const Endpoints = Constants.Endpoints; @@ -16626,10 +16705,10 @@ const User = __webpack_require__(11); const GuildMember = __webpack_require__(13); const Message = __webpack_require__(9); const Role = __webpack_require__(10); -const Invite = __webpack_require__(31); +const Invite = __webpack_require__(32); const Webhook = __webpack_require__(21); const UserProfile = __webpack_require__(137); -const OAuth2Application = __webpack_require__(36); +const OAuth2Application = __webpack_require__(37); const Channel = __webpack_require__(8); const GroupDMChannel = __webpack_require__(19); const Guild = __webpack_require__(16); @@ -17420,6 +17499,15 @@ class RESTMethods { ); } + setChannelPositions(guildID, channels) { + return this.rest.makeRequest('patch', Endpoints.Guild(guildID).channels, true, channels).then(() => + this.client.actions.GuildChannelsPositionUpdate.handle({ + guild_id: guildID, + channels, + }).guild + ); + } + addMessageReaction(message, emoji) { return this.rest.makeRequest( 'put', Endpoints.Message(message).Reaction(emoji).User('@me'), true @@ -18874,7 +18962,7 @@ module.exports = PresenceUpdateHandler; const AbstractHandler = __webpack_require__(1); -const ClientUser = __webpack_require__(29); +const ClientUser = __webpack_require__(30); class ReadyHandler extends AbstractHandler { handle(packet) { @@ -19420,7 +19508,7 @@ module.exports = { SnowflakeUtil: __webpack_require__(5), Util: Util, util: Util, - version: __webpack_require__(28).version, + version: __webpack_require__(29).version, // Shortcuts to Util methods escapeMarkdown: Util.escapeMarkdown, @@ -19429,31 +19517,31 @@ module.exports = { // Structures Channel: __webpack_require__(8), - ClientUser: __webpack_require__(29), - DMChannel: __webpack_require__(30), + ClientUser: __webpack_require__(30), + DMChannel: __webpack_require__(31), Emoji: __webpack_require__(12), Game: __webpack_require__(7).Game, GroupDMChannel: __webpack_require__(19), Guild: __webpack_require__(16), GuildChannel: __webpack_require__(17), GuildMember: __webpack_require__(13), - Invite: __webpack_require__(31), + Invite: __webpack_require__(32), Message: __webpack_require__(9), - MessageAttachment: __webpack_require__(32), - MessageCollector: __webpack_require__(33), - MessageEmbed: __webpack_require__(34), - MessageReaction: __webpack_require__(35), - OAuth2Application: __webpack_require__(36), - PartialGuild: __webpack_require__(37), - PartialGuildChannel: __webpack_require__(38), - PermissionOverwrites: __webpack_require__(39), + MessageAttachment: __webpack_require__(33), + MessageCollector: __webpack_require__(34), + MessageEmbed: __webpack_require__(35), + MessageReaction: __webpack_require__(36), + OAuth2Application: __webpack_require__(37), + PartialGuild: __webpack_require__(38), + PartialGuildChannel: __webpack_require__(39), + PermissionOverwrites: __webpack_require__(40), Presence: __webpack_require__(7).Presence, ReactionEmoji: __webpack_require__(20), RichEmbed: __webpack_require__(48), Role: __webpack_require__(10), - TextChannel: __webpack_require__(40), + TextChannel: __webpack_require__(41), User: __webpack_require__(11), - VoiceChannel: __webpack_require__(41), + VoiceChannel: __webpack_require__(42), Webhook: __webpack_require__(21), }; diff --git a/discord.master.min.js b/discord.master.min.js index 8fe437e1..8fba954c 100644 --- a/discord.master.min.js +++ b/discord.master.min.js @@ -1,18 +1,18 @@ -!function(t){function e(i){if(n[i])return n[i].exports;var s=n[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=145)}([function(t,e,n){(function(t){e.Package=n(28),e.DefaultOptions={apiRequestMethod:"sequential",shardId:0,shardCount:0,messageCacheMaxSize:200,messageCacheLifetime:0,messageSweepInterval:0,fetchAllMembers:!1,disableEveryone:!1,sync:!1,restWsBridgeTimeout:5e3,disabledEvents:[],restTimeOffset:500,ws:{large_threshold:250,compress:"browser"!==n(15).platform(),properties:{$os:t?t.platform:"discord.js",$browser:"discord.js",$device:"discord.js",$referrer:"",$referring_domain:""},version:6},http:{version:6,host:"https://discordapp.com",cdn:"https://cdn.discordapp.com"}},e.Errors={NO_TOKEN:"Request to use token, but token was unavailable to the client.",NO_BOT_ACCOUNT:"Only bot accounts are able to make use of this feature.",NO_USER_ACCOUNT:"Only user accounts are able to make use of this feature.",BAD_WS_MESSAGE:"A bad message was received from the websocket; either bad compression, or not JSON.",TOOK_TOO_LONG:"Something took too long to do.",NOT_A_PERMISSION:"Invalid permission string or number.",INVALID_RATE_LIMIT_METHOD:"Unknown rate limiting method.",BAD_LOGIN:"Incorrect login details were provided.",INVALID_SHARD:"Invalid shard settings were provided.",SHARDING_REQUIRED:"This session would have handled too many guilds - Sharding is required.",INVALID_TOKEN:"An invalid token was provided."};const i=e.Endpoints={User:t=>{t.id&&(t=t.id);const e=`/users/${t}`;return{toString:()=>e,channels:`${e}/channels`,profile:`${e}/profile`,relationships:`${e}/relationships`,Relationship:t=>`${e}/relationships/${t}`,Guild:t=>`${e}/guilds/${t}`,Note:t=>`${e}/notes/${t}`,Mentions:(t,n,i,s)=>`${e}/mentions?limit=${t}&roles=${n}&everyone=${i}${s?`&guild_id=${s}`:""}`,Avatar:(e,n)=>{return"1"===t?n:i.CDN(e).Avatar(t,n)}}},guilds:"/guilds",Guild:t=>{t.id&&(t=t.id);const e=`/guilds/${t}`;return{toString:()=>e,prune:`${e}/prune`,embed:`${e}/embed`,bans:`${e}/bans`,integrations:`${e}/integrations`,members:`${e}/members`,channels:`${e}/channels`,invites:`${e}/invites`,roles:`${e}/roles`,emojis:`${e}/emojis`,search:`${e}/messages/search`,voiceRegions:`${e}/regions`,webhooks:`${e}/webhooks`,ack:`${e}/ack`,settings:`${e}/settings`,Emoji:t=>`${e}/emojis/${t}`,Icon:(e,n)=>i.CDN(e).Icon(t,n),Splash:(e,n)=>i.CDN(e).Splash(t,n),Role:t=>`${e}/roles/${t}`,Member:t=>{t.id&&(t=t.id);const n=`${e}/members/${t}`;return{toString:()=>n,Role:t=>`${n}/roles/${t}`,nickname:`${e}/members/@me/nick`}}}},channels:"/channels",Channel:t=>{t.id&&(t=t.id);const e=`/channels/${t}`;return{toString:()=>e,messages:{toString:()=>`${e}/messages`,bulkDelete:`${e}/messages/bulk-delete`},invites:`${e}/invites`,typing:`${e}/typing`,permissions:`${e}/permissions`,webhooks:`${e}/webhooks`,search:`${e}/search`,ack:`${e}/ack`,pins:`${e}/pins`,Pin:t=>`${e}/pins/${t}`,Recipient:t=>`${e}/recipients/${t}`,Message:t=>{t.id&&(t=t.id);const n=`${e}/messages/${t}`;return{toString:()=>n,reactions:`${n}/reactions`,ack:`${e}/ack`,Reaction:(t,e)=>{const i=`${n}/reactions/${t}${e?`?limit=${e}`:""}`;return{toString:()=>i,User:t=>`${i}/${t}`}}}}}},Message:t=>e.Endpoints.Channel(t.channel).Message(t),Member:t=>e.Endpoints.Guild(t.guild).Member(t),CDN(t){return{Emoji:e=>`${t}/emojis/$${e}.png`,Asset:e=>`${t}/assets/${e}`,Avatar:(e,n)=>`${t}/avatars/${e}/${n}.${n.startsWith("a_")?"gif":"png"}?size=2048`,Icon:(e,n)=>`${t}/icons/${e}/${n}.jpg`,Splash:(e,n)=>`${t}/splashes/${e}/${n}.jpg`}},OAUTH2:{Application:t=>{const e=`/oauth2/applications/${t}`;return{toString:()=>e,reset:`${e}/reset`}},App:t=>`/oauth2/authorize?client_id=${t}`},login:"/auth/login",logout:"/auth/logout",voiceRegions:"/voice/regions",gateway:{toString:()=>"/gateway",bot:"/gateway/bot"},Invite:t=>`/invite/${t}`,Webhook:(t,e)=>`/webhooks/${t}${e?`/${e}`:""}`};e.Status={READY:0,CONNECTING:1,RECONNECTING:2,IDLE:3,NEARLY:4,DISCONNECTED:5},e.VoiceStatus={CONNECTED:0,CONNECTING:1,AUTHENTICATING:2,RECONNECTING:3,DISCONNECTED:4},e.ChannelTypes={TEXT:0,DM:1,VOICE:2,GROUP_DM:3},e.OPCodes={DISPATCH:0,HEARTBEAT:1,IDENTIFY:2,STATUS_UPDATE:3,VOICE_STATE_UPDATE:4,VOICE_GUILD_PING:5,RESUME:6,RECONNECT:7,REQUEST_GUILD_MEMBERS:8,INVALID_SESSION:9,HELLO:10,HEARTBEAT_ACK:11},e.VoiceOPCodes={IDENTIFY:0,SELECT_PROTOCOL:1,READY:2,HEARTBEAT:3,SESSION_DESCRIPTION:4,SPEAKING:5},e.Events={READY:"ready",GUILD_CREATE:"guildCreate",GUILD_DELETE:"guildDelete",GUILD_UPDATE:"guildUpdate",GUILD_UNAVAILABLE:"guildUnavailable",GUILD_AVAILABLE:"guildAvailable",GUILD_MEMBER_ADD:"guildMemberAdd",GUILD_MEMBER_REMOVE:"guildMemberRemove",GUILD_MEMBER_UPDATE:"guildMemberUpdate",GUILD_MEMBER_AVAILABLE:"guildMemberAvailable",GUILD_MEMBER_SPEAKING:"guildMemberSpeaking",GUILD_MEMBERS_CHUNK:"guildMembersChunk",GUILD_ROLE_CREATE:"roleCreate",GUILD_ROLE_DELETE:"roleDelete",GUILD_ROLE_UPDATE:"roleUpdate",GUILD_EMOJI_CREATE:"emojiCreate",GUILD_EMOJI_DELETE:"emojiDelete",GUILD_EMOJI_UPDATE:"emojiUpdate",GUILD_BAN_ADD:"guildBanAdd",GUILD_BAN_REMOVE:"guildBanRemove",CHANNEL_CREATE:"channelCreate",CHANNEL_DELETE:"channelDelete",CHANNEL_UPDATE:"channelUpdate",CHANNEL_PINS_UPDATE:"channelPinsUpdate",MESSAGE_CREATE:"message",MESSAGE_DELETE:"messageDelete",MESSAGE_UPDATE:"messageUpdate",MESSAGE_BULK_DELETE:"messageDeleteBulk",MESSAGE_REACTION_ADD:"messageReactionAdd",MESSAGE_REACTION_REMOVE:"messageReactionRemove",MESSAGE_REACTION_REMOVE_ALL:"messageReactionRemoveAll",USER_UPDATE:"userUpdate",USER_NOTE_UPDATE:"userNoteUpdate",PRESENCE_UPDATE:"presenceUpdate",VOICE_STATE_UPDATE:"voiceStateUpdate",TYPING_START:"typingStart",TYPING_STOP:"typingStop",DISCONNECT:"disconnect",RECONNECTING:"reconnecting",ERROR:"error",WARN:"warn",DEBUG:"debug"},e.WSEvents={READY:"READY",GUILD_SYNC:"GUILD_SYNC",GUILD_CREATE:"GUILD_CREATE",GUILD_DELETE:"GUILD_DELETE",GUILD_UPDATE:"GUILD_UPDATE",GUILD_MEMBER_ADD:"GUILD_MEMBER_ADD",GUILD_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",GUILD_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",GUILD_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",GUILD_ROLE_CREATE:"GUILD_ROLE_CREATE",GUILD_ROLE_DELETE:"GUILD_ROLE_DELETE",GUILD_ROLE_UPDATE:"GUILD_ROLE_UPDATE",GUILD_BAN_ADD:"GUILD_BAN_ADD",GUILD_BAN_REMOVE:"GUILD_BAN_REMOVE",GUILD_EMOJIS_UPDATE:"GUILD_EMOJIS_UPDATE",CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",CHANNEL_PINS_UPDATE:"CHANNEL_PINS_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",MESSAGE_DELETE_BULK:"MESSAGE_DELETE_BULK",MESSAGE_REACTION_ADD:"MESSAGE_REACTION_ADD",MESSAGE_REACTION_REMOVE:"MESSAGE_REACTION_REMOVE",MESSAGE_REACTION_REMOVE_ALL:"MESSAGE_REACTION_REMOVE_ALL",USER_UPDATE:"USER_UPDATE",USER_NOTE_UPDATE:"USER_NOTE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",TYPING_START:"TYPING_START",VOICE_SERVER_UPDATE:"VOICE_SERVER_UPDATE",RELATIONSHIP_ADD:"RELATIONSHIP_ADD",RELATIONSHIP_REMOVE:"RELATIONSHIP_REMOVE"},e.MessageTypes=["DEFAULT","RECIPIENT_ADD","RECIPIENT_REMOVE","CALL","CHANNEL_NAME_CHANGE","CHANNEL_ICON_CHANGE","PINS_ADD","GUILD_MEMBER_JOIN"],e.DefaultAvatars={BLURPLE:"6debd47ed13483642cf09e832ed0bc1b",GREY:"322c936a8c8be1b803cd94861bdfa868",GREEN:"dd4dbc0016779df1378e7812eabaa04d",ORANGE:"0e291f67c9274a1abdddeb3fd919cbaa",RED:"1cbd08c76f8af6dddce02c5138971129"},e.Colors={DEFAULT:0,AQUA:1752220,GREEN:3066993,BLUE:3447003,PURPLE:10181046,GOLD:15844367,ORANGE:15105570,RED:15158332,GREY:9807270,NAVY:3426654,DARK_AQUA:1146986,DARK_GREEN:2067276,DARK_BLUE:2123412,DARK_PURPLE:7419530,DARK_GOLD:12745742,DARK_ORANGE:11027200,DARK_RED:10038562,DARK_GREY:9936031,DARKER_GREY:8359053,LIGHT_GREY:12370112,DARK_NAVY:2899536,BLURPLE:7506394,GREYPLE:10070709,DARK_BUT_NOT_BLACK:2895667,NOT_QUITE_BLACK:2303786}}).call(e,n(18))},function(t,e){class n{constructor(t){this.packetManager=t}handle(t){return t}}t.exports=n},function(t,e){class n{constructor(t){this.client=t}handle(t){return t}}t.exports=n},function(t,e){class n extends Map{constructor(t){super(t),Object.defineProperty(this,"_array",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"_keyArray",{value:null,writable:!0,configurable:!0})}set(t,e){return this._array=null,this._keyArray=null,super.set(t,e)}delete(t){return this._array=null,this._keyArray=null,super.delete(t)}array(){return this._array&&this._array.length===this.size||(this._array=Array.from(this.values())),this._array}keyArray(){return this._keyArray&&this._keyArray.length===this.size||(this._keyArray=Array.from(this.keys())),this._keyArray}first(){return this.values().next().value}firstKey(){return this.keys().next().value}last(){const t=this.array();return t[t.length-1]}lastKey(){const t=this.keyArray();return t[t.length-1]}random(){const t=this.array();return t[Math.floor(Math.random()*t.length)]}randomKey(){const t=this.keyArray();return t[Math.floor(Math.random()*t.length)]}findAll(t,e){if("string"!=typeof t)throw new TypeError("Key must be a string.");if("undefined"==typeof e)throw new Error("Value must be specified.");const n=[];for(const i of this.values())i[t]===e&&n.push(i);return n}find(t,e){if("string"==typeof t){if("undefined"==typeof e)throw new Error("Value must be specified.");for(const n of this.values())if(n[t]===e)return n;return null}if("function"==typeof t){for(const[e,n]of this)if(t(n,e,this))return n;return null}throw new Error("First argument must be a property string or a function.")}findKey(t,e){if("string"==typeof t){if("undefined"==typeof e)throw new Error("Value must be specified.");for(const[n,i]of this)if(i[t]===e)return n;return null}if("function"==typeof t){for(const[e,n]of this)if(t(n,e,this))return e;return null}throw new Error("First argument must be a property string or a function.")}exists(t,e){return Boolean(this.find(t,e))}filter(t,e){e&&(t=t.bind(e));const i=new n;for(const[s,r]of this)t(r,s,this)&&i.set(s,r);return i}filterArray(t,e){e&&(t=t.bind(e));const n=[];for(const[i,s]of this)t(s,i,this)&&n.push(s);return n}map(t,e){e&&(t=t.bind(e));const n=new Array(this.size);let i=0;for(const[s,r]of this)n[i++]=t(r,s,this);return n}some(t,e){e&&(t=t.bind(e));for(const[n,i]of this)if(t(i,n,this))return!0;return!1}every(t,e){e&&(t=t.bind(e));for(const[n,i]of this)if(!t(i,n,this))return!1;return!0}reduce(t,e){let n;if("undefined"!=typeof e){n=e;for(const[i,s]of this)n=t(n,s,i,this)}else{let e=!0;for(const[i,s]of this)e?(n=s,e=!1):n=t(n,s,i,this)}return n}clone(){return new this.constructor(this)}concat(...t){const e=this.clone();for(const n of t)for(const[i,s]of n)e.set(i,s);return e}deleteAll(){const t=[];for(const e of this.values())e.delete&&t.push(e.delete());return t}equals(t){return!!t&&(this===t||this.size===t.size&&!this.find((e,n)=>{const i=t.get(n);return i!==e||void 0===i&&!t.has(n)}))}}t.exports=n},function(t,e,n){(function(e){const i=n(25),s=n(0);class r{constructor(){throw new Error(`The ${this.constructor.name} class may not be instantiated.`)}static splitMessage(t,{maxLength=1950,char="\n",prepend="",append=""}={}){if(t.length<=maxLength)return t;const e=t.split(char);if(1===e.length)throw new Error("Message exceeds the max length and contains no split characters.");const n=[""];let i=0;for(let s=0;smaxLength&&(n[i]+=append,n.push(prepend),i++),n[i]+=(n[i].length>0&&n[i]!==prepend?char:"")+e[s];return n}static escapeMarkdown(t,e=false,n=false){return e?t.replace(/```/g,"`​``"):n?t.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):t.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}static fetchRecommendedShards(t,e=1e3){return new Promise((n,r)=>{if(!t)throw new Error("A token must be provided.");i.get(s.Endpoints.gateway.bot).set("Authorization",`Bot ${t.replace(/^Bot\s*/i,"")}`).end((t,i)=>{t&&r(t),n(i.body.shards*(1e3/e))})})}static parseEmoji(t){if(t.includes("%")&&(t=decodeURIComponent(t)),t.includes(":")){const[e,n]=t.split(":");return{name:e,id:n}}return{name:t,id:null}}static arraysEqual(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(const n in t){const i=t[n],s=e.indexOf(i);s&&e.splice(s,1)}return 0===e.length}static cloneObject(t){return Object.assign(Object.create(t),t)}static mergeDefault(t,e){if(!e)return t;for(const n in t)({}).hasOwnProperty.call(e,n)?e[n]===Object(e[n])&&(e[n]=this.mergeDefault(t[n],e[n])):e[n]=t[n];return e}static convertToBuffer(t){return"string"==typeof t&&(t=this.str2ab(t)),e.from(t)}static str2ab(t){const e=new ArrayBuffer(2*t.length),n=new Uint16Array(e);for(var i=0,s=t.length;i-1&&n=e?String(t):(String(n).repeat(e)+t).slice(-e)}const s=n(42),r=14200704e5;let o=0;class u{static generate(){o>=4095&&(o=0);const t=`${i((Date.now()-r).toString(2),42)}0000100000${i((o++).toString(2),12)}`;return s.fromString(t,2).toString()}static deconstruct(t){const e=i(s.fromString(t).toString(2),64),n={timestamp:parseInt(e.substring(0,42),2)+r,workerID:parseInt(e.substring(42,47),2),processID:parseInt(e.substring(47,52),2),increment:parseInt(e.substring(52,64),2),binary:e};return Object.defineProperty(n,"date",{get:function(){return new Date(this.timestamp)},enumerable:!0}),n}}t.exports=u},function(t,e,n){const i=n(0);class s{constructor(t,e){e="object"!=typeof t||t instanceof Array?t:e,this.member="object"==typeof t?t:null,this.bitfield="number"==typeof e?e:this.constructor.resolve(e)}get raw(){return this.bitfield}set raw(t){this.bitfield=t}has(t,e=true){return t instanceof Array?t.every(t=>this.has(t,e)):(t=this.constructor.resolve(t),!!(e&&(this.bitfield&this.constructor.FLAGS.ADMINISTRATOR)>0)||(this.bitfield&t)===t)}missing(t,e=true){return t.filter(t=>!this.has(t,e))}add(...t){let e=0;for(let n=0;nthis.resolve(t)).reduce((t,e)=>t|e,0);if("string"==typeof t&&(t=this.FLAGS[t]),"number"!=typeof t||t<1)throw new RangeError(i.Errors.NOT_A_PERMISSION);return t}}s.FLAGS={CREATE_INSTANT_INVITE:1,KICK_MEMBERS:2,BAN_MEMBERS:4,ADMINISTRATOR:8,MANAGE_CHANNELS:16,MANAGE_GUILD:32,ADD_REACTIONS:64,READ_MESSAGES:1024,SEND_MESSAGES:2048,SEND_TTS_MESSAGES:4096,MANAGE_MESSAGES:8192,EMBED_LINKS:16384,ATTACH_FILES:32768,READ_MESSAGE_HISTORY:65536,MENTION_EVERYONE:1<<17,EXTERNAL_EMOJIS:1<<18,USE_EXTERNAL_EMOJIS:1<<18,CONNECT:1<<20,SPEAK:1<<21,MUTE_MEMBERS:1<<22,DEAFEN_MEMBERS:1<<23,MOVE_MEMBERS:1<<24,USE_VAD:1<<25,CHANGE_NICKNAME:1<<26,MANAGE_NICKNAMES:1<<27,MANAGE_ROLES:1<<28,MANAGE_ROLES_OR_PERMISSIONS:1<<28,MANAGE_WEBHOOKS:1<<29,MANAGE_EMOJIS:1<<30},s.ALL=Object.keys(s.FLAGS).reduce((t,e)=>t|s.FLAGS[e],0),s.DEFAULT=104324097,t.exports=s},function(t,e){class n{constructor(t={}){this.status=t.status||"offline",this.game=t.game?new i(t.game):null}update(t){this.status=t.status||this.status,this.game=t.game?new i(t.game):null}equals(t){return this===t||(t&&this.status===t.status&&this.game?this.game.equals(t.game):!t.game)}}class i{constructor(t){this.name=t.name,this.type=t.type,this.url=t.url||null}get streaming(){return 1===this.type}equals(t){return this===t||t&&this.name===t.name&&this.type===t.type&&this.url===t.url}}e.Presence=n,e.Game=i},function(t,e,n){const i=n(5);class s{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.type=null,e&&this.setup(e)}setup(t){this.id=t.id}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}delete(){return this.client.rest.methods.deleteChannel(this)}}t.exports=s},function(t,e,n){const i=n(32),s=n(34),r=n(35),o=n(4),u=n(3),c=n(0),h=n(6);let a;class l{constructor(t,e,n){Object.defineProperty(this,"client",{value:n}),this.channel=t,e&&this.setup(e)}setup(t){this.id=t.id,this.type=c.MessageTypes[t.type],this.content=t.content,this.author=this.client.dataManager.newUser(t.author),this.member=this.guild?this.guild.member(this.author)||null:null,this.pinned=t.pinned,this.tts=t.tts,this.nonce=t.nonce,this.system=6===t.type,this.embeds=t.embeds.map(t=>new s(this,t)),this.attachments=new u;for(const e of t.attachments)this.attachments.set(e.id,new i(this,e));this.createdTimestamp=new Date(t.timestamp).getTime(),this.editedTimestamp=t.edited_timestamp?new Date(t.edited_timestamp).getTime():null,this.mentions={users:new u,roles:new u,channels:new u,everyone:t.mention_everyone};for(const n of t.mentions){let t=this.client.users.get(n.id);t||(t=this.client.dataManager.newUser(n)),this.mentions.users.set(t.id,t)}if(Object.defineProperty(this.mentions,"members",{get:()=>{if("text"!==this.channel.type)return null;const t=new u;return this.mentions.users.forEach(e=>{const n=this.client.resolver.resolveGuildMember(this.channel.guild,e);n&&t.set(n.id,n)}),t}}),t.mention_roles)for(const n of t.mention_roles){const t=this.channel.guild.roles.get(n);t&&this.mentions.roles.set(t.id,t)}if("text"===this.channel.type){const e=t.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of e){const t=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);t&&this.mentions.channels.set(t.id,t)}}if(this._edits=[],this.reactions=new u,t.reactions&&t.reactions.length>0)for(const o of t.reactions){const t=o.emoji.id?`${o.emoji.name}:${o.emoji.id}`:o.emoji.name;this.reactions.set(t,new r(this,o.emoji,o.count,o.me))}this.webhookID=t.webhook_id||null,this.hit="boolean"==typeof t.hit?t.hit:null}get createdAt(){return new Date(this.createdTimestamp)}get editedAt(){return this.editedTimestamp?new Date(this.editedTimestamp):null}get guild(){return this.channel.guild||null}get cleanContent(){return this.content.replace(/@(everyone|here)/g,"@​$1").replace(/<@!?[0-9]+>/g,t=>{const e=t.replace(/<|!|>|@/g,"");if("dm"===this.channel.type||"group"===this.channel.type)return this.client.users.has(e)?`@${this.client.users.get(e).username}`:t;const n=this.channel.guild.members.get(e);if(n)return n.nickname?`@${n.nickname}`:`@${n.user.username}`;{const n=this.client.users.get(e);return n?`@${n.username}`:t}}).replace(/<#[0-9]+>/g,t=>{const e=this.client.channels.get(t.replace(/<|#|>/g,""));return e?`#${e.name}`:t}).replace(/<@&[0-9]+>/g,t=>{if("dm"===this.channel.type||"group"===this.channel.type)return t;const e=this.guild.roles.get(t.replace(/<|@|>|&/g,""));return e?`@${e.name}`:t})}get edits(){const t=this._edits.slice();return t.unshift(this),t}get editable(){return this.author.id===this.client.user.id}get deletable(){return this.author.id===this.client.user.id||this.guild&&this.channel.permissionsFor(this.client.user).hasPermission(h.FLAGS.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).hasPermission(h.FLAGS.MANAGE_MESSAGES)}isMentioned(t){return t=t&&t.id?t.id:t,this.mentions.users.has(t)||this.mentions.channels.has(t)||this.mentions.roles.has(t)}isMemberMentioned(t){return a||(a=n(13)),!!this.mentions.everyone||(!!this.mentions.users.has(t.id)||!!(t instanceof a&&t.roles.some(t=>this.mentions.roles.has(t.id))))}edit(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),this.client.rest.methods.updateMessage(this,t,e)}editCode(t,e){return e=o.escapeMarkdown(this.client.resolver.resolveString(e),!0),this.edit(`\`\`\`${t||""} +!function(t){function e(i){if(n[i])return n[i].exports;var s=n[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=145)}([function(t,e,n){(function(t){e.Package=n(29),e.DefaultOptions={apiRequestMethod:"sequential",shardId:0,shardCount:0,messageCacheMaxSize:200,messageCacheLifetime:0,messageSweepInterval:0,fetchAllMembers:!1,disableEveryone:!1,sync:!1,restWsBridgeTimeout:5e3,disabledEvents:[],restTimeOffset:500,ws:{large_threshold:250,compress:"browser"!==n(15).platform(),properties:{$os:t?t.platform:"discord.js",$browser:"discord.js",$device:"discord.js",$referrer:"",$referring_domain:""},version:6},http:{version:6,host:"https://discordapp.com",cdn:"https://cdn.discordapp.com"}},e.Errors={NO_TOKEN:"Request to use token, but token was unavailable to the client.",NO_BOT_ACCOUNT:"Only bot accounts are able to make use of this feature.",NO_USER_ACCOUNT:"Only user accounts are able to make use of this feature.",BAD_WS_MESSAGE:"A bad message was received from the websocket; either bad compression, or not JSON.",TOOK_TOO_LONG:"Something took too long to do.",NOT_A_PERMISSION:"Invalid permission string or number.",INVALID_RATE_LIMIT_METHOD:"Unknown rate limiting method.",BAD_LOGIN:"Incorrect login details were provided.",INVALID_SHARD:"Invalid shard settings were provided.",SHARDING_REQUIRED:"This session would have handled too many guilds - Sharding is required.",INVALID_TOKEN:"An invalid token was provided."};const i=e.Endpoints={User:t=>{t.id&&(t=t.id);const e=`/users/${t}`;return{toString:()=>e,channels:`${e}/channels`,profile:`${e}/profile`,relationships:`${e}/relationships`,Relationship:t=>`${e}/relationships/${t}`,Guild:t=>`${e}/guilds/${t}`,Note:t=>`${e}/notes/${t}`,Mentions:(t,n,i,s)=>`${e}/mentions?limit=${t}&roles=${n}&everyone=${i}${s?`&guild_id=${s}`:""}`,Avatar:(e,n)=>{return"1"===t?n:i.CDN(e).Avatar(t,n)}}},guilds:"/guilds",Guild:t=>{t.id&&(t=t.id);const e=`/guilds/${t}`;return{toString:()=>e,prune:`${e}/prune`,embed:`${e}/embed`,bans:`${e}/bans`,integrations:`${e}/integrations`,members:`${e}/members`,channels:`${e}/channels`,invites:`${e}/invites`,roles:`${e}/roles`,emojis:`${e}/emojis`,search:`${e}/messages/search`,voiceRegions:`${e}/regions`,webhooks:`${e}/webhooks`,ack:`${e}/ack`,settings:`${e}/settings`,Emoji:t=>`${e}/emojis/${t}`,Icon:(e,n)=>i.CDN(e).Icon(t,n),Splash:(e,n)=>i.CDN(e).Splash(t,n),Role:t=>`${e}/roles/${t}`,Member:t=>{t.id&&(t=t.id);const n=`${e}/members/${t}`;return{toString:()=>n,Role:t=>`${n}/roles/${t}`,nickname:`${e}/members/@me/nick`}}}},channels:"/channels",Channel:t=>{t.id&&(t=t.id);const e=`/channels/${t}`;return{toString:()=>e,messages:{toString:()=>`${e}/messages`,bulkDelete:`${e}/messages/bulk-delete`},invites:`${e}/invites`,typing:`${e}/typing`,permissions:`${e}/permissions`,webhooks:`${e}/webhooks`,search:`${e}/search`,ack:`${e}/ack`,pins:`${e}/pins`,Pin:t=>`${e}/pins/${t}`,Recipient:t=>`${e}/recipients/${t}`,Message:t=>{t.id&&(t=t.id);const n=`${e}/messages/${t}`;return{toString:()=>n,reactions:`${n}/reactions`,ack:`${e}/ack`,Reaction:(t,e)=>{const i=`${n}/reactions/${t}${e?`?limit=${e}`:""}`;return{toString:()=>i,User:t=>`${i}/${t}`}}}}}},Message:t=>e.Endpoints.Channel(t.channel).Message(t),Member:t=>e.Endpoints.Guild(t.guild).Member(t),CDN(t){return{Emoji:e=>`${t}/emojis/$${e}.png`,Asset:e=>`${t}/assets/${e}`,Avatar:(e,n)=>`${t}/avatars/${e}/${n}.${n.startsWith("a_")?"gif":"png"}?size=2048`,Icon:(e,n)=>`${t}/icons/${e}/${n}.jpg`,Splash:(e,n)=>`${t}/splashes/${e}/${n}.jpg`}},OAUTH2:{Application:t=>{const e=`/oauth2/applications/${t}`;return{toString:()=>e,reset:`${e}/reset`}},App:t=>`/oauth2/authorize?client_id=${t}`},login:"/auth/login",logout:"/auth/logout",voiceRegions:"/voice/regions",gateway:{toString:()=>"/gateway",bot:"/gateway/bot"},Invite:t=>`/invite/${t}`,Webhook:(t,e)=>`/webhooks/${t}${e?`/${e}`:""}`};e.Status={READY:0,CONNECTING:1,RECONNECTING:2,IDLE:3,NEARLY:4,DISCONNECTED:5},e.VoiceStatus={CONNECTED:0,CONNECTING:1,AUTHENTICATING:2,RECONNECTING:3,DISCONNECTED:4},e.ChannelTypes={TEXT:0,DM:1,VOICE:2,GROUP_DM:3},e.OPCodes={DISPATCH:0,HEARTBEAT:1,IDENTIFY:2,STATUS_UPDATE:3,VOICE_STATE_UPDATE:4,VOICE_GUILD_PING:5,RESUME:6,RECONNECT:7,REQUEST_GUILD_MEMBERS:8,INVALID_SESSION:9,HELLO:10,HEARTBEAT_ACK:11},e.VoiceOPCodes={IDENTIFY:0,SELECT_PROTOCOL:1,READY:2,HEARTBEAT:3,SESSION_DESCRIPTION:4,SPEAKING:5},e.Events={READY:"ready",GUILD_CREATE:"guildCreate",GUILD_DELETE:"guildDelete",GUILD_UPDATE:"guildUpdate",GUILD_UNAVAILABLE:"guildUnavailable",GUILD_AVAILABLE:"guildAvailable",GUILD_MEMBER_ADD:"guildMemberAdd",GUILD_MEMBER_REMOVE:"guildMemberRemove",GUILD_MEMBER_UPDATE:"guildMemberUpdate",GUILD_MEMBER_AVAILABLE:"guildMemberAvailable",GUILD_MEMBER_SPEAKING:"guildMemberSpeaking",GUILD_MEMBERS_CHUNK:"guildMembersChunk",GUILD_ROLE_CREATE:"roleCreate",GUILD_ROLE_DELETE:"roleDelete",GUILD_ROLE_UPDATE:"roleUpdate",GUILD_EMOJI_CREATE:"emojiCreate",GUILD_EMOJI_DELETE:"emojiDelete",GUILD_EMOJI_UPDATE:"emojiUpdate",GUILD_BAN_ADD:"guildBanAdd",GUILD_BAN_REMOVE:"guildBanRemove",CHANNEL_CREATE:"channelCreate",CHANNEL_DELETE:"channelDelete",CHANNEL_UPDATE:"channelUpdate",CHANNEL_PINS_UPDATE:"channelPinsUpdate",MESSAGE_CREATE:"message",MESSAGE_DELETE:"messageDelete",MESSAGE_UPDATE:"messageUpdate",MESSAGE_BULK_DELETE:"messageDeleteBulk",MESSAGE_REACTION_ADD:"messageReactionAdd",MESSAGE_REACTION_REMOVE:"messageReactionRemove",MESSAGE_REACTION_REMOVE_ALL:"messageReactionRemoveAll",USER_UPDATE:"userUpdate",USER_NOTE_UPDATE:"userNoteUpdate",PRESENCE_UPDATE:"presenceUpdate",VOICE_STATE_UPDATE:"voiceStateUpdate",TYPING_START:"typingStart",TYPING_STOP:"typingStop",DISCONNECT:"disconnect",RECONNECTING:"reconnecting",ERROR:"error",WARN:"warn",DEBUG:"debug"},e.WSEvents={READY:"READY",GUILD_SYNC:"GUILD_SYNC",GUILD_CREATE:"GUILD_CREATE",GUILD_DELETE:"GUILD_DELETE",GUILD_UPDATE:"GUILD_UPDATE",GUILD_MEMBER_ADD:"GUILD_MEMBER_ADD",GUILD_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",GUILD_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",GUILD_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",GUILD_ROLE_CREATE:"GUILD_ROLE_CREATE",GUILD_ROLE_DELETE:"GUILD_ROLE_DELETE",GUILD_ROLE_UPDATE:"GUILD_ROLE_UPDATE",GUILD_BAN_ADD:"GUILD_BAN_ADD",GUILD_BAN_REMOVE:"GUILD_BAN_REMOVE",GUILD_EMOJIS_UPDATE:"GUILD_EMOJIS_UPDATE",CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",CHANNEL_PINS_UPDATE:"CHANNEL_PINS_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",MESSAGE_DELETE_BULK:"MESSAGE_DELETE_BULK",MESSAGE_REACTION_ADD:"MESSAGE_REACTION_ADD",MESSAGE_REACTION_REMOVE:"MESSAGE_REACTION_REMOVE",MESSAGE_REACTION_REMOVE_ALL:"MESSAGE_REACTION_REMOVE_ALL",USER_UPDATE:"USER_UPDATE",USER_NOTE_UPDATE:"USER_NOTE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",TYPING_START:"TYPING_START",VOICE_SERVER_UPDATE:"VOICE_SERVER_UPDATE",RELATIONSHIP_ADD:"RELATIONSHIP_ADD",RELATIONSHIP_REMOVE:"RELATIONSHIP_REMOVE"},e.MessageTypes=["DEFAULT","RECIPIENT_ADD","RECIPIENT_REMOVE","CALL","CHANNEL_NAME_CHANGE","CHANNEL_ICON_CHANGE","PINS_ADD","GUILD_MEMBER_JOIN"],e.DefaultAvatars={BLURPLE:"6debd47ed13483642cf09e832ed0bc1b",GREY:"322c936a8c8be1b803cd94861bdfa868",GREEN:"dd4dbc0016779df1378e7812eabaa04d",ORANGE:"0e291f67c9274a1abdddeb3fd919cbaa",RED:"1cbd08c76f8af6dddce02c5138971129"},e.Colors={DEFAULT:0,AQUA:1752220,GREEN:3066993,BLUE:3447003,PURPLE:10181046,GOLD:15844367,ORANGE:15105570,RED:15158332,GREY:9807270,NAVY:3426654,DARK_AQUA:1146986,DARK_GREEN:2067276,DARK_BLUE:2123412,DARK_PURPLE:7419530,DARK_GOLD:12745742,DARK_ORANGE:11027200,DARK_RED:10038562,DARK_GREY:9936031,DARKER_GREY:8359053,LIGHT_GREY:12370112,DARK_NAVY:2899536,BLURPLE:7506394,GREYPLE:10070709,DARK_BUT_NOT_BLACK:2895667,NOT_QUITE_BLACK:2303786}}).call(e,n(18))},function(t,e){class n{constructor(t){this.packetManager=t}handle(t){return t}}t.exports=n},function(t,e){class n{constructor(t){this.client=t}handle(t){return t}}t.exports=n},function(t,e){class n extends Map{constructor(t){super(t),Object.defineProperty(this,"_array",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"_keyArray",{value:null,writable:!0,configurable:!0})}set(t,e){return this._array=null,this._keyArray=null,super.set(t,e)}delete(t){return this._array=null,this._keyArray=null,super.delete(t)}array(){return this._array&&this._array.length===this.size||(this._array=Array.from(this.values())),this._array}keyArray(){return this._keyArray&&this._keyArray.length===this.size||(this._keyArray=Array.from(this.keys())),this._keyArray}first(){return this.values().next().value}firstKey(){return this.keys().next().value}last(){const t=this.array();return t[t.length-1]}lastKey(){const t=this.keyArray();return t[t.length-1]}random(){const t=this.array();return t[Math.floor(Math.random()*t.length)]}randomKey(){const t=this.keyArray();return t[Math.floor(Math.random()*t.length)]}findAll(t,e){if("string"!=typeof t)throw new TypeError("Key must be a string.");if("undefined"==typeof e)throw new Error("Value must be specified.");const n=[];for(const i of this.values())i[t]===e&&n.push(i);return n}find(t,e){if("string"==typeof t){if("undefined"==typeof e)throw new Error("Value must be specified.");for(const n of this.values())if(n[t]===e)return n;return null}if("function"==typeof t){for(const[e,n]of this)if(t(n,e,this))return n;return null}throw new Error("First argument must be a property string or a function.")}findKey(t,e){if("string"==typeof t){if("undefined"==typeof e)throw new Error("Value must be specified.");for(const[n,i]of this)if(i[t]===e)return n;return null}if("function"==typeof t){for(const[e,n]of this)if(t(n,e,this))return e;return null}throw new Error("First argument must be a property string or a function.")}exists(t,e){return Boolean(this.find(t,e))}filter(t,e){e&&(t=t.bind(e));const i=new n;for(const[s,r]of this)t(r,s,this)&&i.set(s,r);return i}filterArray(t,e){e&&(t=t.bind(e));const n=[];for(const[i,s]of this)t(s,i,this)&&n.push(s);return n}map(t,e){e&&(t=t.bind(e));const n=new Array(this.size);let i=0;for(const[s,r]of this)n[i++]=t(r,s,this);return n}some(t,e){e&&(t=t.bind(e));for(const[n,i]of this)if(t(i,n,this))return!0;return!1}every(t,e){e&&(t=t.bind(e));for(const[n,i]of this)if(!t(i,n,this))return!1;return!0}reduce(t,e){let n;if("undefined"!=typeof e){n=e;for(const[i,s]of this)n=t(n,s,i,this)}else{let e=!0;for(const[i,s]of this)e?(n=s,e=!1):n=t(n,s,i,this)}return n}clone(){return new this.constructor(this)}concat(...t){const e=this.clone();for(const n of t)for(const[i,s]of n)e.set(i,s);return e}deleteAll(){const t=[];for(const e of this.values())e.delete&&t.push(e.delete());return t}equals(t){return!!t&&(this===t||this.size===t.size&&!this.find((e,n)=>{const i=t.get(n);return i!==e||void 0===i&&!t.has(n)}))}sort(t=(t,e)=>+(t>e)||+(t===e)-1){return new n(Array.from(this.entries()).sort((e,n)=>t(e[1],n[1],e[0],n[0])))}}t.exports=n},function(t,e,n){(function(e){const i=n(26),s=n(0);class r{constructor(){throw new Error(`The ${this.constructor.name} class may not be instantiated.`)}static splitMessage(t,{maxLength=1950,char="\n",prepend="",append=""}={}){if(t.length<=maxLength)return t;const e=t.split(char);if(1===e.length)throw new Error("Message exceeds the max length and contains no split characters.");const n=[""];let i=0;for(let s=0;smaxLength&&(n[i]+=append,n.push(prepend),i++),n[i]+=(n[i].length>0&&n[i]!==prepend?char:"")+e[s];return n}static escapeMarkdown(t,e=false,n=false){return e?t.replace(/```/g,"`​``"):n?t.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):t.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}static fetchRecommendedShards(t,e=1e3){return new Promise((n,r)=>{if(!t)throw new Error("A token must be provided.");i.get(s.Endpoints.gateway.bot).set("Authorization",`Bot ${t.replace(/^Bot\s*/i,"")}`).end((t,i)=>{t&&r(t),n(i.body.shards*(1e3/e))})})}static parseEmoji(t){if(t.includes("%")&&(t=decodeURIComponent(t)),t.includes(":")){const[e,n]=t.split(":");return{name:e,id:n}}return{name:t,id:null}}static arraysEqual(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(const n in t){const i=t[n],s=e.indexOf(i);s&&e.splice(s,1)}return 0===e.length}static cloneObject(t){return Object.assign(Object.create(t),t)}static mergeDefault(t,e){if(!e)return t;for(const n in t)({}).hasOwnProperty.call(e,n)?e[n]===Object(e[n])&&(e[n]=this.mergeDefault(t[n],e[n])):e[n]=t[n];return e}static convertToBuffer(t){return"string"==typeof t&&(t=this.str2ab(t)),e.from(t)}static str2ab(t){const e=new ArrayBuffer(2*t.length),n=new Uint16Array(e);for(var i=0,s=t.length;i-1&&n=e?String(t):(String(n).repeat(e)+t).slice(-e)}const s=n(24),r=14200704e5;let o=0;class u{static generate(){o>=4095&&(o=0);const t=`${i((Date.now()-r).toString(2),42)}0000100000${i((o++).toString(2),12)}`;return s.fromString(t,2).toString()}static deconstruct(t){const e=i(s.fromString(t).toString(2),64),n={timestamp:parseInt(e.substring(0,42),2)+r,workerID:parseInt(e.substring(42,47),2),processID:parseInt(e.substring(47,52),2),increment:parseInt(e.substring(52,64),2),binary:e};return Object.defineProperty(n,"date",{get:function(){return new Date(this.timestamp)},enumerable:!0}),n}}t.exports=u},function(t,e,n){const i=n(0);class s{constructor(t,e){e="object"!=typeof t||t instanceof Array?t:e,this.member="object"==typeof t?t:null,this.bitfield="number"==typeof e?e:this.constructor.resolve(e)}get raw(){return this.bitfield}set raw(t){this.bitfield=t}has(t,e=true){return t instanceof Array?t.every(t=>this.has(t,e)):(t=this.constructor.resolve(t),!!(e&&(this.bitfield&this.constructor.FLAGS.ADMINISTRATOR)>0)||(this.bitfield&t)===t)}missing(t,e=true){return t.filter(t=>!this.has(t,e))}add(...t){let e=0;for(let n=0;nthis.resolve(t)).reduce((t,e)=>t|e,0);if("string"==typeof t&&(t=this.FLAGS[t]),"number"!=typeof t||t<1)throw new RangeError(i.Errors.NOT_A_PERMISSION);return t}}s.FLAGS={CREATE_INSTANT_INVITE:1,KICK_MEMBERS:2,BAN_MEMBERS:4,ADMINISTRATOR:8,MANAGE_CHANNELS:16,MANAGE_GUILD:32,ADD_REACTIONS:64,READ_MESSAGES:1024,SEND_MESSAGES:2048,SEND_TTS_MESSAGES:4096,MANAGE_MESSAGES:8192,EMBED_LINKS:16384,ATTACH_FILES:32768,READ_MESSAGE_HISTORY:65536,MENTION_EVERYONE:1<<17,EXTERNAL_EMOJIS:1<<18,USE_EXTERNAL_EMOJIS:1<<18,CONNECT:1<<20,SPEAK:1<<21,MUTE_MEMBERS:1<<22,DEAFEN_MEMBERS:1<<23,MOVE_MEMBERS:1<<24,USE_VAD:1<<25,CHANGE_NICKNAME:1<<26,MANAGE_NICKNAMES:1<<27,MANAGE_ROLES:1<<28,MANAGE_ROLES_OR_PERMISSIONS:1<<28,MANAGE_WEBHOOKS:1<<29,MANAGE_EMOJIS:1<<30},s.ALL=Object.keys(s.FLAGS).reduce((t,e)=>t|s.FLAGS[e],0),s.DEFAULT=104324097,t.exports=s},function(t,e){class n{constructor(t={}){this.status=t.status||"offline",this.game=t.game?new i(t.game):null}update(t){this.status=t.status||this.status,this.game=t.game?new i(t.game):null}equals(t){return this===t||(t&&this.status===t.status&&this.game?this.game.equals(t.game):!t.game)}}class i{constructor(t){this.name=t.name,this.type=t.type,this.url=t.url||null}get streaming(){return 1===this.type}equals(t){return this===t||t&&this.name===t.name&&this.type===t.type&&this.url===t.url}}e.Presence=n,e.Game=i},function(t,e,n){const i=n(5);class s{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.type=null,e&&this.setup(e)}setup(t){this.id=t.id}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}delete(){return this.client.rest.methods.deleteChannel(this)}}t.exports=s},function(t,e,n){const i=n(33),s=n(35),r=n(36),o=n(4),u=n(3),c=n(0),h=n(6);let a;class l{constructor(t,e,n){Object.defineProperty(this,"client",{value:n}),this.channel=t,e&&this.setup(e)}setup(t){this.id=t.id,this.type=c.MessageTypes[t.type],this.content=t.content,this.author=this.client.dataManager.newUser(t.author),this.member=this.guild?this.guild.member(this.author)||null:null,this.pinned=t.pinned,this.tts=t.tts,this.nonce=t.nonce,this.system=6===t.type,this.embeds=t.embeds.map(t=>new s(this,t)),this.attachments=new u;for(const e of t.attachments)this.attachments.set(e.id,new i(this,e));this.createdTimestamp=new Date(t.timestamp).getTime(),this.editedTimestamp=t.edited_timestamp?new Date(t.edited_timestamp).getTime():null,this.mentions={users:new u,roles:new u,channels:new u,everyone:t.mention_everyone};for(const n of t.mentions){let t=this.client.users.get(n.id);t||(t=this.client.dataManager.newUser(n)),this.mentions.users.set(t.id,t)}if(Object.defineProperty(this.mentions,"members",{get:()=>{if("text"!==this.channel.type)return null;const t=new u;return this.mentions.users.forEach(e=>{const n=this.client.resolver.resolveGuildMember(this.channel.guild,e);n&&t.set(n.id,n)}),t}}),t.mention_roles)for(const n of t.mention_roles){const t=this.channel.guild.roles.get(n);t&&this.mentions.roles.set(t.id,t)}if("text"===this.channel.type){const e=t.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of e){const t=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);t&&this.mentions.channels.set(t.id,t)}}if(this._edits=[],this.reactions=new u,t.reactions&&t.reactions.length>0)for(const o of t.reactions){const t=o.emoji.id?`${o.emoji.name}:${o.emoji.id}`:o.emoji.name;this.reactions.set(t,new r(this,o.emoji,o.count,o.me))}this.webhookID=t.webhook_id||null,this.hit="boolean"==typeof t.hit?t.hit:null}get createdAt(){return new Date(this.createdTimestamp)}get editedAt(){return this.editedTimestamp?new Date(this.editedTimestamp):null}get guild(){return this.channel.guild||null}get cleanContent(){return this.content.replace(/@(everyone|here)/g,"@​$1").replace(/<@!?[0-9]+>/g,t=>{const e=t.replace(/<|!|>|@/g,"");if("dm"===this.channel.type||"group"===this.channel.type)return this.client.users.has(e)?`@${this.client.users.get(e).username}`:t;const n=this.channel.guild.members.get(e);if(n)return n.nickname?`@${n.nickname}`:`@${n.user.username}`;{const n=this.client.users.get(e);return n?`@${n.username}`:t}}).replace(/<#[0-9]+>/g,t=>{const e=this.client.channels.get(t.replace(/<|#|>/g,""));return e?`#${e.name}`:t}).replace(/<@&[0-9]+>/g,t=>{if("dm"===this.channel.type||"group"===this.channel.type)return t;const e=this.guild.roles.get(t.replace(/<|@|>|&/g,""));return e?`@${e.name}`:t})}get edits(){const t=this._edits.slice();return t.unshift(this),t}get editable(){return this.author.id===this.client.user.id}get deletable(){return this.author.id===this.client.user.id||this.guild&&this.channel.permissionsFor(this.client.user).hasPermission(h.FLAGS.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).hasPermission(h.FLAGS.MANAGE_MESSAGES)}isMentioned(t){return t=t&&t.id?t.id:t,this.mentions.users.has(t)||this.mentions.channels.has(t)||this.mentions.roles.has(t)}isMemberMentioned(t){return a||(a=n(13)),!!this.mentions.everyone||(!!this.mentions.users.has(t.id)||!!(t instanceof a&&t.roles.some(t=>this.mentions.roles.has(t.id))))}edit(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),this.client.rest.methods.updateMessage(this,t,e)}editCode(t,e){return e=o.escapeMarkdown(this.client.resolver.resolveString(e),!0),this.edit(`\`\`\`${t||""} ${e} -\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(t){if(t=this.client.resolver.resolveEmojiIdentifier(t),!t)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,t)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(t=0){return t<=0?this.client.rest.methods.deleteMessage(this):new Promise(e=>{this.client.setTimeout(()=>{e(this.delete())},t)})}reply(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),this.channel.send(t,Object.assign(e,{reply:this.member||this.author}))}acknowledge(){return this.client.rest.methods.ackMessage(this)}fetchWebhook(){return this.webhookID?this.client.fetchWebhook(this.webhookID):Promise.reject(new Error("The message was not sent by a webhook."))}equals(t,e){if(!t)return!1;const n=!t.author&&!t.attachments;if(n)return this.id===t.id&&this.embeds.length===t.embeds.length;let i=this.id===t.id&&this.author.id===t.author.id&&this.content===t.content&&this.tts===t.tts&&this.nonce===t.nonce&&this.embeds.length===t.embeds.length&&this.attachments.length===t.attachments.length;return i&&e&&(i=this.mentions.everyone===t.mentions.everyone&&this.createdTimestamp===new Date(e.timestamp).getTime()&&this.editedTimestamp===new Date(e.edited_timestamp).getTime()),i}toString(){return this.content}_addReaction(t,e){const n=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);let i;return this.reactions.has(n)?(i=this.reactions.get(n),i.me||(i.me=e.id===this.client.user.id)):(i=new r(this,t,0,e.id===this.client.user.id),this.reactions.set(n,i)),i.users.has(e.id)||i.users.set(e.id,e),i.count++,i}_removeReaction(t,e){const n=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);if(this.reactions.has(n)){const t=this.reactions.get(n);if(t.users.has(e.id))return t.users.delete(e.id),t.count--,e.id===this.client.user.id&&(t.me=!1),t}return null}_clearReactions(){this.reactions.clear()}}t.exports=l},function(t,e,n){const i=n(5),s=n(6);class r{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,e&&this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.color=t.color,this.hoist=t.hoist,this.position=t.position,this.permissions=t.permissions,this.managed=t.managed,this.mentionable=t.mentionable}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get hexColor(){let t=this.color.toString(16);for(;t.length<6;)t=`0${t}`;return`#${t}`}get members(){return this.guild.members.filter(t=>t.roles.has(this.id))}get editable(){if(this.managed)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(s.FLAGS.MANAGE_ROLES_OR_PERMISSIONS)&&t.highestRole.comparePositionTo(this)>0}get calculatedPosition(){const t=this.guild.roles.array().sort((t,e)=>t.position!==e.position?t.position-e.position:t.id-e.id);return t.indexOf(t.find(t=>t.id===this.id))}serialize(){return new s(this.permissions).serialize()}hasPermission(t,e=false,n){return new s(this.permissions).has(t,"undefined"!=typeof n?n:!e)}hasPermissions(t,e=false){return new s(this.permissions).has(t,!e)}comparePositionTo(t){return this.constructor.comparePositions(this,t)}edit(t){return this.client.rest.methods.updateGuildRole(this,t)}setName(t){return this.edit({name:t})}setColor(t){return this.edit({color:t})}setHoist(t){return this.edit({hoist:t})}setPosition(t,e){return this.guild.setRolePosition(this,t,e).then(()=>this)}setPermissions(t){return this.edit({permissions:t})}setMentionable(t){return this.edit({mentionable:t})}delete(){return this.client.rest.methods.deleteGuildRole(this)}equals(t){return t&&this.id===t.id&&this.name===t.name&&this.color===t.color&&this.hoist===t.hoist&&this.position===t.position&&this.permissions===t.permissions&&this.managed===t.managed}toString(){return this.id===this.guild.id?"@everyone":`<@&${this.id}>`}static comparePositions(t,e){return t.position===e.position?e.id-t.id:t.position-e.position}}t.exports=r},function(t,e,n){const i=n(14),s=n(0),r=n(7).Presence,o=n(5);class u{constructor(t,e){Object.defineProperty(this,"client",{value:t}),e&&this.setup(e)}setup(t){this.id=t.id,this.username=t.username,this.discriminator=t.discriminator,this.avatar=t.avatar,this.bot=Boolean(t.bot),this.lastMessageID=null,this.lastMessage=null}patch(t){for(const e of["id","username","discriminator","avatar","bot"])"undefined"!=typeof t[e]&&(this[e]=t[e]);t.token&&(this.client.token=t.token)}get createdTimestamp(){return o.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get presence(){if(this.client.presences.has(this.id))return this.client.presences.get(this.id);for(const t of this.client.guilds.values())if(t.presences.has(this.id))return t.presences.get(this.id);return new r}get avatarURL(){return this.avatar?s.Endpoints.User(this).Avatar(this.client.options.http.cdn,this.avatar):null}get defaultAvatarURL(){const t=Object.keys(s.DefaultAvatars),e=t[this.discriminator%t.length];return s.Endpoints.assets(`${s.DefaultAvatars[e]}.png`)}get displayAvatarURL(){return this.avatarURL||this.defaultAvatarURL}get note(){return this.client.user.notes.get(this.id)||null}typingIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)}typingSinceIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?new Date(t._typing.get(this.id).since):null}typingDurationIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?t._typing.get(this.id).elapsedTime:-1}get dmChannel(){return this.client.channels.filter(t=>"dm"===t.type).find(t=>t.recipient.id===this.id)}createDM(){return this.client.rest.methods.createDM(this)}deleteDM(){return this.client.rest.methods.deleteChannel(this)}addFriend(){return this.client.rest.methods.addFriend(this)}removeFriend(){return this.client.rest.methods.removeFriend(this)}block(){return this.client.rest.methods.blockUser(this)}unblock(){return this.client.rest.methods.unblockUser(this)}fetchProfile(){return this.client.rest.methods.fetchUserProfile(this)}setNote(t){return this.client.rest.methods.setNote(this,t)}equals(t){let e=t&&this.id===t.id&&this.username===t.username&&this.discriminator===t.discriminator&&this.avatar===t.avatar&&this.bot===Boolean(t.bot);return e}toString(){return`<@${this.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}i.applyToClass(u),t.exports=u},function(t,e,n){const i=n(0),s=n(3),r=n(5);class o{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.requiresColons=t.require_colons,this.managed=t.managed,this._roles=t.roles}get createdTimestamp(){return r.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get roles(){const t=new s;for(const e of this._roles)this.guild.roles.has(e)&&t.set(e,this.guild.roles.get(e));return t}get url(){return i.Endpoints.emoji(this.id)}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}edit(t){return this.client.rest.methods.updateEmoji(this,t)}toString(){return this.requiresColons?`<:${this.name}:${this.id}>`:this.name}equals(t){return t instanceof o?t.id===this.id&&t.name===this.name&&t.managed===this.managed&&t.requiresColons===this.requiresColons:t.id===this.id&&t.name===this.name}}t.exports=o},function(t,e,n){const i=n(14),s=n(10),r=n(6),o=n(3),u=n(7).Presence;class c{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,this.user={},this._roles=[],e&&this.setup(e),this.lastMessageID=null,this.lastMessage=null}setup(t){this.serverDeaf=t.deaf,this.serverMute=t.mute,this.selfMute=t.self_mute,this.selfDeaf=t.self_deaf,this.voiceSessionID=t.session_id,this.voiceChannelID=t.channel_id,this.speaking=!1,this.nickname=t.nick||null,this.joinedTimestamp=new Date(t.joined_at).getTime(),this.user=t.user,this._roles=t.roles}get joinedAt(){return new Date(this.joinedTimestamp)}get presence(){return this.frozenPresence||this.guild.presences.get(this.id)||new u}get roles(){const t=new o,e=this.guild.roles.get(this.guild.id);e&&t.set(e.id,e);for(const n of this._roles){const e=this.guild.roles.get(n);e&&t.set(e.id,e)}return t}get highestRole(){return this.roles.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t)}get colorRole(){const t=this.roles.filter(t=>t.color);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get displayColor(){const t=this.colorRole;return t&&t.color||0}get displayHexColor(){const t=this.colorRole;return t&&t.hexColor||"#000000"}get hoistRole(){const t=this.roles.filter(t=>t.hoist);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get mute(){return this.selfMute||this.serverMute}get deaf(){return this.selfDeaf||this.serverDeaf}get voiceChannel(){return this.guild.channels.get(this.voiceChannelID)}get id(){return this.user.id}get displayName(){return this.nickname||this.user.username}get permissions(){if(this.user.id===this.guild.ownerID)return new r(this,r.ALL);let t=0;const e=this.roles;for(const n of e.values())t|=n.permissions;return new r(this,t)}get kickable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(r.FLAGS.KICK_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}get bannable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(r.FLAGS.BAN_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(t){if(t=this.client.resolver.resolveChannel(t),!t||!t.guild)throw new Error("Could not resolve channel to a guild channel.");return t.permissionsFor(this)}hasPermission(t,e=false,n,i){return"undefined"==typeof n&&(n=!e),"undefined"==typeof i&&(i=!e),!(!i||this.user.id!==this.guild.ownerID)||this.roles.some(e=>e.hasPermission(t,void 0,n))}hasPermissions(t,e=false){return!e&&this.user.id===this.guild.ownerID||t.every(t=>this.hasPermission(t,e))}missingPermissions(t,e=false){return t.filter(t=>!this.hasPermission(t,e))}edit(t){return this.client.rest.methods.updateGuildMember(this,t)}setMute(t){return this.edit({mute:t})}setDeaf(t){return this.edit({deaf:t})}setVoiceChannel(t){return this.edit({channel:t})}setRoles(t){return this.edit({roles:t})}addRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.addMemberRole(this,t)}addRoles(t){let e;if(t instanceof o){e=this._roles.slice();for(const n of t.values())e.push(n.id)}else e=this._roles.concat(t);return this.edit({roles:e})}removeRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.removeMemberRole(this,t)}removeRoles(t){const e=this._roles.slice();if(t instanceof o)for(const n of t.values()){const t=e.indexOf(n.id);t>=0&&e.splice(t,1)}else for(const n of t){const t=e.indexOf(n instanceof s?n.id:n);t>=0&&e.splice(t,1)}return this.edit({roles:e})}setNickname(t){return this.edit({nick:t})}createDM(){return this.user.createDM()}deleteDM(){return this.user.deleteDM()}kick(){return this.client.rest.methods.kickGuildMember(this.guild,this)}ban(t=0){return this.client.rest.methods.banGuildMember(this.guild,this,t)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}i.applyToClass(c),t.exports=c},function(t,e,n){const i=n(24),s=n(9),r=n(33),o=n(3);class u{constructor(){this.messages=new o,this.lastMessageID=null,this.lastMessage=null}send(t,e){if(e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),e.embed&&e.embed.file&&(e.file=e.embed.file),e.file&&(e.files?e.files.push(e.file):e.files=[e.file]),e.files){for(const n in e.files){let t=e.files[n];"string"==typeof t&&(t={attachment:t}),t.name||("string"==typeof t.attachment?t.name=i.basename(t.attachment):t.attachment&&t.attachment.path?t.name=i.basename(t.attachment.path):t.name="file.jpg"),e.files[n]=t}return Promise.all(e.files.map(t=>this.client.resolver.resolveBuffer(t.attachment).then(e=>{return t.file=e,t}))).then(n=>this.client.rest.methods.sendMessage(this,t,e,n))}return this.client.rest.methods.sendMessage(this,t,e)}sendMessage(t,e){return this.send(t,e)}sendEmbed(t,e,n){return n||"object"!=typeof e||e instanceof Array?n||(n={}):(n=e,e=""),this.send(e,Object.assign(n,{embed:t}))}sendFiles(t,e,n={}){return this.send(e,Object.assign(n,{files:t}))}sendFile(t,e,n,i={}){return this.sendFiles([{attachment:t,name:e}],n,i)}sendCode(t,e,n={}){return this.send(e,Object.assign(n,{code:t}))}fetchMessage(t){return this.client.user.bot?this.client.rest.methods.getChannelMessage(this,t).then(t=>{const e=t instanceof s?t:new s(this,t,this.client);return this._cacheMessage(e),e}):this.fetchMessages({limit:1,around:t}).then(e=>{const n=e.first();if(n.id!==t)throw new Error("Message not found.");return n})}fetchMessages(t={}){return this.client.rest.methods.getChannelMessages(this,t).then(t=>{const e=new o;for(const n of t){const t=new s(this,n,this.client);e.set(n.id,t),this._cacheMessage(t)}return e})}fetchPinnedMessages(){return this.client.rest.methods.getChannelPinnedMessages(this).then(t=>{const e=new o;for(const n of t){const t=new s(this,n,this.client);e.set(n.id,t),this._cacheMessage(t)}return e})}search(t){return this.client.rest.methods.search(this,t)}startTyping(t){if("undefined"!=typeof t&&t<1)throw new RangeError("Count must be at least 1.");if(this.client.user._typing.has(this.id)){const e=this.client.user._typing.get(this.id);e.count=t||e.count+1}else this.client.user._typing.set(this.id,{count:t||1,interval:this.client.setInterval(()=>{this.client.rest.methods.sendTyping(this.id)},9e3)}),this.client.rest.methods.sendTyping(this.id)}stopTyping(t=false){if(this.client.user._typing.has(this.id)){const e=this.client.user._typing.get(this.id);e.count--,(e.count<=0||t)&&(this.client.clearInterval(e.interval),this.client.user._typing.delete(this.id))}}get typing(){return this.client.user._typing.has(this.id)}get typingCount(){return this.client.user._typing.has(this.id)?this.client.user._typing.get(this.id).count:0}createCollector(t,e={}){return new r(this,t,e)}awaitMessages(t,e={}){return new Promise((n,i)=>{const s=this.createCollector(t,e);s.on("end",(t,s)=>{e.errors&&e.errors.includes(s)?i(t):n(t)})})}bulkDelete(t,e=false){if(!isNaN(t))return this.fetchMessages({limit:t}).then(t=>this.bulkDelete(t,e));if(t instanceof Array||t instanceof o){const n=t instanceof o?t.keyArray():t.map(t=>t.id);return this.client.rest.methods.bulkDeleteMessages(this,n,e)}throw new TypeError("The messages must be an Array, Collection, or number.")}acknowledge(){return this.client.rest.methods.ackTextMessage(this)}_cacheMessage(t){const e=this.client.options.messageCacheMaxSize;return 0===e?null:(this.messages.size>=e&&e>0&&this.messages.delete(this.messages.firstKey()),this.messages.set(t.id,t),t)}}e.applyToClass=((t,e=false,n=[])=>{const i=["send","sendMessage","sendEmbed","sendFile","sendFiles","sendCode"];e&&i.push("_cacheMessage","fetchMessages","fetchMessage","search","bulkDelete","startTyping","stopTyping","typing","typingCount","fetchPinnedMessages","createCollector","awaitMessages");for(const s of i)n.includes(s)||Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(u.prototype,s))})},function(t,e){e.endianness=function(){return"LE"},e.hostname=function(){return"undefined"!=typeof location?location.hostname:""},e.loadavg=function(){return[]},e.uptime=function(){return 0},e.freemem=function(){return Number.MAX_VALUE},e.totalmem=function(){return Number.MAX_VALUE},e.cpus=function(){return[]},e.type=function(){return"Browser"},e.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},e.networkInterfaces=e.getNetworkInterfaces=function(){return{}},e.arch=function(){return"javascript"},e.platform=function(){return"browser"},e.tmpdir=e.tmpDir=function(){return"/tmp"},e.EOL="\n"},function(t,e,n){const i=n(11),s=n(10),r=n(12),o=n(7).Presence,u=n(13),c=n(0),h=n(3),a=n(4),l=n(5);class f{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.members=new h,this.channels=new h,this.roles=new h,this.presences=new h,e&&(e.unavailable?(this.available=!1,this.id=e.id):(this.available=!0,this.setup(e)))}setup(t){this.name=t.name,this.icon=t.icon,this.splash=t.splash,this.region=t.region,this.memberCount=t.member_count||this.memberCount,this.large=Boolean("large"in t?t.large:this.large),this.features=t.features,this.applicationID=t.application_id,this.emojis=new h;for(const e of t.emojis)this.emojis.set(e.id,new r(this,e));if(this.afkTimeout=t.afk_timeout,this.afkChannelID=t.afk_channel_id,this.embedEnabled=t.embed_enabled,this.verificationLevel=t.verification_level,this.joinedTimestamp=t.joined_at?new Date(t.joined_at).getTime():this.joinedTimestamp,this.id=t.id,this.available=!t.unavailable,this.features=t.features||this.features||[],t.members){this.members.clear();for(const e of t.members)this._addMember(e,!1)}if(t.owner_id&&(this.ownerID=t.owner_id),t.channels){this.channels.clear();for(const e of t.channels)this.client.dataManager.newChannel(e,this)}if(t.roles){this.roles.clear();for(const e of t.roles){const t=new s(this,e);this.roles.set(t.id,t)}}if(t.presences)for(const n of t.presences)this._setPresence(n.user.id,n);if(this._rawVoiceStates=new h,t.voice_states)for(const i of t.voice_states){this._rawVoiceStates.set(i.user_id,i);const t=this.members.get(i.user_id);t&&(t.serverMute=i.mute,t.serverDeaf=i.deaf,t.selfMute=i.self_mute,t.selfDeaf=i.self_deaf,t.voiceSessionID=i.session_id,t.voiceChannelID=i.channel_id,this.channels.get(i.channel_id).members.set(t.user.id,t))}}get createdTimestamp(){return l.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}get iconURL(){return this.icon?c.Endpoints.Guild(this).Icon(this.client.options.http.cdn,this.icon):null}get splashURL(){return this.splash?c.Endpoints.Guild(this).Splash(this.client.options.http.cdn,this.splash):null}get owner(){return this.members.get(this.ownerID)}get voiceConnection(){return this.client.browser?null:this.client.voice.connections.get(this.id)||null}get defaultChannel(){return this.channels.get(this.id)}get defaultRole(){return this.roles.get(this.id)}member(t){return this.client.resolver.resolveGuildMember(this,t)}fetchBans(){return this.client.rest.methods.getGuildBans(this)}fetchInvites(){return this.client.rest.methods.getGuildInvites(this)}fetchWebhooks(){return this.client.rest.methods.getGuildWebhooks(this)}fetchVoiceRegions(){return this.client.rest.methods.fetchVoiceRegions(this.id)}addMember(t,e){return this.members.has(t.id)?Promise.resolve(this.members.get(t.id)):this.client.rest.methods.putGuildMember(this,t,e)}fetchMember(t,e=true){return t=this.client.resolver.resolveUser(t),t?this.members.has(t.id)?Promise.resolve(this.members.get(t.id)):this.client.rest.methods.getGuildMember(this,t,e):Promise.reject(new Error("User is not cached. Use Client.fetchUser first."))}fetchMembers(t="",e=0){return new Promise((n,i)=>{if(this.memberCount===this.members.size)return void n(this);this.client.ws.send({op:c.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:t,limit:e}});const s=(t,e)=>{e.id===this.id&&(this.memberCount===this.members.size||t.length<1e3)&&(this.client.removeListener(c.Events.GUILD_MEMBERS_CHUNK,s),n(this))};this.client.on(c.Events.GUILD_MEMBERS_CHUNK,s),this.client.setTimeout(()=>i(new Error("Members didn't arrive in time.")),12e4)})}search(t){return this.client.rest.methods.search(this,t)}edit(t){return this.client.rest.methods.updateGuild(this,t)}setName(t){return this.edit({name:t})}setRegion(t){return this.edit({region:t})}setVerificationLevel(t){return this.edit({verificationLevel:t})}setAFKChannel(t){return this.edit({afkChannel:t})}setAFKTimeout(t){return this.edit({afkTimeout:t})}setIcon(t){return this.edit({icon:t})}setOwner(t){return this.edit({owner:t})}setSplash(t){return this.edit({splash:t})}ban(t,e=0){return this.client.rest.methods.banGuildMember(this,t,e)}unban(t){return this.client.rest.methods.unbanGuildMember(this,t)}pruneMembers(t,e=false){if("number"!=typeof t)throw new TypeError("Days must be a number.");return this.client.rest.methods.pruneGuildMembers(this,t,e)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(t,e,n){return this.client.rest.methods.createChannel(this,t,e,n)}setChannelPositions(t){return this.client.rest.methods.updateChannelPositions(this.id,t)}createRole(t={}){return this.client.rest.methods.createGuildRole(this,t)}setRolePosition(t,e,n=false){if("string"==typeof t&&(t=this.roles.get(t),!t))return Promise.reject(new Error("Supplied role is not a role or string."));if(e=Number(e),isNaN(e))return Promise.reject(new Error("Supplied position is not a number."));let i=Object.assign([],this.roles.array().sort((t,e)=>t.position!==e.position?t.position-e.position:t.id-e.id));return a.moveElementInArray(i,t,e,n),i=i.map((t,e)=>({id:t.id,position:e})),this.client.rest.methods.setRolePositions(this.id,i)}createEmoji(t,e,n){return new Promise(i=>{"string"==typeof t&&t.startsWith("data:")?i(this.client.rest.methods.createEmoji(this,t,e,n)):this.client.resolver.resolveBuffer(t).then(t=>{const s=this.client.resolver.resolveBase64(t);i(this.client.rest.methods.createEmoji(this,s,e,n))})})}deleteEmoji(t){return t instanceof r||(t=this.emojis.get(t)),this.client.rest.methods.deleteEmoji(t)}leave(){return this.client.rest.methods.leaveGuild(this)}delete(){return this.client.rest.methods.deleteGuild(this)}acknowledge(){return this.client.rest.methods.ackGuild(this)}equals(t){let e=t&&this.id===t.id&&this.available===!t.unavailable&&this.splash===t.splash&&this.region===t.region&&this.name===t.name&&this.memberCount===t.member_count&&this.large===t.large&&this.icon===t.icon&&a.arraysEqual(this.features,t.features)&&this.ownerID===t.owner_id&&this.verificationLevel===t.verification_level&&this.embedEnabled===t.embed_enabled;return e&&(this.embedChannel?this.embedChannel.id!==t.embed_channel_id&&(e=!1):t.embed_channel_id&&(e=!1)),e}toString(){return this.name}_addMember(t,e=true){const n=this.members.has(t.user.id);t.user instanceof i||(t.user=this.client.dataManager.newUser(t.user)),t.joined_at=t.joined_at||0;const s=new u(this,t);if(this.members.set(s.id,s),this._rawVoiceStates&&this._rawVoiceStates.has(s.user.id)){const t=this._rawVoiceStates.get(s.user.id);s.serverMute=t.mute,s.serverDeaf=t.deaf,s.selfMute=t.self_mute,s.selfDeaf=t.self_deaf,s.voiceSessionID=t.session_id,s.voiceChannelID=t.channel_id,this.client.channels.has(t.channel_id)?this.client.channels.get(t.channel_id).members.set(s.user.id,s):this.client.emit("warn",`Member ${s.id} added in guild ${this.id} with an uncached voice channel`)}return this.client.ws.status===c.Status.READY&&e&&!n&&this.client.emit(c.Events.GUILD_MEMBER_ADD,s),s}_updateMember(t,e){const n=a.cloneObject(t);e.roles&&(t._roles=e.roles),"undefined"!=typeof e.nick&&(t.nickname=e.nick);const i=t.nickname!==n.nickname||!a.arraysEqual(t._roles,n._roles);return this.client.ws.status===c.Status.READY&&i&&this.client.emit(c.Events.GUILD_MEMBER_UPDATE,n,t),{old:n,mem:t}}_removeMember(t){this.members.delete(t.id)}_memberSpeakUpdate(t,e){const n=this.members.get(t);n&&n.speaking!==e&&(n.speaking=e,this.client.emit(c.Events.GUILD_MEMBER_SPEAKING,n,e))}_setPresence(t,e){return this.presences.get(t)?void this.presences.get(t).update(e):void this.presences.set(t,new o(e))}}t.exports=f},function(t,e,n){const i=n(8),s=n(10),r=n(39),o=n(6),u=n(3);class c extends i{constructor(t,e){super(t.client,e),this.guild=t}setup(t){if(super.setup(t),this.name=t.name,this.position=t.position,this.permissionOverwrites=new u,t.permission_overwrites)for(const e of t.permission_overwrites)this.permissionOverwrites.set(e.id,new r(this,e))}permissionsFor(t){if(t=this.client.resolver.resolveGuildMember(this.guild,t),!t)return null;if(t.id===this.guild.ownerID)return new o(t,o.ALL);let e=0;const n=t.roles;for(const i of n.values())e|=i.permissions;const s=this.overwritesFor(t,!0,n);s.everyone&&(e&=~s.everyone.deny,e|=s.everyone.allow);let r=0;for(const u of s.roles)e&=~u.deny,r|=u.allow;e|=r,s.member&&(e&=~s.member.deny,e|=s.member.allow);const c=Boolean(e&o.FLAGS.ADMINISTRATOR);return c&&(e=o.ALL),new o(t,e)}overwritesFor(t,e=false,n=null){if(e||(t=this.client.resolver.resolveGuildMember(this.guild,t)),!t)return[];n=n||t.roles;const i=[];let s,r;for(const o of this.permissionOverwrites.values())o.id===this.guild.id?r=o:n.has(o.id)?i.push(o):o.id===t.id&&(s=o);return{everyone:r,roles:i,member:s}}overwritePermissions(t,e){const n={allow:0,deny:0};if(t instanceof s)n.type="role";else if(this.guild.roles.has(t))t=this.guild.roles.get(t),n.type="role";else if(t=this.client.resolver.resolveUser(t),n.type="member",!t)return Promise.reject(new TypeError("Supplied parameter was neither a User nor a Role."));n.id=t.id;const i=this.permissionOverwrites.get(t.id);i&&(n.allow=i.allow,n.deny=i.deny);for(const r in e)e[r]===!0?(n.allow|=o.FLAGS[r]||0,n.deny&=~(o.FLAGS[r]||0)):e[r]===!1?(n.allow&=~(o.FLAGS[r]||0),n.deny|=o.FLAGS[r]||0):null===e[r]&&(n.allow&=~(o.FLAGS[r]||0),n.deny&=~(o.FLAGS[r]||0));return this.client.rest.methods.setChannelOverwrite(this,n)}edit(t){return this.client.rest.methods.updateChannel(this,t)}setName(t){return this.edit({name:t})}setPosition(t){return this.client.rest.methods.updateChannel(this,{position:t})}setTopic(t){return this.client.rest.methods.updateChannel(this,{topic:t})}createInvite(t={}){return this.client.rest.methods.createChannelInvite(this,t)}clone(t=this.name,e=true,n=true){return this.guild.createChannel(t,this.type,e?this.permissionOverwrites:[]).then(t=>n?t.setTopic(this.topic):t)}equals(t){let e=t&&this.id===t.id&&this.type===t.type&&this.topic===t.topic&&this.position===t.position&&this.name===t.name;return e&&(e=this.permissionOverwrites&&t.permissionOverwrites?this.permissionOverwrites.equals(t.permissionOverwrites):!this.permissionOverwrites&&!t.permissionOverwrites),e}get deletable(){return this.id!==this.guild.id&&this.permissionsFor(this.client.user).hasPermission(o.FLAGS.MANAGE_CHANNELS)}toString(){return`<#${this.id}>`}}t.exports=c},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(t){if(a===setTimeout)return setTimeout(t,0);if((a===n||!a)&&setTimeout)return a=setTimeout,setTimeout(t,0);try{return a(t,0)}catch(e){try{return a.call(null,t,0)}catch(e){return a.call(this,t,0)}}}function r(t){if(l===clearTimeout)return clearTimeout(t);if((l===i||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function o(){m&&d&&(m=!1,d.length?p=d.concat(p):g=-1,p.length&&u())}function u(){if(!m){var t=s(o);m=!0;for(var e=p.length;e;){for(d=p,p=[];++g1)for(var n=1;n[t.id,t.nick]))),this.recipients||(this.recipients=new r),t.recipients)for(const e of t.recipients){const t=this.client.dataManager.newUser(e);this.recipients.set(t.id,t)}this.lastMessageID=t.last_message_id}get owner(){return this.client.users.get(this.ownerID)}equals(t){const e=t&&this.id===t.id&&this.name===t.name&&this.icon===t.icon&&this.ownerID===t.ownerID;return e?this.recipients.equals(t.recipients):e}addUser(t,e){return this.client.rest.methods.addUserToGroupDM(this,{nick:e,id:this.client.resolver.resolveUserID(t),accessToken:t})}toString(){return this.name}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendFiles(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0,["bulkDelete"]),t.exports=o},function(t,e){class n{constructor(t,e,n){this.reaction=t,this.name=e,this.id=n}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}toString(){return this.id?`<:${this.name}:${this.id}>`:this.name}}t.exports=n},function(t,e,n){const i=n(24);class s{constructor(t,e,n){t?(Object.defineProperty(this,"client",{value:t}),e&&this.setup(e)):(this.id=e,this.token=n,Object.defineProperty(this,"client",{value:this}))}setup(t){this.name=t.name,this.token=t.token,this.avatar=t.avatar,this.id=t.id,this.guildID=t.guild_id,this.channelID=t.channel_id,t.user?this.owner=this.client.users?this.client.users.get(t.user.id):t.user:this.owner=null}send(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),e.file?("string"==typeof e.file&&(e.file={attachment:e.file}),e.file.name||("string"==typeof e.file.attachment?e.file.name=i.basename(e.file.attachment):e.file.attachment&&e.file.attachment.path?e.file.name=i.basename(e.file.attachment.path):e.file.name="file.jpg"),this.client.resolver.resolveBuffer(e.file.attachment).then(n=>this.client.rest.methods.sendWebhookMessage(this,t,e,{file:n,name:e.file.name}))):this.client.rest.methods.sendWebhookMessage(this,t,e)}sendMessage(t,e={}){return this.send(t,e)}sendFile(t,e,n,i={}){return this.send(n,Object.assign(i,{file:{attachment:t,name:e}}))}sendCode(t,e,n={}){return this.send(e,Object.assign(n,{code:t}))}sendSlackMessage(t){return this.client.rest.methods.sendSlackWebhookMessage(this,t)}edit(t=this.name,e){return e?this.client.resolver.resolveBuffer(e).then(e=>{const n=this.client.resolver.resolveBase64(e);return this.client.rest.methods.editWebhook(this,t,n)}):this.client.rest.methods.editWebhook(this,t).then(t=>{return this.setup(t),this})}delete(){return this.client.rest.methods.deleteWebhook(this)}}t.exports=s},function(t,e,n){"use strict";(function(t){function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function s(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function r(t,e){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),o.alloc(+t)}function E(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(t).length;default:if(i)return W(t).length;e=(""+e).toLowerCase(),i=!0}}function _(t,e,n){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,n);case"utf8":case"utf-8":return I(this,e,n);case"ascii":return U(this,e,n);case"latin1":case"binary":return L(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function v(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function y(t,e,n,i,s){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof e&&(e=o.from(e,i)),o.isBuffer(e))return 0===e.length?-1:w(t,e,n,i,s);if("number"==typeof e)return e&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):w(t,[e],n,i,s);throw new TypeError("val must be string, number or Buffer")}function w(t,e,n,i,s){function r(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,u=t.length,c=e.length;if(void 0!==i&&(i=String(i).toLowerCase(),"ucs2"===i||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,u/=2,c/=2,n/=2}var h;if(s){var a=-1;for(h=n;hu&&(n=u-c),h=n;h>=0;h--){for(var l=!0,f=0;fs&&(i=s)):i=s;var r=e.length;if(r%2!==0)throw new TypeError("Invalid hex string");i>r/2&&(i=r/2);for(var o=0;o239?4:r>223?3:r>191?2:1;if(s+u<=n){var c,h,a,l;switch(u){case 1:r<128&&(o=r);break;case 2:c=t[s+1],128===(192&c)&&(l=(31&r)<<6|63&c,l>127&&(o=l));break;case 3:c=t[s+1],h=t[s+2],128===(192&c)&&128===(192&h)&&(l=(15&r)<<12|(63&c)<<6|63&h,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:c=t[s+1],h=t[s+2],a=t[s+3],128===(192&c)&&128===(192&h)&&128===(192&a)&&(l=(15&r)<<18|(63&c)<<12|(63&h)<<6|63&a,l>65535&&l<1114112&&(o=l))}}null===o?(o=65533,u=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),s+=u}return C(i)}function C(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var n="",i=0;ii)&&(n=i);for(var s="",r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,n,i,s,r){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function G(t,e,n,i){e<0&&(e=65535+e+1);for(var s=0,r=Math.min(t.length-n,2);s>>8*(i?s:1-s)}function x(t,e,n,i){e<0&&(e=4294967295+e+1);for(var s=0,r=Math.min(t.length-n,4);s>>8*(i?s:3-s)&255}function j(t,e,n,i,s,r){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(t,e,n,i,s){return s||j(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(t,e,n,i,23,4),n+4}function q(t,e,n,i,s){return s||j(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(t,e,n,i,52,8),n+8}function H(t){if(t=V(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function V(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Y(t){return t<16?"0"+t.toString(16):t.toString(16)}function W(t,e){e=e||1/0;for(var n,i=t.length,s=null,r=[],o=0;o55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&r.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&r.push(239,191,189),s=n;continue}n=(s-55296<<10|n-56320)+65536}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;r.push(n)}else if(n<2048){if((e-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;r.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function F(t){for(var e=[],n=0;n>8,s=n%256,r.push(s),r.push(i);return r}function z(t){return $.toByteArray(H(t))}function X(t,e,n,i){for(var s=0;s=e.length||s>=t.length);++s)e[s+n]=t[s];return s}function J(t){return t!==t}/*! +\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(t){if(t=this.client.resolver.resolveEmojiIdentifier(t),!t)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,t)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(t=0){return t<=0?this.client.rest.methods.deleteMessage(this):new Promise(e=>{this.client.setTimeout(()=>{e(this.delete())},t)})}reply(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),this.channel.send(t,Object.assign(e,{reply:this.member||this.author}))}acknowledge(){return this.client.rest.methods.ackMessage(this)}fetchWebhook(){return this.webhookID?this.client.fetchWebhook(this.webhookID):Promise.reject(new Error("The message was not sent by a webhook."))}equals(t,e){if(!t)return!1;const n=!t.author&&!t.attachments;if(n)return this.id===t.id&&this.embeds.length===t.embeds.length;let i=this.id===t.id&&this.author.id===t.author.id&&this.content===t.content&&this.tts===t.tts&&this.nonce===t.nonce&&this.embeds.length===t.embeds.length&&this.attachments.length===t.attachments.length;return i&&e&&(i=this.mentions.everyone===t.mentions.everyone&&this.createdTimestamp===new Date(e.timestamp).getTime()&&this.editedTimestamp===new Date(e.edited_timestamp).getTime()),i}toString(){return this.content}_addReaction(t,e){const n=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);let i;return this.reactions.has(n)?(i=this.reactions.get(n),i.me||(i.me=e.id===this.client.user.id)):(i=new r(this,t,0,e.id===this.client.user.id),this.reactions.set(n,i)),i.users.has(e.id)||i.users.set(e.id,e),i.count++,i}_removeReaction(t,e){const n=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);if(this.reactions.has(n)){const t=this.reactions.get(n);if(t.users.has(e.id))return t.users.delete(e.id),t.count--,e.id===this.client.user.id&&(t.me=!1),t}return null}_clearReactions(){this.reactions.clear()}}t.exports=l},function(t,e,n){const i=n(5),s=n(6);class r{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,e&&this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.color=t.color,this.hoist=t.hoist,this.position=t.position,this.permissions=t.permissions,this.managed=t.managed,this.mentionable=t.mentionable}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get hexColor(){let t=this.color.toString(16);for(;t.length<6;)t=`0${t}`;return`#${t}`}get members(){return this.guild.members.filter(t=>t.roles.has(this.id))}get editable(){if(this.managed)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(s.FLAGS.MANAGE_ROLES_OR_PERMISSIONS)&&t.highestRole.comparePositionTo(this)>0}get calculatedPosition(){const t=this.guild._sortedRoles();return t.array().indexOf(t.get(this.id))}serialize(){return new s(this.permissions).serialize()}hasPermission(t,e=false,n){return new s(this.permissions).has(t,"undefined"!=typeof n?n:!e)}hasPermissions(t,e=false){return new s(this.permissions).has(t,!e)}comparePositionTo(t){return this.constructor.comparePositions(this,t)}edit(t){return this.client.rest.methods.updateGuildRole(this,t)}setName(t){return this.edit({name:t})}setColor(t){return this.edit({color:t})}setHoist(t){return this.edit({hoist:t})}setPosition(t,e){return this.guild.setRolePosition(this,t,e).then(()=>this)}setPermissions(t){return this.edit({permissions:t})}setMentionable(t){return this.edit({mentionable:t})}delete(){return this.client.rest.methods.deleteGuildRole(this)}equals(t){return t&&this.id===t.id&&this.name===t.name&&this.color===t.color&&this.hoist===t.hoist&&this.position===t.position&&this.permissions===t.permissions&&this.managed===t.managed}toString(){return this.id===this.guild.id?"@everyone":`<@&${this.id}>`}static comparePositions(t,e){return t.position===e.position?e.id-t.id:t.position-e.position}}t.exports=r},function(t,e,n){const i=n(14),s=n(0),r=n(7).Presence,o=n(5);class u{constructor(t,e){Object.defineProperty(this,"client",{value:t}),e&&this.setup(e)}setup(t){this.id=t.id,this.username=t.username,this.discriminator=t.discriminator,this.avatar=t.avatar,this.bot=Boolean(t.bot),this.lastMessageID=null,this.lastMessage=null}patch(t){for(const e of["id","username","discriminator","avatar","bot"])"undefined"!=typeof t[e]&&(this[e]=t[e]);t.token&&(this.client.token=t.token)}get createdTimestamp(){return o.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get presence(){if(this.client.presences.has(this.id))return this.client.presences.get(this.id);for(const t of this.client.guilds.values())if(t.presences.has(this.id))return t.presences.get(this.id);return new r}get avatarURL(){return this.avatar?s.Endpoints.User(this).Avatar(this.client.options.http.cdn,this.avatar):null}get defaultAvatarURL(){const t=Object.keys(s.DefaultAvatars),e=t[this.discriminator%t.length];return s.Endpoints.assets(`${s.DefaultAvatars[e]}.png`)}get displayAvatarURL(){return this.avatarURL||this.defaultAvatarURL}get note(){return this.client.user.notes.get(this.id)||null}typingIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)}typingSinceIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?new Date(t._typing.get(this.id).since):null}typingDurationIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?t._typing.get(this.id).elapsedTime:-1}get dmChannel(){return this.client.channels.filter(t=>"dm"===t.type).find(t=>t.recipient.id===this.id)}createDM(){return this.client.rest.methods.createDM(this)}deleteDM(){return this.client.rest.methods.deleteChannel(this)}addFriend(){return this.client.rest.methods.addFriend(this)}removeFriend(){return this.client.rest.methods.removeFriend(this)}block(){return this.client.rest.methods.blockUser(this)}unblock(){return this.client.rest.methods.unblockUser(this)}fetchProfile(){return this.client.rest.methods.fetchUserProfile(this)}setNote(t){return this.client.rest.methods.setNote(this,t)}equals(t){let e=t&&this.id===t.id&&this.username===t.username&&this.discriminator===t.discriminator&&this.avatar===t.avatar&&this.bot===Boolean(t.bot);return e}toString(){return`<@${this.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}i.applyToClass(u),t.exports=u},function(t,e,n){const i=n(0),s=n(3),r=n(5);class o{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.requiresColons=t.require_colons,this.managed=t.managed,this._roles=t.roles}get createdTimestamp(){return r.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get roles(){const t=new s;for(const e of this._roles)this.guild.roles.has(e)&&t.set(e,this.guild.roles.get(e));return t}get url(){return i.Endpoints.emoji(this.id)}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}edit(t){return this.client.rest.methods.updateEmoji(this,t)}toString(){return this.requiresColons?`<:${this.name}:${this.id}>`:this.name}equals(t){return t instanceof o?t.id===this.id&&t.name===this.name&&t.managed===this.managed&&t.requiresColons===this.requiresColons:t.id===this.id&&t.name===this.name}}t.exports=o},function(t,e,n){const i=n(14),s=n(10),r=n(6),o=n(3),u=n(7).Presence;class c{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,this.user={},this._roles=[],e&&this.setup(e),this.lastMessageID=null,this.lastMessage=null}setup(t){this.serverDeaf=t.deaf,this.serverMute=t.mute,this.selfMute=t.self_mute,this.selfDeaf=t.self_deaf,this.voiceSessionID=t.session_id,this.voiceChannelID=t.channel_id,this.speaking=!1,this.nickname=t.nick||null,this.joinedTimestamp=new Date(t.joined_at).getTime(),this.user=t.user,this._roles=t.roles}get joinedAt(){return new Date(this.joinedTimestamp)}get presence(){return this.frozenPresence||this.guild.presences.get(this.id)||new u}get roles(){const t=new o,e=this.guild.roles.get(this.guild.id);e&&t.set(e.id,e);for(const n of this._roles){const e=this.guild.roles.get(n);e&&t.set(e.id,e)}return t}get highestRole(){return this.roles.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t)}get colorRole(){const t=this.roles.filter(t=>t.color);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get displayColor(){const t=this.colorRole;return t&&t.color||0}get displayHexColor(){const t=this.colorRole;return t&&t.hexColor||"#000000"}get hoistRole(){const t=this.roles.filter(t=>t.hoist);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get mute(){return this.selfMute||this.serverMute}get deaf(){return this.selfDeaf||this.serverDeaf}get voiceChannel(){return this.guild.channels.get(this.voiceChannelID)}get id(){return this.user.id}get displayName(){return this.nickname||this.user.username}get permissions(){if(this.user.id===this.guild.ownerID)return new r(this,r.ALL);let t=0;const e=this.roles;for(const n of e.values())t|=n.permissions;return new r(this,t)}get kickable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(r.FLAGS.KICK_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}get bannable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(r.FLAGS.BAN_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(t){if(t=this.client.resolver.resolveChannel(t),!t||!t.guild)throw new Error("Could not resolve channel to a guild channel.");return t.permissionsFor(this)}hasPermission(t,e=false,n,i){return"undefined"==typeof n&&(n=!e),"undefined"==typeof i&&(i=!e),!(!i||this.user.id!==this.guild.ownerID)||this.roles.some(e=>e.hasPermission(t,void 0,n))}hasPermissions(t,e=false){return!e&&this.user.id===this.guild.ownerID||t.every(t=>this.hasPermission(t,e))}missingPermissions(t,e=false){return t.filter(t=>!this.hasPermission(t,e))}edit(t){return this.client.rest.methods.updateGuildMember(this,t)}setMute(t){return this.edit({mute:t})}setDeaf(t){return this.edit({deaf:t})}setVoiceChannel(t){return this.edit({channel:t})}setRoles(t){return this.edit({roles:t})}addRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.addMemberRole(this,t)}addRoles(t){let e;if(t instanceof o){e=this._roles.slice();for(const n of t.values())e.push(n.id)}else e=this._roles.concat(t);return this.edit({roles:e})}removeRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.removeMemberRole(this,t)}removeRoles(t){const e=this._roles.slice();if(t instanceof o)for(const n of t.values()){const t=e.indexOf(n.id);t>=0&&e.splice(t,1)}else for(const n of t){const t=e.indexOf(n instanceof s?n.id:n);t>=0&&e.splice(t,1)}return this.edit({roles:e})}setNickname(t){return this.edit({nick:t})}createDM(){return this.user.createDM()}deleteDM(){return this.user.deleteDM()}kick(){return this.client.rest.methods.kickGuildMember(this.guild,this)}ban(t=0){return this.client.rest.methods.banGuildMember(this.guild,this,t)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}i.applyToClass(c),t.exports=c},function(t,e,n){const i=n(25),s=n(9),r=n(34),o=n(3);class u{constructor(){this.messages=new o,this.lastMessageID=null,this.lastMessage=null}send(t,e){if(e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),e.embed&&e.embed.file&&(e.file=e.embed.file),e.file&&(e.files?e.files.push(e.file):e.files=[e.file]),e.files){for(const n in e.files){let t=e.files[n];"string"==typeof t&&(t={attachment:t}),t.name||("string"==typeof t.attachment?t.name=i.basename(t.attachment):t.attachment&&t.attachment.path?t.name=i.basename(t.attachment.path):t.name="file.jpg"),e.files[n]=t}return Promise.all(e.files.map(t=>this.client.resolver.resolveBuffer(t.attachment).then(e=>{return t.file=e,t}))).then(n=>this.client.rest.methods.sendMessage(this,t,e,n))}return this.client.rest.methods.sendMessage(this,t,e)}sendMessage(t,e){return this.send(t,e)}sendEmbed(t,e,n){return n||"object"!=typeof e||e instanceof Array?n||(n={}):(n=e,e=""),this.send(e,Object.assign(n,{embed:t}))}sendFiles(t,e,n={}){return this.send(e,Object.assign(n,{files:t}))}sendFile(t,e,n,i={}){return this.sendFiles([{attachment:t,name:e}],n,i)}sendCode(t,e,n={}){return this.send(e,Object.assign(n,{code:t}))}fetchMessage(t){return this.client.user.bot?this.client.rest.methods.getChannelMessage(this,t).then(t=>{const e=t instanceof s?t:new s(this,t,this.client);return this._cacheMessage(e),e}):this.fetchMessages({limit:1,around:t}).then(e=>{const n=e.first();if(n.id!==t)throw new Error("Message not found.");return n})}fetchMessages(t={}){return this.client.rest.methods.getChannelMessages(this,t).then(t=>{const e=new o;for(const n of t){const t=new s(this,n,this.client);e.set(n.id,t),this._cacheMessage(t)}return e})}fetchPinnedMessages(){return this.client.rest.methods.getChannelPinnedMessages(this).then(t=>{const e=new o;for(const n of t){const t=new s(this,n,this.client);e.set(n.id,t),this._cacheMessage(t)}return e})}search(t){return this.client.rest.methods.search(this,t)}startTyping(t){if("undefined"!=typeof t&&t<1)throw new RangeError("Count must be at least 1.");if(this.client.user._typing.has(this.id)){const e=this.client.user._typing.get(this.id);e.count=t||e.count+1}else this.client.user._typing.set(this.id,{count:t||1,interval:this.client.setInterval(()=>{this.client.rest.methods.sendTyping(this.id)},9e3)}),this.client.rest.methods.sendTyping(this.id)}stopTyping(t=false){if(this.client.user._typing.has(this.id)){const e=this.client.user._typing.get(this.id);e.count--,(e.count<=0||t)&&(this.client.clearInterval(e.interval),this.client.user._typing.delete(this.id))}}get typing(){return this.client.user._typing.has(this.id)}get typingCount(){return this.client.user._typing.has(this.id)?this.client.user._typing.get(this.id).count:0}createCollector(t,e={}){return new r(this,t,e)}awaitMessages(t,e={}){return new Promise((n,i)=>{const s=this.createCollector(t,e);s.on("end",(t,s)=>{e.errors&&e.errors.includes(s)?i(t):n(t)})})}bulkDelete(t,e=false){if(!isNaN(t))return this.fetchMessages({limit:t}).then(t=>this.bulkDelete(t,e));if(t instanceof Array||t instanceof o){const n=t instanceof o?t.keyArray():t.map(t=>t.id);return this.client.rest.methods.bulkDeleteMessages(this,n,e)}throw new TypeError("The messages must be an Array, Collection, or number.")}acknowledge(){return this.client.rest.methods.ackTextMessage(this)}_cacheMessage(t){const e=this.client.options.messageCacheMaxSize;return 0===e?null:(this.messages.size>=e&&e>0&&this.messages.delete(this.messages.firstKey()),this.messages.set(t.id,t),t)}}e.applyToClass=((t,e=false,n=[])=>{const i=["send","sendMessage","sendEmbed","sendFile","sendFiles","sendCode"];e&&i.push("_cacheMessage","fetchMessages","fetchMessage","search","bulkDelete","startTyping","stopTyping","typing","typingCount","fetchPinnedMessages","createCollector","awaitMessages");for(const s of i)n.includes(s)||Object.defineProperty(t.prototype,s,Object.getOwnPropertyDescriptor(u.prototype,s))})},function(t,e){e.endianness=function(){return"LE"},e.hostname=function(){return"undefined"!=typeof location?location.hostname:""},e.loadavg=function(){return[]},e.uptime=function(){return 0},e.freemem=function(){return Number.MAX_VALUE},e.totalmem=function(){return Number.MAX_VALUE},e.cpus=function(){return[]},e.type=function(){return"Browser"},e.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},e.networkInterfaces=e.getNetworkInterfaces=function(){return{}},e.arch=function(){return"javascript"},e.platform=function(){return"browser"},e.tmpdir=e.tmpDir=function(){return"/tmp"},e.EOL="\n"},function(t,e,n){const i=n(24),s=n(11),r=n(10),o=n(12),u=n(7).Presence,c=n(13),h=n(0),a=n(3),l=n(4),f=n(5);class d{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.members=new a,this.channels=new a,this.roles=new a,this.presences=new a,e&&(e.unavailable?(this.available=!1,this.id=e.id):(this.available=!0,this.setup(e)))}setup(t){this.name=t.name,this.icon=t.icon,this.splash=t.splash,this.region=t.region,this.memberCount=t.member_count||this.memberCount,this.large=Boolean("large"in t?t.large:this.large),this.features=t.features,this.applicationID=t.application_id,this.emojis=new a;for(const e of t.emojis)this.emojis.set(e.id,new o(this,e));if(this.afkTimeout=t.afk_timeout,this.afkChannelID=t.afk_channel_id,this.embedEnabled=t.embed_enabled,this.verificationLevel=t.verification_level,this.joinedTimestamp=t.joined_at?new Date(t.joined_at).getTime():this.joinedTimestamp,this.id=t.id,this.available=!t.unavailable,this.features=t.features||this.features||[],t.members){this.members.clear();for(const e of t.members)this._addMember(e,!1)}if(t.owner_id&&(this.ownerID=t.owner_id),t.channels){this.channels.clear();for(const e of t.channels)this.client.dataManager.newChannel(e,this)}if(t.roles){this.roles.clear();for(const e of t.roles){const t=new r(this,e);this.roles.set(t.id,t)}}if(t.presences)for(const n of t.presences)this._setPresence(n.user.id,n);if(this._rawVoiceStates=new a,t.voice_states)for(const i of t.voice_states){this._rawVoiceStates.set(i.user_id,i);const t=this.members.get(i.user_id);t&&(t.serverMute=i.mute,t.serverDeaf=i.deaf,t.selfMute=i.self_mute,t.selfDeaf=i.self_deaf,t.voiceSessionID=i.session_id,t.voiceChannelID=i.channel_id,this.channels.get(i.channel_id).members.set(t.user.id,t))}}get createdTimestamp(){return f.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}get iconURL(){return this.icon?h.Endpoints.Guild(this).Icon(this.client.options.http.cdn,this.icon):null}get splashURL(){return this.splash?h.Endpoints.Guild(this).Splash(this.client.options.http.cdn,this.splash):null}get owner(){return this.members.get(this.ownerID)}get voiceConnection(){return this.client.browser?null:this.client.voice.connections.get(this.id)||null}get defaultChannel(){return this.channels.get(this.id)}get defaultRole(){return this.roles.get(this.id)}get _sortedRoles(){return this._sortPositionWithID(this.roles)}member(t){return this.client.resolver.resolveGuildMember(this,t)}fetchBans(){return this.client.rest.methods.getGuildBans(this)}fetchInvites(){return this.client.rest.methods.getGuildInvites(this)}fetchWebhooks(){return this.client.rest.methods.getGuildWebhooks(this)}fetchVoiceRegions(){return this.client.rest.methods.fetchVoiceRegions(this.id)}addMember(t,e){return this.members.has(t.id)?Promise.resolve(this.members.get(t.id)):this.client.rest.methods.putGuildMember(this,t,e)}fetchMember(t,e=true){return t=this.client.resolver.resolveUser(t),t?this.members.has(t.id)?Promise.resolve(this.members.get(t.id)):this.client.rest.methods.getGuildMember(this,t,e):Promise.reject(new Error("User is not cached. Use Client.fetchUser first."))}fetchMembers(t="",e=0){return new Promise((n,i)=>{if(this.memberCount===this.members.size)return void n(this);this.client.ws.send({op:h.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:t,limit:e}});const s=(t,e)=>{e.id===this.id&&(this.memberCount===this.members.size||t.length<1e3)&&(this.client.removeListener(h.Events.GUILD_MEMBERS_CHUNK,s),n(this))};this.client.on(h.Events.GUILD_MEMBERS_CHUNK,s),this.client.setTimeout(()=>i(new Error("Members didn't arrive in time.")),12e4)})}search(t){return this.client.rest.methods.search(this,t)}edit(t){return this.client.rest.methods.updateGuild(this,t)}setName(t){return this.edit({name:t})}setRegion(t){return this.edit({region:t})}setVerificationLevel(t){return this.edit({verificationLevel:t})}setAFKChannel(t){return this.edit({afkChannel:t})}setAFKTimeout(t){return this.edit({afkTimeout:t})}setIcon(t){return this.edit({icon:t})}setOwner(t){return this.edit({owner:t})}setSplash(t){return this.edit({splash:t})}ban(t,e=0){return this.client.rest.methods.banGuildMember(this,t,e)}unban(t){return this.client.rest.methods.unbanGuildMember(this,t)}pruneMembers(t,e=false){if("number"!=typeof t)throw new TypeError("Days must be a number.");return this.client.rest.methods.pruneGuildMembers(this,t,e)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(t,e,n){return this.client.rest.methods.createChannel(this,t,e,n)}setChannelPositions(t){return this.client.rest.methods.updateChannelPositions(this.id,t)}createRole(t={}){return this.client.rest.methods.createGuildRole(this,t)}createEmoji(t,e,n){return new Promise(i=>{"string"==typeof t&&t.startsWith("data:")?i(this.client.rest.methods.createEmoji(this,t,e,n)):this.client.resolver.resolveBuffer(t).then(t=>{const s=this.client.resolver.resolveBase64(t);i(this.client.rest.methods.createEmoji(this,s,e,n))})})}deleteEmoji(t){return t instanceof o||(t=this.emojis.get(t)),this.client.rest.methods.deleteEmoji(t)}leave(){return this.client.rest.methods.leaveGuild(this)}delete(){return this.client.rest.methods.deleteGuild(this)}acknowledge(){return this.client.rest.methods.ackGuild(this)}equals(t){let e=t&&this.id===t.id&&this.available===!t.unavailable&&this.splash===t.splash&&this.region===t.region&&this.name===t.name&&this.memberCount===t.member_count&&this.large===t.large&&this.icon===t.icon&&l.arraysEqual(this.features,t.features)&&this.ownerID===t.owner_id&&this.verificationLevel===t.verification_level&&this.embedEnabled===t.embed_enabled;return e&&(this.embedChannel?this.embedChannel.id!==t.embed_channel_id&&(e=!1):t.embed_channel_id&&(e=!1)),e}toString(){return this.name}_addMember(t,e=true){const n=this.members.has(t.user.id);t.user instanceof s||(t.user=this.client.dataManager.newUser(t.user)),t.joined_at=t.joined_at||0;const i=new c(this,t);if(this.members.set(i.id,i),this._rawVoiceStates&&this._rawVoiceStates.has(i.user.id)){const t=this._rawVoiceStates.get(i.user.id);i.serverMute=t.mute,i.serverDeaf=t.deaf,i.selfMute=t.self_mute,i.selfDeaf=t.self_deaf,i.voiceSessionID=t.session_id,i.voiceChannelID=t.channel_id,this.client.channels.has(t.channel_id)?this.client.channels.get(t.channel_id).members.set(i.user.id,i):this.client.emit("warn",`Member ${i.id} added in guild ${this.id} with an uncached voice channel`)}return this.client.ws.status===h.Status.READY&&e&&!n&&this.client.emit(h.Events.GUILD_MEMBER_ADD,i),i}_updateMember(t,e){const n=l.cloneObject(t);e.roles&&(t._roles=e.roles),"undefined"!=typeof e.nick&&(t.nickname=e.nick);const i=t.nickname!==n.nickname||!l.arraysEqual(t._roles,n._roles);return this.client.ws.status===h.Status.READY&&i&&this.client.emit(h.Events.GUILD_MEMBER_UPDATE,n,t),{old:n,mem:t}}_removeMember(t){this.members.delete(t.id)}_memberSpeakUpdate(t,e){const n=this.members.get(t);n&&n.speaking!==e&&(n.speaking=e,this.client.emit(h.Events.GUILD_MEMBER_SPEAKING,n,e))}_setPresence(t,e){return this.presences.get(t)?void this.presences.get(t).update(e):void this.presences.set(t,new u(e))}setRolePosition(t,e,n=false){if("string"==typeof t&&(t=this.roles.get(t),!t))return Promise.reject(new Error("Supplied role is not a role or snowflake."));if(e=Number(e),isNaN(e))return Promise.reject(new Error("Supplied position is not a number."));let i=this._sortedRoles().array();return l.moveElementInArray(i,t,e,n),i=i.map((t,e)=>({id:t.id,position:e})),this.client.rest.methods.setRolePositions(this.id,i)}setChannelPosition(t,e,n=false){if("string"==typeof t&&(t=this.channels.get(t),!t))return Promise.reject(new Error("Supplied channel is not a channel or snowflake."));if(e=Number(e),isNaN(e))return Promise.reject(new Error("Supplied position is not a number."));let i=this._sortedChannels(t.type).array();return l.moveElementInArray(i,t,e,n),i=i.map((t,e)=>({id:t.id,position:e})),this.client.rest.methods.setChannelPositions(this.id,i)}_sortedChannels(t){return this._sortPositionWithID(this.channels.filter(e=>{return"voice"===t&&"voice"===e.type||("voice"!==t&&"voice"!==e.type||t===e.type)}))}_sortPositionWithID(t){return t.sort((t,e)=>t.position!==e.position?t.position-e.position:i.fromString(t.id).sub(i.fromString(e.id)).toNumber())}}t.exports=d},function(t,e,n){const i=n(8),s=n(10),r=n(40),o=n(6),u=n(3);class c extends i{constructor(t,e){super(t.client,e),this.guild=t}setup(t){if(super.setup(t),this.name=t.name,this.position=t.position,this.permissionOverwrites=new u,t.permission_overwrites)for(const e of t.permission_overwrites)this.permissionOverwrites.set(e.id,new r(this,e))}get calculatedPosition(){const t=this.guild._sortedChannels(this.type);return t.array().indexOf(t.get(this.id))}permissionsFor(t){if(t=this.client.resolver.resolveGuildMember(this.guild,t),!t)return null;if(t.id===this.guild.ownerID)return new o(t,o.ALL);let e=0;const n=t.roles;for(const i of n.values())e|=i.permissions;const s=this.overwritesFor(t,!0,n);s.everyone&&(e&=~s.everyone.deny,e|=s.everyone.allow);let r=0;for(const u of s.roles)e&=~u.deny,r|=u.allow;e|=r,s.member&&(e&=~s.member.deny,e|=s.member.allow);const c=Boolean(e&o.FLAGS.ADMINISTRATOR);return c&&(e=o.ALL),new o(t,e)}overwritesFor(t,e=false,n=null){if(e||(t=this.client.resolver.resolveGuildMember(this.guild,t)),!t)return[];n=n||t.roles;const i=[];let s,r;for(const o of this.permissionOverwrites.values())o.id===this.guild.id?r=o:n.has(o.id)?i.push(o):o.id===t.id&&(s=o);return{everyone:r,roles:i,member:s}}overwritePermissions(t,e){const n={allow:0,deny:0};if(t instanceof s)n.type="role";else if(this.guild.roles.has(t))t=this.guild.roles.get(t),n.type="role";else if(t=this.client.resolver.resolveUser(t),n.type="member",!t)return Promise.reject(new TypeError("Supplied parameter was neither a User nor a Role."));n.id=t.id;const i=this.permissionOverwrites.get(t.id);i&&(n.allow=i.allow,n.deny=i.deny);for(const r in e)e[r]===!0?(n.allow|=o.FLAGS[r]||0,n.deny&=~(o.FLAGS[r]||0)):e[r]===!1?(n.allow&=~(o.FLAGS[r]||0),n.deny|=o.FLAGS[r]||0):null===e[r]&&(n.allow&=~(o.FLAGS[r]||0),n.deny&=~(o.FLAGS[r]||0));return this.client.rest.methods.setChannelOverwrite(this,n)}edit(t){return this.client.rest.methods.updateChannel(this,t)}setName(t){return this.edit({name:t})}setPosition(t,e){return this.guild.setChannelPosition(this,t,e).then(()=>this)}setTopic(t){return this.client.rest.methods.updateChannel(this,{topic:t})}createInvite(t={}){return this.client.rest.methods.createChannelInvite(this,t)}clone(t=this.name,e=true,n=true){return this.guild.createChannel(t,this.type,e?this.permissionOverwrites:[]).then(t=>n?t.setTopic(this.topic):t)}equals(t){let e=t&&this.id===t.id&&this.type===t.type&&this.topic===t.topic&&this.position===t.position&&this.name===t.name;return e&&(e=this.permissionOverwrites&&t.permissionOverwrites?this.permissionOverwrites.equals(t.permissionOverwrites):!this.permissionOverwrites&&!t.permissionOverwrites),e}get deletable(){return this.id!==this.guild.id&&this.permissionsFor(this.client.user).hasPermission(o.FLAGS.MANAGE_CHANNELS)}toString(){return`<#${this.id}>`}}t.exports=c},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(t){if(a===setTimeout)return setTimeout(t,0);if((a===n||!a)&&setTimeout)return a=setTimeout,setTimeout(t,0);try{return a(t,0)}catch(e){try{return a.call(null,t,0)}catch(e){return a.call(this,t,0)}}}function r(t){if(l===clearTimeout)return clearTimeout(t);if((l===i||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function o(){m&&d&&(m=!1,d.length?p=d.concat(p):g=-1,p.length&&u())}function u(){if(!m){var t=s(o);m=!0;for(var e=p.length;e;){for(d=p,p=[];++g1)for(var n=1;n[t.id,t.nick]))),this.recipients||(this.recipients=new r),t.recipients)for(const e of t.recipients){const t=this.client.dataManager.newUser(e);this.recipients.set(t.id,t)}this.lastMessageID=t.last_message_id}get owner(){return this.client.users.get(this.ownerID)}equals(t){const e=t&&this.id===t.id&&this.name===t.name&&this.icon===t.icon&&this.ownerID===t.ownerID;return e?this.recipients.equals(t.recipients):e}addUser(t,e){return this.client.rest.methods.addUserToGroupDM(this,{nick:e,id:this.client.resolver.resolveUserID(t),accessToken:t})}toString(){return this.name}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendFiles(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0,["bulkDelete"]),t.exports=o},function(t,e){class n{constructor(t,e,n){this.reaction=t,this.name=e,this.id=n}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}toString(){return this.id?`<:${this.name}:${this.id}>`:this.name}}t.exports=n},function(t,e,n){const i=n(25);class s{constructor(t,e,n){t?(Object.defineProperty(this,"client",{value:t}),e&&this.setup(e)):(this.id=e,this.token=n,Object.defineProperty(this,"client",{value:this}))}setup(t){this.name=t.name,this.token=t.token,this.avatar=t.avatar,this.id=t.id,this.guildID=t.guild_id,this.channelID=t.channel_id,t.user?this.owner=this.client.users?this.client.users.get(t.user.id):t.user:this.owner=null}send(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),e.file?("string"==typeof e.file&&(e.file={attachment:e.file}),e.file.name||("string"==typeof e.file.attachment?e.file.name=i.basename(e.file.attachment):e.file.attachment&&e.file.attachment.path?e.file.name=i.basename(e.file.attachment.path):e.file.name="file.jpg"),this.client.resolver.resolveBuffer(e.file.attachment).then(n=>this.client.rest.methods.sendWebhookMessage(this,t,e,{file:n,name:e.file.name}))):this.client.rest.methods.sendWebhookMessage(this,t,e)}sendMessage(t,e={}){return this.send(t,e)}sendFile(t,e,n,i={}){return this.send(n,Object.assign(i,{file:{attachment:t,name:e}}))}sendCode(t,e,n={}){return this.send(e,Object.assign(n,{code:t}))}sendSlackMessage(t){return this.client.rest.methods.sendSlackWebhookMessage(this,t)}edit(t=this.name,e){return e?this.client.resolver.resolveBuffer(e).then(e=>{const n=this.client.resolver.resolveBase64(e);return this.client.rest.methods.editWebhook(this,t,n)}):this.client.rest.methods.editWebhook(this,t).then(t=>{return this.setup(t),this})}delete(){return this.client.rest.methods.deleteWebhook(this)}}t.exports=s},function(t,e,n){"use strict";(function(t){function i(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength; +}catch(t){return!1}}function s(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function r(t,e){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),o.alloc(+t)}function E(t,e){if(o.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(t).length;default:if(i)return Y(t).length;e=(""+e).toLowerCase(),i=!0}}function _(t,e,n){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,e>>>=0,n<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,n);case"utf8":case"utf-8":return I(this,e,n);case"ascii":return U(this,e,n);case"latin1":case"binary":return L(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function v(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function y(t,e,n,i,s){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof e&&(e=o.from(e,i)),o.isBuffer(e))return 0===e.length?-1:w(t,e,n,i,s);if("number"==typeof e)return e&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):w(t,[e],n,i,s);throw new TypeError("val must be string, number or Buffer")}function w(t,e,n,i,s){function r(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,u=t.length,c=e.length;if(void 0!==i&&(i=String(i).toLowerCase(),"ucs2"===i||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,u/=2,c/=2,n/=2}var h;if(s){var a=-1;for(h=n;hu&&(n=u-c),h=n;h>=0;h--){for(var l=!0,f=0;fs&&(i=s)):i=s;var r=e.length;if(r%2!==0)throw new TypeError("Invalid hex string");i>r/2&&(i=r/2);for(var o=0;o239?4:r>223?3:r>191?2:1;if(s+u<=n){var c,h,a,l;switch(u){case 1:r<128&&(o=r);break;case 2:c=t[s+1],128===(192&c)&&(l=(31&r)<<6|63&c,l>127&&(o=l));break;case 3:c=t[s+1],h=t[s+2],128===(192&c)&&128===(192&h)&&(l=(15&r)<<12|(63&c)<<6|63&h,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:c=t[s+1],h=t[s+2],a=t[s+3],128===(192&c)&&128===(192&h)&&128===(192&a)&&(l=(15&r)<<18|(63&c)<<12|(63&h)<<6|63&a,l>65535&&l<1114112&&(o=l))}}null===o?(o=65533,u=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),s+=u}return C(i)}function C(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var n="",i=0;ii)&&(n=i);for(var s="",r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,n,i,s,r){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||et.length)throw new RangeError("Index out of range")}function G(t,e,n,i){e<0&&(e=65535+e+1);for(var s=0,r=Math.min(t.length-n,2);s>>8*(i?s:1-s)}function x(t,e,n,i){e<0&&(e=4294967295+e+1);for(var s=0,r=Math.min(t.length-n,4);s>>8*(i?s:3-s)&255}function j(t,e,n,i,s,r){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function B(t,e,n,i,s){return s||j(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(t,e,n,i,23,4),n+4}function q(t,e,n,i,s){return s||j(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(t,e,n,i,52,8),n+8}function H(t){if(t=V(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function V(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function Y(t,e){e=e||1/0;for(var n,i=t.length,s=null,r=[],o=0;o55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&r.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&r.push(239,191,189),s=n;continue}n=(s-55296<<10|n-56320)+65536}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;r.push(n)}else if(n<2048){if((e-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;r.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function F(t){for(var e=[],n=0;n>8,s=n%256,r.push(s),r.push(i);return r}function z(t){return $.toByteArray(H(t))}function X(t,e,n,i){for(var s=0;s=e.length||s>=t.length);++s)e[s+n]=t[s];return s}function J(t){return t!==t}/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -var $=n(52),Q=n(54),Z=n(55);e.Buffer=o,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),e.kMaxLength=s(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,n){return u(null,t,e,n)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,e,n){return h(null,t,e,n)},o.allocUnsafe=function(t){return a(null,t)},o.allocUnsafeSlow=function(t){return a(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,i=e.length,s=0,r=Math.min(n,i);s0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},o.prototype.compare=function(t,e,n,i,s){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var r=s-i,u=n-e,c=Math.min(r,u),h=this.slice(i,s),a=t.slice(e,n),l=0;ls)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var r=!1;;)switch(i){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return A(this,t,e,n);case"ascii":return T(this,t,e,n);case"latin1":case"binary":return R(this,t,e,n);case"base64":return D(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;o.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e0&&(s*=256);)i+=this[t+--e]*s;return i},o.prototype.readUInt8=function(t,e){return e||O(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||O(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||O(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||O(t,e,this.length);for(var i=this[t],s=1,r=0;++r=s&&(i-=Math.pow(2,8*e)),i},o.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||O(t,e,this.length);for(var i=e,s=1,r=this[t+--i];i>0&&(s*=256);)r+=this[t+--i]*s;return s*=128,r>=s&&(r-=Math.pow(2,8*e)),r},o.prototype.readInt8=function(t,e){return e||O(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,e){e||O(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){e||O(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e|=0,n|=0,!i){var s=Math.pow(2,8*n)-1;P(this,t,e,n,s,0)}var r=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+r]=t/o&255;return e+n},o.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):G(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):G(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):x(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e|=0,!i){var s=Math.pow(2,8*n-1);P(this,t,e,n,s-1,-s)}var r=0,o=1,u=0;for(this[e]=255&t;++r>0)-u&255;return e+n},o.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e|=0,!i){var s=Math.pow(2,8*n-1);P(this,t,e,n,s-1,-s)}var r=n-1,o=1,u=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===u&&0!==this[e+r+1]&&(u=1),this[e+r]=(t/o>>0)-u&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):G(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):G(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):x(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return q(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return q(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,i){if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e=0;--s)t[s+e]=this[s+n];else if(r<1e3||!o.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var r;if("number"==typeof t)for(r=e;r0&&this._events[t].length>s&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function n(){this.removeListener(t,n),s||(s=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var s=!1;return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var n,s,o,u;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,s=-1,n===e||i(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(r(n)){for(u=o;u-- >0;)if(n[u]===e||n[u].listener&&n[u].listener===e){s=u;break}if(s<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],i(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,n){(function(t){function n(t,e){for(var n=0,i=t.length-1;i>=0;i--){var s=t[i];"."===s?t.splice(i,1):".."===s?(t.splice(i,1),n++):n&&(t.splice(i,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(t,e){if(t.filter)return t.filter(e);for(var n=[],i=0;i=-1&&!s;r--){var o=r>=0?arguments[r]:t.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(e=o+"/"+e,s="/"===o.charAt(0))}return e=n(i(e.split("/"),function(t){return!!t}),!s).join("/"),(s?"/":"")+e||"."},e.normalize=function(t){var s=e.isAbsolute(t),r="/"===o(t,-1);return t=n(i(t.split("/"),function(t){return!!t}),!s).join("/"),t||s||(t="."),t&&r&&(t+="/"),(s?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(i(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},e.relative=function(t,n){function i(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=e.resolve(t).substr(1),n=e.resolve(n).substr(1);for(var s=i(t.split("/")),r=i(n.split("/")),o=Math.min(s.length,r.length),u=o,c=0;c=0?"&":"?")+t),this._sort){var e=this.url.indexOf("?");if(e>=0){var n=this.url.substring(e+1).split("&");g(this._sort)?n.sort(this._sort):n.sort(),this.url=this.url.substring(0,e)+"?"+n.join("&")}}},a.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},a.prototype.end=function(t){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||i,this._appendQueryString(),this._end()},a.prototype._end=function(){var t=this,e=this.xhr=v.getXHR(),n=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var n=e.readyState;if(n>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==n){var i;try{i=e.status}catch(t){i=0}if(!i){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var i=function(e,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=e,t.emit("progress",n)};if(this.hasListeners("progress"))try{e.onprogress=i.bind(null,"download"),e.upload&&(e.upload.onprogress=i.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof n&&!this._isHost(n)){var s=this._header["content-type"],r=this._serializer||v.serialize[s?s.split(";")[0]:""];!r&&c(s)&&(r=v.serialize["application/json"]),r&&(n=r(n))}for(var o in this.header)null!=this.header[o]&&e.setRequestHeader(o,this.header[o]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send("undefined"!=typeof n?n:null),this},v.get=function(t,e,n){var i=v("GET",t);return"function"==typeof e&&(n=e,e=null),e&&i.query(e),n&&i.end(n),i},v.head=function(t,e,n){var i=v("HEAD",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.options=function(t,e,n){var i=v("OPTIONS",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.del=l,v.delete=l,v.patch=function(t,e,n){var i=v("PATCH",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.post=function(t,e,n){var i=v("POST",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.put=function(t,e,n){var i=v("PUT",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i}},function(t,e){function n(t){return null!==t&&"object"==typeof t}t.exports=n},function(t,e,n){(function(e){const i=n(24),s=n(43),r=n(25),o=n(0),u=n(4).convertToBuffer,c=n(11),h=n(9),a=n(16),l=n(8),f=n(13),d=n(12),p=n(20);class m{constructor(t){this.client=t}resolveUser(t){return t instanceof c?t:"string"==typeof t?this.client.users.get(t)||null:t instanceof f?t.user:t instanceof h?t.author:t instanceof a?t.owner:null}resolveUserID(t){return t instanceof c||t instanceof f?t.id:"string"==typeof t?t||null:t instanceof h?t.author.id:t instanceof a?t.ownerID:null}resolveGuild(t){return t instanceof a?t:"string"==typeof t?this.client.guilds.get(t)||null:null}resolveGuildMember(t,e){return e instanceof f?e:(t=this.resolveGuild(t),e=this.resolveUser(e),t&&e?t.members.get(e.id)||null:null)}resolveChannel(t){return t instanceof l?t:"string"==typeof t?this.client.channels.get(t)||null:t instanceof h?t.channel:t instanceof a?t.channels.get(t.id)||null:null}resolveChannelID(t){return t instanceof l?t.id:"string"==typeof t?t:t instanceof h?t.channel.id:t instanceof a?t.defaultChannel.id:null}resolveInviteCode(t){const e=/discord(?:app\.com\/invite|\.gg)\/([\w-]{2,255})/i,n=e.exec(t);return n&&n[1]?n[1]:t}resolveString(t){return"string"==typeof t?t:t instanceof Array?t.join("\n"):String(t)}resolveBase64(t){return t instanceof e?`data:image/jpg;base64,${t.toString("base64")}`:t}resolveBuffer(t){return t instanceof e?Promise.resolve(t):this.client.browser&&t instanceof ArrayBuffer?Promise.resolve(u(t)):"string"==typeof t?new Promise((n,o)=>{if(/^https?:\/\//.test(t)){const i=r.get(t).set("Content-Type","blob");this.client.browser&&i.responseType("arraybuffer"),i.end((t,i)=>{return t?o(t):this.client.browser?n(u(i.xhr.response)):i.body instanceof e?n(i.body):o(new TypeError("The response body isn't a Buffer."))})}else{const e=i.resolve(t);s.stat(e,(t,i)=>{return t?o(t):i&&i.isFile()?(s.readFile(e,(t,e)=>{t?o(t):n(e)}),null):o(new Error(`The file could not be found: ${e}`))})}}):Promise.reject(new TypeError("The resource must be a string or Buffer."))}resolveEmojiIdentifier(t){return t instanceof d||t instanceof p?t.identifier:"string"!=typeof t||t.includes("%")?null:encodeURIComponent(t)}static resolveColor(t){if("string"==typeof t){if("RANDOM"===t)return Math.floor(16777216*Math.random());t=o.Colors[t]||parseInt(t.replace("#",""),16)}else t instanceof Array&&(t=(t[0]<<16)+(t[1]<<8)+t[2]);if(t<0||t>16777215)throw new RangeError("Color must be within the range 0 - 16777215 (0xFFFFFF).");if(t&&isNaN(t))throw new TypeError("Unable to convert color to a number.");return t}resolveColor(t){return this.constructor.resolveColor(t)}}t.exports=m}).call(e,n(22).Buffer)},function(t,e){t.exports={name:"discord.js",version:"11.0.0",description:"A powerful library for interacting with the Discord API",main:"./src/index",types:"./typings/index.d.ts",scripts:{test:"npm run lint && npm run docs:test",docs:"docgen --source src --custom docs/index.yml --output docs/docs.json","docs:test":"docgen --source src --custom docs/index.yml",lint:"eslint src","lint:fix":"eslint --fix src",webpack:"parallel-webpack"},repository:{type:"git",url:"git+https://github.com/hydrabolt/discord.js.git"},keywords:["discord","api","bot","client","node","discordapp"],author:"Amish Shah ",license:"Apache-2.0",bugs:{url:"https://github.com/hydrabolt/discord.js/issues"},homepage:"https://github.com/hydrabolt/discord.js#readme",runkitExampleFilename:"./docs/examples/ping.js",dependencies:{"@types/node":"^7.0.0",long:"^3.2.0","prism-media":"hydrabolt/prism-media",superagent:"^3.4.0",tweetnacl:"^0.14.0",ws:"^2.0.0"},peerDependencies:{bufferutil:"^2.0.0",erlpack:"hammerandchisel/erlpack","node-opus":"^0.2.0",opusscript:"^0.0.2",sodium:"^2.0.1",uws:"^0.14.1"},devDependencies:{"discord.js-docgen":"hydrabolt/discord.js-docgen",eslint:"^3.17.0","parallel-webpack":"^1.6.0","uglify-js":"mishoo/UglifyJS2#harmony",webpack:"^2.2.0"},engines:{node:">=6.0.0"},browser:{ws:!1,uws:!1,erlpack:!1,"prism-media":!1,opusscript:!1,"node-opus":!1,tweetnacl:!1,sodium:!1,"src/sharding/Shard.js":!1,"src/sharding/ShardClientUtil.js":!1,"src/sharding/ShardingManager.js":!1,"src/client/voice/dispatcher/StreamDispatcher.js":!1,"src/client/voice/opus/BaseOpusEngine.js":!1,"src/client/voice/opus/NodeOpusEngine.js":!1,"src/client/voice/opus/OpusEngineList.js":!1,"src/client/voice/opus/OpusScriptEngine.js":!1,"src/client/voice/pcm/ConverterEngine.js":!1,"src/client/voice/pcm/ConverterEngineList.js":!1,"src/client/voice/pcm/FfmpegConverterEngine.js":!1,"src/client/voice/player/AudioPlayer.js":!1,"src/client/voice/receiver/VoiceReadable.js":!1,"src/client/voice/receiver/VoiceReceiver.js":!1,"src/client/voice/util/Secretbox.js":!1,"src/client/voice/util/SecretKey.js":!1,"src/client/voice/util/VolumeInterface.js":!1,"src/client/voice/ClientVoiceManager.js":!1,"src/client/voice/VoiceBroadcast.js":!1,"src/client/voice/VoiceConnection.js":!1,"src/client/voice/VoiceUDPClient.js":!1,"src/client/voice/VoiceWebSocket.js":!1}}},function(t,e,n){const i=n(11),s=n(3);class r extends i{setup(t){super.setup(t),this.verified=t.verified,this.email=t.email,this.localPresence={},this._typing=new Map,this.friends=new s,this.blocked=new s,this.notes=new s,this.settings={},this.premium="boolean"==typeof t.premium?t.premium:null,this.mfaEnabled="boolean"==typeof t.mfa_enabled?t.mfa_enabled:null,this.mobile="boolean"==typeof t.mobile?t.mobile:null}edit(t){return this.client.rest.methods.updateCurrentUser(t)}setUsername(t,e){return this.client.rest.methods.updateCurrentUser({username:t},e)}setEmail(t,e){return this.client.rest.methods.updateCurrentUser({email:t},e)}setPassword(t,e){return this.client.rest.methods.updateCurrentUser({password:t},e)}setAvatar(t){return"string"==typeof t&&t.startsWith("data:")?this.client.rest.methods.updateCurrentUser({avatar:t}):this.client.resolver.resolveBuffer(t).then(t=>this.client.rest.methods.updateCurrentUser({avatar:t}))}setPresence(t){return new Promise(e=>{let n=this.localPresence.status||this.presence.status,i=this.localPresence.game,s=this.localPresence.afk||this.presence.afk;if(!i&&this.presence.game&&(i={name:this.presence.game.name,type:this.presence.game.type,url:this.presence.game.url}),t.status){if("string"!=typeof t.status)throw new TypeError("Status must be a string");n=t.status}t.game&&(i=t.game,i.url&&(i.type=1)),null===t.game&&(i=null),"undefined"!=typeof t.afk&&(s=t.afk),s=Boolean(s),this.localPresence={status:n,game:i,afk:s},this.localPresence.since=0,this.localPresence.game=this.localPresence.game||null,this.client.ws.send({op:3,d:this.localPresence}),this.client._setPresence(this.id,this.localPresence),e(this)})}setStatus(t){return this.setPresence({status:t})}setGame(t,e){return null===t?this.setPresence({game:t}):this.setPresence({game:{name:t,url:e}})}setAFK(t){return this.setPresence({afk:t})}fetchMentions(t={limit:25,roles:true,everyone:true,guild:null}){return this.client.rest.methods.fetchMentions(t)}addFriend(t){return t=this.client.resolver.resolveUser(t),this.client.rest.methods.addFriend(t)}removeFriend(t){return t=this.client.resolver.resolveUser(t),this.client.rest.methods.removeFriend(t)}createGuild(t,e,n=null){return n?"string"==typeof n&&n.startsWith("data:")?this.client.rest.methods.createGuild({name:t,icon:n,region:e}):this.client.resolver.resolveBuffer(n).then(n=>this.client.rest.methods.createGuild({ -name:t,icon:n,region:e})):this.client.rest.methods.createGuild({name:t,icon:n,region:e})}createGroupDM(t){return this.client.rest.methods.createGroupDM({recipients:t.map(t=>this.client.resolver.resolveUserID(t.user)),accessTokens:t.map(t=>t.accessToken),nicks:t.map(t=>t.nick)})}acceptInvite(t){return this.client.rest.methods.acceptInvite(t)}}t.exports=r},function(t,e,n){const i=n(8),s=n(14),r=n(3);class o extends i{constructor(t,e){super(t,e),this.type="dm",this.messages=new r,this._typing=new Map}setup(t){super.setup(t),this.recipient=this.client.dataManager.newUser(t.recipients[0]),this.lastMessageID=t.last_message_id}toString(){return this.recipient.toString()}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendFiles(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0,["bulkDelete"]),t.exports=o},function(t,e,n){const i=n(37),s=n(38),r=n(0);class o{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.guild=this.client.guilds.get(t.guild.id)||new i(this.client,t.guild),this.code=t.code,this.temporary=t.temporary,this.maxAge=t.max_age,this.uses=t.uses,this.maxUses=t.max_uses,t.inviter&&(this.inviter=this.client.dataManager.newUser(t.inviter)),this.channel=this.client.channels.get(t.channel.id)||new s(this.client,t.channel),this.createdTimestamp=new Date(t.created_at).getTime()}get createdAt(){return new Date(this.createdTimestamp)}get expiresTimestamp(){return this.createdTimestamp+1e3*this.maxAge}get expiresAt(){return new Date(this.expiresTimestamp)}get url(){return r.Endpoints.inviteLink(this.code)}delete(){return this.client.rest.methods.deleteInvite(this)}toString(){return this.url}}t.exports=o},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.message=t,this.setup(e)}setup(t){this.id=t.id,this.filename=t.filename,this.filesize=t.size,this.url=t.url,this.proxyURL=t.proxy_url,this.height=t.height,this.width=t.width}}t.exports=n},function(t,e,n){const i=n(23).EventEmitter,s=n(3);class r extends i{constructor(t,e,n={}){super(),this.channel=t,this.filter=e,this.options=n,this.ended=!1,this.collected=new s,this.listener=(t=>this.verify(t)),this.channel.client.on("message",this.listener),n.time&&this.channel.client.setTimeout(()=>this.stop("time"),n.time)}verify(t){return(!this.channel||this.channel.id===t.channel.id)&&(!!this.filter(t,this)&&(this.collected.set(t.id,t),this.emit("message",t,this),this.collected.size>=this.options.maxMatches?this.stop("matchesLimit"):this.options.max&&this.collected.size===this.options.max&&this.stop("limit"),!0))}get next(){return new Promise((t,e)=>{if(this.ended)return void e(this.collected);const n=()=>{this.removeListener("message",i),this.removeListener("end",s)},i=(...e)=>{n(),t(...e)},s=(...t)=>{n(),e(...t)};this.once("message",i),this.once("end",s)})}stop(t="user"){this.ended||(this.ended=!0,this.channel.client.removeListener("message",this.listener),this.emit("end",this.collected,t))}}t.exports=r},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.message=t,this.setup(e)}setup(t){if(this.type=t.type,this.title=t.title,this.description=t.description,this.url=t.url,this.color=t.color,this.fields=[],t.fields)for(const e of t.fields)this.fields.push(new c(this,e));this.createdTimestamp=t.timestamp,this.thumbnail=t.thumbnail?new i(this,t.thumbnail):null,this.image=t.image?new s(this,t.image):null,this.video=t.video?new r(this,t.video):null,this.author=t.author?new u(this,t.author):null,this.provider=t.provider?new o(this,t.provider):null,this.footer=t.footer?new h(this,t.footer):null}get createdAt(){return new Date(this.createdTimestamp)}get hexColor(){let t=this.color.toString(16);for(;t.length<6;)t=`0${t}`;return`#${t}`}}class i{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.url=t.url,this.proxyURL=t.proxy_url,this.height=t.height,this.width=t.width}}class s{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.url=t.url,this.proxyURL=t.proxy_url,this.height=t.height,this.width=t.width}}class r{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.url=t.url,this.height=t.height,this.width=t.width}}class o{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.url=t.url}}class u{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.url=t.url,this.iconURL=t.icon_url}}class c{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.value=t.value,this.inline=t.inline}}class h{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.text=t.text,this.iconURL=t.icon_url,this.proxyIconUrl=t.proxy_icon_url}}n.Thumbnail=i,n.Image=s,n.Video=r,n.Provider=o,n.Author=u,n.Field=c,n.Footer=h,t.exports=n},function(t,e,n){const i=n(3),s=n(12),r=n(20);class o{constructor(t,e,n,s){this.message=t,this.me=s,this.count=n||0,this.users=new i,this._emoji=new r(this,e.name,e.id)}get emoji(){if(this._emoji instanceof s)return this._emoji;if(this._emoji.id){const t=this.message.client.emojis;if(t.has(this._emoji.id)){const e=t.get(this._emoji.id);return this._emoji=e,e}}return this._emoji}remove(t=this.message.client.user){const e=this.message;return t=this.message.client.resolver.resolveUserID(t),t?e.client.rest.methods.removeMessageReaction(e,this.emoji.identifier,t):Promise.reject(new Error("Couldn't resolve the user ID to remove from the reaction."))}fetchUsers(t=100){const e=this.message;return e.client.rest.methods.getMessageReactionUsers(e,this.emoji.identifier,t).then(t=>{this.users=new i;for(const e of t){const t=this.message.client.dataManager.newUser(e);this.users.set(t.id,t)}return this.count=this.users.size,this.users})}}t.exports=o},function(t,e,n){const i=n(5);class s{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.description=t.description,this.icon=t.icon,this.iconURL=`https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`,this.rpcOrigins=t.rpc_origins,this.redirectURIs=t.redirect_uris,this.botRequireCodeGrant=t.bot_require_code_grant,this.botPublic=t.bot_public,this.rpcApplicationState=t.rpc_application_state,this.bot=t.bot,this.flags=t.flags,this.secret=t.secret}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}reset(){return this.client.rest.methods.resetApplication(this.id)}toString(){return this.name}}t.exports=s},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.icon=t.icon,this.splash=t.splash}}t.exports=n},function(t,e,n){const i=n(0);class s{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.type=i.ChannelTypes.TEXT===t.type?"text":"voice"}}t.exports=s},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"channel",{value:t}),e&&this.setup(e)}setup(t){this.id=t.id,this.type=t.type,this.deny=t.deny,this.allow=t.allow}delete(){return this.channel.client.rest.methods.deletePermissionOverwrites(this)}}t.exports=n},function(t,e,n){const i=n(17),s=n(14),r=n(3);class o extends i{constructor(t,e){super(t,e),this.type="text",this.messages=new r,this._typing=new Map}setup(t){super.setup(t),this.topic=t.topic,this.lastMessageID=t.last_message_id}get members(){const t=new r;for(const e of this.guild.members.values())this.permissionsFor(e).hasPermission("READ_MESSAGES")&&t.set(e.id,e);return t}fetchWebhooks(){return this.client.rest.methods.getChannelWebhooks(this)}createWebhook(t,e){return new Promise(n=>{"string"==typeof e&&e.startsWith("data:")?n(this.client.rest.methods.createWebhook(this,t,e)):this.client.resolver.resolveBuffer(e).then(e=>n(this.client.rest.methods.createWebhook(this,t,e)))})}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendFiles(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0),t.exports=o},function(t,e,n){const i=n(17),s=n(3);class r extends i{constructor(t,e){super(t,e),this.members=new s,this.type="voice"}setup(t){super.setup(t),this.bitrate=t.bitrate,this.userLimit=t.user_limit}get connection(){const t=this.guild.voiceConnection;return t&&t.channel.id===this.id?t:null}get full(){return this.userLimit>0&&this.members.size>=this.userLimit}get joinable(){return!this.client.browser&&(!!this.permissionsFor(this.client.user).hasPermission("CONNECT")&&!(this.full&&!this.permissionsFor(this.client.user).hasPermission("MOVE_MEMBERS")))}get speakable(){return this.permissionsFor(this.client.user).hasPermission("SPEAK")}setBitrate(t){return this.edit({bitrate:t})}setUserLimit(t){return this.edit({userLimit:t})}join(){return this.client.browser?Promise.reject(new Error("Voice connections are not available in browsers.")):this.client.voice.joinChannel(this)}leave(){if(!this.client.browser){const t=this.client.voice.connections.get(this.guild.id);t&&t.channel.id===this.id&&t.disconnect()}}}t.exports=r},function(t,e,n){var i,s,r;!function(n,o){s=[],i=o,r="function"==typeof i?i.apply(e,s):i,!(void 0!==r&&(t.exports=r))}(this,function(){"use strict";function t(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function e(t){return(t&&t.__isLong__)===!0}function n(t,e){var n,i,r;return e?(t>>>=0,(r=0<=t&&t<256)&&(i=c[t])?i:(n=s(t,(0|t)<0?-1:0,!0),r&&(c[t]=n),n)):(t|=0,(r=-128<=t&&t<128)&&(i=u[t])?i:(n=s(t,t<0?-1:0,!1),r&&(u[t]=n),n))}function i(t,e){if(isNaN(t)||!isFinite(t))return e?m:p;if(e){if(t<0)return m;if(t>=l)return y}else{if(t<=-f)return w;if(t+1>=f)return v}return t<0?i(-t,e).neg():s(t%4294967296|0,t/4294967296|0,e)}function s(e,n,i){return new t(e,n,i)}function r(t,e,n){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return p;if("number"==typeof e?(n=e,e=!1):e=!!e,n=n||10,n<2||360)throw Error("interior hyphen");if(0===s)return r(t.substring(1),e,n).neg();for(var o=i(h(n,8)),u=p,c=0;c>>0:this.low},b.toNumber=function(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(this.low>>>0)},b.toString=function(t){if(t=t||10,t<2||36>>0,l=a.toString(t);if(o=c,o.isZero())return l+u;for(;l.length<6;)l="0"+l;u=""+l+u}},b.getHighBits=function(){return this.high},b.getHighBitsUnsigned=function(){return this.high>>>0},b.getLowBits=function(){return this.low},b.getLowBitsUnsigned=function(){return this.low>>>0},b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(w)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<=0},b.isOdd=function(){return 1===(1&this.low)},b.isEven=function(){return 0===(1&this.low)},b.equals=function(t){return e(t)||(t=o(t)),(this.unsigned===t.unsigned||this.high>>>31!==1||t.high>>>31!==1)&&(this.high===t.high&&this.low===t.low)},b.eq=b.equals,b.notEquals=function(t){return!this.eq(t)},b.neq=b.notEquals,b.lessThan=function(t){return this.comp(t)<0},b.lt=b.lessThan,b.lessThanOrEqual=function(t){return this.comp(t)<=0},b.lte=b.lessThanOrEqual,b.greaterThan=function(t){return this.comp(t)>0},b.gt=b.greaterThan,b.greaterThanOrEqual=function(t){return this.comp(t)>=0},b.gte=b.greaterThanOrEqual,b.compare=function(t){if(e(t)||(t=o(t)),this.eq(t))return 0;var n=this.isNegative(),i=t.isNegative();return n&&!i?-1:!n&&i?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},b.comp=b.compare,b.negate=function(){return!this.unsigned&&this.eq(w)?w:this.not().add(g)},b.neg=b.negate,b.add=function(t){e(t)||(t=o(t));var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,u=65535&this.low,c=t.high>>>16,h=65535&t.high,a=t.low>>>16,l=65535&t.low,f=0,d=0,p=0,m=0;return m+=u+l,p+=m>>>16,m&=65535,p+=r+a,d+=p>>>16,p&=65535,d+=i+h,f+=d>>>16,d&=65535,f+=n+c,f&=65535,s(p<<16|m,f<<16|d,this.unsigned)},b.subtract=function(t){return e(t)||(t=o(t)),this.add(t.neg())},b.sub=b.subtract,b.multiply=function(t){if(this.isZero())return p;if(e(t)||(t=o(t)),t.isZero())return p;if(this.eq(w))return t.isOdd()?w:p;if(t.eq(w))return this.isOdd()?w:p;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(d)&&t.lt(d))return i(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,r=65535&this.high,u=this.low>>>16,c=65535&this.low,h=t.high>>>16,a=65535&t.high,l=t.low>>>16,f=65535&t.low,m=0,g=0,E=0,_=0;return _+=c*f,E+=_>>>16,_&=65535,E+=u*f,g+=E>>>16,E&=65535,E+=c*l,g+=E>>>16,E&=65535,g+=r*f,m+=g>>>16,g&=65535,g+=u*l,m+=g>>>16,g&=65535,g+=c*a,m+=g>>>16,g&=65535,m+=n*f+r*l+u*a+c*h,m&=65535,s(E<<16|_,m<<16|g,this.unsigned)},b.mul=b.multiply,b.divide=function(t){if(e(t)||(t=o(t)),t.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:p;var n,s,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return m;if(t.gt(this.shru(1)))return E;r=m}else{if(this.eq(w)){if(t.eq(g)||t.eq(_))return w;if(t.eq(w))return g;var u=this.shr(1);return n=u.div(t).shl(1),n.eq(p)?t.isNegative()?g:_:(s=this.sub(t.mul(n)),r=n.add(s.div(t)))}if(t.eq(w))return this.unsigned?m:p;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=p}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(n)/Math.LN2),a=c<=48?1:h(2,c-48),l=i(n),f=l.mul(t);f.isNegative()||f.gt(s);)n-=a,l=i(n,this.unsigned),f=l.mul(t);l.isZero()&&(l=g),r=r.add(l),s=s.sub(f)}return r},b.div=b.divide,b.modulo=function(t){return e(t)||(t=o(t)),this.sub(this.div(t).mul(t))},b.mod=b.modulo,b.not=function(){return s(~this.low,~this.high,this.unsigned)},b.and=function(t){return e(t)||(t=o(t)),s(this.low&t.low,this.high&t.high,this.unsigned)},b.or=function(t){return e(t)||(t=o(t)),s(this.low|t.low,this.high|t.high,this.unsigned)},b.xor=function(t){return e(t)||(t=o(t)),s(this.low^t.low,this.high^t.high,this.unsigned)},b.shiftLeft=function(t){return e(t)&&(t=t.toInt()),0===(t&=63)?this:t<32?s(this.low<>>32-t,this.unsigned):s(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):s(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},b.shr=b.shiftRight,b.shiftRightUnsigned=function(t){if(e(t)&&(t=t.toInt()),t&=63,0===t)return this;var n=this.high;if(t<32){var i=this.low;return s(i>>>t|n<<32-t,n>>>t,this.unsigned)}return 32===t?s(n,0,this.unsigned):s(n>>>t-32,0,this.unsigned)},b.shru=b.shiftRightUnsigned,b.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},b.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},b.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},b.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255]},b.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e]},t})},function(t,e){},function(t,e,n){const i=n(99),s=n(96),r=n(98),o=n(97),u=n(95),c=n(0);class h{constructor(t){this.client=t,this.handlers={},this.userAgentManager=new i(this),this.methods=new s(this),this.rateLimitedEndpoints={},this.globallyRateLimited=!1}push(t,e){return new Promise((n,i)=>{t.push({request:e,resolve:n,reject:i})})}getRequestHandler(){switch(this.client.options.apiRequestMethod){case"sequential":return r;case"burst":return o;default:throw new Error(c.Errors.INVALID_RATE_LIMIT_METHOD)}}makeRequest(t,e,n,i,s){const r=new u(this,t,e,n,i,s);if(!this.handlers[r.route]){const t=this.getRequestHandler();this.handlers[r.route]=new t(this,r.route)}return this.push(this.handlers[r.route],r)}}t.exports=h},function(t,e){class n{constructor(t){this.restManager=t,this.queue=[]}get globalLimit(){return this.restManager.globallyRateLimited}set globalLimit(t){this.restManager.globallyRateLimited=t}push(t){this.queue.push(t)}handle(){}}t.exports=n},function(module,exports,__webpack_require__){(function(process){const os=__webpack_require__(15),EventEmitter=__webpack_require__(23).EventEmitter,Constants=__webpack_require__(0),Permissions=__webpack_require__(6),Util=__webpack_require__(4),RESTManager=__webpack_require__(44),ClientDataManager=__webpack_require__(65),ClientManager=__webpack_require__(66),ClientDataResolver=__webpack_require__(27),ClientVoiceManager=__webpack_require__(140),WebSocketManager=__webpack_require__(100),ActionsManager=__webpack_require__(67),Collection=__webpack_require__(3),Presence=__webpack_require__(7).Presence,ShardClientUtil=__webpack_require__(139),VoiceBroadcast=__webpack_require__(141);class Client extends EventEmitter{constructor(t={}){super(),!t.shardId&&"SHARD_ID"in process.env&&(t.shardId=Number(process.env.SHARD_ID)),!t.shardCount&&"SHARD_COUNT"in process.env&&(t.shardCount=Number(process.env.SHARD_COUNT)),this.options=Util.mergeDefault(Constants.DefaultOptions,t),this._validateOptions(),this.rest=new RESTManager(this),this.dataManager=new ClientDataManager(this),this.manager=new ClientManager(this),this.ws=new WebSocketManager(this),this.resolver=new ClientDataResolver(this),this.actions=new ActionsManager(this),this.voice=this.browser?null:new ClientVoiceManager(this),this.shard=process.send?ShardClientUtil.singleton(this):null,this.users=new Collection,this.guilds=new Collection,this.channels=new Collection,this.presences=new Collection,!this.token&&"CLIENT_TOKEN"in process.env?this.token=process.env.CLIENT_TOKEN:this.token=null,this.user=null,this.readyAt=null,this.broadcasts=[],this.pings=[],this._pingTimestamp=0,this._timeouts=new Set,this._intervals=new Set,this.options.messageSweepInterval>0&&this.setInterval(this.sweepMessages.bind(this),1e3*this.options.messageSweepInterval)}get status(){return this.ws.status}get uptime(){return this.readyAt?Date.now()-this.readyAt:null}get ping(){return this.pings.reduce((t,e)=>t+e,0)/this.pings.length}get voiceConnections(){return this.browser?new Collection:this.voice.connections}get emojis(){const t=new Collection;for(const e of this.guilds.values())for(const n of e.emojis.values())t.set(n.id,n);return t}get readyTimestamp(){return this.readyAt?this.readyAt.getTime():null}get browser(){return"browser"===os.platform()}createVoiceBroadcast(){const t=new VoiceBroadcast(this);return this.broadcasts.push(t),t}login(t){return this.rest.methods.login(t)}destroy(){for(const t of this._timeouts)clearTimeout(t);for(const e of this._intervals)clearInterval(e);return this._timeouts.clear(),this._intervals.clear(),this.manager.destroy()}syncGuilds(t=this.guilds){this.user.bot||this.ws.send({op:12,d:t instanceof Collection?t.keyArray():t.map(t=>t.id)})}fetchUser(t,e=true){return this.users.has(t)?Promise.resolve(this.users.get(t)):this.rest.methods.getUser(t,e)}fetchInvite(t){const e=this.resolver.resolveInviteCode(t);return this.rest.methods.getInvite(e)}fetchWebhook(t,e){return this.rest.methods.getWebhook(t,e)}fetchVoiceRegions(){return this.rest.methods.fetchVoiceRegions()}sweepMessages(t=this.options.messageCacheLifetime){if("number"!=typeof t||isNaN(t))throw new TypeError("The lifetime must be a number.");if(t<=0)return this.emit("debug","Didn't sweep messages - lifetime is unlimited"),-1;const e=1e3*t,n=Date.now();let i=0,s=0;for(const r of this.channels.values())if(r.messages){i++;for(const t of r.messages.values())n-(t.editedTimestamp||t.createdTimestamp)>e&&(r.messages.delete(t.id),s++)}return this.emit("debug",`Swept ${s} messages older than ${t} seconds in ${i} text-based channels`),s}fetchApplication(t="@me"){return this.rest.methods.getApplication(t)}generateInvite(t){return t?t instanceof Array&&(t=Permissions.resolve(t)):t=0,this.fetchApplication().then(e=>`https://discordapp.com/oauth2/authorize?client_id=${e.id}&permissions=${t}&scope=bot`)}setTimeout(t,e,...n){const i=setTimeout(()=>{t(),this._timeouts.delete(i)},e,...n);return this._timeouts.add(i),i}clearTimeout(t){clearTimeout(t),this._timeouts.delete(t)}setInterval(t,e,...n){const i=setInterval(t,e,...n);return this._intervals.add(i),i}clearInterval(t){clearInterval(t),this._intervals.delete(t)}_pong(t){this.pings.unshift(Date.now()-t),this.pings.length>3&&(this.pings.length=3),this.ws.lastHeartbeatAck=!0}_setPresence(t,e){return this.presences.has(t)?void this.presences.get(t).update(e):void this.presences.set(t,new Presence(e))}_eval(script){return eval(script)}_validateOptions(t=this.options){if("number"!=typeof t.shardCount||isNaN(t.shardCount))throw new TypeError("The shardCount option must be a number.");if("number"!=typeof t.shardId||isNaN(t.shardId))throw new TypeError("The shardId option must be a number.");if(t.shardCount<0)throw new RangeError("The shardCount option must be at least 0.");if(t.shardId<0)throw new RangeError("The shardId option must be at least 0.");if(0!==t.shardId&&t.shardId>=t.shardCount)throw new RangeError("The shardId option must be less than shardCount.");if("number"!=typeof t.messageCacheMaxSize||isNaN(t.messageCacheMaxSize))throw new TypeError("The messageCacheMaxSize option must be a number.");if("number"!=typeof t.messageCacheLifetime||isNaN(t.messageCacheLifetime))throw new TypeError("The messageCacheLifetime option must be a number.");if("number"!=typeof t.messageSweepInterval||isNaN(t.messageSweepInterval))throw new TypeError("The messageSweepInterval option must be a number.");if("boolean"!=typeof t.fetchAllMembers)throw new TypeError("The fetchAllMembers option must be a boolean.");if("boolean"!=typeof t.disableEveryone)throw new TypeError("The disableEveryone option must be a boolean.");if("number"!=typeof t.restWsBridgeTimeout||isNaN(t.restWsBridgeTimeout))throw new TypeError("The restWsBridgeTimeout option must be a number.");if(!(t.disabledEvents instanceof Array))throw new TypeError("The disabledEvents option must be an Array.")}}module.exports=Client}).call(exports,__webpack_require__(18))},function(t,e,n){const i=n(21),s=n(44),r=n(27),o=n(0),u=n(4);class c extends i{constructor(t,e,n){super(null,t,e),this.options=u.mergeDefault(o.DefaultOptions,n),this.rest=new s(this),this.resolver=new r(this),this._timeouts=new Set,this._intervals=new Set}setTimeout(t,e,...n){const i=setTimeout(()=>{t(),this._timeouts.delete(i)},e,...n);return this._timeouts.add(i),i}clearTimeout(t){clearTimeout(t),this._timeouts.delete(t)}setInterval(t,e,...n){const i=setInterval(t,e,...n);return this._intervals.add(i),i}clearInterval(t){clearInterval(t),this._intervals.delete(t)}destroy(){for(const t of this._timeouts)clearTimeout(t);for(const e of this._intervals)clearInterval(e);this._timeouts.clear(),this._intervals.clear()}}t.exports=c},function(t,e,n){function i(t){return"string"==typeof t?t:t instanceof Array?t.join("\n"):String(t)}const s=n(27);class r{constructor(t={}){this.title=t.title,this.description=t.description,this.url=t.url,this.color=t.color,this.author=t.author,this.timestamp=t.timestamp,this.fields=t.fields||[],this.thumbnail=t.thumbnail,this.image=t.image,this.footer=t.footer,this.file=t.file}setTitle(t){if(t=i(t),t.length>256)throw new RangeError("RichEmbed titles may not exceed 256 characters.");return this.title=t,this}setDescription(t){if(t=i(t),t.length>2048)throw new RangeError("RichEmbed descriptions may not exceed 2048 characters.");return this.description=t,this}setURL(t){return this.url=t,this}setColor(t){return this.color=s.resolveColor(t),this}setAuthor(t,e,n){return this.author={name:i(t),icon_url:e,url:n},this}setTimestamp(t=new Date){return this.timestamp=t,this}addField(t,e,n=false){if(this.fields.length>=25)throw new RangeError("RichEmbeds may not exceed 25 fields.");if(t=i(t),t.length>256)throw new RangeError("RichEmbed field names may not exceed 256 characters.");if(!/\S/.test(t))throw new RangeError("RichEmbed field names may not be empty.");if(e=i(e),e.length>1024)throw new RangeError("RichEmbed field values may not exceed 1024 characters.");if(!/\S/.test(e))throw new RangeError("RichEmbed field values may not be empty.");return this.fields.push({name:t,value:e,inline:n}),this}addBlankField(t=false){return this.addField("​","​",t)}setThumbnail(t){return this.thumbnail={url:t},this}setImage(t){return this.image={url:t},this}setFooter(t,e){if(t=i(t),t.length>2048)throw new RangeError("RichEmbed footer text may not exceed 2048 characters.");return this.footer={text:t,icon_url:e},this}attachFile(t){if(this.file)throw new RangeError("You may not upload more than one file at once.");return this.file=t,this}}t.exports=r},function(t,e){},function(t,e){},function(t,e){},function(t,e,n){"use strict";function i(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function s(t){return 3*t.length/4-i(t)}function r(t){var e,n,s,r,o,u,c=t.length;o=i(t),u=new l(3*c/4-o),s=o>0?c-4:c;var h=0;for(e=0,n=0;e>16&255,u[h++]=r>>8&255,u[h++]=255&r;return 2===o?(r=a[t.charCodeAt(e)]<<2|a[t.charCodeAt(e+1)]>>4,u[h++]=255&r):1===o&&(r=a[t.charCodeAt(e)]<<10|a[t.charCodeAt(e+1)]<<4|a[t.charCodeAt(e+2)]>>2,u[h++]=r>>8&255,u[h++]=255&r),u}function o(t){return h[t>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}function u(t,e,n){for(var i,s=[],r=e;ra?a:c+o));return 1===i?(e=t[n-1],s+=h[e>>2],s+=h[e<<4&63],s+="=="):2===i&&(e=(t[n-2]<<8)+t[n-1],s+=h[e>>10],s+=h[e>>4&63],s+=h[e<<2&63],s+="="),r.push(s),r.join("")}e.byteLength=s,e.toByteArray=r,e.fromByteArray=c;for(var h=[],a=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=f.length;d>1,a=-7,l=n?s-1:0,f=n?-1:1,d=t[e+l];for(l+=f,r=d&(1<<-a)-1,d>>=-a,a+=u;a>0;r=256*r+t[e+l],l+=f,a-=8);for(o=r&(1<<-a)-1,r>>=-a,a+=i;a>0;o=256*o+t[e+l],l+=f,a-=8);if(0===r)r=1-h;else{if(r===c)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,i),r-=h}return(d?-1:1)*o*Math.pow(2,r-i)},e.write=function(t,e,n,i,s,r){var o,u,c,h=8*r-s-1,a=(1<>1,f=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:r-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=a):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),e+=o+l>=1?f/c:f*Math.pow(2,1-l),e*c>=2&&(o++,c/=2),o+l>=a?(u=0,o=a):o+l>=1?(u=(e*c-1)*Math.pow(2,s),o+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,s),o=0));s>=8;t[n+d]=255&u,d+=p,u/=256,s-=8);for(o=o<0;t[n+d]=255&o,d+=p,o/=256,h-=8);t[n+d-p]|=128*m}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,r){e=e||"&",n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var u=/\+/g;t=t.split(e);var c=1e3;r&&"number"==typeof r.maxKeys&&(c=r.maxKeys);var h=t.length;c>0&&h>c&&(h=c);for(var a=0;a=0?(l=m.substr(0,g),f=m.substr(g+1)):(l=m,f=""),d=decodeURIComponent(l),p=decodeURIComponent(f),i(o,d)?s(o[d])?o[d].push(p):o[d]=[o[d],p]:o[d]=p}return o};var s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";function i(t,e){if(t.map)return t.map(e);for(var n=[],i=0;i=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(r(t)){for(var n in t)this.set(n,t[n]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),r(t)){for(var n in t)this.field(n,t[n]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype.withCredentials=function(){return this._withCredentials=!0,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=r(t),n=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&r(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(n||this.type("form"),n=this._header["content-type"],"application/x-www-form-urlencoded"==n?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(n||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort="undefined"==typeof t||t,this},i.prototype._timeoutError=function(t,e){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout)},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout)},this._responseTimeout))}},function(t,e,n){function i(t){if(t)return s(t)}function s(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}var r=n(63);t.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=r.type(e);var n=r.params(e);for(var i in n)this[i]=n[i];this.links={};try{t.link&&(this.links=r.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t}},function(t,e){var n=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];t.exports=function(t,e){return!!(t&&t.code&&~n.indexOf(t.code))||(!!(e&&e.status&&e.status>=500)||!!(t&&"timeout"in t&&"ECONNABORTED"==t.code))}},function(t,e){e.type=function(t){return t.split(/ *; */).shift()},e.params=function(t){return t.split(/ *; */).reduce(function(t,e){var n=e.split(/ *= */),i=n.shift(),s=n.shift();return i&&s&&(t[i]=s),t},{})},e.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var n=e.split(/ *; */),i=n[0].slice(1,-1),s=n[1].split(/ *= */)[1].slice(1,-1);return t[s]=i,t},{})},e.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&delete t.cookie,t}},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){const i=n(0),s=n(4),r=n(16),o=n(11),u=n(30),c=n(12),h=n(40),a=n(41),l=n(17),f=n(19);class d{constructor(t){this.client=t}get pastReady(){return this.client.ws.status===i.Status.READY}newGuild(t){const e=this.client.guilds.has(t.id),n=new r(this.client,t);return this.client.guilds.set(n.id,n),this.pastReady&&!e&&(this.client.options.fetchAllMembers?n.fetchMembers().then(()=>{this.client.emit(i.Events.GUILD_CREATE,n)}):this.client.emit(i.Events.GUILD_CREATE,n)),n}newUser(t){if(this.client.users.has(t.id))return this.client.users.get(t.id);const e=new o(this.client,t);return this.client.users.set(e.id,e),e}newChannel(t,e){const n=this.client.channels.has(t.id);let s;return t.type===i.ChannelTypes.DM?s=new u(this.client,t):t.type===i.ChannelTypes.GROUP_DM?s=new f(this.client,t):(e=e||this.client.guilds.get(t.guild_id),e&&(t.type===i.ChannelTypes.TEXT?(s=new h(e,t),e.channels.set(s.id,s)):t.type===i.ChannelTypes.VOICE&&(s=new a(e,t),e.channels.set(s.id,s)))),s?(this.pastReady&&!n&&this.client.emit(i.Events.CHANNEL_CREATE,s),this.client.channels.set(s.id,s),s):null}newEmoji(t,e){const n=e.emojis.has(t.id);if(t&&!n){let n=new c(e,t);return this.client.emit(i.Events.GUILD_EMOJI_CREATE,n),e.emojis.set(n.id,n),n}return n?e.emojis.get(t.id):null}killEmoji(t){t instanceof c&&t.guild&&(this.client.emit(i.Events.GUILD_EMOJI_DELETE,t),t.guild.emojis.delete(t.id))}killGuild(t){const e=this.client.guilds.has(t.id);this.client.guilds.delete(t.id),e&&this.pastReady&&this.client.emit(i.Events.GUILD_DELETE,t)}killUser(t){this.client.users.delete(t.id)}killChannel(t){this.client.channels.delete(t.id),t instanceof l&&t.guild.channels.delete(t.id)}updateGuild(t,e){const n=s.cloneObject(t);t.setup(e),this.pastReady&&this.client.emit(i.Events.GUILD_UPDATE,n,t)}updateChannel(t,e){t.setup(e)}updateEmoji(t,e){const n=s.cloneObject(t);return t.setup(e),this.client.emit(i.Events.GUILD_EMOJI_UPDATE,n,t),t}}t.exports=d},function(t,e,n){const i=n(0);class s{constructor(t){this.client=t,this.heartbeatInterval=null}connectToWebSocket(t,e,n){this.client.emit(i.Events.DEBUG,`Authenticated using token ${t}`),this.client.token=t;const s=this.client.setTimeout(()=>n(new Error(i.Errors.TOOK_TOO_LONG)),3e5);this.client.rest.methods.getGateway().then(r=>{this.client.emit(i.Events.DEBUG,`Using gateway ${r}`),this.client.ws.connect(r),this.client.ws.once("close",t=>{4004===t.code&&n(new Error(i.Errors.BAD_LOGIN)),4010===t.code&&n(new Error(i.Errors.INVALID_SHARD)),4011===t.code&&n(new Error(i.Errors.SHARDING_REQUIRED))}),this.client.once(i.Events.READY,()=>{e(t),this.client.clearTimeout(s)})},n)}setupKeepAlive(t){this.heartbeatInterval=this.client.setInterval(()=>this.client.ws.heartbeat(!0),t)}destroy(){return this.client.ws.destroy(),this.client.user?this.client.user.bot?(this.client.token=null,Promise.resolve()):this.client.rest.methods.logout().then(()=>{this.client.token=null}):Promise.resolve()}}t.exports=s},function(t,e,n){class i{constructor(t){this.client=t,this.register(n(85)),this.register(n(86)),this.register(n(87)),this.register(n(91)),this.register(n(88)),this.register(n(89)),this.register(n(90)),this.register(n(68)),this.register(n(69)),this.register(n(70)),this.register(n(73)),this.register(n(84)),this.register(n(77)),this.register(n(78)),this.register(n(71)),this.register(n(79)),this.register(n(80)),this.register(n(81)),this.register(n(92)),this.register(n(94)),this.register(n(93)),this.register(n(83)),this.register(n(74)),this.register(n(75)),this.register(n(76)),this.register(n(82)),this.register(n(72))}register(t){this[t.name.replace(/Action$/,"")]=new t(this.client)}}t.exports=i},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.dataManager.newChannel(t);return{channel:n}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client;let n=e.channels.get(t.id);return n?(e.dataManager.killChannel(n),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)):n=this.deleted.get(t.id)||null,{channel:n}}scheduleForDeletion(t){this.client.setTimeout(()=>this.deleted.delete(t),this.client.options.restWsBridgeTimeout)}}t.exports=s},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client,n=e.channels.get(t.id);if(n){const i=r.cloneObject(n);return n.setup(t),e.emit(s.Events.CHANNEL_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id),i=e.dataManager.newUser(t.user);n&&i&&e.emit(s.Events.GUILD_BAN_REMOVE,n,i)}}t.exports=r},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n)for(const i of t.channels){const t=n.roles.get(i.id);t&&(t.position=i.position)}return{guild:n}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0);class r extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client;let n=e.guilds.get(t.id);if(n){for(const i of n.channels.values())"text"===i.type&&i.stopTyping(!0);if(n.available&&t.unavailable)return n.available=!1,e.emit(s.Events.GUILD_UNAVAILABLE,n),{guild:null};e.guilds.delete(n.id),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)}else n=this.deleted.get(t.id)||null;return{guild:n}}scheduleForDeletion(t){this.client.setTimeout(()=>this.deleted.delete(t),this.client.options.restWsBridgeTimeout)}}t.exports=r},function(t,e,n){const i=n(2);class s extends i{handle(t,e){const n=this.client,i=n.dataManager.newEmoji(e,t);return{emoji:i}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client;return e.dataManager.killEmoji(t),{emoji:t}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t,e){const n=this.client.dataManager.updateEmoji(t,e);return{emoji:n}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t,e){const n=t._addMember(e,!1);return{member:n}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0);class r extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){let i=n.members.get(t.user.id);return i?(n.memberCount--,n._removeMember(i),this.deleted.set(n.id+t.user.id,i),e.status===s.Status.READY&&e.emit(s.Events.GUILD_MEMBER_REMOVE,i),this.scheduleForDeletion(n.id,t.user.id)):i=this.deleted.get(n.id+t.user.id)||null,{guild:n,member:i}}return{guild:n,member:null}}scheduleForDeletion(t,e){this.client.setTimeout(()=>this.deleted.delete(t+e),this.client.options.restWsBridgeTimeout)}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(10);class o extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){const i=n.roles.has(t.role.id),o=new r(n,t.role);return n.roles.set(o.id,o),i||e.emit(s.Events.GUILD_ROLE_CREATE,o),{role:o}}return{role:null}}}t.exports=o},function(t,e,n){const i=n(2),s=n(0);class r extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){let i=n.roles.get(t.role_id);return i?(n.roles.delete(t.role_id),this.deleted.set(n.id+t.role_id,i),this.scheduleForDeletion(n.id,t.role_id),e.emit(s.Events.GUILD_ROLE_DELETE,i)):i=this.deleted.get(n.id+t.role_id)||null,{role:i}}return{role:null}}scheduleForDeletion(t,e){this.client.setTimeout(()=>this.deleted.delete(t+e),this.client.options.restWsBridgeTimeout)}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){const i=t.role;let o=null;const u=n.roles.get(i.id);return u&&(o=r.cloneObject(u),u.setup(t.role),e.emit(s.Events.GUILD_ROLE_UPDATE,o,u)),{old:o,updated:u}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n)for(const i of t.roles){const t=n.roles.get(i.id);t&&(t.position=i.position)}return{guild:n}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.guilds.get(t.id);if(n){if(t.presences)for(const e of t.presences)n._setPresence(e.user.id,e);if(t.members)for(const i of t.members){const t=n.members.get(i.user.id);t?n._updateMember(t,i):n._addMember(i,!1)}"large"in t&&(n.large=t.large)}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client,n=e.guilds.get(t.id);if(n){const i=r.cloneObject(n);return n.setup(t),e.emit(s.Events.GUILD_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(2),s=n(9);class r extends i{handle(t){const e=this.client,n=e.channels.get((t instanceof Array?t[0]:t).channel_id),i=e.users.get((t instanceof Array?t[0]:t).author.id);if(n){const r=n.guild?n.guild.member(i):null;if(t instanceof Array){const o=new Array(t.length);for(let u=0;uthis.deleted.delete(t+e),this.client.options.restWsBridgeTimeout)}}t.exports=s},function(t,e,n){const i=n(2),s=n(3),r=n(0);class o extends i{handle(t){const e=this.client,n=e.channels.get(t.channel_id),i=t.ids,o=new s;for(const u of i){const t=n.messages.get(u);t&&o.set(t.id,t)}return o.size>0&&e.emit(r.Events.MESSAGE_BULK_DELETE,o),{messages:o}}}t.exports=o},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client.users.get(t.user_id);if(!e)return!1;const n=this.client.channels.get(t.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(t.message_id);if(!i)return!1;if(!t.emoji)return!1;const r=i._addReaction(t.emoji,e);return r&&this.client.emit(s.Events.MESSAGE_REACTION_ADD,r,e),{message:i,reaction:r,user:e}}}t.exports=r},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client.users.get(t.user_id);if(!e)return!1;const n=this.client.channels.get(t.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(t.message_id);if(!i)return!1;if(!t.emoji)return!1;const r=i._removeReaction(t.emoji,e);return r&&this.client.emit(s.Events.MESSAGE_REACTION_REMOVE,r,e),{message:i,reaction:r,user:e}}}t.exports=r},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client.channels.get(t.channel_id);if(!e||"voice"===e.type)return!1;const n=e.messages.get(t.message_id);return!!n&&(n._clearReactions(),this.client.emit(s.Events.MESSAGE_REACTION_REMOVE_ALL,n),{message:n})}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(9);class o extends i{handle(t){const e=this.client,n=e.channels.get(t.channel_id);if(n){const i=n.messages.get(t.id);if(i){const o=new r(i.channel,this.patchDataPacket(t,i),e);return o._edits.push(i,...i._edits),o.reactions=i.reactions,n.messages.set(t.id,o),e.emit(s.Events.MESSAGE_UPDATE,i,o),{old:i,updated:o}}return{old:i,updated:i}}return{old:null,updated:null}}patchDataPacket(t,e){return t.type="type"in t?t.type:s.MessageTypes.indexOf(e.type),t.tts="tts"in t?t.tts:e.tts,t.timestamp="timestamp"in t?t.timestamp:e.createdAt.toString(),t.pinned="pinned"in t?t.pinned:e.pinned,t.nonce="nonce"in t?t.nonce:e.nonce,t.mentions="mentions"in t?t.mentions:e.mentions.users.keyArray(),t.mentions_roles="mentions_roles"in t?t.mentions_roles:e.mentions.roles.keyArray(),t.mention_everyone="mention_everyone"in t?t.mention_everyone:e.mentions.everyone,t.embeds="embeds"in t?t.embeds:e.embeds,t.content="content"in t?t.content:e.content,t.author="author"in t?t.author:{username:e.author.username,id:e.author.id,discriminator:e.author.discriminator,avatar:e.author.avatar},t.attachments="attachments"in t?t.attachments:e.attachments.array(),t}}t.exports=o},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.dataManager.newUser(t);return{user:n}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client,n=e.user.notes.get(t.id),i=t.note.length?t.note:null;return e.user.notes.set(t.id,i),e.emit(s.Events.USER_NOTE_UPDATE,t.id,n,i),{old:n,updated:i}}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client;if(e.user){if(e.user.equals(t))return{old:e.user,updated:e.user};const n=r.cloneObject(e.user);return e.user.patch(t),e.emit(s.Events.USER_UPDATE,n,e.user),{old:n,updated:e.user}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(25),s=n(0);class r{constructor(t,e,n,i,s,r){this.rest=t,this.client=t.client,this.method=e,this.path=n.toString(),this.auth=i,this.data=s,this.files=r,this.route=this.getRoute(this.path)}getRoute(t){let e=t.split("?")[0];if(e.includes("/channels/")||e.includes("/guilds/")){const t=e.includes("/channels/")?e.indexOf("/channels/"):e.indexOf("/guilds/"),n=e.substring(t).split("/")[2];e=e.replace(/(\d{8,})/g,":id").replace(":id",n)}return e}getAuth(){if(this.client.token&&this.client.user&&this.client.user.bot)return`Bot ${this.client.token}`;if(this.client.token)return this.client.token;throw new Error(s.Errors.NO_TOKEN)}gen(){const t=`${this.client.options.http.host}/api/v${this.client.options.http.version}`,e=i[this.method](`${t}${this.path}`);if(this.auth&&e.set("authorization",this.getAuth()),this.files){for(const t of this.files)t&&t.file&&e.attach(t.name,t.file,t.name);this.data=this.data||{},e.field("payload_json",JSON.stringify(this.data))}else this.data&&e.send(this.data);return this.client.browser||e.set("User-Agent",this.rest.userAgentManager.userAgent),e}}t.exports=r},function(t,e,n){const i=n(58),s=n(42),r=n(6),o=n(0),u=o.Endpoints,c=n(3),h=n(5),a=n(4),l=n(11),f=n(13),d=n(9),p=n(10),m=n(31),g=n(21),E=n(137),_=n(36),v=n(8),y=n(19),w=n(16),b=n(138);class A{constructor(t){this.rest=t,this.client=t.client,this._ackToken=null}login(t=this.client.token){return new Promise((e,n)=>{if("string"!=typeof t)throw new Error(o.Errors.INVALID_TOKEN);t=t.replace(/^Bot\s*/i,""),this.client.manager.connectToWebSocket(t,e,n)})}logout(){return this.rest.makeRequest("post",u.logout,!0,{})}getGateway(){return this.rest.makeRequest("get",u.gateway,!0).then(t=>{return this.client.ws.gateway=`${t.url}/?v=${this.client.options.ws.version}`,this.client.ws.gateway})}getBotGateway(){return this.rest.makeRequest("get",u.gateway.bot,!0)}fetchVoiceRegions(t){let e;return e=t?u.Guild(t).voiceRegions:u.voiceRegions,this.rest.makeRequest("get",e,!0).then(t=>{const e=new c;for(const n of t)e.set(n.id,new b(n));return e})}sendMessage(t,e,{tts,nonce,embed,disableEveryone,split,code,reply}={},n=null){return new Promise((i,s)=>{if("undefined"!=typeof e&&(e=this.client.resolver.resolveString(e)),"undefined"!=typeof nonce&&(nonce=parseInt(nonce),isNaN(nonce)||nonce<0))throw new RangeError("Message nonce must fit in an unsigned 64-bit integer.");if(e){if(split&&"object"!=typeof split&&(split={}),"undefined"==typeof code||"boolean"==typeof code&&code!==!0||(e=a.escapeMarkdown(this.client.resolver.resolveString(e),!0),e=`\`\`\`${"boolean"!=typeof code?code||"":""} +var $=n(52),Q=n(54),Z=n(55);e.Buffer=o,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),e.kMaxLength=s(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,n){return u(null,t,e,n)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,e,n){return h(null,t,e,n)},o.allocUnsafe=function(t){return a(null,t)},o.allocUnsafeSlow=function(t){return a(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,i=e.length,s=0,r=Math.min(n,i);s0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},o.prototype.compare=function(t,e,n,i,s){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var r=s-i,u=n-e,c=Math.min(r,u),h=this.slice(i,s),a=t.slice(e,n),l=0;ls)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var r=!1;;)switch(i){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return A(this,t,e,n);case"ascii":return T(this,t,e,n);case"latin1":case"binary":return R(this,t,e,n);case"base64":return D(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,e,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;o.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e0&&(s*=256);)i+=this[t+--e]*s;return i},o.prototype.readUInt8=function(t,e){return e||O(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||O(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||O(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||O(t,e,this.length);for(var i=this[t],s=1,r=0;++r=s&&(i-=Math.pow(2,8*e)),i},o.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||O(t,e,this.length);for(var i=e,s=1,r=this[t+--i];i>0&&(s*=256);)r+=this[t+--i]*s;return s*=128,r>=s&&(r-=Math.pow(2,8*e)),r},o.prototype.readInt8=function(t,e){return e||O(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},o.prototype.readInt16LE=function(t,e){e||O(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(t,e){e||O(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(t,e){return e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||O(t,4,this.length),Q.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||O(t,8,this.length),Q.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e|=0,n|=0,!i){var s=Math.pow(2,8*n)-1;P(this,t,e,n,s,0)}var r=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+r]=t/o&255;return e+n},o.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):G(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):G(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):x(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e|=0,!i){var s=Math.pow(2,8*n-1);P(this,t,e,n,s-1,-s)}var r=0,o=1,u=0;for(this[e]=255&t;++r>0)-u&255;return e+n},o.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e|=0,!i){var s=Math.pow(2,8*n-1);P(this,t,e,n,s-1,-s)}var r=n-1,o=1,u=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===u&&0!==this[e+r+1]&&(u=1),this[e+r]=(t/o>>0)-u&255;return e+n},o.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):G(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):G(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):x(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):x(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},o.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},o.prototype.writeDoubleLE=function(t,e,n){return q(this,t,e,!0,n)},o.prototype.writeDoubleBE=function(t,e,n){return q(this,t,e,!1,n)},o.prototype.copy=function(t,e,n,i){if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e=0;--s)t[s+e]=this[s+n];else if(r<1e3||!o.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var r;if("number"==typeof t)for(r=e;r0&&this._events[t].length>s&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function n(){this.removeListener(t,n),s||(s=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var s=!1;return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var n,s,o,u;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,s=-1,n===e||i(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(r(n)){for(u=o;u-- >0;)if(n[u]===e||n[u].listener&&n[u].listener===e){s=u;break}if(s<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],i(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,n){var i,s,r;!function(n,o){s=[],i=o,r="function"==typeof i?i.apply(e,s):i,!(void 0!==r&&(t.exports=r))}(this,function(){"use strict";function t(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function e(t){return(t&&t.__isLong__)===!0}function n(t,e){var n,i,r;return e?(t>>>=0,(r=0<=t&&t<256)&&(i=c[t])?i:(n=s(t,(0|t)<0?-1:0,!0),r&&(c[t]=n),n)):(t|=0,(r=-128<=t&&t<128)&&(i=u[t])?i:(n=s(t,t<0?-1:0,!1),r&&(u[t]=n),n))}function i(t,e){if(isNaN(t)||!isFinite(t))return e?m:p;if(e){if(t<0)return m;if(t>=l)return y}else{if(t<=-f)return w;if(t+1>=f)return v}return t<0?i(-t,e).neg():s(t%4294967296|0,t/4294967296|0,e)}function s(e,n,i){return new t(e,n,i)}function r(t,e,n){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return p;if("number"==typeof e?(n=e,e=!1):e=!!e,n=n||10,n<2||360)throw Error("interior hyphen");if(0===s)return r(t.substring(1),e,n).neg();for(var o=i(h(n,8)),u=p,c=0;c>>0:this.low},b.toNumber=function(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(this.low>>>0)},b.toString=function(t){if(t=t||10,t<2||36>>0,l=a.toString(t);if(o=c,o.isZero())return l+u;for(;l.length<6;)l="0"+l;u=""+l+u}},b.getHighBits=function(){return this.high},b.getHighBitsUnsigned=function(){return this.high>>>0},b.getLowBits=function(){return this.low},b.getLowBitsUnsigned=function(){return this.low>>>0},b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(w)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<=0},b.isOdd=function(){return 1===(1&this.low)},b.isEven=function(){return 0===(1&this.low)},b.equals=function(t){return e(t)||(t=o(t)),(this.unsigned===t.unsigned||this.high>>>31!==1||t.high>>>31!==1)&&(this.high===t.high&&this.low===t.low)},b.eq=b.equals,b.notEquals=function(t){return!this.eq(t)},b.neq=b.notEquals,b.lessThan=function(t){return this.comp(t)<0},b.lt=b.lessThan,b.lessThanOrEqual=function(t){return this.comp(t)<=0},b.lte=b.lessThanOrEqual,b.greaterThan=function(t){return this.comp(t)>0},b.gt=b.greaterThan,b.greaterThanOrEqual=function(t){return this.comp(t)>=0},b.gte=b.greaterThanOrEqual,b.compare=function(t){if(e(t)||(t=o(t)),this.eq(t))return 0;var n=this.isNegative(),i=t.isNegative();return n&&!i?-1:!n&&i?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},b.comp=b.compare,b.negate=function(){return!this.unsigned&&this.eq(w)?w:this.not().add(g)},b.neg=b.negate,b.add=function(t){e(t)||(t=o(t));var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,u=65535&this.low,c=t.high>>>16,h=65535&t.high,a=t.low>>>16,l=65535&t.low,f=0,d=0,p=0,m=0;return m+=u+l,p+=m>>>16,m&=65535,p+=r+a,d+=p>>>16,p&=65535,d+=i+h,f+=d>>>16,d&=65535,f+=n+c,f&=65535,s(p<<16|m,f<<16|d,this.unsigned)},b.subtract=function(t){return e(t)||(t=o(t)),this.add(t.neg())},b.sub=b.subtract,b.multiply=function(t){if(this.isZero())return p;if(e(t)||(t=o(t)),t.isZero())return p;if(this.eq(w))return t.isOdd()?w:p;if(t.eq(w))return this.isOdd()?w:p;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(d)&&t.lt(d))return i(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,r=65535&this.high,u=this.low>>>16,c=65535&this.low,h=t.high>>>16,a=65535&t.high,l=t.low>>>16,f=65535&t.low,m=0,g=0,E=0,_=0;return _+=c*f,E+=_>>>16,_&=65535,E+=u*f,g+=E>>>16,E&=65535,E+=c*l,g+=E>>>16,E&=65535,g+=r*f,m+=g>>>16,g&=65535,g+=u*l,m+=g>>>16,g&=65535,g+=c*a,m+=g>>>16,g&=65535,m+=n*f+r*l+u*a+c*h,m&=65535,s(E<<16|_,m<<16|g,this.unsigned)},b.mul=b.multiply,b.divide=function(t){if(e(t)||(t=o(t)),t.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:p;var n,s,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return m;if(t.gt(this.shru(1)))return E;r=m}else{if(this.eq(w)){if(t.eq(g)||t.eq(_))return w;if(t.eq(w))return g;var u=this.shr(1);return n=u.div(t).shl(1),n.eq(p)?t.isNegative()?g:_:(s=this.sub(t.mul(n)),r=n.add(s.div(t)))}if(t.eq(w))return this.unsigned?m:p;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=p}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(n)/Math.LN2),a=c<=48?1:h(2,c-48),l=i(n),f=l.mul(t);f.isNegative()||f.gt(s);)n-=a,l=i(n,this.unsigned),f=l.mul(t);l.isZero()&&(l=g),r=r.add(l),s=s.sub(f)}return r},b.div=b.divide,b.modulo=function(t){return e(t)||(t=o(t)),this.sub(this.div(t).mul(t))},b.mod=b.modulo,b.not=function(){return s(~this.low,~this.high,this.unsigned)},b.and=function(t){return e(t)||(t=o(t)),s(this.low&t.low,this.high&t.high,this.unsigned)},b.or=function(t){return e(t)||(t=o(t)),s(this.low|t.low,this.high|t.high,this.unsigned)},b.xor=function(t){return e(t)||(t=o(t)),s(this.low^t.low,this.high^t.high,this.unsigned)},b.shiftLeft=function(t){return e(t)&&(t=t.toInt()),0===(t&=63)?this:t<32?s(this.low<>>32-t,this.unsigned):s(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):s(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},b.shr=b.shiftRight,b.shiftRightUnsigned=function(t){if(e(t)&&(t=t.toInt()),t&=63,0===t)return this;var n=this.high;if(t<32){var i=this.low;return s(i>>>t|n<<32-t,n>>>t,this.unsigned)}return 32===t?s(n,0,this.unsigned):s(n>>>t-32,0,this.unsigned)},b.shru=b.shiftRightUnsigned,b.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},b.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},b.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},b.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255]},b.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e]},t})},function(t,e,n){(function(t){function n(t,e){for(var n=0,i=t.length-1;i>=0;i--){var s=t[i];"."===s?t.splice(i,1):".."===s?(t.splice(i,1),n++):n&&(t.splice(i,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(t,e){if(t.filter)return t.filter(e);for(var n=[],i=0;i=-1&&!s;r--){var o=r>=0?arguments[r]:t.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(e=o+"/"+e,s="/"===o.charAt(0))}return e=n(i(e.split("/"),function(t){return!!t}),!s).join("/"),(s?"/":"")+e||"."},e.normalize=function(t){var s=e.isAbsolute(t),r="/"===o(t,-1);return t=n(i(t.split("/"),function(t){return!!t}),!s).join("/"),t||s||(t="."),t&&r&&(t+="/"),(s?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(i(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},e.relative=function(t,n){function i(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=e.resolve(t).substr(1),n=e.resolve(n).substr(1);for(var s=i(t.split("/")),r=i(n.split("/")),o=Math.min(s.length,r.length),u=o,c=0;c=0?"&":"?")+t),this._sort){var e=this.url.indexOf("?");if(e>=0){var n=this.url.substring(e+1).split("&");g(this._sort)?n.sort(this._sort):n.sort(),this.url=this.url.substring(0,e)+"?"+n.join("&")}}},a.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},a.prototype.end=function(t){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||i,this._appendQueryString(),this._end()},a.prototype._end=function(){var t=this,e=this.xhr=v.getXHR(),n=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var n=e.readyState;if(n>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==n){var i;try{i=e.status}catch(t){i=0}if(!i){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var i=function(e,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=e,t.emit("progress",n)};if(this.hasListeners("progress"))try{e.onprogress=i.bind(null,"download"),e.upload&&(e.upload.onprogress=i.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof n&&!this._isHost(n)){var s=this._header["content-type"],r=this._serializer||v.serialize[s?s.split(";")[0]:""];!r&&c(s)&&(r=v.serialize["application/json"]),r&&(n=r(n))}for(var o in this.header)null!=this.header[o]&&e.setRequestHeader(o,this.header[o]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send("undefined"!=typeof n?n:null),this},v.get=function(t,e,n){var i=v("GET",t);return"function"==typeof e&&(n=e,e=null),e&&i.query(e),n&&i.end(n),i},v.head=function(t,e,n){var i=v("HEAD",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.options=function(t,e,n){var i=v("OPTIONS",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.del=l,v.delete=l,v.patch=function(t,e,n){var i=v("PATCH",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.post=function(t,e,n){var i=v("POST",t); +return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},v.put=function(t,e,n){var i=v("PUT",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i}},function(t,e){function n(t){return null!==t&&"object"==typeof t}t.exports=n},function(t,e,n){(function(e){const i=n(25),s=n(43),r=n(26),o=n(0),u=n(4).convertToBuffer,c=n(11),h=n(9),a=n(16),l=n(8),f=n(13),d=n(12),p=n(20);class m{constructor(t){this.client=t}resolveUser(t){return t instanceof c?t:"string"==typeof t?this.client.users.get(t)||null:t instanceof f?t.user:t instanceof h?t.author:t instanceof a?t.owner:null}resolveUserID(t){return t instanceof c||t instanceof f?t.id:"string"==typeof t?t||null:t instanceof h?t.author.id:t instanceof a?t.ownerID:null}resolveGuild(t){return t instanceof a?t:"string"==typeof t?this.client.guilds.get(t)||null:null}resolveGuildMember(t,e){return e instanceof f?e:(t=this.resolveGuild(t),e=this.resolveUser(e),t&&e?t.members.get(e.id)||null:null)}resolveChannel(t){return t instanceof l?t:"string"==typeof t?this.client.channels.get(t)||null:t instanceof h?t.channel:t instanceof a?t.channels.get(t.id)||null:null}resolveChannelID(t){return t instanceof l?t.id:"string"==typeof t?t:t instanceof h?t.channel.id:t instanceof a?t.defaultChannel.id:null}resolveInviteCode(t){const e=/discord(?:app\.com\/invite|\.gg)\/([\w-]{2,255})/i,n=e.exec(t);return n&&n[1]?n[1]:t}resolveString(t){return"string"==typeof t?t:t instanceof Array?t.join("\n"):String(t)}resolveBase64(t){return t instanceof e?`data:image/jpg;base64,${t.toString("base64")}`:t}resolveBuffer(t){return t instanceof e?Promise.resolve(t):this.client.browser&&t instanceof ArrayBuffer?Promise.resolve(u(t)):"string"==typeof t?new Promise((n,o)=>{if(/^https?:\/\//.test(t)){const i=r.get(t).set("Content-Type","blob");this.client.browser&&i.responseType("arraybuffer"),i.end((t,i)=>{return t?o(t):this.client.browser?n(u(i.xhr.response)):i.body instanceof e?n(i.body):o(new TypeError("The response body isn't a Buffer."))})}else{const e=i.resolve(t);s.stat(e,(t,i)=>{return t?o(t):i&&i.isFile()?(s.readFile(e,(t,e)=>{t?o(t):n(e)}),null):o(new Error(`The file could not be found: ${e}`))})}}):Promise.reject(new TypeError("The resource must be a string or Buffer."))}resolveEmojiIdentifier(t){return t instanceof d||t instanceof p?t.identifier:"string"!=typeof t||t.includes("%")?null:encodeURIComponent(t)}static resolveColor(t){if("string"==typeof t){if("RANDOM"===t)return Math.floor(16777216*Math.random());t=o.Colors[t]||parseInt(t.replace("#",""),16)}else t instanceof Array&&(t=(t[0]<<16)+(t[1]<<8)+t[2]);if(t<0||t>16777215)throw new RangeError("Color must be within the range 0 - 16777215 (0xFFFFFF).");if(t&&isNaN(t))throw new TypeError("Unable to convert color to a number.");return t}resolveColor(t){return this.constructor.resolveColor(t)}}t.exports=m}).call(e,n(22).Buffer)},function(t,e){t.exports={name:"discord.js",version:"11.0.0",description:"A powerful library for interacting with the Discord API",main:"./src/index",types:"./typings/index.d.ts",scripts:{test:"npm run lint && npm run docs:test",docs:"docgen --source src --custom docs/index.yml --output docs/docs.json","docs:test":"docgen --source src --custom docs/index.yml",lint:"eslint src","lint:fix":"eslint --fix src",webpack:"parallel-webpack"},repository:{type:"git",url:"git+https://github.com/hydrabolt/discord.js.git"},keywords:["discord","api","bot","client","node","discordapp"],author:"Amish Shah ",license:"Apache-2.0",bugs:{url:"https://github.com/hydrabolt/discord.js/issues"},homepage:"https://github.com/hydrabolt/discord.js#readme",runkitExampleFilename:"./docs/examples/ping.js",dependencies:{"@types/node":"^7.0.0",long:"^3.2.0","prism-media":"hydrabolt/prism-media",superagent:"^3.4.0",tweetnacl:"^0.14.0",ws:"^2.0.0"},peerDependencies:{bufferutil:"^2.0.0",erlpack:"hammerandchisel/erlpack","node-opus":"^0.2.0",opusscript:"^0.0.2",sodium:"^2.0.1",uws:"^0.14.1"},devDependencies:{"discord.js-docgen":"hydrabolt/discord.js-docgen",eslint:"^3.17.0","parallel-webpack":"^1.6.0","uglify-js":"mishoo/UglifyJS2#harmony",webpack:"^2.2.0"},engines:{node:">=6.0.0"},browser:{ws:!1,uws:!1,erlpack:!1,"prism-media":!1,opusscript:!1,"node-opus":!1,tweetnacl:!1,sodium:!1,"src/sharding/Shard.js":!1,"src/sharding/ShardClientUtil.js":!1,"src/sharding/ShardingManager.js":!1,"src/client/voice/dispatcher/StreamDispatcher.js":!1,"src/client/voice/opus/BaseOpusEngine.js":!1,"src/client/voice/opus/NodeOpusEngine.js":!1,"src/client/voice/opus/OpusEngineList.js":!1,"src/client/voice/opus/OpusScriptEngine.js":!1,"src/client/voice/pcm/ConverterEngine.js":!1,"src/client/voice/pcm/ConverterEngineList.js":!1,"src/client/voice/pcm/FfmpegConverterEngine.js":!1,"src/client/voice/player/AudioPlayer.js":!1,"src/client/voice/receiver/VoiceReadable.js":!1,"src/client/voice/receiver/VoiceReceiver.js":!1,"src/client/voice/util/Secretbox.js":!1,"src/client/voice/util/SecretKey.js":!1,"src/client/voice/util/VolumeInterface.js":!1,"src/client/voice/ClientVoiceManager.js":!1,"src/client/voice/VoiceBroadcast.js":!1,"src/client/voice/VoiceConnection.js":!1,"src/client/voice/VoiceUDPClient.js":!1,"src/client/voice/VoiceWebSocket.js":!1}}},function(t,e,n){const i=n(11),s=n(3);class r extends i{setup(t){super.setup(t),this.verified=t.verified,this.email=t.email,this.localPresence={},this._typing=new Map,this.friends=new s,this.blocked=new s,this.notes=new s,this.settings={},this.premium="boolean"==typeof t.premium?t.premium:null,this.mfaEnabled="boolean"==typeof t.mfa_enabled?t.mfa_enabled:null,this.mobile="boolean"==typeof t.mobile?t.mobile:null}edit(t){return this.client.rest.methods.updateCurrentUser(t)}setUsername(t,e){return this.client.rest.methods.updateCurrentUser({username:t},e)}setEmail(t,e){return this.client.rest.methods.updateCurrentUser({email:t},e)}setPassword(t,e){return this.client.rest.methods.updateCurrentUser({password:t},e)}setAvatar(t){return"string"==typeof t&&t.startsWith("data:")?this.client.rest.methods.updateCurrentUser({avatar:t}):this.client.resolver.resolveBuffer(t).then(t=>this.client.rest.methods.updateCurrentUser({avatar:t}))}setPresence(t){return new Promise(e=>{let n=this.localPresence.status||this.presence.status,i=this.localPresence.game,s=this.localPresence.afk||this.presence.afk;if(!i&&this.presence.game&&(i={name:this.presence.game.name,type:this.presence.game.type,url:this.presence.game.url}),t.status){if("string"!=typeof t.status)throw new TypeError("Status must be a string");n=t.status}t.game&&(i=t.game,i.url&&(i.type=1)),null===t.game&&(i=null),"undefined"!=typeof t.afk&&(s=t.afk),s=Boolean(s),this.localPresence={status:n,game:i,afk:s},this.localPresence.since=0,this.localPresence.game=this.localPresence.game||null,this.client.ws.send({op:3,d:this.localPresence}),this.client._setPresence(this.id,this.localPresence),e(this)})}setStatus(t){return this.setPresence({status:t})}setGame(t,e){return null===t?this.setPresence({game:t}):this.setPresence({game:{name:t,url:e}})}setAFK(t){return this.setPresence({afk:t})}fetchMentions(t={limit:25,roles:true,everyone:true,guild:null}){return this.client.rest.methods.fetchMentions(t)}addFriend(t){return t=this.client.resolver.resolveUser(t),this.client.rest.methods.addFriend(t)}removeFriend(t){return t=this.client.resolver.resolveUser(t),this.client.rest.methods.removeFriend(t)}createGuild(t,e,n=null){return n?"string"==typeof n&&n.startsWith("data:")?this.client.rest.methods.createGuild({name:t,icon:n,region:e}):this.client.resolver.resolveBuffer(n).then(n=>this.client.rest.methods.createGuild({name:t,icon:n,region:e})):this.client.rest.methods.createGuild({name:t,icon:n,region:e})}createGroupDM(t){return this.client.rest.methods.createGroupDM({recipients:t.map(t=>this.client.resolver.resolveUserID(t.user)),accessTokens:t.map(t=>t.accessToken),nicks:t.map(t=>t.nick)})}acceptInvite(t){return this.client.rest.methods.acceptInvite(t)}}t.exports=r},function(t,e,n){const i=n(8),s=n(14),r=n(3);class o extends i{constructor(t,e){super(t,e),this.type="dm",this.messages=new r,this._typing=new Map}setup(t){super.setup(t),this.recipient=this.client.dataManager.newUser(t.recipients[0]),this.lastMessageID=t.last_message_id}toString(){return this.recipient.toString()}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendFiles(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0,["bulkDelete"]),t.exports=o},function(t,e,n){const i=n(38),s=n(39),r=n(0);class o{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.guild=this.client.guilds.get(t.guild.id)||new i(this.client,t.guild),this.code=t.code,this.temporary=t.temporary,this.maxAge=t.max_age,this.uses=t.uses,this.maxUses=t.max_uses,t.inviter&&(this.inviter=this.client.dataManager.newUser(t.inviter)),this.channel=this.client.channels.get(t.channel.id)||new s(this.client,t.channel),this.createdTimestamp=new Date(t.created_at).getTime()}get createdAt(){return new Date(this.createdTimestamp)}get expiresTimestamp(){return this.createdTimestamp+1e3*this.maxAge}get expiresAt(){return new Date(this.expiresTimestamp)}get url(){return r.Endpoints.inviteLink(this.code)}delete(){return this.client.rest.methods.deleteInvite(this)}toString(){return this.url}}t.exports=o},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.message=t,this.setup(e)}setup(t){this.id=t.id,this.filename=t.filename,this.filesize=t.size,this.url=t.url,this.proxyURL=t.proxy_url,this.height=t.height,this.width=t.width}}t.exports=n},function(t,e,n){const i=n(23).EventEmitter,s=n(3);class r extends i{constructor(t,e,n={}){super(),this.channel=t,this.filter=e,this.options=n,this.ended=!1,this.collected=new s,this.listener=(t=>this.verify(t)),this.channel.client.on("message",this.listener),n.time&&this.channel.client.setTimeout(()=>this.stop("time"),n.time)}verify(t){return(!this.channel||this.channel.id===t.channel.id)&&(!!this.filter(t,this)&&(this.collected.set(t.id,t),this.emit("message",t,this),this.collected.size>=this.options.maxMatches?this.stop("matchesLimit"):this.options.max&&this.collected.size===this.options.max&&this.stop("limit"),!0))}get next(){return new Promise((t,e)=>{if(this.ended)return void e(this.collected);const n=()=>{this.removeListener("message",i),this.removeListener("end",s)},i=(...e)=>{n(),t(...e)},s=(...t)=>{n(),e(...t)};this.once("message",i),this.once("end",s)})}stop(t="user"){this.ended||(this.ended=!0,this.channel.client.removeListener("message",this.listener),this.emit("end",this.collected,t))}}t.exports=r},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.message=t,this.setup(e)}setup(t){if(this.type=t.type,this.title=t.title,this.description=t.description,this.url=t.url,this.color=t.color,this.fields=[],t.fields)for(const e of t.fields)this.fields.push(new c(this,e));this.createdTimestamp=t.timestamp,this.thumbnail=t.thumbnail?new i(this,t.thumbnail):null,this.image=t.image?new s(this,t.image):null,this.video=t.video?new r(this,t.video):null,this.author=t.author?new u(this,t.author):null,this.provider=t.provider?new o(this,t.provider):null,this.footer=t.footer?new h(this,t.footer):null}get createdAt(){return new Date(this.createdTimestamp)}get hexColor(){let t=this.color.toString(16);for(;t.length<6;)t=`0${t}`;return`#${t}`}}class i{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.url=t.url,this.proxyURL=t.proxy_url,this.height=t.height,this.width=t.width}}class s{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.url=t.url,this.proxyURL=t.proxy_url,this.height=t.height,this.width=t.width}}class r{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.url=t.url,this.height=t.height,this.width=t.width}}class o{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.url=t.url}}class u{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.url=t.url,this.iconURL=t.icon_url}}class c{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.value=t.value,this.inline=t.inline}}class h{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.text=t.text,this.iconURL=t.icon_url,this.proxyIconUrl=t.proxy_icon_url}}n.Thumbnail=i,n.Image=s,n.Video=r,n.Provider=o,n.Author=u,n.Field=c,n.Footer=h,t.exports=n},function(t,e,n){const i=n(3),s=n(12),r=n(20);class o{constructor(t,e,n,s){this.message=t,this.me=s,this.count=n||0,this.users=new i,this._emoji=new r(this,e.name,e.id)}get emoji(){if(this._emoji instanceof s)return this._emoji;if(this._emoji.id){const t=this.message.client.emojis;if(t.has(this._emoji.id)){const e=t.get(this._emoji.id);return this._emoji=e,e}}return this._emoji}remove(t=this.message.client.user){const e=this.message;return t=this.message.client.resolver.resolveUserID(t),t?e.client.rest.methods.removeMessageReaction(e,this.emoji.identifier,t):Promise.reject(new Error("Couldn't resolve the user ID to remove from the reaction."))}fetchUsers(t=100){const e=this.message;return e.client.rest.methods.getMessageReactionUsers(e,this.emoji.identifier,t).then(t=>{this.users=new i;for(const e of t){const t=this.message.client.dataManager.newUser(e);this.users.set(t.id,t)}return this.count=this.users.size,this.users})}}t.exports=o},function(t,e,n){const i=n(5);class s{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.description=t.description,this.icon=t.icon,this.iconURL=`https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`,this.rpcOrigins=t.rpc_origins,this.redirectURIs=t.redirect_uris,this.botRequireCodeGrant=t.bot_require_code_grant,this.botPublic=t.bot_public,this.rpcApplicationState=t.rpc_application_state,this.bot=t.bot,this.flags=t.flags,this.secret=t.secret}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}reset(){return this.client.rest.methods.resetApplication(this.id)}toString(){return this.name}}t.exports=s},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.icon=t.icon,this.splash=t.splash}}t.exports=n},function(t,e,n){const i=n(0);class s{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.type=i.ChannelTypes.TEXT===t.type?"text":"voice"}}t.exports=s},function(t,e){class n{constructor(t,e){Object.defineProperty(this,"channel",{value:t}),e&&this.setup(e)}setup(t){this.id=t.id,this.type=t.type,this.deny=t.deny,this.allow=t.allow}delete(){return this.channel.client.rest.methods.deletePermissionOverwrites(this)}}t.exports=n},function(t,e,n){const i=n(17),s=n(14),r=n(3);class o extends i{constructor(t,e){super(t,e),this.type="text",this.messages=new r,this._typing=new Map}setup(t){super.setup(t),this.topic=t.topic,this.lastMessageID=t.last_message_id}get members(){const t=new r;for(const e of this.guild.members.values())this.permissionsFor(e).hasPermission("READ_MESSAGES")&&t.set(e.id,e);return t}fetchWebhooks(){return this.client.rest.methods.getChannelWebhooks(this)}createWebhook(t,e){return new Promise(n=>{"string"==typeof e&&e.startsWith("data:")?n(this.client.rest.methods.createWebhook(this,t,e)):this.client.resolver.resolveBuffer(e).then(e=>n(this.client.rest.methods.createWebhook(this,t,e)))})}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendFiles(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0),t.exports=o},function(t,e,n){const i=n(17),s=n(3);class r extends i{constructor(t,e){super(t,e),this.members=new s,this.type="voice"}setup(t){super.setup(t),this.bitrate=t.bitrate,this.userLimit=t.user_limit}get connection(){const t=this.guild.voiceConnection;return t&&t.channel.id===this.id?t:null}get full(){return this.userLimit>0&&this.members.size>=this.userLimit}get joinable(){return!this.client.browser&&(!!this.permissionsFor(this.client.user).hasPermission("CONNECT")&&!(this.full&&!this.permissionsFor(this.client.user).hasPermission("MOVE_MEMBERS")))}get speakable(){return this.permissionsFor(this.client.user).hasPermission("SPEAK")}setBitrate(t){return this.edit({bitrate:t})}setUserLimit(t){return this.edit({userLimit:t})}join(){return this.client.browser?Promise.reject(new Error("Voice connections are not available in browsers.")):this.client.voice.joinChannel(this)}leave(){if(!this.client.browser){const t=this.client.voice.connections.get(this.guild.id);t&&t.channel.id===this.id&&t.disconnect()}}}t.exports=r},function(t,e){},function(t,e,n){const i=n(99),s=n(96),r=n(98),o=n(97),u=n(95),c=n(0);class h{constructor(t){this.client=t,this.handlers={},this.userAgentManager=new i(this),this.methods=new s(this),this.rateLimitedEndpoints={},this.globallyRateLimited=!1}push(t,e){return new Promise((n,i)=>{t.push({request:e,resolve:n,reject:i})})}getRequestHandler(){switch(this.client.options.apiRequestMethod){case"sequential":return r;case"burst":return o;default:throw new Error(c.Errors.INVALID_RATE_LIMIT_METHOD)}}makeRequest(t,e,n,i,s){const r=new u(this,t,e,n,i,s);if(!this.handlers[r.route]){const t=this.getRequestHandler();this.handlers[r.route]=new t(this,r.route)}return this.push(this.handlers[r.route],r)}}t.exports=h},function(t,e){class n{constructor(t){this.restManager=t,this.queue=[]}get globalLimit(){return this.restManager.globallyRateLimited}set globalLimit(t){this.restManager.globallyRateLimited=t}push(t){this.queue.push(t)}handle(){}}t.exports=n},function(module,exports,__webpack_require__){(function(process){const os=__webpack_require__(15),EventEmitter=__webpack_require__(23).EventEmitter,Constants=__webpack_require__(0),Permissions=__webpack_require__(6),Util=__webpack_require__(4),RESTManager=__webpack_require__(44),ClientDataManager=__webpack_require__(65),ClientManager=__webpack_require__(66),ClientDataResolver=__webpack_require__(28),ClientVoiceManager=__webpack_require__(140),WebSocketManager=__webpack_require__(100),ActionsManager=__webpack_require__(67),Collection=__webpack_require__(3),Presence=__webpack_require__(7).Presence,ShardClientUtil=__webpack_require__(139),VoiceBroadcast=__webpack_require__(141);class Client extends EventEmitter{constructor(t={}){super(),!t.shardId&&"SHARD_ID"in process.env&&(t.shardId=Number(process.env.SHARD_ID)),!t.shardCount&&"SHARD_COUNT"in process.env&&(t.shardCount=Number(process.env.SHARD_COUNT)),this.options=Util.mergeDefault(Constants.DefaultOptions,t),this._validateOptions(),this.rest=new RESTManager(this),this.dataManager=new ClientDataManager(this),this.manager=new ClientManager(this),this.ws=new WebSocketManager(this),this.resolver=new ClientDataResolver(this),this.actions=new ActionsManager(this),this.voice=this.browser?null:new ClientVoiceManager(this),this.shard=process.send?ShardClientUtil.singleton(this):null,this.users=new Collection,this.guilds=new Collection,this.channels=new Collection,this.presences=new Collection,!this.token&&"CLIENT_TOKEN"in process.env?this.token=process.env.CLIENT_TOKEN:this.token=null,this.user=null,this.readyAt=null,this.broadcasts=[],this.pings=[],this._pingTimestamp=0,this._timeouts=new Set,this._intervals=new Set,this.options.messageSweepInterval>0&&this.setInterval(this.sweepMessages.bind(this),1e3*this.options.messageSweepInterval)}get status(){return this.ws.status}get uptime(){return this.readyAt?Date.now()-this.readyAt:null}get ping(){return this.pings.reduce((t,e)=>t+e,0)/this.pings.length}get voiceConnections(){return this.browser?new Collection:this.voice.connections}get emojis(){const t=new Collection;for(const e of this.guilds.values())for(const n of e.emojis.values())t.set(n.id,n);return t}get readyTimestamp(){return this.readyAt?this.readyAt.getTime():null}get browser(){return"browser"===os.platform()}createVoiceBroadcast(){const t=new VoiceBroadcast(this);return this.broadcasts.push(t),t}login(t){return this.rest.methods.login(t)}destroy(){for(const t of this._timeouts)clearTimeout(t);for(const e of this._intervals)clearInterval(e);return this._timeouts.clear(),this._intervals.clear(),this.manager.destroy()}syncGuilds(t=this.guilds){this.user.bot||this.ws.send({op:12,d:t instanceof Collection?t.keyArray():t.map(t=>t.id)})}fetchUser(t,e=true){return this.users.has(t)?Promise.resolve(this.users.get(t)):this.rest.methods.getUser(t,e)}fetchInvite(t){const e=this.resolver.resolveInviteCode(t);return this.rest.methods.getInvite(e)}fetchWebhook(t,e){return this.rest.methods.getWebhook(t,e)}fetchVoiceRegions(){return this.rest.methods.fetchVoiceRegions()}sweepMessages(t=this.options.messageCacheLifetime){if("number"!=typeof t||isNaN(t))throw new TypeError("The lifetime must be a number.");if(t<=0)return this.emit("debug","Didn't sweep messages - lifetime is unlimited"),-1;const e=1e3*t,n=Date.now();let i=0,s=0;for(const r of this.channels.values())if(r.messages){i++;for(const t of r.messages.values())n-(t.editedTimestamp||t.createdTimestamp)>e&&(r.messages.delete(t.id),s++)}return this.emit("debug",`Swept ${s} messages older than ${t} seconds in ${i} text-based channels`),s}fetchApplication(t="@me"){return this.rest.methods.getApplication(t)}generateInvite(t){return t?t instanceof Array&&(t=Permissions.resolve(t)):t=0,this.fetchApplication().then(e=>`https://discordapp.com/oauth2/authorize?client_id=${e.id}&permissions=${t}&scope=bot`)}setTimeout(t,e,...n){const i=setTimeout(()=>{t(),this._timeouts.delete(i)},e,...n);return this._timeouts.add(i),i}clearTimeout(t){clearTimeout(t),this._timeouts.delete(t)}setInterval(t,e,...n){const i=setInterval(t,e,...n);return this._intervals.add(i),i}clearInterval(t){clearInterval(t),this._intervals.delete(t)}_pong(t){this.pings.unshift(Date.now()-t),this.pings.length>3&&(this.pings.length=3),this.ws.lastHeartbeatAck=!0}_setPresence(t,e){return this.presences.has(t)?void this.presences.get(t).update(e):void this.presences.set(t,new Presence(e))}_eval(script){return eval(script)}_validateOptions(t=this.options){if("number"!=typeof t.shardCount||isNaN(t.shardCount))throw new TypeError("The shardCount option must be a number.");if("number"!=typeof t.shardId||isNaN(t.shardId))throw new TypeError("The shardId option must be a number.");if(t.shardCount<0)throw new RangeError("The shardCount option must be at least 0.");if(t.shardId<0)throw new RangeError("The shardId option must be at least 0.");if(0!==t.shardId&&t.shardId>=t.shardCount)throw new RangeError("The shardId option must be less than shardCount.");if("number"!=typeof t.messageCacheMaxSize||isNaN(t.messageCacheMaxSize))throw new TypeError("The messageCacheMaxSize option must be a number.");if("number"!=typeof t.messageCacheLifetime||isNaN(t.messageCacheLifetime))throw new TypeError("The messageCacheLifetime option must be a number.");if("number"!=typeof t.messageSweepInterval||isNaN(t.messageSweepInterval))throw new TypeError("The messageSweepInterval option must be a number.");if("boolean"!=typeof t.fetchAllMembers)throw new TypeError("The fetchAllMembers option must be a boolean.");if("boolean"!=typeof t.disableEveryone)throw new TypeError("The disableEveryone option must be a boolean.");if("number"!=typeof t.restWsBridgeTimeout||isNaN(t.restWsBridgeTimeout))throw new TypeError("The restWsBridgeTimeout option must be a number.");if(!(t.disabledEvents instanceof Array))throw new TypeError("The disabledEvents option must be an Array.")}}module.exports=Client}).call(exports,__webpack_require__(18))},function(t,e,n){const i=n(21),s=n(44),r=n(28),o=n(0),u=n(4);class c extends i{constructor(t,e,n){super(null,t,e),this.options=u.mergeDefault(o.DefaultOptions,n),this.rest=new s(this),this.resolver=new r(this),this._timeouts=new Set,this._intervals=new Set}setTimeout(t,e,...n){const i=setTimeout(()=>{t(),this._timeouts.delete(i)},e,...n);return this._timeouts.add(i),i}clearTimeout(t){clearTimeout(t),this._timeouts.delete(t)}setInterval(t,e,...n){const i=setInterval(t,e,...n);return this._intervals.add(i),i}clearInterval(t){clearInterval(t),this._intervals.delete(t)}destroy(){for(const t of this._timeouts)clearTimeout(t);for(const e of this._intervals)clearInterval(e);this._timeouts.clear(),this._intervals.clear()}}t.exports=c},function(t,e,n){function i(t){return"string"==typeof t?t:t instanceof Array?t.join("\n"):String(t)}const s=n(28);class r{constructor(t={}){this.title=t.title,this.description=t.description,this.url=t.url,this.color=t.color,this.author=t.author,this.timestamp=t.timestamp,this.fields=t.fields||[],this.thumbnail=t.thumbnail,this.image=t.image,this.footer=t.footer,this.file=t.file}setTitle(t){if(t=i(t),t.length>256)throw new RangeError("RichEmbed titles may not exceed 256 characters.");return this.title=t,this}setDescription(t){if(t=i(t),t.length>2048)throw new RangeError("RichEmbed descriptions may not exceed 2048 characters.");return this.description=t,this}setURL(t){return this.url=t,this}setColor(t){return this.color=s.resolveColor(t),this}setAuthor(t,e,n){return this.author={name:i(t),icon_url:e,url:n},this}setTimestamp(t=new Date){return this.timestamp=t,this}addField(t,e,n=false){if(this.fields.length>=25)throw new RangeError("RichEmbeds may not exceed 25 fields.");if(t=i(t),t.length>256)throw new RangeError("RichEmbed field names may not exceed 256 characters.");if(!/\S/.test(t))throw new RangeError("RichEmbed field names may not be empty.");if(e=i(e),e.length>1024)throw new RangeError("RichEmbed field values may not exceed 1024 characters.");if(!/\S/.test(e))throw new RangeError("RichEmbed field values may not be empty.");return this.fields.push({name:t,value:e,inline:n}),this}addBlankField(t=false){return this.addField("​","​",t)}setThumbnail(t){return this.thumbnail={url:t},this}setImage(t){return this.image={url:t},this}setFooter(t,e){if(t=i(t),t.length>2048)throw new RangeError("RichEmbed footer text may not exceed 2048 characters.");return this.footer={text:t,icon_url:e},this}attachFile(t){if(this.file)throw new RangeError("You may not upload more than one file at once.");return this.file=t,this}}t.exports=r},function(t,e){},function(t,e){},function(t,e){},function(t,e,n){"use strict";function i(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function s(t){return 3*t.length/4-i(t)}function r(t){var e,n,s,r,o,u,c=t.length;o=i(t),u=new l(3*c/4-o),s=o>0?c-4:c;var h=0;for(e=0,n=0;e>16&255,u[h++]=r>>8&255,u[h++]=255&r;return 2===o?(r=a[t.charCodeAt(e)]<<2|a[t.charCodeAt(e+1)]>>4,u[h++]=255&r):1===o&&(r=a[t.charCodeAt(e)]<<10|a[t.charCodeAt(e+1)]<<4|a[t.charCodeAt(e+2)]>>2,u[h++]=r>>8&255,u[h++]=255&r),u}function o(t){return h[t>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}function u(t,e,n){for(var i,s=[],r=e;ra?a:c+o));return 1===i?(e=t[n-1],s+=h[e>>2],s+=h[e<<4&63],s+="=="):2===i&&(e=(t[n-2]<<8)+t[n-1],s+=h[e>>10],s+=h[e>>4&63],s+=h[e<<2&63],s+="="),r.push(s),r.join("")}e.byteLength=s,e.toByteArray=r,e.fromByteArray=c;for(var h=[],a=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,p=f.length;d>1,a=-7,l=n?s-1:0,f=n?-1:1,d=t[e+l];for(l+=f,r=d&(1<<-a)-1,d>>=-a,a+=u;a>0;r=256*r+t[e+l],l+=f,a-=8);for(o=r&(1<<-a)-1,r>>=-a,a+=i;a>0;o=256*o+t[e+l],l+=f,a-=8);if(0===r)r=1-h;else{if(r===c)return o?NaN:(d?-1:1)*(1/0);o+=Math.pow(2,i),r-=h}return(d?-1:1)*o*Math.pow(2,r-i)},e.write=function(t,e,n,i,s,r){var o,u,c,h=8*r-s-1,a=(1<>1,f=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:r-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,o=a):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),e+=o+l>=1?f/c:f*Math.pow(2,1-l),e*c>=2&&(o++,c/=2),o+l>=a?(u=0,o=a):o+l>=1?(u=(e*c-1)*Math.pow(2,s),o+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,s),o=0));s>=8;t[n+d]=255&u,d+=p,u/=256,s-=8);for(o=o<0;t[n+d]=255&o,d+=p,o/=256,h-=8);t[n+d-p]|=128*m}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,r){e=e||"&",n=n||"=";var o={};if("string"!=typeof t||0===t.length)return o;var u=/\+/g;t=t.split(e);var c=1e3;r&&"number"==typeof r.maxKeys&&(c=r.maxKeys);var h=t.length;c>0&&h>c&&(h=c);for(var a=0;a=0?(l=m.substr(0,g),f=m.substr(g+1)):(l=m,f=""),d=decodeURIComponent(l),p=decodeURIComponent(f),i(o,d)?s(o[d])?o[d].push(p):o[d]=[o[d],p]:o[d]=p}return o};var s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";function i(t,e){if(t.map)return t.map(e);for(var n=[],i=0;i=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(r(t)){for(var n in t)this.set(n,t[n]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),r(t)){for(var n in t)this.field(n,t[n]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype.withCredentials=function(){return this._withCredentials=!0,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=r(t),n=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&r(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(n||this.type("form"),n=this._header["content-type"],"application/x-www-form-urlencoded"==n?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(n||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort="undefined"==typeof t||t,this},i.prototype._timeoutError=function(t,e){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout)},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout)},this._responseTimeout))}},function(t,e,n){function i(t){if(t)return s(t)}function s(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}var r=n(63);t.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=r.type(e);var n=r.params(e);for(var i in n)this[i]=n[i];this.links={};try{t.link&&(this.links=r.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t}},function(t,e){var n=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];t.exports=function(t,e){return!!(t&&t.code&&~n.indexOf(t.code))||(!!(e&&e.status&&e.status>=500)||!!(t&&"timeout"in t&&"ECONNABORTED"==t.code))}},function(t,e){e.type=function(t){return t.split(/ *; */).shift()},e.params=function(t){return t.split(/ *; */).reduce(function(t,e){var n=e.split(/ *= */),i=n.shift(),s=n.shift();return i&&s&&(t[i]=s),t},{})},e.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var n=e.split(/ *; */),i=n[0].slice(1,-1),s=n[1].split(/ *= */)[1].slice(1,-1);return t[s]=i,t},{})},e.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&delete t.cookie,t}},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){const i=n(0),s=n(4),r=n(16),o=n(11),u=n(31),c=n(12),h=n(41),a=n(42),l=n(17),f=n(19);class d{constructor(t){this.client=t}get pastReady(){return this.client.ws.status===i.Status.READY}newGuild(t){const e=this.client.guilds.has(t.id),n=new r(this.client,t);return this.client.guilds.set(n.id,n),this.pastReady&&!e&&(this.client.options.fetchAllMembers?n.fetchMembers().then(()=>{this.client.emit(i.Events.GUILD_CREATE,n)}):this.client.emit(i.Events.GUILD_CREATE,n)),n}newUser(t){if(this.client.users.has(t.id))return this.client.users.get(t.id);const e=new o(this.client,t);return this.client.users.set(e.id,e),e}newChannel(t,e){const n=this.client.channels.has(t.id);let s;return t.type===i.ChannelTypes.DM?s=new u(this.client,t):t.type===i.ChannelTypes.GROUP_DM?s=new f(this.client,t):(e=e||this.client.guilds.get(t.guild_id),e&&(t.type===i.ChannelTypes.TEXT?(s=new h(e,t),e.channels.set(s.id,s)):t.type===i.ChannelTypes.VOICE&&(s=new a(e,t),e.channels.set(s.id,s)))),s?(this.pastReady&&!n&&this.client.emit(i.Events.CHANNEL_CREATE,s),this.client.channels.set(s.id,s),s):null}newEmoji(t,e){const n=e.emojis.has(t.id);if(t&&!n){let n=new c(e,t);return this.client.emit(i.Events.GUILD_EMOJI_CREATE,n),e.emojis.set(n.id,n),n}return n?e.emojis.get(t.id):null}killEmoji(t){t instanceof c&&t.guild&&(this.client.emit(i.Events.GUILD_EMOJI_DELETE,t),t.guild.emojis.delete(t.id))}killGuild(t){const e=this.client.guilds.has(t.id);this.client.guilds.delete(t.id),e&&this.pastReady&&this.client.emit(i.Events.GUILD_DELETE,t)}killUser(t){this.client.users.delete(t.id)}killChannel(t){this.client.channels.delete(t.id),t instanceof l&&t.guild.channels.delete(t.id)}updateGuild(t,e){const n=s.cloneObject(t);t.setup(e),this.pastReady&&this.client.emit(i.Events.GUILD_UPDATE,n,t)}updateChannel(t,e){t.setup(e)}updateEmoji(t,e){const n=s.cloneObject(t);return t.setup(e),this.client.emit(i.Events.GUILD_EMOJI_UPDATE,n,t),t}}t.exports=d},function(t,e,n){const i=n(0);class s{constructor(t){this.client=t,this.heartbeatInterval=null}connectToWebSocket(t,e,n){this.client.emit(i.Events.DEBUG,`Authenticated using token ${t}`),this.client.token=t;const s=this.client.setTimeout(()=>n(new Error(i.Errors.TOOK_TOO_LONG)),3e5);this.client.rest.methods.getGateway().then(r=>{this.client.emit(i.Events.DEBUG,`Using gateway ${r}`),this.client.ws.connect(r),this.client.ws.once("close",t=>{4004===t.code&&n(new Error(i.Errors.BAD_LOGIN)),4010===t.code&&n(new Error(i.Errors.INVALID_SHARD)),4011===t.code&&n(new Error(i.Errors.SHARDING_REQUIRED))}),this.client.once(i.Events.READY,()=>{e(t),this.client.clearTimeout(s)})},n)}setupKeepAlive(t){this.heartbeatInterval=this.client.setInterval(()=>this.client.ws.heartbeat(!0),t)}destroy(){return this.client.ws.destroy(),this.client.user?this.client.user.bot?(this.client.token=null,Promise.resolve()):this.client.rest.methods.logout().then(()=>{this.client.token=null}):Promise.resolve()}}t.exports=s},function(t,e,n){class i{constructor(t){this.client=t,this.register(n(85)),this.register(n(86)),this.register(n(87)),this.register(n(91)),this.register(n(88)),this.register(n(89)),this.register(n(90)),this.register(n(68)),this.register(n(69)),this.register(n(70)),this.register(n(73)),this.register(n(84)),this.register(n(77)),this.register(n(78)),this.register(n(71)),this.register(n(79)),this.register(n(80)),this.register(n(81)),this.register(n(92)),this.register(n(94)),this.register(n(93)),this.register(n(83)),this.register(n(74)),this.register(n(75)),this.register(n(76)),this.register(n(82)),this.register(n(72))}register(t){this[t.name.replace(/Action$/,"")]=new t(this.client)}}t.exports=i},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.dataManager.newChannel(t);return{channel:n}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client;let n=e.channels.get(t.id);return n?(e.dataManager.killChannel(n),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)):n=this.deleted.get(t.id)||null,{channel:n}}scheduleForDeletion(t){this.client.setTimeout(()=>this.deleted.delete(t),this.client.options.restWsBridgeTimeout)}}t.exports=s},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client,n=e.channels.get(t.id);if(n){const i=r.cloneObject(n);return n.setup(t),e.emit(s.Events.CHANNEL_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id),i=e.dataManager.newUser(t.user);n&&i&&e.emit(s.Events.GUILD_BAN_REMOVE,n,i)}}t.exports=r},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n)for(const i of t.channels){const t=n.channels.get(i.id);t&&(t.position=i.position)}return{guild:n}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0);class r extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client;let n=e.guilds.get(t.id);if(n){for(const i of n.channels.values())"text"===i.type&&i.stopTyping(!0);if(n.available&&t.unavailable)return n.available=!1,e.emit(s.Events.GUILD_UNAVAILABLE,n),{guild:null};e.guilds.delete(n.id),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)}else n=this.deleted.get(t.id)||null;return{guild:n}}scheduleForDeletion(t){this.client.setTimeout(()=>this.deleted.delete(t),this.client.options.restWsBridgeTimeout)}}t.exports=r},function(t,e,n){const i=n(2);class s extends i{handle(t,e){const n=this.client,i=n.dataManager.newEmoji(e,t);return{emoji:i}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client;return e.dataManager.killEmoji(t),{emoji:t}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t,e){const n=this.client.dataManager.updateEmoji(t,e);return{emoji:n}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t,e){const n=t._addMember(e,!1);return{member:n}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0);class r extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){let i=n.members.get(t.user.id);return i?(n.memberCount--,n._removeMember(i),this.deleted.set(n.id+t.user.id,i),e.status===s.Status.READY&&e.emit(s.Events.GUILD_MEMBER_REMOVE,i),this.scheduleForDeletion(n.id,t.user.id)):i=this.deleted.get(n.id+t.user.id)||null,{guild:n,member:i}}return{guild:n,member:null}}scheduleForDeletion(t,e){this.client.setTimeout(()=>this.deleted.delete(t+e),this.client.options.restWsBridgeTimeout)}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(10);class o extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){const i=n.roles.has(t.role.id),o=new r(n,t.role);return n.roles.set(o.id,o),i||e.emit(s.Events.GUILD_ROLE_CREATE,o),{role:o}}return{role:null}}}t.exports=o},function(t,e,n){const i=n(2),s=n(0);class r extends i{constructor(t){super(t),this.deleted=new Map}handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){let i=n.roles.get(t.role_id);return i?(n.roles.delete(t.role_id),this.deleted.set(n.id+t.role_id,i),this.scheduleForDeletion(n.id,t.role_id),e.emit(s.Events.GUILD_ROLE_DELETE,i)):i=this.deleted.get(n.id+t.role_id)||null,{role:i}}return{role:null}}scheduleForDeletion(t,e){this.client.setTimeout(()=>this.deleted.delete(t+e),this.client.options.restWsBridgeTimeout)}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n){const i=t.role;let o=null;const u=n.roles.get(i.id);return u&&(o=r.cloneObject(u),u.setup(t.role),e.emit(s.Events.GUILD_ROLE_UPDATE,o,u)),{old:o,updated:u}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);if(n)for(const i of t.roles){const t=n.roles.get(i.id);t&&(t.position=i.position)}return{guild:n}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.guilds.get(t.id);if(n){if(t.presences)for(const e of t.presences)n._setPresence(e.user.id,e);if(t.members)for(const i of t.members){const t=n.members.get(i.user.id);t?n._updateMember(t,i):n._addMember(i,!1)}"large"in t&&(n.large=t.large)}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client,n=e.guilds.get(t.id);if(n){const i=r.cloneObject(n);return n.setup(t),e.emit(s.Events.GUILD_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(2),s=n(9);class r extends i{handle(t){const e=this.client,n=e.channels.get((t instanceof Array?t[0]:t).channel_id),i=e.users.get((t instanceof Array?t[0]:t).author.id);if(n){const r=n.guild?n.guild.member(i):null;if(t instanceof Array){const o=new Array(t.length);for(let u=0;uthis.deleted.delete(t+e),this.client.options.restWsBridgeTimeout)}}t.exports=s},function(t,e,n){const i=n(2),s=n(3),r=n(0);class o extends i{handle(t){const e=this.client,n=e.channels.get(t.channel_id),i=t.ids,o=new s;for(const u of i){const t=n.messages.get(u);t&&o.set(t.id,t)}return o.size>0&&e.emit(r.Events.MESSAGE_BULK_DELETE,o),{messages:o}}}t.exports=o},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client.users.get(t.user_id);if(!e)return!1;const n=this.client.channels.get(t.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(t.message_id);if(!i)return!1;if(!t.emoji)return!1;const r=i._addReaction(t.emoji,e);return r&&this.client.emit(s.Events.MESSAGE_REACTION_ADD,r,e),{message:i,reaction:r,user:e}}}t.exports=r},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client.users.get(t.user_id);if(!e)return!1;const n=this.client.channels.get(t.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(t.message_id);if(!i)return!1;if(!t.emoji)return!1;const r=i._removeReaction(t.emoji,e);return r&&this.client.emit(s.Events.MESSAGE_REACTION_REMOVE,r,e),{message:i,reaction:r,user:e}}}t.exports=r},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client.channels.get(t.channel_id);if(!e||"voice"===e.type)return!1;const n=e.messages.get(t.message_id);return!!n&&(n._clearReactions(),this.client.emit(s.Events.MESSAGE_REACTION_REMOVE_ALL,n),{message:n})}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(9);class o extends i{handle(t){const e=this.client,n=e.channels.get(t.channel_id);if(n){const i=n.messages.get(t.id);if(i){const o=new r(i.channel,this.patchDataPacket(t,i),e);return o._edits.push(i,...i._edits),o.reactions=i.reactions,n.messages.set(t.id,o),e.emit(s.Events.MESSAGE_UPDATE,i,o),{old:i,updated:o}}return{old:i,updated:i}}return{old:null,updated:null}}patchDataPacket(t,e){return t.type="type"in t?t.type:s.MessageTypes.indexOf(e.type),t.tts="tts"in t?t.tts:e.tts,t.timestamp="timestamp"in t?t.timestamp:e.createdAt.toString(),t.pinned="pinned"in t?t.pinned:e.pinned,t.nonce="nonce"in t?t.nonce:e.nonce,t.mentions="mentions"in t?t.mentions:e.mentions.users.keyArray(),t.mentions_roles="mentions_roles"in t?t.mentions_roles:e.mentions.roles.keyArray(),t.mention_everyone="mention_everyone"in t?t.mention_everyone:e.mentions.everyone,t.embeds="embeds"in t?t.embeds:e.embeds,t.content="content"in t?t.content:e.content,t.author="author"in t?t.author:{username:e.author.username,id:e.author.id,discriminator:e.author.discriminator,avatar:e.author.avatar},t.attachments="attachments"in t?t.attachments:e.attachments.array(),t}}t.exports=o},function(t,e,n){const i=n(2);class s extends i{handle(t){const e=this.client,n=e.dataManager.newUser(t);return{user:n}}}t.exports=s},function(t,e,n){const i=n(2),s=n(0);class r extends i{handle(t){const e=this.client,n=e.user.notes.get(t.id),i=t.note.length?t.note:null;return e.user.notes.set(t.id,i),e.emit(s.Events.USER_NOTE_UPDATE,t.id,n,i),{old:n,updated:i}}}t.exports=r},function(t,e,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(t){const e=this.client;if(e.user){if(e.user.equals(t))return{old:e.user,updated:e.user};const n=r.cloneObject(e.user);return e.user.patch(t),e.emit(s.Events.USER_UPDATE,n,e.user),{old:n,updated:e.user}}return{old:null,updated:null}}}t.exports=o},function(t,e,n){const i=n(26),s=n(0);class r{constructor(t,e,n,i,s,r){this.rest=t,this.client=t.client,this.method=e,this.path=n.toString(),this.auth=i,this.data=s,this.files=r,this.route=this.getRoute(this.path)}getRoute(t){let e=t.split("?")[0];if(e.includes("/channels/")||e.includes("/guilds/")){const t=e.includes("/channels/")?e.indexOf("/channels/"):e.indexOf("/guilds/"),n=e.substring(t).split("/")[2];e=e.replace(/(\d{8,})/g,":id").replace(":id",n)}return e}getAuth(){if(this.client.token&&this.client.user&&this.client.user.bot)return`Bot ${this.client.token}`;if(this.client.token)return this.client.token;throw new Error(s.Errors.NO_TOKEN)}gen(){const t=`${this.client.options.http.host}/api/v${this.client.options.http.version}`,e=i[this.method](`${t}${this.path}`);if(this.auth&&e.set("authorization",this.getAuth()),this.files){for(const t of this.files)t&&t.file&&e.attach(t.name,t.file,t.name);this.data=this.data||{},e.field("payload_json",JSON.stringify(this.data))}else this.data&&e.send(this.data);return this.client.browser||e.set("User-Agent",this.rest.userAgentManager.userAgent),e}}t.exports=r},function(t,e,n){const i=n(58),s=n(24),r=n(6),o=n(0),u=o.Endpoints,c=n(3),h=n(5),a=n(4),l=n(11),f=n(13),d=n(9),p=n(10),m=n(32),g=n(21),E=n(137),_=n(37),v=n(8),y=n(19),w=n(16),b=n(138);class A{constructor(t){this.rest=t,this.client=t.client,this._ackToken=null}login(t=this.client.token){return new Promise((e,n)=>{if("string"!=typeof t)throw new Error(o.Errors.INVALID_TOKEN);t=t.replace(/^Bot\s*/i,""),this.client.manager.connectToWebSocket(t,e,n)})}logout(){return this.rest.makeRequest("post",u.logout,!0,{})}getGateway(){return this.rest.makeRequest("get",u.gateway,!0).then(t=>{return this.client.ws.gateway=`${t.url}/?v=${this.client.options.ws.version}`,this.client.ws.gateway})}getBotGateway(){return this.rest.makeRequest("get",u.gateway.bot,!0)}fetchVoiceRegions(t){let e;return e=t?u.Guild(t).voiceRegions:u.voiceRegions,this.rest.makeRequest("get",e,!0).then(t=>{const e=new c;for(const n of t)e.set(n.id,new b(n));return e})}sendMessage(t,e,{tts,nonce,embed,disableEveryone,split,code,reply}={},n=null){return new Promise((i,s)=>{if("undefined"!=typeof e&&(e=this.client.resolver.resolveString(e)),"undefined"!=typeof nonce&&(nonce=parseInt(nonce),isNaN(nonce)||nonce<0))throw new RangeError("Message nonce must fit in an unsigned 64-bit integer.");if(e){if(split&&"object"!=typeof split&&(split={}),"undefined"==typeof code||"boolean"==typeof code&&code!==!0||(e=a.escapeMarkdown(this.client.resolver.resolveString(e),!0),e=`\`\`\`${"boolean"!=typeof code?code||"":""} ${e} \`\`\``,split&&(split.prepend=`\`\`\`${"boolean"!=typeof code?code||"":""} `,split.append="\n```")),(disableEveryone||"undefined"==typeof disableEveryone&&this.client.options.disableEveryone)&&(e=e.replace(/@(everyone|here)/g,"@​$1")),reply&&!(t instanceof l||t instanceof f)&&"dm"!==t.type){const t=this.client.resolver.resolveUserID(reply),n=`<@${reply instanceof f&&reply.nickname?"!":""}${t}>`;e=`${n}${e?`, ${e}`:""}`,split&&(split.prepend=`${n}, ${split.prepend||""}`)}split&&(e=a.splitMessage(e,split))}else if(reply&&!(t instanceof l||t instanceof f)&&"dm"!==t.type){const t=this.client.resolver.resolveUserID(reply);e=`<@${reply instanceof f&&reply.nickname?"!":""}${t}>`}const r=t=>{if(e instanceof Array){const s=[];!function e(r,o){const u=o===r.length?{tts:tts,embed:embed}:{tts:tts};t.send(r[o],u,o===r.length?n:null).then(t=>{return s.push(t),o>=r.length-1?i(s):e(r,++o)})}(e,0)}else this.rest.makeRequest("post",u.Channel(t).messages,!0,{content:e,tts:tts,nonce:nonce,embed:embed},n).then(t=>i(this.client.actions.MessageCreate.handle(t).message),s)};t instanceof l||t instanceof f?this.createDM(t).then(r,s):r(t)})}updateMessage(t,e,{embed,code,reply}={}){if("undefined"!=typeof e&&(e=this.client.resolver.resolveString(e)),"undefined"==typeof code||"boolean"==typeof code&&code!==!0||(e=a.escapeMarkdown(this.client.resolver.resolveString(e),!0),e=`\`\`\`${"boolean"!=typeof code?code||"":""} ${e} -\`\`\``),reply&&"dm"!==t.channel.type){const t=this.client.resolver.resolveUserID(reply),n=`<@${reply instanceof f&&reply.nickname?"!":""}${t}>`;e=`${n}${e?`, ${e}`:""}`}return this.rest.makeRequest("patch",u.Message(t),!0,{content:e,embed:embed}).then(t=>this.client.actions.MessageUpdate.handle(t).updated)}deleteMessage(t){return this.rest.makeRequest("del",u.Message(t),!0).then(()=>this.client.actions.MessageDelete.handle({id:t.id,channel_id:t.channel.id}).message)}ackMessage(t){return this.rest.makeRequest("post",u.Message(t).ack,!0,{token:this._ackToken}).then(e=>{return e.token&&(this._ackToken=e.token),t})}ackTextChannel(t){return this.rest.makeRequest("post",u.Channel(t).ack,!0,{token:this._ackToken}).then(e=>{return e.token&&(this._ackToken=e.token),t})}ackGuild(t){return this.rest.makeRequest("post",u.Guild(t).ack,!0).then(()=>t)}bulkDeleteMessages(t,e,n){return n&&(e=e.filter(t=>Date.now()-h.deconstruct(t).date.getTime()<12096e5)),this.rest.makeRequest("post",u.Channel(t).messages.bulkDelete,!0,{messages:e}).then(()=>this.client.actions.MessageDeleteBulk.handle({channel_id:t.id,ids:e}).messages)}search(t,e){if(e.before&&(e.before instanceof Date||(e.before=new Date(e.before)),e.maxID=s.fromNumber(e.before.getTime()-14200704e5).shiftLeft(22).toString()),e.after&&(e.after instanceof Date||(e.after=new Date(e.after)),e.minID=s.fromNumber(e.after.getTime()-14200704e5).shiftLeft(22).toString()),e.during){e.during instanceof Date||(e.during=new Date(e.during));const t=e.during.getTime()-14200704e5;e.minID=s.fromNumber(t).shiftLeft(22).toString(),e.maxID=s.fromNumber(t+864e5).shiftLeft(22).toString()}e.channel&&(e.channel=this.client.resolver.resolveChannelID(e.channel)),e.author&&(e.author=this.client.resolver.resolveUserID(e.author)),e.mentions&&(e.mentions=this.client.resolver.resolveUserID(e.options.mentions)),e={content:e.content,max_id:e.maxID,min_id:e.minID,has:e.has,channel_id:e.channel,author_id:e.author,author_type:e.authorType,context_size:e.contextSize,sort_by:e.sortBy,sort_order:e.sortOrder,limit:e.limit,offset:e.offset,mentions:e.mentions,mentions_everyone:e.mentionsEveryone,link_hostname:e.linkHostname,embed_provider:e.embedProvider,embed_type:e.embedType,attachment_filename:e.attachmentFilename,attachment_extension:e.attachmentExtension};for(const n in e)void 0===e[n]&&delete e[n];const r=(i.stringify(e).match(/[^=&?]+=[^=&?]+/g)||[]).join("&");let o;if(t instanceof v)o=u.Channel(t).search;else{if(!(t instanceof w))throw new TypeError("Target must be a TextChannel, DMChannel, GroupDMChannel, or Guild.");o=u.Guild(t).search}return this.rest.makeRequest("get",`${o}?${r}`,!0).then(t=>{const e=t.messages.map(t=>t.map(t=>new d(this.client.channels.get(t.channel_id),t,this.client)));return{totalResults:t.total_results,messages:e}})}createChannel(t,e,n,i){return i instanceof c&&(i=i.array()),this.rest.makeRequest("post",u.Guild(t).channels,!0,{name:e,type:n,permission_overwrites:i}).then(t=>this.client.actions.ChannelCreate.handle(t).channel)}createDM(t){const e=this.getExistingDM(t);return e?Promise.resolve(e):this.rest.makeRequest("post",u.User(this.client.user).channels,!0,{recipient_id:t.id}).then(t=>this.client.actions.ChannelCreate.handle(t).channel)}createGroupDM(t){const e=this.client.user.bot?{access_tokens:t.accessTokens,nicks:t.nicks}:{recipients:t.recipients};return this.rest.makeRequest("post",u.User("@me").channels,!0,e).then(t=>new y(this.client,t))}addUserToGroupDM(t,e){const n=this.client.user.bot?{nick:e.nick,access_token:e.accessToken}:{recipient:e.id};return this.rest.makeRequest("put",u.Channel(t).Recipient(e.id),!0,n).then(()=>t)}getExistingDM(t){return this.client.channels.find(e=>e.recipient&&e.recipient.id===t.id)}deleteChannel(t){return(t instanceof l||t instanceof f)&&(t=this.getExistingDM(t)),t?this.rest.makeRequest("del",u.Channel(t),!0).then(e=>{return e.id=t.id,this.client.actions.ChannelDelete.handle(e).channel}):Promise.reject(new Error("No channel to delete."))}updateChannel(t,e){const n={};return n.name=(e.name||t.name).trim(),n.topic=e.topic||t.topic,n.position=e.position||t.position,n.bitrate=e.bitrate||t.bitrate,n.user_limit=e.userLimit||t.userLimit,this.rest.makeRequest("patch",u.Channel(t),!0,n).then(t=>this.client.actions.ChannelUpdate.handle(t).updated)}leaveGuild(t){return t.ownerID===this.client.user.id?Promise.reject(new Error("Guild is owned by the client.")):this.rest.makeRequest("del",u.User("@me").Guild(t.id),!0).then(()=>this.client.actions.GuildDelete.handle({id:t.id}).guild)}createGuild(t){return t.icon=this.client.resolver.resolveBase64(t.icon)||null,t.region=t.region||"us-central",new Promise((e,n)=>{this.rest.makeRequest("post",u.guilds,!0,t).then(t=>{if(this.client.guilds.has(t.id))return e(this.client.guilds.get(t.id));const i=n=>{n.id===t.id&&(this.client.removeListener(o.Events.GUILD_CREATE,i),this.client.clearTimeout(s),e(n))};this.client.on(o.Events.GUILD_CREATE,i);const s=this.client.setTimeout(()=>{this.client.removeListener(o.Events.GUILD_CREATE,i),n(new Error("Took too long to receive guild data."))},1e4)},n)})}deleteGuild(t){return this.rest.makeRequest("del",u.Guild(t),!0).then(()=>this.client.actions.GuildDelete.handle({id:t.id}).guild)}getUser(t,e){return this.rest.makeRequest("get",u.User(t),!0).then(t=>{return e?this.client.actions.UserGet.handle(t).user:new l(this.client,t)})}updateCurrentUser(t,e){const n=this.client.user,i={};return i.username=t.username||n.username,i.avatar=this.client.resolver.resolveBase64(t.avatar)||n.avatar,n.bot||(i.email=t.email||n.email,i.password=e,t.new_password&&(i.new_password=t.newPassword)),this.rest.makeRequest("patch",u.User("@me"),!0,i).then(t=>this.client.actions.UserUpdate.handle(t).updated)}updateGuild(t,e){const n={};return e.name&&(n.name=e.name),e.region&&(n.region=e.region),e.verificationLevel&&(n.verification_level=Number(e.verificationLevel)),e.afkChannel&&(n.afk_channel_id=this.client.resolver.resolveChannel(e.afkChannel).id),e.afkTimeout&&(n.afk_timeout=Number(e.afkTimeout)),e.icon&&(n.icon=this.client.resolver.resolveBase64(e.icon)),e.owner&&(n.owner_id=this.client.resolver.resolveUser(e.owner).id),e.splash&&(n.splash=this.client.resolver.resolveBase64(e.splash)),this.rest.makeRequest("patch",u.Guild(t),!0,n).then(t=>this.client.actions.GuildUpdate.handle(t).updated)}kickGuildMember(t,e){return this.rest.makeRequest("del",u.Guild(t).Member(e),!0).then(()=>this.client.actions.GuildMemberRemove.handle({guild_id:t.id,user:e.user}).member)}createGuildRole(t,e){return e.color&&(e.color=this.client.resolver.resolveColor(e.color)),e.permissions&&(e.permissions=r.resolve(e.permissions)),this.rest.makeRequest("post",u.Guild(t).roles,!0,e).then(e=>this.client.actions.GuildRoleCreate.handle({guild_id:t.id,role:e}).role)}deleteGuildRole(t){return this.rest.makeRequest("del",u.Guild(t.guild).Role(t.id),!0).then(()=>this.client.actions.GuildRoleDelete.handle({guild_id:t.guild.id,role_id:t.id}).role)}setChannelOverwrite(t,e){return this.rest.makeRequest("put",`${u.Channel(t).permissions}/${e.id}`,!0,e)}deletePermissionOverwrites(t){return this.rest.makeRequest("del",`${u.Channel(t.channel).permissions}/${t.id}`,!0).then(()=>t)}getChannelMessages(t,e={}){const n=[];e.limit&&n.push(`limit=${e.limit}`),e.around?n.push(`around=${e.around}`):e.before?n.push(`before=${e.before}`):e.after&&n.push(`after=${e.after}`);let i=u.Channel(t).messages;return n.length>0&&(i+=`?${n.join("&")}`),this.rest.makeRequest("get",i,!0)}getChannelMessage(t,e){const n=t.messages.get(e);return n?Promise.resolve(n):this.rest.makeRequest("get",u.Channel(t).Message(e),!0)}putGuildMember(t,e,n){if(n.access_token=n.accessToken,n.roles){const t=n.roles;(t instanceof c||t instanceof Array&&t[0]instanceof p)&&(n.roles=t.map(t=>t.id))}return this.rest.makeRequest("put",u.Guild(t).Member(e.id),!0,n).then(e=>this.client.actions.GuildMemberGet.handle(t,e).member)}getGuildMember(t,e,n){return this.rest.makeRequest("get",u.Guild(t).Member(e.id),!0).then(e=>{return n?this.client.actions.GuildMemberGet.handle(t,e).member:new f(t,e)})}updateGuildMember(t,e){e.channel&&(e.channel_id=this.client.resolver.resolveChannel(e.channel).id),e.roles&&(e.roles=e.roles.map(t=>t instanceof p?t.id:t));let n=u.Member(t);if(t.id===this.client.user.id){const i=Object.keys(e);1===i.length&&"nick"===i[0]&&(n=u.Member(t).nickname)}return this.rest.makeRequest("patch",n,!0,e).then(e=>t.guild._updateMember(t,e).mem)}addMemberRole(t,e){return new Promise((n,i)=>{if(t._roles.includes(e.id))return n(t);const s=(t,i)=>{!t._roles.includes(e.id)&&i._roles.includes(e.id)&&(this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),n(i))};this.client.on(o.Events.GUILD_MEMBER_UPDATE,s);const r=this.client.setTimeout(()=>this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),1e4);return this.rest.makeRequest("put",u.Member(t).Role(e.id),!0).catch(t=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,s),this.client.clearTimeout(r),i(t)})})}removeMemberRole(t,e){return new Promise((n,i)=>{if(!t._roles.includes(e.id))return n(t);const s=(t,i)=>{t._roles.includes(e.id)&&!i._roles.includes(e.id)&&(this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),n(i))};this.client.on(o.Events.GUILD_MEMBER_UPDATE,s);const r=this.client.setTimeout(()=>this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),1e4);return this.rest.makeRequest("delete",u.Member(t).Role(e.id),!0).catch(t=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,s),this.client.clearTimeout(r),i(t)})})}sendTyping(t){return this.rest.makeRequest("post",u.Channel(t).typing,!0)}banGuildMember(t,e,n=0){const i=this.client.resolver.resolveUserID(e);return i?this.rest.makeRequest("put",`${u.Guild(t).bans}/${i}?delete-message-days=${n}`,!0,{"delete-message-days":n}).then(()=>{if(e instanceof f)return e;const n=this.client.resolver.resolveUser(i);return n?(e=this.client.resolver.resolveGuildMember(t,n),e||n):i}):Promise.reject(new Error("Couldn't resolve the user ID to ban."))}unbanGuildMember(t,e){return new Promise((n,i)=>{const s=this.client.resolver.resolveUserID(e);if(!s)throw new Error("Couldn't resolve the user ID to unban.");const r=(e,i)=>{e.id===t.id&&i.id===s&&(this.client.removeListener(o.Events.GUILD_BAN_REMOVE,r),this.client.clearTimeout(c),n(i))};this.client.on(o.Events.GUILD_BAN_REMOVE,r);const c=this.client.setTimeout(()=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,r),i(new Error("Took too long to receive the ban remove event."))},1e4);this.rest.makeRequest("del",`${u.Guild(t).bans}/${s}`,!0).catch(t=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,r),this.client.clearTimeout(c),i(t)})})}getGuildBans(t){return this.rest.makeRequest("get",u.Guild(t).bans,!0).then(t=>{const e=new c;for(const n of t){const t=this.client.dataManager.newUser(n.user);e.set(t.id,t)}return e})}updateGuildRole(t,e){const n={};return n.name=e.name||t.name,n.position="undefined"!=typeof e.position?e.position:t.position,n.color=this.client.resolver.resolveColor(e.color||t.color),n.hoist="undefined"!=typeof e.hoist?e.hoist:t.hoist,n.mentionable="undefined"!=typeof e.mentionable?e.mentionable:t.mentionable,e.permissions?n.permissions=r.resolve(e.permissions):n.permissions=t.permissions,this.rest.makeRequest("patch",u.Guild(t.guild).Role(t.id),!0,n).then(e=>this.client.actions.GuildRoleUpdate.handle({role:e,guild_id:t.guild.id}).updated)}pinMessage(t){return this.rest.makeRequest("put",u.Channel(t.channel).Pin(t.id),!0).then(()=>t)}unpinMessage(t){return this.rest.makeRequest("del",u.Channel(t.channel).Pin(t.id),!0).then(()=>t)}getChannelPinnedMessages(t){return this.rest.makeRequest("get",u.Channel(t).pins,!0)}createChannelInvite(t,e){const n={};return n.temporary=e.temporary,n.max_age=e.maxAge,n.max_uses=e.maxUses,this.rest.makeRequest("post",u.Channel(t).invites,!0,n).then(t=>new m(this.client,t))}deleteInvite(t){return this.rest.makeRequest("del",u.Invite(t.code),!0).then(()=>t)}getInvite(t){return this.rest.makeRequest("get",u.Invite(t),!0).then(t=>new m(this.client,t))}getGuildInvites(t){return this.rest.makeRequest("get",u.Guild(t).invites,!0).then(t=>{const e=new c;for(const n of t){const t=new m(this.client,n);e.set(t.code,t)}return e})}pruneGuildMembers(t,e,n){return this.rest.makeRequest(n?"get":"post",`${u.Guild(t).prune}?days=${e}`,!0).then(t=>t.pruned)}createEmoji(t,e,n,i){const s={image:e,name:n};return i&&(s.roles=i.map(t=>t.id?t.id:t)),this.rest.makeRequest("post",u.Guild(t).emojis,!0,s).then(e=>this.client.actions.GuildEmojiCreate.handle(t,e).emoji)}updateEmoji(t,e){const n={};return e.name&&(n.name=e.name),e.roles&&(n.roles=e.roles.map(t=>t.id?t.id:t)),this.rest.makeRequest("patch",u.Guild(t.guild).Emoji(t.id),!0,n).then(e=>this.client.actions.GuildEmojiUpdate.handle(t,e).emoji)}deleteEmoji(t){return this.rest.makeRequest("delete",u.Guild(t.guild).Emoji(t.id),!0).then(()=>this.client.actions.GuildEmojiDelete.handle(t).data)}getWebhook(t,e){return this.rest.makeRequest("get",u.Webhook(t,e),!e).then(t=>new g(this.client,t))}getGuildWebhooks(t){return this.rest.makeRequest("get",u.Guild(t).webhooks,!0).then(t=>{const e=new c;for(const n of t)e.set(n.id,new g(this.client,n));return e})}getChannelWebhooks(t){return this.rest.makeRequest("get",u.Channel(t).webhooks,!0).then(t=>{const e=new c;for(const n of t)e.set(n.id,new g(this.client,n));return e})}createWebhook(t,e,n){return this.rest.makeRequest("post",u.Channel(t).webhooks,!0,{name:e,avatar:n}).then(t=>new g(this.client,t))}editWebhook(t,e,n){return this.rest.makeRequest("patch",u.Webhook(t.id,t.token),!1,{name:e,avatar:n}).then(e=>{return t.name=e.name,t.avatar=e.avatar,t})}deleteWebhook(t){return this.rest.makeRequest("delete",u.Webhook(t.id,t.token),!1)}sendWebhookMessage(t,e,{avatarURL,tts,disableEveryone,embeds,username}={},n=null){return username=username||t.name,"undefined"!=typeof e&&(e=this.client.resolver.resolveString(e)),e&&(disableEveryone||"undefined"==typeof disableEveryone&&this.client.options.disableEveryone)&&(e=e.replace(/@(everyone|here)/g,"@​$1")),this.rest.makeRequest("post",`${u.Webhook(t.id,t.token)}?wait=true`,!1,{username:username,avatar_url:avatarURL,content:e,tts:tts,embeds:embeds},n)}sendSlackWebhookMessage(t,e){return this.rest.makeRequest("post",`${u.Webhook(t.id,t.token)}/slack?wait=true`,!1,e)}fetchUserProfile(t){return this.rest.makeRequest("get",u.User(t).profile,!0).then(e=>new E(t,e))}fetchMeMentions(t){return t.guild&&(t.guild=t.guild.id?t.guild.id:t.guild),this.rest.makeRequest("get",u.User("@me").mentions(t.limit,t.roles,t.everyone,t.guild)).then(t=>t.body.map(t=>new d(this.client.channels.get(t.channel_id),t,this.client)))}addFriend(t){return this.rest.makeRequest("post",u.User("@me"),!0,{username:t.username,discriminator:t.discriminator}).then(()=>t)}removeFriend(t){return this.rest.makeRequest("delete",u.User("@me").Relationship(t.id),!0).then(()=>t)}blockUser(t){return this.rest.makeRequest("put",u.User("@me").Relationship(t.id),!0,{type:2}).then(()=>t)}unblockUser(t){return this.rest.makeRequest("delete",u.User("@me").Relationship(t.id),!0).then(()=>t)}updateChannelPositions(t,e){const n=new Array(e.length);for(let i=0;ithis.client.actions.GuildChannelsPositionUpdate.handle({guild_id:t,channels:e}).guild)}setRolePositions(t,e){return this.rest.makeRequest("patch",u.Guild(t).roles,!0,e).then(()=>this.client.actions.GuildRolesPositionUpdate.handle({guild_id:t,roles:e}).guild)}addMessageReaction(t,e){return this.rest.makeRequest("put",u.Message(t).Reaction(e).User("@me"),!0).then(()=>this.client.actions.MessageReactionAdd.handle({user_id:this.client.user.id,message_id:t.id,emoji:a.parseEmoji(e),channel_id:t.channel.id}).reaction)}removeMessageReaction(t,e,n){const i=u.Message(t).Reaction(e).User(n===this.client.user.id?"@me":n.id);return this.rest.makeRequest("delete",i,!0).then(()=>this.client.actions.MessageReactionRemove.handle({user_id:n,message_id:t.id,emoji:a.parseEmoji(e),channel_id:t.channel.id}).reaction)}removeMessageReactions(t){return this.rest.makeRequest("delete",u.Message(t).reactions,!0).then(()=>t)}getMessageReactionUsers(t,e,n=100){return this.rest.makeRequest("get",u.Message(t).Reaction(e,n),!0)}getApplication(t){return this.rest.makeRequest("get",u.OAUTH2.Application(t),!0).then(t=>new _(this.client,t))}resetApplication(t){return this.rest.makeRequest("post",u.OAUTH2.Application(t).reset,!0).then(t=>new _(this.client,t))}setNote(t,e){return this.rest.makeRequest("put",u.User(t).note,!0,{note:e}).then(()=>t)}acceptInvite(t){return t.id&&(t=t.id),new Promise((e,n)=>this.rest.makeRequest("post",u.Invite(t),!0).then(t=>{const i=n=>{n.id===t.id&&(e(n),this.client.removeListener(o.Events.GUILD_CREATE,i))};this.client.on(o.Events.GUILD_CREATE,i),this.client.setTimeout(()=>{this.client.removeListener(o.Events.GUILD_CREATE,i),n(new Error("Accepting invite timed out"))},12e4)}))}}t.exports=A},function(t,e,n){const i=n(45);class s extends i{constructor(t,e){super(t,e),this.client=t.client,this.limit=1/0,this.resetTime=null,this.remaining=1,this.timeDifference=0,this.resetTimeout=null}push(t){super.push(t),this.handle()}execute(t){t&&t.request.gen().end((e,n)=>{if(n&&n.headers&&(this.limit=Number(n.headers["x-ratelimit-limit"]),this.resetTime=1e3*Number(n.headers["x-ratelimit-reset"]),this.remaining=Number(n.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(n.headers.date).getTime()),e)if(429===e.status){if(this.queue.unshift(t),n.headers["x-ratelimit-global"]&&(this.globalLimit=!0),this.resetTimeout)return;this.resetTimeout=this.client.setTimeout(()=>{this.remaining=this.limit,this.globalLimit=!1,this.handle(),this.resetTimeout=null},Number(n.headers["retry-after"])+this.client.options.restTimeOffset)}else t.reject(e),this.handle();else{this.globalLimit=!1;const e=n&&n.body?n.body:{};t.resolve(e),this.handle()}})}handle(){super.handle(),this.remaining<=0||0===this.queue.length||this.globalLimit||(this.execute(this.queue.shift()),this.remaining--,this.handle())}}t.exports=s},function(t,e,n){const i=n(45);class s extends i{constructor(t,e){super(t,e),this.endpoint=e,this.timeDifference=0}push(t){super.push(t),this.handle()}execute(t){return new Promise(e=>{t.request.gen().end((n,i)=>{if(i&&i.headers&&(this.requestLimit=Number(i.headers["x-ratelimit-limit"]),this.requestResetTime=1e3*Number(i.headers["x-ratelimit-reset"]),this.requestRemaining=Number(i.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(i.headers.date).getTime()),n)429===n.status?(this.queue.unshift(t),this.restManager.client.setTimeout(()=>{this.globalLimit=!1,e()},Number(i.headers["retry-after"])+this.restManager.client.options.restTimeOffset),i.headers["x-ratelimit-global"]&&(this.globalLimit=!0)):(t.reject(n),e(n));else{this.globalLimit=!1;const n=i&&i.body?i.body:{};t.resolve(n),0===this.requestRemaining?this.restManager.client.setTimeout(()=>{this.waiting=!1,e(n)},this.requestResetTime-Date.now()+this.timeDifference+this.restManager.client.options.restTimeOffset):e(n)}})})}handle(){super.handle(),0===this.remaining||0===this.queue.length||this.globalLimit||this.execute(this.queue.shift()).then(()=>this.handle())}}t.exports=s},function(t,e,n){(function(e){const i=n(0);class s{constructor(){this.build(this.constructor.DEFAULT)}set({url,version}={}){this.build({url:url||this.constructor.DFEAULT.url,version:version||this.constructor.DEFAULT.version})}build(t){this.userAgent=`DiscordBot (${t.url}, ${t.version}) Node.js/${e.version}`}}s.DEFAULT={url:i.Package.homepage.split("#")[0],version:i.Package.version},t.exports=s}).call(e,n(18))},function(t,e,n){(function(e){const i="browser"===n(15).platform(),s=n(23).EventEmitter,r=n(0),o=n(4).convertToBuffer,u=n(43),c=n(101);let h,a,l=JSON.stringify;if(i)h=window.WebSocket;else{try{h=n(143)}catch(t){h=n(144)}try{a=n(142),l=a.pack}catch(t){a=null}}class f extends s{constructor(t){super(),this.client=t,this.packetManager=new c(this),this.status=r.Status.IDLE,this.sessionID=null,this.sequence=-1,this.gateway=null,this.normalReady=!1,this.ws=null,this.disabledEvents={};for(const e of t.options.disabledEvents)this.disabledEvents[e]=!0;this.first=!0,this.lastHeartbeatAck=!0}_connect(t){this.client.emit("debug",`Connecting to gateway ${t}`),this.normalReady=!1,this.status!==r.Status.RECONNECTING&&(this.status=r.Status.CONNECTING),this.ws=new h(t),i&&(this.ws.binaryType="arraybuffer"),this.ws.onopen=this.eventOpen.bind(this),this.ws.onmessage=this.eventMessage.bind(this),this.ws.onclose=this.eventClose.bind(this),this.ws.onerror=this.eventError.bind(this),this._queue=[],this._remaining=120,this.client.setInterval(()=>{this._remaining=120,this._remainingReset=Date.now()},6e4)}connect(t){t=`${t}&encoding=${a?"etf":"json"}`,this.first?(this._connect(t),this.first=!1):this.client.setTimeout(()=>this._connect(t),5500)}heartbeat(t){return t&&!this.lastHeartbeatAck?void this.ws.close(1007):(this.client.emit("debug","Sending heartbeat"),this.client._pingTimestamp=Date.now(),this.client.ws.send({op:r.OPCodes.HEARTBEAT,d:this.sequence},!0),void(this.lastHeartbeatAck=!1))}send(t,e=false){return e?void this._send(l(t)):(this._queue.push(l(t)),void this.doQueue())}destroy(){this.ws&&this.ws.close(1e3),this._queue=[],this.status=r.Status.IDLE}_send(t){this.ws.readyState===h.OPEN&&(this.emit("send",t),this.ws.send(t))}doQueue(){const t=this._queue[0];if(this.ws.readyState===h.OPEN&&t){if(0===this.remaining)return void this.client.setTimeout(this.doQueue.bind(this),Date.now()-this.remainingReset);this._remaining--,this._send(t),this._queue.shift(),this.doQueue()}}eventOpen(){this.client.emit("debug","Connection to gateway opened"),this.lastHeartbeatAck=!0,this.status===r.Status.RECONNECTING?this._sendResume():this._sendNewIdentify()}_sendResume(){if(!this.sessionID)return void this._sendNewIdentify();this.client.emit("debug","Identifying as resumed session");const t={token:this.client.token,session_id:this.sessionID,seq:this.sequence};this.send({op:r.OPCodes.RESUME,d:t})}_sendNewIdentify(){this.reconnecting=!1;const t=this.client.options.ws;t.token=this.client.token,this.client.options.shardCount>0&&(t.shard=[Number(this.client.options.shardId),Number(this.client.options.shardCount)]),this.client.emit("debug","Identifying as new session"),this.send({op:r.OPCodes.IDENTIFY,d:t}),this.sequence=-1}eventClose(t){this.emit("close",t),this.client.clearInterval(this.client.manager.heartbeatInterval),this.status=r.Status.DISCONNECTED,this._queue=[],this.reconnecting||this.client.emit(r.Events.DISCONNECT,t),[4004,4010,4011].includes(t.code)||this.reconnecting||1e3===t.code||this.tryReconnect()}eventMessage(t){const e=this.tryParseEventData(t.data);return null===e?(this.eventError(new Error(r.Errors.BAD_WS_MESSAGE)),!1):(this.client.emit("raw",e),e.op===r.OPCodes.HELLO&&this.client.manager.setupKeepAlive(e.d.heartbeat_interval),this.packetManager.handle(e))}parseEventData(t){return a?(t instanceof ArrayBuffer&&(t=o(t)),a.unpack(t)):((t instanceof e||t instanceof ArrayBuffer)&&(t=u.inflateSync(t).toString()),JSON.parse(t))}tryParseEventData(t){try{return this.parseEventData(t)}catch(t){return null}}eventError(t){this.client.listenerCount("error")>0&&this.client.emit("error",t),this.tryReconnect()}_emitReady(t=true){this.status=r.Status.READY,this.client.emit(r.Events.READY),this.packetManager.handleQueue(),this.normalReady=t}checkIfReady(){if(this.status!==r.Status.READY&&this.status!==r.Status.NEARLY){let t=0;for(const e of this.client.guilds.keys())t+=this.client.guilds.get(e).available?0:1;if(0===t){if(this.status=r.Status.NEARLY,this.client.options.fetchAllMembers){const t=this.client.guilds.map(t=>t.fetchMembers());return void Promise.all(t).then(()=>this._emitReady(),t=>{this.client.emit(r.Events.WARN,"Error in pre-ready guild member fetching"),this.client.emit(r.Events.ERROR,t),this._emitReady()})}this._emitReady()}}}tryReconnect(){this.status!==r.Status.RECONNECTING&&this.status!==r.Status.CONNECTING&&(this.status=r.Status.RECONNECTING,this.ws.close(),this.packetManager.handleQueue(),this.client.emit(r.Events.RECONNECTING),this.connect(this.client.ws.gateway))}}t.exports=f}).call(e,n(22).Buffer)},function(t,e,n){const i=n(0),s=[i.WSEvents.READY,i.WSEvents.GUILD_CREATE,i.WSEvents.GUILD_DELETE,i.WSEvents.GUILD_MEMBERS_CHUNK,i.WSEvents.GUILD_MEMBER_ADD,i.WSEvents.GUILD_MEMBER_REMOVE];class r{constructor(t){this.ws=t,this.handlers={},this.queue=[],this.register(i.WSEvents.READY,n(128)),this.register(i.WSEvents.GUILD_CREATE,n(108)),this.register(i.WSEvents.GUILD_DELETE,n(109)),this.register(i.WSEvents.GUILD_UPDATE,n(119)),this.register(i.WSEvents.GUILD_BAN_ADD,n(106)),this.register(i.WSEvents.GUILD_BAN_REMOVE,n(107)),this.register(i.WSEvents.GUILD_MEMBER_ADD,n(111)),this.register(i.WSEvents.GUILD_MEMBER_REMOVE,n(112)),this.register(i.WSEvents.GUILD_MEMBER_UPDATE,n(113)),this.register(i.WSEvents.GUILD_ROLE_CREATE,n(115)),this.register(i.WSEvents.GUILD_ROLE_DELETE,n(116)),this.register(i.WSEvents.GUILD_ROLE_UPDATE,n(117)),this.register(i.WSEvents.GUILD_EMOJIS_UPDATE,n(110)),this.register(i.WSEvents.GUILD_MEMBERS_CHUNK,n(114)),this.register(i.WSEvents.CHANNEL_CREATE,n(102)),this.register(i.WSEvents.CHANNEL_DELETE,n(103)),this.register(i.WSEvents.CHANNEL_UPDATE,n(105)),this.register(i.WSEvents.CHANNEL_PINS_UPDATE,n(104)),this.register(i.WSEvents.PRESENCE_UPDATE,n(127)),this.register(i.WSEvents.USER_UPDATE,n(133)),this.register(i.WSEvents.USER_NOTE_UPDATE,n(132)),this.register(i.WSEvents.VOICE_STATE_UPDATE,n(135)),this.register(i.WSEvents.TYPING_START,n(131)),this.register(i.WSEvents.MESSAGE_CREATE,n(120)),this.register(i.WSEvents.MESSAGE_DELETE,n(121)),this.register(i.WSEvents.MESSAGE_UPDATE,n(126)),this.register(i.WSEvents.MESSAGE_DELETE_BULK,n(122)),this.register(i.WSEvents.VOICE_SERVER_UPDATE,n(134)),this.register(i.WSEvents.GUILD_SYNC,n(118)),this.register(i.WSEvents.RELATIONSHIP_ADD,n(129)),this.register(i.WSEvents.RELATIONSHIP_REMOVE,n(130)),this.register(i.WSEvents.MESSAGE_REACTION_ADD,n(123)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE,n(124)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE_ALL,n(125))}get client(){return this.ws.client}register(t,e){this.handlers[t]=new e(this)}handleQueue(){this.queue.forEach((t,e)=>{this.handle(this.queue[e]),this.queue.splice(e,1)})}setSequence(t){t&&t>this.ws.sequence&&(this.ws.sequence=t)}handle(t){return t.op===i.OPCodes.RECONNECT?(this.setSequence(t.s),this.ws.tryReconnect(),!1):t.op===i.OPCodes.INVALID_SESSION?(t.d?setTimeout(()=>{this.ws._sendResume()},2500):(this.ws.sessionID=null,this.ws._sendNewIdentify()),!1):(t.op===i.OPCodes.HEARTBEAT_ACK?(this.ws.client._pong(this.ws.client._pingTimestamp),this.ws.lastHeartbeatAck=!0,this.ws.client.emit("debug","Heartbeat acknowledged")):t.op===i.OPCodes.HEARTBEAT&&(this.client.ws.send({op:i.OPCodes.HEARTBEAT,d:this.client.ws.sequence}),this.ws.client.emit("debug","Received gateway heartbeat")),this.ws.status===i.Status.RECONNECTING&&(this.ws.reconnecting=!1,this.ws.checkIfReady()),this.setSequence(t.s),void 0===this.ws.disabledEvents[t.t]&&(this.ws.status!==i.Status.READY&&s.indexOf(t.t)===-1?(this.queue.push(t),!1):!!this.handlers[t.t]&&this.handlers[t.t].handle(t)))}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.ChannelCreate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.ChannelDelete.handle(n);i.channel&&e.emit(s.Events.CHANNEL_DELETE,i.channel)}}t.exports=r},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.channels.get(n.channel_id),r=new Date(n.last_pin_timestamp);i&&r&&e.emit(s.Events.CHANNEL_PINS_UPDATE,i,r)}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.ChannelUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id),r=e.users.get(n.user.id);i&&r&&e.emit(s.Events.GUILD_BAN_ADD,i,r)}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildBanRemove.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.id);i?i.available||n.unavailable||(i.setup(n),this.packetManager.ws.checkIfReady()):e.dataManager.newGuild(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.GuildDelete.handle(n);i.guild&&e.emit(s.Events.GUILD_DELETE,i.guild)}}t.exports=r},function(t,e,n){function i(t){const e=new Map;for(const n of t)e.set(...n);return e}const s=n(1);class r extends s{handle(t){const e=this.packetManager.client,n=t.d,s=e.guilds.get(n.guild_id);if(s&&s.emojis){const t=i(s.emojis.entries());for(const r of n.emojis){const n=s.emojis.get(r.id);n?(t.delete(r.id),n.equals(r,!0)||e.actions.GuildEmojiUpdate.handle(n,r)):e.actions.GuildEmojiCreate.handle(s,r)}for(const r of t.values())e.actions.GuildEmojiDelete.handle(r)}}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);i&&(i.memberCount++,i._addMember(n))}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildMemberRemove.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);if(i){const t=i.members.get(n.user.id);t&&i._updateMember(t,n)}}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);if(i){const t=n.members.map(t=>i._addMember(t,!1));e.emit(s.Events.GUILD_MEMBERS_CHUNK,t,i),e.ws.lastHeartbeatAck=!0}}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildRoleCreate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildRoleDelete.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildRoleUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildSync.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.MessageCreate.handle(n);i.message&&e.emit(s.Events.MESSAGE_CREATE,i.message)}}t.exports=r},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.MessageDelete.handle(n);i.message&&e.emit(s.Events.MESSAGE_DELETE,i.message)}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageDeleteBulk.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageReactionAdd.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageReactionRemove.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageReactionRemoveAll.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageUpdate.handle(n)}}t.exports=s},function(t,e,n){ -const i=n(1),s=n(0),r=n(4);class o extends i{handle(t){const e=this.packetManager.client,n=t.d;let i=e.users.get(n.user.id);const o=e.guilds.get(n.guild_id);if(!i){if(!n.user.username)return;i=e.dataManager.newUser(n.user)}const u=r.cloneObject(i);if(i.patch(n.user),i.equals(u)||e.emit(s.Events.USER_UPDATE,u,i),o){let t=o.members.get(i.id);if(t||"offline"===n.status||(t=o._addMember({user:i,roles:n.roles,deaf:!1,mute:!1},!1),e.emit(s.Events.GUILD_MEMBER_AVAILABLE,t)),t){if(0===e.listenerCount(s.Events.PRESENCE_UPDATE))return void o._setPresence(i.id,n);const u=r.cloneObject(t);t.presence&&(u.frozenPresence=r.cloneObject(t.presence)),o._setPresence(i.id,n),e.emit(s.Events.PRESENCE_UPDATE,u,t)}else o._setPresence(i.id,n)}}}t.exports=o},function(t,e,n){const i=n(1),s=n(29);class r extends i{handle(t){const e=this.packetManager.client,n=t.d;e.ws.heartbeat();const i=new s(e,n.user);i.settings=n.user_settings,e.user=i,e.readyAt=new Date,e.users.set(i.id,i);for(const r of n.guilds)e.dataManager.newGuild(r);for(const o of n.private_channels)e.dataManager.newChannel(o);for(const u of n.relationships){const t=e.dataManager.newUser(u.user);1===u.type?e.user.friends.set(t.id,t):2===u.type&&e.user.blocked.set(t.id,t)}n.presences=n.presences||[];for(const c of n.presences)e.dataManager.newUser(c.user),e._setPresence(c.user.id,c);if(n.notes)for(const h in n.notes){let t=n.notes[h];t.length||(t=null),e.user.notes.set(h,t)}!e.user.bot&&e.options.sync&&e.setInterval(e.syncGuilds.bind(e),3e4),e.once("ready",e.syncGuilds.bind(e)),e.users.has("1")||e.dataManager.newUser({id:"1",username:"Clyde",discriminator:"0000",avatar:"https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png",bot:!0,status:"online",game:null,verified:!0}),e.setTimeout(()=>{e.ws.normalReady||e.ws._emitReady(!1)},1200*n.guilds.length),this.packetManager.ws.sessionID=n.session_id,this.packetManager.ws.checkIfReady()}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;1===n.type?e.fetchUser(n.id).then(t=>{e.user.friends.set(t.id,t)}):2===n.type&&e.fetchUser(n.id).then(t=>{e.user.blocked.set(t.id,t)})}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;2===n.type?e.user.blocked.has(n.id)&&e.user.blocked.delete(n.id):1===n.type&&e.user.friends.has(n.id)&&e.user.friends.delete(n.id)}}t.exports=s},function(t,e,n){function i(t,e){return t.client.setTimeout(()=>{t.client.emit(r.Events.TYPING_STOP,t,e,t._typing.get(e.id)),t._typing.delete(e.id)},6e3)}const s=n(1),r=n(0);class o extends s{handle(t){const e=this.packetManager.client,n=t.d,s=e.channels.get(n.channel_id),o=e.users.get(n.user_id),c=new Date(1e3*n.timestamp);if(s&&o){if("voice"===s.type)return void e.emit(r.Events.WARN,`Discord sent a typing packet to voice channel ${s.id}`);if(s._typing.has(o.id)){const t=s._typing.get(o.id);t.lastTimestamp=c,t.resetTimeout(i(s,o))}else s._typing.set(o.id,new u(e,c,c,i(s,o))),e.emit(r.Events.TYPING_START,s,o)}}}class u{constructor(t,e,n,i){this.client=t,this.since=e,this.lastTimestamp=n,this._timeout=i}resetTimeout(t){this.client.clearTimeout(this._timeout),this._timeout=t}get elapsedTime(){return Date.now()-this.since}}t.exports=o},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.UserNoteUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.UserUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.emit("self.voiceServer",n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0),r=n(4);class o extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);if(i){const t=i.members.get(n.user_id);if(t){const i=r.cloneObject(t);t.voiceChannel&&t.voiceChannel.id!==n.channel_id&&t.voiceChannel.members.delete(i.id),n.channel_id||(t.speaking=null),t.user.id===e.user.id&&n.channel_id&&e.emit("self.voiceStateUpdate",n);const o=e.channels.get(n.channel_id);o&&o.members.set(t.user.id,t),t.serverMute=n.mute,t.serverDeaf=n.deaf,t.selfMute=n.self_mute,t.selfDeaf=n.self_deaf,t.voiceSessionID=n.session_id,t.voiceChannelID=n.channel_id,e.emit(s.Events.VOICE_STATE_UPDATE,i,t)}}}}t.exports=o},function(t,e){class n{constructor(t,e){this.user=t,this.setup(e)}setup(t){this.type=t.type,this.name=t.name,this.id=t.id,this.revoked=t.revoked,this.integrations=t.integrations}}t.exports=n},function(t,e,n){const i=n(3),s=n(136);class r{constructor(t,e){this.user=t,Object.defineProperty(this,"client",{value:t.client}),this.mutualGuilds=new i,this.connections=new i,this.setup(e)}setup(t){this.premium=t.premium,this.premiumSince=t.premium_since?new Date(t.premium_since):null;for(const e of t.mutual_guilds)this.client.guilds.has(e.id)&&this.mutualGuilds.set(e.id,this.client.guilds.get(e.id));for(const n of t.connected_accounts)this.connections.set(n.id,new s(this.user,n))}}t.exports=r},function(t,e){class n{constructor(t){this.id=t.id,this.name=t.name,this.vip=t.vip,this.deprecated=t.deprecated,this.optimal=t.optimal,this.custom=t.custom,this.sampleHostname=t.sample_hostname}}t.exports=n},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e,n){const i=n(4);t.exports={Client:n(46),Shard:n(49),ShardClientUtil:n(50),ShardingManager:n(51),WebhookClient:n(47),Collection:n(3),Constants:n(0),EvaluatedPermissions:n(6),Permissions:n(6),Snowflake:n(5),SnowflakeUtil:n(5),Util:i,util:i,version:n(28).version,escapeMarkdown:i.escapeMarkdown,fetchRecommendedShards:i.fetchRecommendedShards,splitMessage:i.splitMessage,Channel:n(8),ClientUser:n(29),DMChannel:n(30),Emoji:n(12),Game:n(7).Game,GroupDMChannel:n(19),Guild:n(16),GuildChannel:n(17),GuildMember:n(13),Invite:n(31),Message:n(9),MessageAttachment:n(32),MessageCollector:n(33),MessageEmbed:n(34),MessageReaction:n(35),OAuth2Application:n(36),PartialGuild:n(37),PartialGuildChannel:n(38),PermissionOverwrites:n(39),Presence:n(7).Presence,ReactionEmoji:n(20),RichEmbed:n(48),Role:n(10),TextChannel:n(40),User:n(11),VoiceChannel:n(41),Webhook:n(21)},"browser"===n(15).platform()&&(window.Discord=t.exports)}]); \ No newline at end of file +\`\`\``),reply&&"dm"!==t.channel.type){const t=this.client.resolver.resolveUserID(reply),n=`<@${reply instanceof f&&reply.nickname?"!":""}${t}>`;e=`${n}${e?`, ${e}`:""}`}return this.rest.makeRequest("patch",u.Message(t),!0,{content:e,embed:embed}).then(t=>this.client.actions.MessageUpdate.handle(t).updated)}deleteMessage(t){return this.rest.makeRequest("del",u.Message(t),!0).then(()=>this.client.actions.MessageDelete.handle({id:t.id,channel_id:t.channel.id}).message)}ackMessage(t){return this.rest.makeRequest("post",u.Message(t).ack,!0,{token:this._ackToken}).then(e=>{return e.token&&(this._ackToken=e.token),t})}ackTextChannel(t){return this.rest.makeRequest("post",u.Channel(t).ack,!0,{token:this._ackToken}).then(e=>{return e.token&&(this._ackToken=e.token),t})}ackGuild(t){return this.rest.makeRequest("post",u.Guild(t).ack,!0).then(()=>t)}bulkDeleteMessages(t,e,n){return n&&(e=e.filter(t=>Date.now()-h.deconstruct(t).date.getTime()<12096e5)),this.rest.makeRequest("post",u.Channel(t).messages.bulkDelete,!0,{messages:e}).then(()=>this.client.actions.MessageDeleteBulk.handle({channel_id:t.id,ids:e}).messages)}search(t,e){if(e.before&&(e.before instanceof Date||(e.before=new Date(e.before)),e.maxID=s.fromNumber(e.before.getTime()-14200704e5).shiftLeft(22).toString()),e.after&&(e.after instanceof Date||(e.after=new Date(e.after)),e.minID=s.fromNumber(e.after.getTime()-14200704e5).shiftLeft(22).toString()),e.during){e.during instanceof Date||(e.during=new Date(e.during));const t=e.during.getTime()-14200704e5;e.minID=s.fromNumber(t).shiftLeft(22).toString(),e.maxID=s.fromNumber(t+864e5).shiftLeft(22).toString()}e.channel&&(e.channel=this.client.resolver.resolveChannelID(e.channel)),e.author&&(e.author=this.client.resolver.resolveUserID(e.author)),e.mentions&&(e.mentions=this.client.resolver.resolveUserID(e.options.mentions)),e={content:e.content,max_id:e.maxID,min_id:e.minID,has:e.has,channel_id:e.channel,author_id:e.author,author_type:e.authorType,context_size:e.contextSize,sort_by:e.sortBy,sort_order:e.sortOrder,limit:e.limit,offset:e.offset,mentions:e.mentions,mentions_everyone:e.mentionsEveryone,link_hostname:e.linkHostname,embed_provider:e.embedProvider,embed_type:e.embedType,attachment_filename:e.attachmentFilename,attachment_extension:e.attachmentExtension};for(const n in e)void 0===e[n]&&delete e[n];const r=(i.stringify(e).match(/[^=&?]+=[^=&?]+/g)||[]).join("&");let o;if(t instanceof v)o=u.Channel(t).search;else{if(!(t instanceof w))throw new TypeError("Target must be a TextChannel, DMChannel, GroupDMChannel, or Guild.");o=u.Guild(t).search}return this.rest.makeRequest("get",`${o}?${r}`,!0).then(t=>{const e=t.messages.map(t=>t.map(t=>new d(this.client.channels.get(t.channel_id),t,this.client)));return{totalResults:t.total_results,messages:e}})}createChannel(t,e,n,i){return i instanceof c&&(i=i.array()),this.rest.makeRequest("post",u.Guild(t).channels,!0,{name:e,type:n,permission_overwrites:i}).then(t=>this.client.actions.ChannelCreate.handle(t).channel)}createDM(t){const e=this.getExistingDM(t);return e?Promise.resolve(e):this.rest.makeRequest("post",u.User(this.client.user).channels,!0,{recipient_id:t.id}).then(t=>this.client.actions.ChannelCreate.handle(t).channel)}createGroupDM(t){const e=this.client.user.bot?{access_tokens:t.accessTokens,nicks:t.nicks}:{recipients:t.recipients};return this.rest.makeRequest("post",u.User("@me").channels,!0,e).then(t=>new y(this.client,t))}addUserToGroupDM(t,e){const n=this.client.user.bot?{nick:e.nick,access_token:e.accessToken}:{recipient:e.id};return this.rest.makeRequest("put",u.Channel(t).Recipient(e.id),!0,n).then(()=>t)}getExistingDM(t){return this.client.channels.find(e=>e.recipient&&e.recipient.id===t.id)}deleteChannel(t){return(t instanceof l||t instanceof f)&&(t=this.getExistingDM(t)),t?this.rest.makeRequest("del",u.Channel(t),!0).then(e=>{return e.id=t.id,this.client.actions.ChannelDelete.handle(e).channel}):Promise.reject(new Error("No channel to delete."))}updateChannel(t,e){const n={};return n.name=(e.name||t.name).trim(),n.topic=e.topic||t.topic,n.position=e.position||t.position,n.bitrate=e.bitrate||t.bitrate,n.user_limit=e.userLimit||t.userLimit,this.rest.makeRequest("patch",u.Channel(t),!0,n).then(t=>this.client.actions.ChannelUpdate.handle(t).updated)}leaveGuild(t){return t.ownerID===this.client.user.id?Promise.reject(new Error("Guild is owned by the client.")):this.rest.makeRequest("del",u.User("@me").Guild(t.id),!0).then(()=>this.client.actions.GuildDelete.handle({id:t.id}).guild)}createGuild(t){return t.icon=this.client.resolver.resolveBase64(t.icon)||null,t.region=t.region||"us-central",new Promise((e,n)=>{this.rest.makeRequest("post",u.guilds,!0,t).then(t=>{if(this.client.guilds.has(t.id))return e(this.client.guilds.get(t.id));const i=n=>{n.id===t.id&&(this.client.removeListener(o.Events.GUILD_CREATE,i),this.client.clearTimeout(s),e(n))};this.client.on(o.Events.GUILD_CREATE,i);const s=this.client.setTimeout(()=>{this.client.removeListener(o.Events.GUILD_CREATE,i),n(new Error("Took too long to receive guild data."))},1e4)},n)})}deleteGuild(t){return this.rest.makeRequest("del",u.Guild(t),!0).then(()=>this.client.actions.GuildDelete.handle({id:t.id}).guild)}getUser(t,e){return this.rest.makeRequest("get",u.User(t),!0).then(t=>{return e?this.client.actions.UserGet.handle(t).user:new l(this.client,t)})}updateCurrentUser(t,e){const n=this.client.user,i={};return i.username=t.username||n.username,i.avatar=this.client.resolver.resolveBase64(t.avatar)||n.avatar,n.bot||(i.email=t.email||n.email,i.password=e,t.new_password&&(i.new_password=t.newPassword)),this.rest.makeRequest("patch",u.User("@me"),!0,i).then(t=>this.client.actions.UserUpdate.handle(t).updated)}updateGuild(t,e){const n={};return e.name&&(n.name=e.name),e.region&&(n.region=e.region),e.verificationLevel&&(n.verification_level=Number(e.verificationLevel)),e.afkChannel&&(n.afk_channel_id=this.client.resolver.resolveChannel(e.afkChannel).id),e.afkTimeout&&(n.afk_timeout=Number(e.afkTimeout)),e.icon&&(n.icon=this.client.resolver.resolveBase64(e.icon)),e.owner&&(n.owner_id=this.client.resolver.resolveUser(e.owner).id),e.splash&&(n.splash=this.client.resolver.resolveBase64(e.splash)),this.rest.makeRequest("patch",u.Guild(t),!0,n).then(t=>this.client.actions.GuildUpdate.handle(t).updated)}kickGuildMember(t,e){return this.rest.makeRequest("del",u.Guild(t).Member(e),!0).then(()=>this.client.actions.GuildMemberRemove.handle({guild_id:t.id,user:e.user}).member)}createGuildRole(t,e){return e.color&&(e.color=this.client.resolver.resolveColor(e.color)),e.permissions&&(e.permissions=r.resolve(e.permissions)),this.rest.makeRequest("post",u.Guild(t).roles,!0,e).then(e=>this.client.actions.GuildRoleCreate.handle({guild_id:t.id,role:e}).role)}deleteGuildRole(t){return this.rest.makeRequest("del",u.Guild(t.guild).Role(t.id),!0).then(()=>this.client.actions.GuildRoleDelete.handle({guild_id:t.guild.id,role_id:t.id}).role)}setChannelOverwrite(t,e){return this.rest.makeRequest("put",`${u.Channel(t).permissions}/${e.id}`,!0,e)}deletePermissionOverwrites(t){return this.rest.makeRequest("del",`${u.Channel(t.channel).permissions}/${t.id}`,!0).then(()=>t)}getChannelMessages(t,e={}){const n=[];e.limit&&n.push(`limit=${e.limit}`),e.around?n.push(`around=${e.around}`):e.before?n.push(`before=${e.before}`):e.after&&n.push(`after=${e.after}`);let i=u.Channel(t).messages;return n.length>0&&(i+=`?${n.join("&")}`),this.rest.makeRequest("get",i,!0)}getChannelMessage(t,e){const n=t.messages.get(e);return n?Promise.resolve(n):this.rest.makeRequest("get",u.Channel(t).Message(e),!0)}putGuildMember(t,e,n){if(n.access_token=n.accessToken,n.roles){const t=n.roles;(t instanceof c||t instanceof Array&&t[0]instanceof p)&&(n.roles=t.map(t=>t.id))}return this.rest.makeRequest("put",u.Guild(t).Member(e.id),!0,n).then(e=>this.client.actions.GuildMemberGet.handle(t,e).member)}getGuildMember(t,e,n){return this.rest.makeRequest("get",u.Guild(t).Member(e.id),!0).then(e=>{return n?this.client.actions.GuildMemberGet.handle(t,e).member:new f(t,e)})}updateGuildMember(t,e){e.channel&&(e.channel_id=this.client.resolver.resolveChannel(e.channel).id),e.roles&&(e.roles=e.roles.map(t=>t instanceof p?t.id:t));let n=u.Member(t);if(t.id===this.client.user.id){const i=Object.keys(e);1===i.length&&"nick"===i[0]&&(n=u.Member(t).nickname)}return this.rest.makeRequest("patch",n,!0,e).then(e=>t.guild._updateMember(t,e).mem)}addMemberRole(t,e){return new Promise((n,i)=>{if(t._roles.includes(e.id))return n(t);const s=(t,i)=>{!t._roles.includes(e.id)&&i._roles.includes(e.id)&&(this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),n(i))};this.client.on(o.Events.GUILD_MEMBER_UPDATE,s);const r=this.client.setTimeout(()=>this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),1e4);return this.rest.makeRequest("put",u.Member(t).Role(e.id),!0).catch(t=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,s),this.client.clearTimeout(r),i(t)})})}removeMemberRole(t,e){return new Promise((n,i)=>{if(!t._roles.includes(e.id))return n(t);const s=(t,i)=>{t._roles.includes(e.id)&&!i._roles.includes(e.id)&&(this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),n(i))};this.client.on(o.Events.GUILD_MEMBER_UPDATE,s);const r=this.client.setTimeout(()=>this.client.removeListener(o.Events.GUILD_MEMBER_UPDATE,s),1e4);return this.rest.makeRequest("delete",u.Member(t).Role(e.id),!0).catch(t=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,s),this.client.clearTimeout(r),i(t)})})}sendTyping(t){return this.rest.makeRequest("post",u.Channel(t).typing,!0)}banGuildMember(t,e,n=0){const i=this.client.resolver.resolveUserID(e);return i?this.rest.makeRequest("put",`${u.Guild(t).bans}/${i}?delete-message-days=${n}`,!0,{"delete-message-days":n}).then(()=>{if(e instanceof f)return e;const n=this.client.resolver.resolveUser(i);return n?(e=this.client.resolver.resolveGuildMember(t,n),e||n):i}):Promise.reject(new Error("Couldn't resolve the user ID to ban."))}unbanGuildMember(t,e){return new Promise((n,i)=>{const s=this.client.resolver.resolveUserID(e);if(!s)throw new Error("Couldn't resolve the user ID to unban.");const r=(e,i)=>{e.id===t.id&&i.id===s&&(this.client.removeListener(o.Events.GUILD_BAN_REMOVE,r),this.client.clearTimeout(c),n(i))};this.client.on(o.Events.GUILD_BAN_REMOVE,r);const c=this.client.setTimeout(()=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,r),i(new Error("Took too long to receive the ban remove event."))},1e4);this.rest.makeRequest("del",`${u.Guild(t).bans}/${s}`,!0).catch(t=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,r),this.client.clearTimeout(c),i(t)})})}getGuildBans(t){return this.rest.makeRequest("get",u.Guild(t).bans,!0).then(t=>{const e=new c;for(const n of t){const t=this.client.dataManager.newUser(n.user);e.set(t.id,t)}return e})}updateGuildRole(t,e){const n={};return n.name=e.name||t.name,n.position="undefined"!=typeof e.position?e.position:t.position,n.color=this.client.resolver.resolveColor(e.color||t.color),n.hoist="undefined"!=typeof e.hoist?e.hoist:t.hoist,n.mentionable="undefined"!=typeof e.mentionable?e.mentionable:t.mentionable,e.permissions?n.permissions=r.resolve(e.permissions):n.permissions=t.permissions,this.rest.makeRequest("patch",u.Guild(t.guild).Role(t.id),!0,n).then(e=>this.client.actions.GuildRoleUpdate.handle({role:e,guild_id:t.guild.id}).updated)}pinMessage(t){return this.rest.makeRequest("put",u.Channel(t.channel).Pin(t.id),!0).then(()=>t)}unpinMessage(t){return this.rest.makeRequest("del",u.Channel(t.channel).Pin(t.id),!0).then(()=>t)}getChannelPinnedMessages(t){return this.rest.makeRequest("get",u.Channel(t).pins,!0)}createChannelInvite(t,e){const n={};return n.temporary=e.temporary,n.max_age=e.maxAge,n.max_uses=e.maxUses,this.rest.makeRequest("post",u.Channel(t).invites,!0,n).then(t=>new m(this.client,t))}deleteInvite(t){return this.rest.makeRequest("del",u.Invite(t.code),!0).then(()=>t)}getInvite(t){return this.rest.makeRequest("get",u.Invite(t),!0).then(t=>new m(this.client,t))}getGuildInvites(t){return this.rest.makeRequest("get",u.Guild(t).invites,!0).then(t=>{const e=new c;for(const n of t){const t=new m(this.client,n);e.set(t.code,t)}return e})}pruneGuildMembers(t,e,n){return this.rest.makeRequest(n?"get":"post",`${u.Guild(t).prune}?days=${e}`,!0).then(t=>t.pruned)}createEmoji(t,e,n,i){const s={image:e,name:n};return i&&(s.roles=i.map(t=>t.id?t.id:t)),this.rest.makeRequest("post",u.Guild(t).emojis,!0,s).then(e=>this.client.actions.GuildEmojiCreate.handle(t,e).emoji)}updateEmoji(t,e){const n={};return e.name&&(n.name=e.name),e.roles&&(n.roles=e.roles.map(t=>t.id?t.id:t)),this.rest.makeRequest("patch",u.Guild(t.guild).Emoji(t.id),!0,n).then(e=>this.client.actions.GuildEmojiUpdate.handle(t,e).emoji)}deleteEmoji(t){return this.rest.makeRequest("delete",u.Guild(t.guild).Emoji(t.id),!0).then(()=>this.client.actions.GuildEmojiDelete.handle(t).data)}getWebhook(t,e){return this.rest.makeRequest("get",u.Webhook(t,e),!e).then(t=>new g(this.client,t))}getGuildWebhooks(t){return this.rest.makeRequest("get",u.Guild(t).webhooks,!0).then(t=>{const e=new c;for(const n of t)e.set(n.id,new g(this.client,n));return e})}getChannelWebhooks(t){return this.rest.makeRequest("get",u.Channel(t).webhooks,!0).then(t=>{const e=new c;for(const n of t)e.set(n.id,new g(this.client,n));return e})}createWebhook(t,e,n){return this.rest.makeRequest("post",u.Channel(t).webhooks,!0,{name:e,avatar:n}).then(t=>new g(this.client,t))}editWebhook(t,e,n){return this.rest.makeRequest("patch",u.Webhook(t.id,t.token),!1,{name:e,avatar:n}).then(e=>{return t.name=e.name,t.avatar=e.avatar,t})}deleteWebhook(t){return this.rest.makeRequest("delete",u.Webhook(t.id,t.token),!1)}sendWebhookMessage(t,e,{avatarURL,tts,disableEveryone,embeds,username}={},n=null){return username=username||t.name,"undefined"!=typeof e&&(e=this.client.resolver.resolveString(e)),e&&(disableEveryone||"undefined"==typeof disableEveryone&&this.client.options.disableEveryone)&&(e=e.replace(/@(everyone|here)/g,"@​$1")),this.rest.makeRequest("post",`${u.Webhook(t.id,t.token)}?wait=true`,!1,{username:username,avatar_url:avatarURL,content:e,tts:tts,embeds:embeds},n)}sendSlackWebhookMessage(t,e){return this.rest.makeRequest("post",`${u.Webhook(t.id,t.token)}/slack?wait=true`,!1,e)}fetchUserProfile(t){return this.rest.makeRequest("get",u.User(t).profile,!0).then(e=>new E(t,e))}fetchMeMentions(t){return t.guild&&(t.guild=t.guild.id?t.guild.id:t.guild),this.rest.makeRequest("get",u.User("@me").mentions(t.limit,t.roles,t.everyone,t.guild)).then(t=>t.body.map(t=>new d(this.client.channels.get(t.channel_id),t,this.client)))}addFriend(t){return this.rest.makeRequest("post",u.User("@me"),!0,{username:t.username,discriminator:t.discriminator}).then(()=>t)}removeFriend(t){return this.rest.makeRequest("delete",u.User("@me").Relationship(t.id),!0).then(()=>t)}blockUser(t){return this.rest.makeRequest("put",u.User("@me").Relationship(t.id),!0,{type:2}).then(()=>t)}unblockUser(t){return this.rest.makeRequest("delete",u.User("@me").Relationship(t.id),!0).then(()=>t)}updateChannelPositions(t,e){const n=new Array(e.length);for(let i=0;ithis.client.actions.GuildChannelsPositionUpdate.handle({guild_id:t,channels:e}).guild)}setRolePositions(t,e){return this.rest.makeRequest("patch",u.Guild(t).roles,!0,e).then(()=>this.client.actions.GuildRolesPositionUpdate.handle({guild_id:t,roles:e}).guild)}setChannelPositions(t,e){return this.rest.makeRequest("patch",u.Guild(t).channels,!0,e).then(()=>this.client.actions.GuildChannelsPositionUpdate.handle({guild_id:t,channels:e}).guild)}addMessageReaction(t,e){return this.rest.makeRequest("put",u.Message(t).Reaction(e).User("@me"),!0).then(()=>this.client.actions.MessageReactionAdd.handle({user_id:this.client.user.id,message_id:t.id,emoji:a.parseEmoji(e),channel_id:t.channel.id}).reaction)}removeMessageReaction(t,e,n){const i=u.Message(t).Reaction(e).User(n===this.client.user.id?"@me":n.id);return this.rest.makeRequest("delete",i,!0).then(()=>this.client.actions.MessageReactionRemove.handle({user_id:n,message_id:t.id,emoji:a.parseEmoji(e),channel_id:t.channel.id}).reaction)}removeMessageReactions(t){return this.rest.makeRequest("delete",u.Message(t).reactions,!0).then(()=>t)}getMessageReactionUsers(t,e,n=100){return this.rest.makeRequest("get",u.Message(t).Reaction(e,n),!0)}getApplication(t){return this.rest.makeRequest("get",u.OAUTH2.Application(t),!0).then(t=>new _(this.client,t))}resetApplication(t){return this.rest.makeRequest("post",u.OAUTH2.Application(t).reset,!0).then(t=>new _(this.client,t))}setNote(t,e){return this.rest.makeRequest("put",u.User(t).note,!0,{note:e}).then(()=>t)}acceptInvite(t){return t.id&&(t=t.id),new Promise((e,n)=>this.rest.makeRequest("post",u.Invite(t),!0).then(t=>{const i=n=>{n.id===t.id&&(e(n),this.client.removeListener(o.Events.GUILD_CREATE,i))};this.client.on(o.Events.GUILD_CREATE,i),this.client.setTimeout(()=>{this.client.removeListener(o.Events.GUILD_CREATE,i),n(new Error("Accepting invite timed out"))},12e4)}))}}t.exports=A},function(t,e,n){const i=n(45);class s extends i{constructor(t,e){super(t,e),this.client=t.client,this.limit=1/0,this.resetTime=null,this.remaining=1,this.timeDifference=0,this.resetTimeout=null}push(t){super.push(t),this.handle()}execute(t){t&&t.request.gen().end((e,n)=>{if(n&&n.headers&&(this.limit=Number(n.headers["x-ratelimit-limit"]),this.resetTime=1e3*Number(n.headers["x-ratelimit-reset"]),this.remaining=Number(n.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(n.headers.date).getTime()),e)if(429===e.status){if(this.queue.unshift(t),n.headers["x-ratelimit-global"]&&(this.globalLimit=!0),this.resetTimeout)return;this.resetTimeout=this.client.setTimeout(()=>{this.remaining=this.limit,this.globalLimit=!1,this.handle(),this.resetTimeout=null},Number(n.headers["retry-after"])+this.client.options.restTimeOffset)}else t.reject(e),this.handle();else{this.globalLimit=!1;const e=n&&n.body?n.body:{};t.resolve(e),this.handle()}})}handle(){super.handle(),this.remaining<=0||0===this.queue.length||this.globalLimit||(this.execute(this.queue.shift()),this.remaining--,this.handle())}}t.exports=s},function(t,e,n){const i=n(45);class s extends i{constructor(t,e){super(t,e),this.endpoint=e,this.timeDifference=0}push(t){super.push(t),this.handle()}execute(t){return new Promise(e=>{t.request.gen().end((n,i)=>{if(i&&i.headers&&(this.requestLimit=Number(i.headers["x-ratelimit-limit"]),this.requestResetTime=1e3*Number(i.headers["x-ratelimit-reset"]),this.requestRemaining=Number(i.headers["x-ratelimit-remaining"]),this.timeDifference=Date.now()-new Date(i.headers.date).getTime()),n)429===n.status?(this.queue.unshift(t),this.restManager.client.setTimeout(()=>{this.globalLimit=!1,e()},Number(i.headers["retry-after"])+this.restManager.client.options.restTimeOffset),i.headers["x-ratelimit-global"]&&(this.globalLimit=!0)):(t.reject(n),e(n));else{this.globalLimit=!1;const n=i&&i.body?i.body:{};t.resolve(n),0===this.requestRemaining?this.restManager.client.setTimeout(()=>{this.waiting=!1,e(n)},this.requestResetTime-Date.now()+this.timeDifference+this.restManager.client.options.restTimeOffset):e(n)}})})}handle(){super.handle(),0===this.remaining||0===this.queue.length||this.globalLimit||this.execute(this.queue.shift()).then(()=>this.handle())}}t.exports=s},function(t,e,n){(function(e){const i=n(0);class s{constructor(){this.build(this.constructor.DEFAULT)}set({url,version}={}){this.build({url:url||this.constructor.DFEAULT.url,version:version||this.constructor.DEFAULT.version})}build(t){this.userAgent=`DiscordBot (${t.url}, ${t.version}) Node.js/${e.version}`}}s.DEFAULT={url:i.Package.homepage.split("#")[0],version:i.Package.version},t.exports=s}).call(e,n(18))},function(t,e,n){(function(e){const i="browser"===n(15).platform(),s=n(23).EventEmitter,r=n(0),o=n(4).convertToBuffer,u=n(43),c=n(101);let h,a,l=JSON.stringify;if(i)h=window.WebSocket;else{try{h=n(143)}catch(t){h=n(144)}try{a=n(142),l=a.pack}catch(t){a=null}}class f extends s{constructor(t){super(),this.client=t,this.packetManager=new c(this),this.status=r.Status.IDLE,this.sessionID=null,this.sequence=-1,this.gateway=null,this.normalReady=!1,this.ws=null,this.disabledEvents={};for(const e of t.options.disabledEvents)this.disabledEvents[e]=!0;this.first=!0,this.lastHeartbeatAck=!0}_connect(t){this.client.emit("debug",`Connecting to gateway ${t}`),this.normalReady=!1,this.status!==r.Status.RECONNECTING&&(this.status=r.Status.CONNECTING),this.ws=new h(t),i&&(this.ws.binaryType="arraybuffer"),this.ws.onopen=this.eventOpen.bind(this),this.ws.onmessage=this.eventMessage.bind(this),this.ws.onclose=this.eventClose.bind(this),this.ws.onerror=this.eventError.bind(this),this._queue=[],this._remaining=120,this.client.setInterval(()=>{this._remaining=120,this._remainingReset=Date.now()},6e4)}connect(t){t=`${t}&encoding=${a?"etf":"json"}`,this.first?(this._connect(t),this.first=!1):this.client.setTimeout(()=>this._connect(t),5500)}heartbeat(t){return t&&!this.lastHeartbeatAck?void this.ws.close(1007):(this.client.emit("debug","Sending heartbeat"),this.client._pingTimestamp=Date.now(),this.client.ws.send({op:r.OPCodes.HEARTBEAT,d:this.sequence},!0),void(this.lastHeartbeatAck=!1))}send(t,e=false){return e?void this._send(l(t)):(this._queue.push(l(t)),void this.doQueue())}destroy(){this.ws&&this.ws.close(1e3),this._queue=[],this.status=r.Status.IDLE}_send(t){this.ws.readyState===h.OPEN&&(this.emit("send",t),this.ws.send(t))}doQueue(){const t=this._queue[0];if(this.ws.readyState===h.OPEN&&t){if(0===this.remaining)return void this.client.setTimeout(this.doQueue.bind(this),Date.now()-this.remainingReset);this._remaining--,this._send(t),this._queue.shift(),this.doQueue()}}eventOpen(){this.client.emit("debug","Connection to gateway opened"),this.lastHeartbeatAck=!0,this.status===r.Status.RECONNECTING?this._sendResume():this._sendNewIdentify()}_sendResume(){if(!this.sessionID)return void this._sendNewIdentify();this.client.emit("debug","Identifying as resumed session");const t={token:this.client.token,session_id:this.sessionID,seq:this.sequence};this.send({op:r.OPCodes.RESUME,d:t})}_sendNewIdentify(){this.reconnecting=!1;const t=this.client.options.ws;t.token=this.client.token,this.client.options.shardCount>0&&(t.shard=[Number(this.client.options.shardId),Number(this.client.options.shardCount)]),this.client.emit("debug","Identifying as new session"),this.send({op:r.OPCodes.IDENTIFY,d:t}),this.sequence=-1}eventClose(t){this.emit("close",t),this.client.clearInterval(this.client.manager.heartbeatInterval),this.status=r.Status.DISCONNECTED,this._queue=[],this.reconnecting||this.client.emit(r.Events.DISCONNECT,t),[4004,4010,4011].includes(t.code)||this.reconnecting||1e3===t.code||this.tryReconnect()}eventMessage(t){const e=this.tryParseEventData(t.data);return null===e?(this.eventError(new Error(r.Errors.BAD_WS_MESSAGE)),!1):(this.client.emit("raw",e),e.op===r.OPCodes.HELLO&&this.client.manager.setupKeepAlive(e.d.heartbeat_interval),this.packetManager.handle(e))}parseEventData(t){return a?(t instanceof ArrayBuffer&&(t=o(t)),a.unpack(t)):((t instanceof e||t instanceof ArrayBuffer)&&(t=u.inflateSync(t).toString()),JSON.parse(t))}tryParseEventData(t){try{return this.parseEventData(t)}catch(t){return null}}eventError(t){this.client.listenerCount("error")>0&&this.client.emit("error",t),this.tryReconnect()}_emitReady(t=true){this.status=r.Status.READY,this.client.emit(r.Events.READY),this.packetManager.handleQueue(),this.normalReady=t}checkIfReady(){if(this.status!==r.Status.READY&&this.status!==r.Status.NEARLY){let t=0;for(const e of this.client.guilds.keys())t+=this.client.guilds.get(e).available?0:1;if(0===t){if(this.status=r.Status.NEARLY,this.client.options.fetchAllMembers){const t=this.client.guilds.map(t=>t.fetchMembers());return void Promise.all(t).then(()=>this._emitReady(),t=>{this.client.emit(r.Events.WARN,"Error in pre-ready guild member fetching"),this.client.emit(r.Events.ERROR,t),this._emitReady()})}this._emitReady()}}}tryReconnect(){this.status!==r.Status.RECONNECTING&&this.status!==r.Status.CONNECTING&&(this.status=r.Status.RECONNECTING,this.ws.close(),this.packetManager.handleQueue(),this.client.emit(r.Events.RECONNECTING),this.connect(this.client.ws.gateway))}}t.exports=f}).call(e,n(22).Buffer)},function(t,e,n){const i=n(0),s=[i.WSEvents.READY,i.WSEvents.GUILD_CREATE,i.WSEvents.GUILD_DELETE,i.WSEvents.GUILD_MEMBERS_CHUNK,i.WSEvents.GUILD_MEMBER_ADD,i.WSEvents.GUILD_MEMBER_REMOVE];class r{constructor(t){this.ws=t,this.handlers={},this.queue=[],this.register(i.WSEvents.READY,n(128)),this.register(i.WSEvents.GUILD_CREATE,n(108)),this.register(i.WSEvents.GUILD_DELETE,n(109)),this.register(i.WSEvents.GUILD_UPDATE,n(119)),this.register(i.WSEvents.GUILD_BAN_ADD,n(106)),this.register(i.WSEvents.GUILD_BAN_REMOVE,n(107)),this.register(i.WSEvents.GUILD_MEMBER_ADD,n(111)),this.register(i.WSEvents.GUILD_MEMBER_REMOVE,n(112)),this.register(i.WSEvents.GUILD_MEMBER_UPDATE,n(113)),this.register(i.WSEvents.GUILD_ROLE_CREATE,n(115)),this.register(i.WSEvents.GUILD_ROLE_DELETE,n(116)),this.register(i.WSEvents.GUILD_ROLE_UPDATE,n(117)),this.register(i.WSEvents.GUILD_EMOJIS_UPDATE,n(110)),this.register(i.WSEvents.GUILD_MEMBERS_CHUNK,n(114)),this.register(i.WSEvents.CHANNEL_CREATE,n(102)),this.register(i.WSEvents.CHANNEL_DELETE,n(103)),this.register(i.WSEvents.CHANNEL_UPDATE,n(105)),this.register(i.WSEvents.CHANNEL_PINS_UPDATE,n(104)),this.register(i.WSEvents.PRESENCE_UPDATE,n(127)),this.register(i.WSEvents.USER_UPDATE,n(133)),this.register(i.WSEvents.USER_NOTE_UPDATE,n(132)),this.register(i.WSEvents.VOICE_STATE_UPDATE,n(135)),this.register(i.WSEvents.TYPING_START,n(131)),this.register(i.WSEvents.MESSAGE_CREATE,n(120)),this.register(i.WSEvents.MESSAGE_DELETE,n(121)),this.register(i.WSEvents.MESSAGE_UPDATE,n(126)),this.register(i.WSEvents.MESSAGE_DELETE_BULK,n(122)),this.register(i.WSEvents.VOICE_SERVER_UPDATE,n(134)),this.register(i.WSEvents.GUILD_SYNC,n(118)),this.register(i.WSEvents.RELATIONSHIP_ADD,n(129)),this.register(i.WSEvents.RELATIONSHIP_REMOVE,n(130)),this.register(i.WSEvents.MESSAGE_REACTION_ADD,n(123)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE,n(124)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE_ALL,n(125))}get client(){return this.ws.client}register(t,e){this.handlers[t]=new e(this)}handleQueue(){this.queue.forEach((t,e)=>{this.handle(this.queue[e]),this.queue.splice(e,1)})}setSequence(t){t&&t>this.ws.sequence&&(this.ws.sequence=t)}handle(t){return t.op===i.OPCodes.RECONNECT?(this.setSequence(t.s),this.ws.tryReconnect(),!1):t.op===i.OPCodes.INVALID_SESSION?(t.d?setTimeout(()=>{this.ws._sendResume()},2500):(this.ws.sessionID=null,this.ws._sendNewIdentify()),!1):(t.op===i.OPCodes.HEARTBEAT_ACK?(this.ws.client._pong(this.ws.client._pingTimestamp),this.ws.lastHeartbeatAck=!0,this.ws.client.emit("debug","Heartbeat acknowledged")):t.op===i.OPCodes.HEARTBEAT&&(this.client.ws.send({op:i.OPCodes.HEARTBEAT,d:this.client.ws.sequence}),this.ws.client.emit("debug","Received gateway heartbeat")),this.ws.status===i.Status.RECONNECTING&&(this.ws.reconnecting=!1,this.ws.checkIfReady()),this.setSequence(t.s),void 0===this.ws.disabledEvents[t.t]&&(this.ws.status!==i.Status.READY&&s.indexOf(t.t)===-1?(this.queue.push(t),!1):!!this.handlers[t.t]&&this.handlers[t.t].handle(t)))}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.ChannelCreate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.ChannelDelete.handle(n);i.channel&&e.emit(s.Events.CHANNEL_DELETE,i.channel)}}t.exports=r},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.channels.get(n.channel_id),r=new Date(n.last_pin_timestamp);i&&r&&e.emit(s.Events.CHANNEL_PINS_UPDATE,i,r)}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.ChannelUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id),r=e.users.get(n.user.id);i&&r&&e.emit(s.Events.GUILD_BAN_ADD,i,r)}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildBanRemove.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.id);i?i.available||n.unavailable||(i.setup(n),this.packetManager.ws.checkIfReady()):e.dataManager.newGuild(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.GuildDelete.handle(n);i.guild&&e.emit(s.Events.GUILD_DELETE,i.guild)}}t.exports=r},function(t,e,n){function i(t){const e=new Map;for(const n of t)e.set(...n);return e}const s=n(1);class r extends s{handle(t){const e=this.packetManager.client,n=t.d,s=e.guilds.get(n.guild_id);if(s&&s.emojis){const t=i(s.emojis.entries());for(const r of n.emojis){const n=s.emojis.get(r.id);n?(t.delete(r.id),n.equals(r,!0)||e.actions.GuildEmojiUpdate.handle(n,r)):e.actions.GuildEmojiCreate.handle(s,r)}for(const r of t.values())e.actions.GuildEmojiDelete.handle(r)}}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);i&&(i.memberCount++,i._addMember(n))}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildMemberRemove.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);if(i){const t=i.members.get(n.user.id);t&&i._updateMember(t,n)}}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);if(i){const t=n.members.map(t=>i._addMember(t,!1));e.emit(s.Events.GUILD_MEMBERS_CHUNK,t,i),e.ws.lastHeartbeatAck=!0}}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildRoleCreate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildRoleDelete.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildRoleUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildSync.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.MessageCreate.handle(n);i.message&&e.emit(s.Events.MESSAGE_CREATE,i.message)}}t.exports=r},function(t,e,n){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.actions.MessageDelete.handle(n);i.message&&e.emit(s.Events.MESSAGE_DELETE,i.message)}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageDeleteBulk.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageReactionAdd.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageReactionRemove.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageReactionRemoveAll.handle(n); +}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.MessageUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0),r=n(4);class o extends i{handle(t){const e=this.packetManager.client,n=t.d;let i=e.users.get(n.user.id);const o=e.guilds.get(n.guild_id);if(!i){if(!n.user.username)return;i=e.dataManager.newUser(n.user)}const u=r.cloneObject(i);if(i.patch(n.user),i.equals(u)||e.emit(s.Events.USER_UPDATE,u,i),o){let t=o.members.get(i.id);if(t||"offline"===n.status||(t=o._addMember({user:i,roles:n.roles,deaf:!1,mute:!1},!1),e.emit(s.Events.GUILD_MEMBER_AVAILABLE,t)),t){if(0===e.listenerCount(s.Events.PRESENCE_UPDATE))return void o._setPresence(i.id,n);const u=r.cloneObject(t);t.presence&&(u.frozenPresence=r.cloneObject(t.presence)),o._setPresence(i.id,n),e.emit(s.Events.PRESENCE_UPDATE,u,t)}else o._setPresence(i.id,n)}}}t.exports=o},function(t,e,n){const i=n(1),s=n(30);class r extends i{handle(t){const e=this.packetManager.client,n=t.d;e.ws.heartbeat();const i=new s(e,n.user);i.settings=n.user_settings,e.user=i,e.readyAt=new Date,e.users.set(i.id,i);for(const r of n.guilds)e.dataManager.newGuild(r);for(const o of n.private_channels)e.dataManager.newChannel(o);for(const u of n.relationships){const t=e.dataManager.newUser(u.user);1===u.type?e.user.friends.set(t.id,t):2===u.type&&e.user.blocked.set(t.id,t)}n.presences=n.presences||[];for(const c of n.presences)e.dataManager.newUser(c.user),e._setPresence(c.user.id,c);if(n.notes)for(const h in n.notes){let t=n.notes[h];t.length||(t=null),e.user.notes.set(h,t)}!e.user.bot&&e.options.sync&&e.setInterval(e.syncGuilds.bind(e),3e4),e.once("ready",e.syncGuilds.bind(e)),e.users.has("1")||e.dataManager.newUser({id:"1",username:"Clyde",discriminator:"0000",avatar:"https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png",bot:!0,status:"online",game:null,verified:!0}),e.setTimeout(()=>{e.ws.normalReady||e.ws._emitReady(!1)},1200*n.guilds.length),this.packetManager.ws.sessionID=n.session_id,this.packetManager.ws.checkIfReady()}}t.exports=r},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;1===n.type?e.fetchUser(n.id).then(t=>{e.user.friends.set(t.id,t)}):2===n.type&&e.fetchUser(n.id).then(t=>{e.user.blocked.set(t.id,t)})}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;2===n.type?e.user.blocked.has(n.id)&&e.user.blocked.delete(n.id):1===n.type&&e.user.friends.has(n.id)&&e.user.friends.delete(n.id)}}t.exports=s},function(t,e,n){function i(t,e){return t.client.setTimeout(()=>{t.client.emit(r.Events.TYPING_STOP,t,e,t._typing.get(e.id)),t._typing.delete(e.id)},6e3)}const s=n(1),r=n(0);class o extends s{handle(t){const e=this.packetManager.client,n=t.d,s=e.channels.get(n.channel_id),o=e.users.get(n.user_id),c=new Date(1e3*n.timestamp);if(s&&o){if("voice"===s.type)return void e.emit(r.Events.WARN,`Discord sent a typing packet to voice channel ${s.id}`);if(s._typing.has(o.id)){const t=s._typing.get(o.id);t.lastTimestamp=c,t.resetTimeout(i(s,o))}else s._typing.set(o.id,new u(e,c,c,i(s,o))),e.emit(r.Events.TYPING_START,s,o)}}}class u{constructor(t,e,n,i){this.client=t,this.since=e,this.lastTimestamp=n,this._timeout=i}resetTimeout(t){this.client.clearTimeout(this._timeout),this._timeout=t}get elapsedTime(){return Date.now()-this.since}}t.exports=o},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.UserNoteUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.UserUpdate.handle(n)}}t.exports=s},function(t,e,n){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.emit("self.voiceServer",n)}}t.exports=s},function(t,e,n){const i=n(1),s=n(0),r=n(4);class o extends i{handle(t){const e=this.packetManager.client,n=t.d,i=e.guilds.get(n.guild_id);if(i){const t=i.members.get(n.user_id);if(t){const i=r.cloneObject(t);t.voiceChannel&&t.voiceChannel.id!==n.channel_id&&t.voiceChannel.members.delete(i.id),n.channel_id||(t.speaking=null),t.user.id===e.user.id&&n.channel_id&&e.emit("self.voiceStateUpdate",n);const o=e.channels.get(n.channel_id);o&&o.members.set(t.user.id,t),t.serverMute=n.mute,t.serverDeaf=n.deaf,t.selfMute=n.self_mute,t.selfDeaf=n.self_deaf,t.voiceSessionID=n.session_id,t.voiceChannelID=n.channel_id,e.emit(s.Events.VOICE_STATE_UPDATE,i,t)}}}}t.exports=o},function(t,e){class n{constructor(t,e){this.user=t,this.setup(e)}setup(t){this.type=t.type,this.name=t.name,this.id=t.id,this.revoked=t.revoked,this.integrations=t.integrations}}t.exports=n},function(t,e,n){const i=n(3),s=n(136);class r{constructor(t,e){this.user=t,Object.defineProperty(this,"client",{value:t.client}),this.mutualGuilds=new i,this.connections=new i,this.setup(e)}setup(t){this.premium=t.premium,this.premiumSince=t.premium_since?new Date(t.premium_since):null;for(const e of t.mutual_guilds)this.client.guilds.has(e.id)&&this.mutualGuilds.set(e.id,this.client.guilds.get(e.id));for(const n of t.connected_accounts)this.connections.set(n.id,new s(this.user,n))}}t.exports=r},function(t,e){class n{constructor(t){this.id=t.id,this.name=t.name,this.vip=t.vip,this.deprecated=t.deprecated,this.optimal=t.optimal,this.custom=t.custom,this.sampleHostname=t.sample_hostname}}t.exports=n},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e,n){const i=n(4);t.exports={Client:n(46),Shard:n(49),ShardClientUtil:n(50),ShardingManager:n(51),WebhookClient:n(47),Collection:n(3),Constants:n(0),EvaluatedPermissions:n(6),Permissions:n(6),Snowflake:n(5),SnowflakeUtil:n(5),Util:i,util:i,version:n(29).version,escapeMarkdown:i.escapeMarkdown,fetchRecommendedShards:i.fetchRecommendedShards,splitMessage:i.splitMessage,Channel:n(8),ClientUser:n(30),DMChannel:n(31),Emoji:n(12),Game:n(7).Game,GroupDMChannel:n(19),Guild:n(16),GuildChannel:n(17),GuildMember:n(13),Invite:n(32),Message:n(9),MessageAttachment:n(33),MessageCollector:n(34),MessageEmbed:n(35),MessageReaction:n(36),OAuth2Application:n(37),PartialGuild:n(38),PartialGuildChannel:n(39),PermissionOverwrites:n(40),Presence:n(7).Presence,ReactionEmoji:n(20),RichEmbed:n(48),Role:n(10),TextChannel:n(41),User:n(11),VoiceChannel:n(42),Webhook:n(21)},"browser"===n(15).platform()&&(window.Discord=t.exports)}]); \ No newline at end of file