From 4966797bff19c5ecff92abcf9a12dfa40411575e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sun, 21 May 2017 05:08:46 +0000 Subject: [PATCH] Webpack build for branch master: 0baa59b679d8542857926d645a02982204b3b80c --- discord.master.js | 9625 +++++++++++++++++++++-------------------- discord.master.min.js | 24 +- 2 files changed, 4900 insertions(+), 4749 deletions(-) diff --git a/discord.master.js b/discord.master.js index ed40718e..b3ee078d 100644 --- a/discord.master.js +++ b/discord.master.js @@ -63,14 +63,14 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 178); +/******/ return __webpack_require__(__webpack_require__.s = 183); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(process) {exports.Package = __webpack_require__(40); +/* WEBPACK VAR INJECTION */(function(process) {exports.Package = __webpack_require__(41); /** * Options for a client. @@ -125,7 +125,7 @@ exports.DefaultOptions = { */ ws: { large_threshold: 250, - compress: __webpack_require__(23).platform() !== 'browser', + compress: __webpack_require__(25).platform() !== 'browser', properties: { $os: process ? process.platform : 'discord.js', $browser: 'discord.js', @@ -178,101 +178,7 @@ const AllowedImageSizes = [ 2048, ]; -const Endpoints = exports.Endpoints = { - User: userID => { - if (userID.id) userID = userID.id; - const base = `/users/${userID}`; - return { - toString: () => base, - channels: `${base}/channels`, - profile: `${base}/profile`, - relationships: `${base}/relationships`, - settings: `${base}/settings`, - Relationship: uID => `${base}/relationships/${uID}`, - Guild: guildID => `${base}/guilds/${guildID}`, - Note: id => `${base}/notes/${id}`, - Mentions: (limit, roles, everyone, guildID) => - `${base}/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`, - Avatar: (root, hash, format, size) => { - if (userID === '1') return hash; - return Endpoints.CDN(root).Avatar(userID, hash, format, size); - }, - }; - }, - guilds: '/guilds', - Guild: guildID => { - if (guildID.id) guildID = guildID.id; - const base = `/guilds/${guildID}`; - return { - toString: () => base, - prune: `${base}/prune`, - embed: `${base}/embed`, - bans: `${base}/bans`, - integrations: `${base}/integrations`, - members: `${base}/members`, - channels: `${base}/channels`, - invites: `${base}/invites`, - roles: `${base}/roles`, - emojis: `${base}/emojis`, - search: `${base}/messages/search`, - voiceRegions: `${base}/regions`, - webhooks: `${base}/webhooks`, - ack: `${base}/ack`, - settings: `${base}/settings`, - auditLogs: `${base}/audit-logs`, - Emoji: emojiID => `${base}/emojis/${emojiID}`, - Icon: (root, hash, format, size) => Endpoints.CDN(root).Icon(guildID, hash, format, size), - Splash: (root, hash) => Endpoints.CDN(root).Splash(guildID, hash), - Role: roleID => `${base}/roles/${roleID}`, - Member: memberID => { - if (memberID.id) memberID = memberID.id; - const mbase = `${base}/members/${memberID}`; - return { - toString: () => mbase, - Role: roleID => `${mbase}/roles/${roleID}`, - nickname: `${base}/members/@me/nick`, - }; - }, - }; - }, - channels: '/channels', - Channel: channelID => { - if (channelID.id) channelID = channelID.id; - const base = `/channels/${channelID}`; - return { - toString: () => base, - messages: { - toString: () => `${base}/messages`, - bulkDelete: `${base}/messages/bulk-delete`, - }, - invites: `${base}/invites`, - typing: `${base}/typing`, - permissions: `${base}/permissions`, - webhooks: `${base}/webhooks`, - search: `${base}/messages/search`, - pins: `${base}/pins`, - Pin: messageID => `${base}/pins/${messageID}`, - Recipient: recipientID => `${base}/recipients/${recipientID}`, - Message: messageID => { - if (messageID.id) messageID = messageID.id; - const mbase = `${base}/messages/${messageID}`; - return { - toString: () => mbase, - reactions: `${mbase}/reactions`, - ack: `${mbase}/ack`, - Reaction: (emoji, limit) => { - const rbase = `${mbase}/reactions/${emoji}${limit ? `?limit=${limit}` : ''}`; - return { - toString: () => rbase, - User: userID => `${rbase}/${userID}`, - }; - }, - }; - }, - }; - }, - Message: m => exports.Endpoints.Channel(m.channel).Message(m), - Member: m => exports.Endpoints.Guild(m.guild).Member(m), +exports.Endpoints = { CDN(root) { return { Emoji: emojiID => `${root}/emojis/${emojiID}.png`, @@ -299,26 +205,7 @@ const Endpoints = exports.Endpoints = { Splash: (guildID, hash) => `${root}/splashes/${guildID}/${hash}.jpg`, }; }, - OAUTH2: { - Application: appID => { - const base = `/oauth2/applications/${appID}`; - return { - toString: () => base, - reset: `${base}/reset`, - }; - }, - App: appID => `/oauth2/authorize?client_id=${appID}`, - }, - login: '/auth/login', - logout: '/auth/logout', - voiceRegions: '/voice/regions', - gateway: { - toString: () => '/gateway', - bot: '/gateway/bot', - }, - Invite: inviteID => `/invite/${inviteID}?with_counts=true`, - inviteLink: id => `https://discord.gg/${id}`, - Webhook: (webhookID, token) => `/webhooks/${webhookID}${token ? `/${token}` : ''}`, + invite: code => `https://discord.gg/${code}`, }; @@ -1135,7 +1022,7 @@ module.exports = Collection; /* 4 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {const snekfetch = __webpack_require__(37); +/* WEBPACK VAR INJECTION */(function(Buffer) {const snekfetch = __webpack_require__(38); const Constants = __webpack_require__(0); const ConstantsHttp = Constants.DefaultOptions.http; @@ -1167,7 +1054,7 @@ class Util { } messages[msg] += (messages[msg].length > 0 && messages[msg] !== prepend ? char : '') + splitText[i]; } - return messages; + return messages.filter(m => m); } /** @@ -1365,8 +1252,8 @@ module.exports = Util; -var base64 = __webpack_require__(76) -var ieee754 = __webpack_require__(79) +var base64 = __webpack_require__(78) +var ieee754 = __webpack_require__(81) var isArray = __webpack_require__(57) exports.Buffer = Buffer @@ -3151,7 +3038,7 @@ function isnan (val) { /* 6 */ /***/ (function(module, exports, __webpack_require__) { -const Long = __webpack_require__(33); +const Long = __webpack_require__(34); // Discord epoch (2015-01-01T00:00:00.000Z) const EPOCH = 1420070400000; @@ -3422,2197 +3309,6 @@ process.umask = function() { return 0; }; /* 8 */ /***/ (function(module, exports, __webpack_require__) { -const Constants = __webpack_require__(0); - -/** - * Data structure that makes it easy to interact with a permission bitfield. All {@link GuildMember}s have a set of - * permissions in their guild, and each channel in the guild may also have {@link PermissionOverwrites} for the member - * that override their default permissions. - */ -class Permissions { - /** - * @param {number|PermissionResolvable[]} permissions Permissions or bitfield to read from - */ - constructor(permissions) { - /** - * Bitfield of the packed permissions - * @type {number} - */ - this.bitfield = typeof permissions === 'number' ? permissions : this.constructor.resolve(permissions); - } - - /** - * Checks whether the bitfield has a permission, or multiple permissions. - * @param {PermissionResolvable|PermissionResolvable[]} permission Permission(s) to check for - * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override - * @returns {boolean} - */ - has(permission, checkAdmin = true) { - if (permission instanceof Array) return permission.every(p => this.has(p, checkAdmin)); - permission = this.constructor.resolve(permission); - if (checkAdmin && (this.bitfield & this.constructor.FLAGS.ADMINISTRATOR) > 0) return true; - return (this.bitfield & permission) === permission; - } - - /** - * Gets all given permissions that are missing from the bitfield. - * @param {PermissionResolvable[]} permissions Permissions to check for - * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override - * @returns {PermissionResolvable[]} - */ - missing(permissions, checkAdmin = true) { - return permissions.filter(p => !this.has(p, checkAdmin)); - } - - /** - * Adds permissions to this one, creating a new instance to represent the new bitfield. - * @param {...PermissionResolvable} permissions Permissions to add - * @returns {Permissions} - */ - add(...permissions) { - let total = 0; - for (let p = 0; p < permissions.length; p++) { - const perm = this.constructor.resolve(permissions[p]); - if ((this.bitfield & perm) !== perm) total |= perm; - } - return new this.constructor(this.member, this.bitfield | total); - } - - /** - * Removes permissions to this one, creating a new instance to represent the new bitfield. - * @param {...PermissionResolvable} permissions Permissions to remove - * @returns {Permissions} - */ - remove(...permissions) { - let total = 0; - for (let p = 0; p < permissions.length; p++) { - const perm = this.constructor.resolve(permissions[p]); - if ((this.bitfield & perm) === perm) total |= perm; - } - return new this.constructor(this.member, this.bitfield & ~total); - } - - /** - * Gets an object mapping permission name (like `READ_MESSAGES`) to a {@link boolean} indicating whether the - * permission is available. - * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override - * @returns {Object} - */ - serialize(checkAdmin = true) { - const serialized = {}; - for (const perm in this.constructor.FLAGS) serialized[perm] = this.has(perm, checkAdmin); - return serialized; - } - - /** - * Data that can be resolved to give a permission number. This can be: - * - A string (see {@link Permissions.FLAGS}) - * - A permission number - * @typedef {string|number} PermissionResolvable - */ - - /** - * Resolves permissions to their numeric form. - * @param {PermissionResolvable|PermissionResolvable[]} permission - Permission(s) to resolve - * @returns {number} - */ - static resolve(permission) { - if (permission instanceof Array) return permission.map(p => this.resolve(p)).reduce((prev, p) => prev | p, 0); - if (typeof permission === 'string') permission = this.FLAGS[permission]; - if (typeof permission !== 'number' || permission < 1) throw new RangeError(Constants.Errors.NOT_A_PERMISSION); - return permission; - } -} - -/** - * Numeric permission flags. All available properties: - * - `ADMINISTRATOR` (implicitly has *all* permissions, and bypasses all channel overwrites) - * - `CREATE_INSTANT_INVITE` (create invitations to the guild) - * - `KICK_MEMBERS` - * - `BAN_MEMBERS` - * - `MANAGE_CHANNELS` (edit and reorder channels) - * - `MANAGE_GUILD` (edit the guild information, region, etc.) - * - `ADD_REACTIONS` (add new reactions to messages) - * - `VIEW_AUDIT_LOG` - * - `READ_MESSAGES` - * - `SEND_MESSAGES` - * - `SEND_TTS_MESSAGES` - * - `MANAGE_MESSAGES` (delete messages and reactions) - * - `EMBED_LINKS` (links posted will have a preview embedded) - * - `ATTACH_FILES` - * - `READ_MESSAGE_HISTORY` (view messages that were posted prior to opening Discord) - * - `MENTION_EVERYONE` - * - `USE_EXTERNAL_EMOJIS` (use emojis from different guilds) - * - `CONNECT` (connect to a voice channel) - * - `SPEAK` (speak in a voice channel) - * - `MUTE_MEMBERS` (mute members across all voice channels) - * - `DEAFEN_MEMBERS` (deafen members across all voice channels) - * - `MOVE_MEMBERS` (move members between voice channels) - * - `USE_VAD` (use voice activity detection) - * - `CHANGE_NICKNAME` - * - `MANAGE_NICKNAMES` (change other members' nicknames) - * - `MANAGE_ROLES` - * - `MANAGE_WEBHOOKS` - * - `MANAGE_EMOJIS` - * @type {Object} - * @see {@link https://discordapp.com/developers/docs/topics/permissions} - */ -Permissions.FLAGS = { - CREATE_INSTANT_INVITE: 1 << 0, - KICK_MEMBERS: 1 << 1, - BAN_MEMBERS: 1 << 2, - ADMINISTRATOR: 1 << 3, - MANAGE_CHANNELS: 1 << 4, - MANAGE_GUILD: 1 << 5, - ADD_REACTIONS: 1 << 6, - VIEW_AUDIT_LOG: 1 << 7, - - READ_MESSAGES: 1 << 10, - SEND_MESSAGES: 1 << 11, - SEND_TTS_MESSAGES: 1 << 12, - MANAGE_MESSAGES: 1 << 13, - EMBED_LINKS: 1 << 14, - ATTACH_FILES: 1 << 15, - READ_MESSAGE_HISTORY: 1 << 16, - MENTION_EVERYONE: 1 << 17, - 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_WEBHOOKS: 1 << 29, - MANAGE_EMOJIS: 1 << 30, -}; - -/** - * Bitfield representing every permission combined - * @type {number} - */ -Permissions.ALL = Object.keys(Permissions.FLAGS).reduce((all, p) => all | Permissions.FLAGS[p], 0); - -/** - * Bitfield representing the default permissions for users - * @type {number} - */ -Permissions.DEFAULT = 104324097; - -module.exports = Permissions; - - -/***/ }), -/* 9 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 10 */ -/***/ (function(module, exports) { - -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - - -/***/ }), -/* 11 */ -/***/ (function(module, exports) { - -/** - * Represents a user's presence. - */ -class Presence { - constructor(data = {}) { - /** - * The status of the presence: - * - * * **`online`** - user is online - * * **`offline`** - user is offline or invisible - * * **`idle`** - user is AFK - * * **`dnd`** - user is in Do not Disturb - * @type {string} - */ - this.status = data.status || 'offline'; - - /** - * The game that the user is playing - * @type {?Game} - */ - this.game = data.game ? new Game(data.game) : null; - } - - update(data) { - this.status = data.status || this.status; - this.game = data.game ? new Game(data.game) : null; - } - - /** - * Whether this presence is equal to another - * @param {Presence} presence The presence to compare with - * @returns {boolean} - */ - equals(presence) { - return this === presence || ( - presence && - this.status === presence.status && - this.game ? this.game.equals(presence.game) : !presence.game - ); - } -} - -/** - * Represents a game that is part of a user's presence. - */ -class Game { - constructor(data) { - /** - * The name of the game being played - * @type {string} - */ - this.name = data.name; - - /** - * The type of the game status - * @type {number} - */ - this.type = data.type; - - /** - * If the game is being streamed, a link to the stream - * @type {?string} - */ - this.url = data.url || null; - } - - /** - * Whether or not the game is being streamed - * @type {boolean} - * @readonly - */ - get streaming() { - return this.type === 1; - } - - /** - * Whether this game is equal to another game - * @param {Game} game The game to compare with - * @returns {boolean} - */ - equals(game) { - return this === game || ( - game && - this.name === game.name && - this.type === game.type && - this.url === game.url - ); - } -} - -exports.Presence = Presence; -exports.Game = Game; - - -/***/ }), -/* 12 */ -/***/ (function(module, exports) { - -// 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. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - - -/***/ }), -/* 13 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from -// Writable. - - - -/**/ - -var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - keys.push(key); - }return keys; -}; -/**/ - -module.exports = Duplex; - -/**/ -var processNextTick = __webpack_require__(34); -/**/ - -/**/ -var util = __webpack_require__(20); -util.inherits = __webpack_require__(10); -/**/ - -var Readable = __webpack_require__(58); -var Writable = __webpack_require__(36); - -util.inherits(Duplex, Readable); - -var keys = objectKeys(Writable.prototype); -for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; -} - -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); - - Readable.call(this, options); - Writable.call(this, options); - - if (options && options.readable === false) this.readable = false; - - if (options && options.writable === false) this.writable = false; - - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; - - this.once('end', onend); -} - -// the no-half-open enforcer -function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; - - // no more data can be written. - // But allow more writes to happen in this tick. - processNextTick(onEndNT, this); -} - -function onEndNT(self) { - self.end(); -} - -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } -} - -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { - -const Snowflake = __webpack_require__(6); - -/** - * Represents any channel on Discord. - */ -class Channel { - constructor(client, data) { - /** - * The client that instantiated the Channel - * @name Channel#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - /** - * The type of the channel, either: - * * `dm` - a DM channel - * * `group` - a Group DM channel - * * `text` - a guild text channel - * * `voice` - a guild voice channel - * @type {string} - */ - this.type = null; - - if (data) this.setup(data); - } - - setup(data) { - /** - * The unique ID of the channel - * @type {Snowflake} - */ - this.id = data.id; - } - - /** - * The timestamp the channel was created at - * @type {number} - * @readonly - */ - get createdTimestamp() { - return Snowflake.deconstruct(this.id).timestamp; - } - - /** - * The time the channel was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * Deletes the channel. - * @returns {Promise} - * @example - * // Delete the channel - * channel.delete() - * .then() // Success - * .catch(console.error); // Log error - */ - delete() { - return this.client.rest.methods.deleteChannel(this); - } -} - -module.exports = Channel; - - -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -const Snowflake = __webpack_require__(6); -const Permissions = __webpack_require__(8); - -/** - * Represents a role on Discord. - */ -class Role { - constructor(guild, data) { - /** - * The client that instantiated the role - * @name Role#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: guild.client }); - - /** - * The guild that the role belongs to - * @type {Guild} - */ - this.guild = guild; - - if (data) this.setup(data); - } - - setup(data) { - /** - * The ID of the role (unique to the guild it is part of) - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The name of the role - * @type {string} - */ - this.name = data.name; - - /** - * The base 10 color of the role - * @type {number} - */ - this.color = data.color; - - /** - * If true, users that are part of this role will appear in a separate category in the users list - * @type {boolean} - */ - this.hoist = data.hoist; - - /** - * The position of the role from the API - * @type {number} - */ - this.position = data.position; - - /** - * The permissions bitfield of the role - * @type {number} - */ - this.permissions = data.permissions; - - /** - * Whether or not the role is managed by an external service - * @type {boolean} - */ - this.managed = data.managed; - - /** - * Whether or not the role can be mentioned by anyone - * @type {boolean} - */ - this.mentionable = data.mentionable; - } - - /** - * The timestamp the role was created at - * @type {number} - * @readonly - */ - get createdTimestamp() { - return Snowflake.deconstruct(this.id).timestamp; - } - - /** - * The time the role was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * The hexadecimal version of the role color, with a leading hashtag - * @type {string} - * @readonly - */ - get hexColor() { - let col = this.color.toString(16); - while (col.length < 6) col = `0${col}`; - return `#${col}`; - } - - /** - * The cached guild members that have this role - * @type {Collection} - * @readonly - */ - get members() { - return this.guild.members.filter(m => m.roles.has(this.id)); - } - - /** - * Whether the role is editable by the client user - * @type {boolean} - * @readonly - */ - get editable() { - if (this.managed) return false; - const clientMember = this.guild.member(this.client.user); - if (!clientMember.permissions.has(Permissions.FLAGS.MANAGE_ROLES_OR_PERMISSIONS)) return false; - return clientMember.highestRole.comparePositionTo(this) > 0; - } - - /** - * The position of the role in the role manager - * @type {number} - * @readonly - */ - get calculatedPosition() { - const sorted = this.guild._sortedRoles; - return sorted.array().indexOf(sorted.get(this.id)); - } - - /** - * Get an object mapping permission names to whether or not the role enables that permission - * @returns {Object} - * @example - * // Print the serialized role permissions - * console.log(role.serialize()); - */ - serialize() { - return new Permissions(this.permissions).serialize(); - } - - /** - * Checks if the role has a permission. - * @param {PermissionResolvable|PermissionResolvable[]} permission Permission(s) to check for - * @param {boolean} [explicit=false] Whether to require the role to explicitly have the exact permission - * **(deprecated)** - * @param {boolean} [checkAdmin] Whether to allow the administrator permission to override - * (takes priority over `explicit`) - * @returns {boolean} - * @example - * // See if a role can ban a member - * if (role.hasPermission('BAN_MEMBERS')) { - * console.log('This role can ban members'); - * } else { - * console.log('This role can\'t ban members'); - * } - */ - hasPermission(permission, explicit = false, checkAdmin) { - return new Permissions(this.permissions).has( - permission, typeof checkAdmin !== 'undefined' ? checkAdmin : !explicit - ); - } - - /** - * Compares this role's position to another role's. - * @param {Role} role Role to compare to this one - * @returns {number} Negative number if the this role's position is lower (other role's is higher), - * positive number if the this one is higher (other's is lower), 0 if equal - */ - comparePositionTo(role) { - return this.constructor.comparePositions(this, role); - } - - /** - * The data for a role. - * @typedef {Object} RoleData - * @property {string} [name] The name of the role - * @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number - * @property {boolean} [hoist] Whether or not the role should be hoisted - * @property {number} [position] The position of the role - * @property {string[]} [permissions] The permissions of the role - * @property {boolean} [mentionable] Whether or not the role should be mentionable - */ - - /** - * Edits the role. - * @param {RoleData} data The new data for the role - * @returns {Promise} - * @example - * // Edit a role - * role.edit({name: 'new role'}) - * .then(r => console.log(`Edited role ${r}`)) - * .catch(console.error); - */ - edit(data) { - return this.client.rest.methods.updateGuildRole(this, data); - } - - /** - * Set a new name for the role. - * @param {string} name The new name of the role - * @returns {Promise} - * @example - * // Set the name of the role - * role.setName('new role') - * .then(r => console.log(`Edited name of role ${r}`)) - * .catch(console.error); - */ - setName(name) { - return this.edit({ name }); - } - - /** - * Set a new color for the role. - * @param {ColorResolvable} color The color of the role - * @returns {Promise} - * @example - * // Set the color of a role - * role.setColor('#FF0000') - * .then(r => console.log(`Set color of role ${r}`)) - * .catch(console.error); - */ - setColor(color) { - return this.edit({ color }); - } - - /** - * Set whether or not the role should be hoisted. - * @param {boolean} hoist Whether or not to hoist the role - * @returns {Promise} - * @example - * // Set the hoist of the role - * role.setHoist(true) - * .then(r => console.log(`Role hoisted: ${r.hoist}`)) - * .catch(console.error); - */ - setHoist(hoist) { - return this.edit({ hoist }); - } - - /** - * Set the position of the role. - * @param {number} position The position of the role - * @param {boolean} [relative=false] Move the position relative to its current value - * @returns {Promise} - * @example - * // Set the position of the role - * role.setPosition(1) - * .then(r => console.log(`Role position: ${r.position}`)) - * .catch(console.error); - */ - setPosition(position, relative) { - return this.guild.setRolePosition(this, position, relative).then(() => this); - } - - /** - * Set the permissions of the role. - * @param {string[]} permissions The permissions of the role - * @returns {Promise} - * @example - * // Set the permissions of the role - * role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS']) - * .then(r => console.log(`Role updated ${r}`)) - * .catch(console.error); - */ - setPermissions(permissions) { - return this.edit({ permissions }); - } - - /** - * Set whether this role is mentionable. - * @param {boolean} mentionable Whether this role should be mentionable - * @returns {Promise} - * @example - * // Make the role mentionable - * role.setMentionable(true) - * .then(r => console.log(`Role updated ${r}`)) - * .catch(console.error); - */ - setMentionable(mentionable) { - return this.edit({ mentionable }); - } - - /** - * Deletes the role. - * @returns {Promise} - * @example - * // Delete a role - * role.delete() - * .then(r => console.log(`Deleted role ${r}`)) - * .catch(console.error); - */ - delete() { - return this.client.rest.methods.deleteGuildRole(this); - } - - /** - * Whether this role equals another role. It compares all properties, so for most operations - * it is advisable to just compare `role.id === role2.id` as it is much faster and is often - * what most users need. - * @param {Role} role Role to compare with - * @returns {boolean} - */ - equals(role) { - return role && - this.id === role.id && - this.name === role.name && - this.color === role.color && - this.hoist === role.hoist && - this.position === role.position && - this.permissions === role.permissions && - this.managed === role.managed; - } - - /** - * When concatenated with a string, this automatically concatenates the role mention rather than the Role object. - * @returns {string} - */ - toString() { - if (this.id === this.guild.id) return '@everyone'; - return `<@&${this.id}>`; - } - - /** - * Compares the positions of two roles. - * @param {Role} role1 First role to compare - * @param {Role} role2 Second role to compare - * @returns {number} Negative number if the first role's position is lower (second role's is higher), - * positive number if the first's is higher (second's is lower), 0 if equal - */ - static comparePositions(role1, role2) { - if (role1.position === role2.position) return role2.id - role1.id; - return role1.position - role2.position; - } -} - -module.exports = Role; - - -/***/ }), -/* 16 */ -/***/ (function(module, exports, __webpack_require__) { - -const TextBasedChannel = __webpack_require__(22); -const Constants = __webpack_require__(0); -const Presence = __webpack_require__(11).Presence; -const Snowflake = __webpack_require__(6); - -/** - * Represents a user on Discord. - * @implements {TextBasedChannel} - */ -class User { - constructor(client, data) { - /** - * The client that created the instance of the the user - * @name User#client - * @type {} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - - if (data) this.setup(data); - } - - setup(data) { - /** - * The ID of the user - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The username of the user - * @type {string} - */ - this.username = data.username; - - /** - * A discriminator based on username for the user - * @type {string} - */ - this.discriminator = data.discriminator; - - /** - * The ID of the user's avatar - * @type {string} - */ - this.avatar = data.avatar; - - /** - * Whether or not the user is a bot - * @type {boolean} - */ - this.bot = Boolean(data.bot); - - /** - * The ID of the last message sent by the user, if one was sent - * @type {?Snowflake} - */ - this.lastMessageID = null; - - /** - * The Message object of the last message sent by the user, if one was sent - * @type {?Message} - */ - this.lastMessage = null; - } - - patch(data) { - for (const prop of ['id', 'username', 'discriminator', 'avatar', 'bot']) { - if (typeof data[prop] !== 'undefined') this[prop] = data[prop]; - } - if (data.token) this.client.token = data.token; - } - - /** - * The timestamp the user was created at - * @type {number} - * @readonly - */ - get createdTimestamp() { - return Snowflake.deconstruct(this.id).timestamp; - } - - /** - * The time the user was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * The presence of this user - * @type {Presence} - * @readonly - */ - get presence() { - if (this.client.presences.has(this.id)) return this.client.presences.get(this.id); - for (const guild of this.client.guilds.values()) { - if (guild.presences.has(this.id)) return guild.presences.get(this.id); - } - return new Presence(); - } - - /** - * A link to the user's avatar - * @param {string} [format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided, it will be `gif` - * for animated avatars or otherwise `webp` - * @param {number} [size=128] One of `128`, '256', `512`, `1024`, `2048` - * @returns {?string} avatarURL - */ - avatarURL(format, size) { - if (!this.avatar) return null; - if (typeof format === 'number') { - size = format; - format = 'default'; - } - return Constants.Endpoints.User(this).Avatar(this.client.options.http.cdn, this.avatar, format, size); - } - - /** - * A link to the user's default avatar - * @type {string} - * @readonly - */ - get defaultAvatarURL() { - return Constants.Endpoints.CDN(this.client.options.http.host).DefaultAvatar(this.discriminator % 5); - } - - /** - * A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned - * @type {string} - * @readonly - */ - get displayAvatarURL() { - return this.avatarURL() || this.defaultAvatarURL; - } - - /** - * The Discord "tag" for this user - * @type {string} - * @readonly - */ - get tag() { - return `${this.username}#${this.discriminator}`; - } - - /** - * The note that is set for the user - * This is only available when using a user account. - * @type {?string} - * @readonly - */ - get note() { - return this.client.user.notes.get(this.id) || null; - } - - /** - * Check whether the user is typing in a channel. - * @param {ChannelResolvable} channel The channel to check in - * @returns {boolean} - */ - typingIn(channel) { - channel = this.client.resolver.resolveChannel(channel); - return channel._typing.has(this.id); - } - - /** - * Get the time that the user started typing. - * @param {ChannelResolvable} channel The channel to get the time in - * @returns {?Date} - */ - typingSinceIn(channel) { - channel = this.client.resolver.resolveChannel(channel); - return channel._typing.has(this.id) ? new Date(channel._typing.get(this.id).since) : null; - } - - /** - * Get the amount of time the user has been typing in a channel for (in milliseconds), or -1 if they're not typing. - * @param {ChannelResolvable} channel The channel to get the time in - * @returns {number} - */ - typingDurationIn(channel) { - channel = this.client.resolver.resolveChannel(channel); - return channel._typing.has(this.id) ? channel._typing.get(this.id).elapsedTime : -1; - } - - /** - * The DM between the client's user and this user - * @type {?DMChannel} - * @readonly - */ - get dmChannel() { - return this.client.channels.filter(c => c.type === 'dm').find(c => c.recipient.id === this.id); - } - - /** - * Creates a DM channel between the client and the user. - * @returns {Promise} - */ - createDM() { - return this.client.rest.methods.createDM(this); - } - - /** - * Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful. - * @returns {Promise} - */ - deleteDM() { - return this.client.rest.methods.deleteChannel(this); - } - - /** - * Sends a friend request to the user. - * This is only available when using a user account. - * @returns {Promise} - */ - addFriend() { - return this.client.rest.methods.addFriend(this); - } - - /** - * Removes the user from your friends. - * This is only available when using a user account. - * @returns {Promise} - */ - removeFriend() { - return this.client.rest.methods.removeFriend(this); - } - - /** - * Blocks the user. - * This is only available when using a user account. - * @returns {Promise} - */ - block() { - return this.client.rest.methods.blockUser(this); - } - - /** - * Unblocks the user. - * This is only available when using a user account. - * @returns {Promise} - */ - unblock() { - return this.client.rest.methods.unblockUser(this); - } - - /** - * Get the profile of the user. - * This is only available when using a user account. - * @returns {Promise} - */ - fetchProfile() { - return this.client.rest.methods.fetchUserProfile(this); - } - - /** - * Sets a note for the user. - * This is only available when using a user account. - * @param {string} note The note to set for the user - * @returns {Promise} - */ - setNote(note) { - return this.client.rest.methods.setNote(this, note); - } - - /** - * Checks if the user is equal to another. It compares ID, username, discriminator, avatar, and bot flags. - * It is recommended to compare equality by using `user.id === user2.id` unless you want to compare all properties. - * @param {User} user User to compare with - * @returns {boolean} - */ - equals(user) { - let equal = user && - this.id === user.id && - this.username === user.username && - this.discriminator === user.discriminator && - this.avatar === user.avatar && - this.bot === Boolean(user.bot); - - return equal; - } - - /** - * When concatenated with a string, this automatically concatenates the user's mention instead of the User object. - * @returns {string} - * @example - * // logs: Hello from <@123456789>! - * console.log(`Hello from ${user}!`); - */ - toString() { - return `<@${this.id}>`; - } - - // These are here only for documentation purposes - they are implemented by TextBasedChannel - /* eslint-disable no-empty-function */ - send() {} -} - -TextBasedChannel.applyToClass(User); - -module.exports = User; - - -/***/ }), -/* 17 */ -/***/ (function(module, exports, __webpack_require__) { - -const Constants = __webpack_require__(0); -const Collection = __webpack_require__(3); -const Snowflake = __webpack_require__(6); - -/** - * Represents a custom emoji. - */ -class Emoji { - constructor(guild, data) { - /** - * The client that instantiated this object - * @name Emoji#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: guild.client }); - - /** - * The guild this emoji is part of - * @type {Guild} - */ - this.guild = guild; - - this.setup(data); - } - - setup(data) { - /** - * The ID of the emoji - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The name of the emoji - * @type {string} - */ - this.name = data.name; - - /** - * Whether or not this emoji requires colons surrounding it - * @type {boolean} - */ - this.requiresColons = data.require_colons; - - /** - * Whether this emoji is managed by an external service - * @type {boolean} - */ - this.managed = data.managed; - - this._roles = data.roles; - } - - /** - * The timestamp the emoji was created at - * @type {number} - * @readonly - */ - get createdTimestamp() { - return Snowflake.deconstruct(this.id).timestamp; - } - - /** - * The time the emoji was created - * @type {Date} - * @readonly - */ - get createdAt() { - return new Date(this.createdTimestamp); - } - - /** - * A collection of roles this emoji is active for (empty if all), mapped by role ID - * @type {Collection} - * @readonly - */ - get roles() { - const roles = new Collection(); - for (const role of this._roles) { - if (this.guild.roles.has(role)) roles.set(role, this.guild.roles.get(role)); - } - return roles; - } - - /** - * The URL to the emoji file - * @type {string} - * @readonly - */ - get url() { - return Constants.Endpoints.CDN(this.client.options.http.cdn).Emoji(this.id); - } - - /** - * The identifier of this emoji, used for message reactions - * @type {string} - * @readonly - */ - get identifier() { - if (this.id) return `${this.name}:${this.id}`; - return encodeURIComponent(this.name); - } - - /** - * Data for editing an emoji. - * @typedef {Object} EmojiEditData - * @property {string} [name] The name of the emoji - * @property {Collection|Array} [roles] Roles to restrict emoji to - */ - - /** - * Edits the emoji. - * @param {EmojiEditData} data The new data for the emoji - * @returns {Promise} - * @example - * // Edit a emoji - * emoji.edit({name: 'newemoji'}) - * .then(e => console.log(`Edited emoji ${e}`)) - * .catch(console.error); - */ - edit(data) { - return this.client.rest.methods.updateEmoji(this, data); - } - - /** - * Set the name of the emoji. - * @param {string} name The new name for the emoji - * @returns {Promise} - */ - setName(name) { - return this.edit({ name }); - } - - /** - * Add a role to the list of roles that can use this emoji. - * @param {Role} role The role to add - * @returns {Promise} - */ - addRestrictedRole(role) { - return this.addRestrictedRoles([role]); - } - - /** - * Add multiple roles to the list of roles that can use this emoji. - * @param {Role[]} roles Roles to add - * @returns {Promise} - */ - addRestrictedRoles(roles) { - const newRoles = new Collection(this.roles); - for (const role of roles) { - if (this.guild.roles.has(role.id)) newRoles.set(role.id, role); - } - return this.edit({ roles: newRoles }); - } - - /** - * Remove a role from the list of roles that can use this emoji. - * @param {Role} role The role to remove - * @returns {Promise} - */ - removeRestrictedRole(role) { - return this.removeRestrictedRoles([role]); - } - - /** - * Remove multiple roles from the list of roles that can use this emoji. - * @param {Role[]} roles Roles to remove - * @returns {Promise} - */ - removeRestrictedRoles(roles) { - const newRoles = new Collection(this.roles); - for (const role of roles) { - if (newRoles.has(role.id)) newRoles.delete(role.id); - } - return this.edit({ roles: newRoles }); - } - - /** - * When concatenated with a string, this automatically returns the emoji mention rather than the object. - * @returns {string} - * @example - * // Send an emoji: - * const emoji = guild.emojis.first(); - * msg.reply(`Hello! ${emoji}`); - */ - toString() { - return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name; - } - - /** - * Whether this emoji is the same as another one. - * @param {Emoji|Object} other The emoji to compare it to - * @returns {boolean} Whether the emoji is equal to the given emoji or not - */ - equals(other) { - if (other instanceof Emoji) { - return ( - other.id === this.id && - other.name === this.name && - other.managed === this.managed && - other.requiresColons === this.requiresColons - ); - } else { - return ( - other.id === this.id && - other.name === this.name - ); - } - } -} - -module.exports = Emoji; - - -/***/ }), -/* 18 */ -/***/ (function(module, exports, __webpack_require__) { - -const TextBasedChannel = __webpack_require__(22); -const Role = __webpack_require__(15); -const Permissions = __webpack_require__(8); -const Collection = __webpack_require__(3); -const Presence = __webpack_require__(11).Presence; - -/** - * Represents a member of a guild on Discord. - * @implements {TextBasedChannel} - */ -class GuildMember { - constructor(guild, data) { - /** - * The client that instantiated this GuildMember - * @name GuildMember#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: guild.client }); - - /** - * The guild that this member is part of - * @type {Guild} - */ - this.guild = guild; - - /** - * The user that this guild member instance Represents - * @type {User} - */ - this.user = {}; - - this._roles = []; - if (data) this.setup(data); - - /** - * The ID of the last message sent by the member in their guild, if one was sent - * @type {?Snowflake} - */ - this.lastMessageID = null; - - /** - * The Message object of the last message sent by the member in their guild, if one was sent - * @type {?Message} - */ - this.lastMessage = null; - } - - setup(data) { - /** - * Whether this member is deafened server-wide - * @type {boolean} - */ - this.serverDeaf = data.deaf; - - /** - * Whether this member is muted server-wide - * @type {boolean} - */ - this.serverMute = data.mute; - - /** - * Whether this member is self-muted - * @type {boolean} - */ - this.selfMute = data.self_mute; - - /** - * Whether this member is self-deafened - * @type {boolean} - */ - this.selfDeaf = data.self_deaf; - - /** - * The voice session ID of this member, if any - * @type {?Snowflake} - */ - this.voiceSessionID = data.session_id; - - /** - * The voice channel ID of this member, if any - * @type {?Snowflake} - */ - this.voiceChannelID = data.channel_id; - - /** - * Whether this member is speaking - * @type {boolean} - */ - this.speaking = false; - - /** - * The nickname of this guild member, if they have one - * @type {?string} - */ - this.nickname = data.nick || null; - - /** - * The timestamp the member joined the guild at - * @type {number} - */ - this.joinedTimestamp = new Date(data.joined_at).getTime(); - - this.user = data.user; - this._roles = data.roles; - } - - /** - * The time the member joined the guild - * @type {Date} - * @readonly - */ - get joinedAt() { - return new Date(this.joinedTimestamp); - } - - /** - * The presence of this guild member - * @type {Presence} - * @readonly - */ - get presence() { - return this.frozenPresence || this.guild.presences.get(this.id) || new Presence(); - } - - /** - * A list of roles that are applied to this GuildMember, mapped by the role ID - * @type {Collection} - * @readonly - */ - get roles() { - const list = new Collection(); - const everyoneRole = this.guild.roles.get(this.guild.id); - - if (everyoneRole) list.set(everyoneRole.id, everyoneRole); - - for (const roleID of this._roles) { - const role = this.guild.roles.get(roleID); - if (role) list.set(role.id, role); - } - - return list; - } - - /** - * The role of the member with the highest position - * @type {Role} - * @readonly - */ - get highestRole() { - return this.roles.reduce((prev, role) => !prev || role.comparePositionTo(prev) > 0 ? role : prev); - } - - /** - * The role of the member used to set their color - * @type {?Role} - * @readonly - */ - get colorRole() { - const coloredRoles = this.roles.filter(role => role.color); - if (!coloredRoles.size) return null; - return coloredRoles.reduce((prev, role) => !prev || role.comparePositionTo(prev) > 0 ? role : prev); - } - - /** - * The displayed color of the member in base 10 - * @type {number} - * @readonly - */ - get displayColor() { - const role = this.colorRole; - return (role && role.color) || 0; - } - - /** - * The displayed color of the member in hexadecimal - * @type {string} - * @readonly - */ - get displayHexColor() { - const role = this.colorRole; - return (role && role.hexColor) || '#000000'; - } - - /** - * The role of the member used to hoist them in a separate category in the users list - * @type {?Role} - * @readonly - */ - get hoistRole() { - const hoistedRoles = this.roles.filter(role => role.hoist); - if (!hoistedRoles.size) return null; - return hoistedRoles.reduce((prev, role) => !prev || role.comparePositionTo(prev) > 0 ? role : prev); - } - - /** - * Whether this member is muted in any way - * @type {boolean} - * @readonly - */ - get mute() { - return this.selfMute || this.serverMute; - } - - /** - * Whether this member is deafened in any way - * @type {boolean} - * @readonly - */ - get deaf() { - return this.selfDeaf || this.serverDeaf; - } - - /** - * The voice channel this member is in, if any - * @type {?VoiceChannel} - * @readonly - */ - get voiceChannel() { - return this.guild.channels.get(this.voiceChannelID); - } - - /** - * The ID of this user - * @type {Snowflake} - * @readonly - */ - get id() { - return this.user.id; - } - - /** - * The nickname of the member, or their username if they don't have one - * @type {string} - * @readonly - */ - get displayName() { - return this.nickname || this.user.username; - } - - /** - * The overall set of permissions for the guild member, taking only roles into account - * @type {Permissions} - * @readonly - */ - get permissions() { - if (this.user.id === this.guild.ownerID) return new Permissions(Permissions.ALL); - - let permissions = 0; - const roles = this.roles; - for (const role of roles.values()) permissions |= role.permissions; - - return new Permissions(permissions); - } - - /** - * Whether the member is kickable by the client user - * @type {boolean} - * @readonly - */ - get kickable() { - if (this.user.id === this.guild.ownerID) return false; - if (this.user.id === this.client.user.id) return false; - const clientMember = this.guild.member(this.client.user); - if (!clientMember.permissions.has(Permissions.FLAGS.KICK_MEMBERS)) return false; - return clientMember.highestRole.comparePositionTo(this.highestRole) > 0; - } - - /** - * Whether the member is bannable by the client user - * @type {boolean} - * @readonly - */ - get bannable() { - if (this.user.id === this.guild.ownerID) return false; - if (this.user.id === this.client.user.id) return false; - const clientMember = this.guild.member(this.client.user); - if (!clientMember.permissions.has(Permissions.FLAGS.BAN_MEMBERS)) return false; - return clientMember.highestRole.comparePositionTo(this.highestRole) > 0; - } - - /** - * Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel, - * taking into account roles and permission overwrites. - * @param {ChannelResolvable} channel The guild channel to use as context - * @returns {?Permissions} - */ - permissionsIn(channel) { - channel = this.client.resolver.resolveChannel(channel); - if (!channel || !channel.guild) throw new Error('Could not resolve channel to a guild channel.'); - return channel.permissionsFor(this); - } - - /** - * Checks if any of the member's roles have a permission. - * @param {PermissionResolvable|PermissionResolvable[]} permission Permission(s) to check for - * @param {boolean} [explicit=false] Whether to require the role to explicitly have the exact permission - * **(deprecated)** - * @param {boolean} [checkAdmin] Whether to allow the administrator permission to override - * (takes priority over `explicit`) - * @param {boolean} [checkOwner] Whether to allow being the guild's owner to override - * (takes priority over `explicit`) - * @returns {boolean} - */ - hasPermission(permission, explicit = false, checkAdmin, checkOwner) { - if (typeof checkAdmin === 'undefined') checkAdmin = !explicit; - if (typeof checkOwner === 'undefined') checkOwner = !explicit; - if (checkOwner && this.user.id === this.guild.ownerID) return true; - return this.roles.some(r => r.hasPermission(permission, undefined, checkAdmin)); - } - - /** - * Checks whether the roles of the member allows them to perform specific actions, and lists any missing permissions. - * @param {PermissionResolvable[]} permissions The permissions to check for - * @param {boolean} [explicit=false] Whether to require the member to explicitly have the exact permissions - * @returns {PermissionResolvable[]} - */ - missingPermissions(permissions, explicit = false) { - return permissions.missing(permissions, explicit); - } - - /** - * The data for editing a guild member. - * @typedef {Object} GuildMemberEditData - * @property {string} [nick] The nickname to set for the member - * @property {Collection|Role[]|Snowflake[]} [roles] The roles or role IDs to apply - * @property {boolean} [mute] Whether or not the member should be muted - * @property {boolean} [deaf] Whether or not the member should be deafened - * @property {ChannelResolvable} [channel] Channel to move member to (if they are connected to voice) - */ - - /** - * Edit a guild member. - * @param {GuildMemberEditData} data The data to edit the member with - * @returns {Promise} - */ - edit(data) { - return this.client.rest.methods.updateGuildMember(this, data); - } - - /** - * Mute/unmute a user. - * @param {boolean} mute Whether or not the member should be muted - * @returns {Promise} - */ - setMute(mute) { - return this.edit({ mute }); - } - - /** - * Deafen/undeafen a user. - * @param {boolean} deaf Whether or not the member should be deafened - * @returns {Promise} - */ - setDeaf(deaf) { - return this.edit({ deaf }); - } - - /** - * Moves the guild member to the given channel. - * @param {ChannelResolvable} channel The channel to move the member to - * @returns {Promise} - */ - setVoiceChannel(channel) { - return this.edit({ channel }); - } - - /** - * Sets the roles applied to the member. - * @param {Collection|Role[]|Snowflake[]} roles The roles or role IDs to apply - * @returns {Promise} - */ - setRoles(roles) { - return this.edit({ roles }); - } - - /** - * Adds a single role to the member. - * @param {Role|Snowflake} role The role or ID of the role to add - * @returns {Promise} - */ - addRole(role) { - if (!(role instanceof Role)) role = this.guild.roles.get(role); - if (!role) return Promise.reject(new TypeError('Supplied parameter was neither a Role nor a Snowflake.')); - return this.client.rest.methods.addMemberRole(this, role); - } - - /** - * Adds multiple roles to the member. - * @param {Collection|Role[]|Snowflake[]} roles The roles or role IDs to add - * @returns {Promise} - */ - addRoles(roles) { - let allRoles; - if (roles instanceof Collection) { - allRoles = this._roles.slice(); - for (const role of roles.values()) allRoles.push(role.id); - } else { - allRoles = this._roles.concat(roles); - } - return this.edit({ roles: allRoles }); - } - - /** - * Removes a single role from the member. - * @param {Role|Snowflake} role The role or ID of the role to remove - * @returns {Promise} - */ - removeRole(role) { - if (!(role instanceof Role)) role = this.guild.roles.get(role); - if (!role) return Promise.reject(new TypeError('Supplied parameter was neither a Role nor a Snowflake.')); - return this.client.rest.methods.removeMemberRole(this, role); - } - - /** - * Removes multiple roles from the member. - * @param {Collection|Role[]|Snowflake[]} roles The roles or role IDs to remove - * @returns {Promise} - */ - removeRoles(roles) { - const allRoles = this._roles.slice(); - if (roles instanceof Collection) { - for (const role of roles.values()) { - const index = allRoles.indexOf(role.id); - if (index >= 0) allRoles.splice(index, 1); - } - } else { - for (const role of roles) { - const index = allRoles.indexOf(role instanceof Role ? role.id : role); - if (index >= 0) allRoles.splice(index, 1); - } - } - return this.edit({ roles: allRoles }); - } - - /** - * Set the nickname for the guild member. - * @param {string} nick The nickname for the guild member - * @returns {Promise} - */ - setNickname(nick) { - return this.edit({ nick }); - } - - /** - * Creates a DM channel between the client and the member. - * @returns {Promise} - */ - createDM() { - return this.user.createDM(); - } - - /** - * Deletes any DMs with this guild member. - * @returns {Promise} - */ - deleteDM() { - return this.user.deleteDM(); - } - - /** - * Kick this member from the guild. - * @param {string} [reason] Reason for kicking user - * @returns {Promise} - */ - kick(reason) { - return this.client.rest.methods.kickGuildMember(this.guild, this, reason); - } - - /** - * Ban this guild member - * @param {Object|number|string} [options] Ban options. If a number, the number of days to delete messages for, if a - * string, the ban reason. Supplying an object allows you to do both. - * @param {number} [options.days=0] Number of days of messages to delete - * @param {string} [options.reason] Reason for banning - * @returns {Promise} - * @example - * // ban a guild member - * guildMember.ban(7); - */ - ban(options) { - return this.guild.ban(this, options); - } - - /** - * When concatenated with a string, this automatically concatenates the user's mention instead of the Member object. - * @returns {string} - * @example - * // Logs: Hello from <@123456789>! - * console.log(`Hello from ${member}!`); - */ - toString() { - return `<@${this.nickname ? '!' : ''}${this.user.id}>`; - } - - // These are here only for documentation purposes - they are implemented by TextBasedChannel - /* eslint-disable no-empty-function */ - send() {} -} - -TextBasedChannel.applyToClass(GuildMember); - -module.exports = GuildMember; - - -/***/ }), -/* 19 */ -/***/ (function(module, exports, __webpack_require__) { - const Mentions = __webpack_require__(49); const Attachment = __webpack_require__(46); const Embed = __webpack_require__(48); @@ -5621,7 +3317,7 @@ const ReactionCollector = __webpack_require__(54); const Util = __webpack_require__(4); const Collection = __webpack_require__(3); const Constants = __webpack_require__(0); -const Permissions = __webpack_require__(8); +const Permissions = __webpack_require__(10); let GuildMember; /** @@ -5963,7 +3659,7 @@ class Message { */ isMemberMentioned(member) { // Lazy-loading is used here to get around a circular dependency that breaks things - if (!GuildMember) GuildMember = __webpack_require__(18); + if (!GuildMember) GuildMember = __webpack_require__(19); if (this.mentions.everyone) return true; if (this.mentions.users.has(member.id)) return true; if (member instanceof GuildMember && member.roles.some(r => this.mentions.roles.has(r.id))) return true; @@ -5995,7 +3691,27 @@ class Message { } else if (!options) { options = {}; } - return this.client.rest.methods.updateMessage(this, content, options); + + if (typeof content !== 'undefined') content = this.client.resolver.resolveString(content); + + const { embed, code, reply } = options; + + // Wrap everything in a code block + if (typeof code !== 'undefined' && (typeof code !== 'boolean' || code === true)) { + content = Util.escapeMarkdown(this.client.resolver.resolveString(content), true); + content = `\`\`\`${typeof code !== 'boolean' ? code || '' : ''}\n${content}\n\`\`\``; + } + + // Add the reply prefix + if (reply && this.channel.type !== 'dm') { + const id = this.client.resolver.resolveUserID(reply); + const mention = `<@${reply instanceof GuildMember && reply.nickname ? '!' : ''}${id}>`; + content = `${mention}${content ? `, ${content}` : ''}`; + } + + return this.client.api.channels(this.channel.id).messages(this.id) + .patch({ data: { content, embed } }) + .then(data => this.client.actions.MessageUpdate.handle(data).updated); } /** @@ -6003,7 +3719,8 @@ class Message { * @returns {Promise} */ pin() { - return this.client.rest.methods.pinMessage(this); + return this.client.api.channels(this.channel.id).pins(this.id).put() + .then(() => this); } /** @@ -6011,7 +3728,8 @@ class Message { * @returns {Promise} */ unpin() { - return this.client.rest.methods.unpinMessage(this); + return this.client.api.channels(this.channel.id).pins(this.id).delete() + .then(() => this); } /** @@ -6023,7 +3741,9 @@ class Message { emoji = this.client.resolver.resolveEmojiIdentifier(emoji); if (!emoji) throw new TypeError('Emoji must be a string or Emoji/ReactionEmoji'); - return this.client.rest.methods.addMessageReaction(this, emoji); + return this.client.api.channels(this.channel.id).messages(this.id).reactions(emoji)['@me'] + .put() + .then(() => this._addReaction(Util.parseEmoji(emoji), this.client.user)); } /** @@ -6031,12 +3751,15 @@ class Message { * @returns {Promise} */ clearReactions() { - return this.client.rest.methods.removeMessageReactions(this); + return this.client.api.channels(this.channel.id).messages(this.id).reactions.delete() + .then(() => this); } /** * Deletes the message. - * @param {number} [timeout=0] How long to wait to delete the message in milliseconds + * @param {Object} [options] Options + * @param {number} [options.timeout=0] How long to wait to delete the message in milliseconds + * @param {string} [options.reason] Reason for deleting this message, if it does not belong to the client user * @returns {Promise} * @example * // Delete a message @@ -6044,13 +3767,19 @@ class Message { * .then(msg => console.log(`Deleted message from ${msg.author}`)) * .catch(console.error); */ - delete(timeout = 0) { + delete({ timeout = 0, reason } = {}) { if (timeout <= 0) { - return this.client.rest.methods.deleteMessage(this); + return this.client.api.channels(this.channel.id).messages(this.id) + .delete({ reason }) + .then(() => + this.client.actions.MessageDelete.handle({ + id: this.id, + channel_id: this.channel.id, + }).message); } else { return new Promise(resolve => { this.client.setTimeout(() => { - resolve(this.delete()); + resolve(this.delete({ reason })); }, timeout); }); } @@ -6083,7 +3812,12 @@ class Message { * @returns {Promise} */ acknowledge() { - return this.client.rest.methods.ackMessage(this); + return this.client.api.channels(this.channel.id).messages(this.id).ack + .post({ data: { token: this.client.rest._ackToken } }) + .then(res => { + if (res.token) this.client.rest._ackToken = res.token; + return this; + }); } /** @@ -6175,10 +3909,634 @@ module.exports = Message; /***/ }), -/* 20 */ +/* 9 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 10 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. +const Constants = __webpack_require__(0); + +/** + * Data structure that makes it easy to interact with a permission bitfield. All {@link GuildMember}s have a set of + * permissions in their guild, and each channel in the guild may also have {@link PermissionOverwrites} for the member + * that override their default permissions. + */ +class Permissions { + /** + * @param {number|PermissionResolvable[]} permissions Permissions or bitfield to read from + */ + constructor(permissions) { + /** + * Bitfield of the packed permissions + * @type {number} + */ + this.bitfield = typeof permissions === 'number' ? permissions : this.constructor.resolve(permissions); + } + + /** + * Checks whether the bitfield has a permission, or multiple permissions. + * @param {PermissionResolvable|PermissionResolvable[]} permission Permission(s) to check for + * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override + * @returns {boolean} + */ + has(permission, checkAdmin = true) { + if (permission instanceof Array) return permission.every(p => this.has(p, checkAdmin)); + permission = this.constructor.resolve(permission); + if (checkAdmin && (this.bitfield & this.constructor.FLAGS.ADMINISTRATOR) > 0) return true; + return (this.bitfield & permission) === permission; + } + + /** + * Gets all given permissions that are missing from the bitfield. + * @param {PermissionResolvable[]} permissions Permissions to check for + * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override + * @returns {PermissionResolvable[]} + */ + missing(permissions, checkAdmin = true) { + return permissions.filter(p => !this.has(p, checkAdmin)); + } + + /** + * Adds permissions to this one, creating a new instance to represent the new bitfield. + * @param {...PermissionResolvable} permissions Permissions to add + * @returns {Permissions} + */ + add(...permissions) { + let total = 0; + for (let p = 0; p < permissions.length; p++) { + const perm = this.constructor.resolve(permissions[p]); + if ((this.bitfield & perm) !== perm) total |= perm; + } + return new this.constructor(this.member, this.bitfield | total); + } + + /** + * Removes permissions to this one, creating a new instance to represent the new bitfield. + * @param {...PermissionResolvable} permissions Permissions to remove + * @returns {Permissions} + */ + remove(...permissions) { + let total = 0; + for (let p = 0; p < permissions.length; p++) { + const perm = this.constructor.resolve(permissions[p]); + if ((this.bitfield & perm) === perm) total |= perm; + } + return new this.constructor(this.member, this.bitfield & ~total); + } + + /** + * Gets an object mapping permission name (like `READ_MESSAGES`) to a {@link boolean} indicating whether the + * permission is available. + * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override + * @returns {Object} + */ + serialize(checkAdmin = true) { + const serialized = {}; + for (const perm in this.constructor.FLAGS) serialized[perm] = this.has(perm, checkAdmin); + return serialized; + } + + /** + * Data that can be resolved to give a permission number. This can be: + * - A string (see {@link Permissions.FLAGS}) + * - A permission number + * @typedef {string|number} PermissionResolvable + */ + + /** + * Resolves permissions to their numeric form. + * @param {PermissionResolvable|PermissionResolvable[]} permission - Permission(s) to resolve + * @returns {number} + */ + static resolve(permission) { + if (permission instanceof Array) return permission.map(p => this.resolve(p)).reduce((prev, p) => prev | p, 0); + if (typeof permission === 'string') permission = this.FLAGS[permission]; + if (typeof permission !== 'number' || permission < 1) throw new RangeError(Constants.Errors.NOT_A_PERMISSION); + return permission; + } +} + +/** + * Numeric permission flags. All available properties: + * - `ADMINISTRATOR` (implicitly has *all* permissions, and bypasses all channel overwrites) + * - `CREATE_INSTANT_INVITE` (create invitations to the guild) + * - `KICK_MEMBERS` + * - `BAN_MEMBERS` + * - `MANAGE_CHANNELS` (edit and reorder channels) + * - `MANAGE_GUILD` (edit the guild information, region, etc.) + * - `ADD_REACTIONS` (add new reactions to messages) + * - `VIEW_AUDIT_LOG` + * - `READ_MESSAGES` + * - `SEND_MESSAGES` + * - `SEND_TTS_MESSAGES` + * - `MANAGE_MESSAGES` (delete messages and reactions) + * - `EMBED_LINKS` (links posted will have a preview embedded) + * - `ATTACH_FILES` + * - `READ_MESSAGE_HISTORY` (view messages that were posted prior to opening Discord) + * - `MENTION_EVERYONE` + * - `USE_EXTERNAL_EMOJIS` (use emojis from different guilds) + * - `CONNECT` (connect to a voice channel) + * - `SPEAK` (speak in a voice channel) + * - `MUTE_MEMBERS` (mute members across all voice channels) + * - `DEAFEN_MEMBERS` (deafen members across all voice channels) + * - `MOVE_MEMBERS` (move members between voice channels) + * - `USE_VAD` (use voice activity detection) + * - `CHANGE_NICKNAME` + * - `MANAGE_NICKNAMES` (change other members' nicknames) + * - `MANAGE_ROLES` + * - `MANAGE_WEBHOOKS` + * - `MANAGE_EMOJIS` + * @type {Object} + * @see {@link https://discordapp.com/developers/docs/topics/permissions} + */ +Permissions.FLAGS = { + CREATE_INSTANT_INVITE: 1 << 0, + KICK_MEMBERS: 1 << 1, + BAN_MEMBERS: 1 << 2, + ADMINISTRATOR: 1 << 3, + MANAGE_CHANNELS: 1 << 4, + MANAGE_GUILD: 1 << 5, + ADD_REACTIONS: 1 << 6, + VIEW_AUDIT_LOG: 1 << 7, + + READ_MESSAGES: 1 << 10, + SEND_MESSAGES: 1 << 11, + SEND_TTS_MESSAGES: 1 << 12, + MANAGE_MESSAGES: 1 << 13, + EMBED_LINKS: 1 << 14, + ATTACH_FILES: 1 << 15, + READ_MESSAGE_HISTORY: 1 << 16, + MENTION_EVERYONE: 1 << 17, + 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_WEBHOOKS: 1 << 29, + MANAGE_EMOJIS: 1 << 30, +}; + +/** + * Bitfield representing every permission combined + * @type {number} + */ +Permissions.ALL = Object.keys(Permissions.FLAGS).reduce((all, p) => all | Permissions.FLAGS[p], 0); + +/** + * Bitfield representing the default permissions for users + * @type {number} + */ +Permissions.DEFAULT = 104324097; + +module.exports = Permissions; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +const TextBasedChannel = __webpack_require__(24); +const Constants = __webpack_require__(0); +const Presence = __webpack_require__(13).Presence; +const UserProfile = __webpack_require__(185); +const Snowflake = __webpack_require__(6); + +/** + * Represents a user on Discord. + * @implements {TextBasedChannel} + */ +class User { + constructor(client, data) { + /** + * The client that created the instance of the the user + * @name User#client + * @type {} + * @readonly + */ + Object.defineProperty(this, 'client', { value: client }); + + if (data) this.setup(data); + } + + setup(data) { + /** + * The ID of the user + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The username of the user + * @type {string} + */ + this.username = data.username; + + /** + * A discriminator based on username for the user + * @type {string} + */ + this.discriminator = data.discriminator; + + /** + * The ID of the user's avatar + * @type {string} + */ + this.avatar = data.avatar; + + /** + * Whether or not the user is a bot + * @type {boolean} + */ + this.bot = Boolean(data.bot); + + /** + * The ID of the last message sent by the user, if one was sent + * @type {?Snowflake} + */ + this.lastMessageID = null; + + /** + * The Message object of the last message sent by the user, if one was sent + * @type {?Message} + */ + this.lastMessage = null; + } + + patch(data) { + for (const prop of ['id', 'username', 'discriminator', 'avatar', 'bot']) { + if (typeof data[prop] !== 'undefined') this[prop] = data[prop]; + } + if (data.token) this.client.token = data.token; + } + + /** + * The timestamp the user was created at + * @type {number} + * @readonly + */ + get createdTimestamp() { + return Snowflake.deconstruct(this.id).timestamp; + } + + /** + * The time the user was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * The presence of this user + * @type {Presence} + * @readonly + */ + get presence() { + if (this.client.presences.has(this.id)) return this.client.presences.get(this.id); + for (const guild of this.client.guilds.values()) { + if (guild.presences.has(this.id)) return guild.presences.get(this.id); + } + return new Presence(); + } + + /** + * A link to the user's avatar + * @param {string} [format='webp'] One of `webp`, `png`, `jpg`, `gif`. If no format is provided, it will be `gif` + * for animated avatars or otherwise `webp` + * @param {number} [size=128] One of `128`, '256', `512`, `1024`, `2048` + * @returns {?string} avatarURL + */ + avatarURL(format, size) { + if (!this.avatar) return null; + if (typeof format === 'number') { + size = format; + format = 'default'; + } + return Constants.Endpoints.CDN(this.client.options.http.cdn).Avatar(this.id, this.avatar, format, size); + } + + /** + * A link to the user's default avatar + * @type {string} + * @readonly + */ + get defaultAvatarURL() { + return Constants.Endpoints.CDN(this.client.options.http.host).DefaultAvatar(this.discriminator % 5); + } + + /** + * A link to the user's avatar if they have one. Otherwise a link to their default avatar will be returned + * @type {string} + * @readonly + */ + get displayAvatarURL() { + return this.avatarURL() || this.defaultAvatarURL; + } + + /** + * The Discord "tag" for this user + * @type {string} + * @readonly + */ + get tag() { + return `${this.username}#${this.discriminator}`; + } + + /** + * The note that is set for the user + * This is only available when using a user account. + * @type {?string} + * @readonly + */ + get note() { + return this.client.user.notes.get(this.id) || null; + } + + /** + * Check whether the user is typing in a channel. + * @param {ChannelResolvable} channel The channel to check in + * @returns {boolean} + */ + typingIn(channel) { + channel = this.client.resolver.resolveChannel(channel); + return channel._typing.has(this.id); + } + + /** + * Get the time that the user started typing. + * @param {ChannelResolvable} channel The channel to get the time in + * @returns {?Date} + */ + typingSinceIn(channel) { + channel = this.client.resolver.resolveChannel(channel); + return channel._typing.has(this.id) ? new Date(channel._typing.get(this.id).since) : null; + } + + /** + * Get the amount of time the user has been typing in a channel for (in milliseconds), or -1 if they're not typing. + * @param {ChannelResolvable} channel The channel to get the time in + * @returns {number} + */ + typingDurationIn(channel) { + channel = this.client.resolver.resolveChannel(channel); + return channel._typing.has(this.id) ? channel._typing.get(this.id).elapsedTime : -1; + } + + /** + * The DM between the client's user and this user + * @type {?DMChannel} + * @readonly + */ + get dmChannel() { + return this.client.channels.filter(c => c.type === 'dm').find(c => c.recipient.id === this.id); + } + + /** + * Creates a DM channel between the client and the user. + * @returns {Promise} + */ + createDM() { + if (this.dmChannel) return Promise.resolve(this.dmChannel); + return this.client.api.users(this.client.user.id).channels.post({ data: { + recipient_id: this.id, + } }) + .then(data => this.client.actions.ChannelCreate.handle(data).channel); + } + + /** + * Deletes a DM channel (if one exists) between the client and the user. Resolves with the channel if successful. + * @returns {Promise} + */ + deleteDM() { + if (!this.dmChannel) return Promise.reject(new Error('No DM Channel exists!')); + return this.client.api.channels(this.dmChannel.id).delete().then(data => + this.client.actions.ChannelDelete.handle(data).channel + ); + } + + /** + * Get the profile of the user. + * This is only available when using a user account. + * @returns {Promise} + */ + fetchProfile() { + return this.client.api.users(this.id).profile.get().then(data => new UserProfile(data)); + } + + /** + * Sets a note for the user. + * This is only available when using a user account. + * @param {string} note The note to set for the user + * @returns {Promise} + */ + setNote(note) { + return this.client.api.users('@me').notes(this.id).put({ data: { note } }) + .then(() => this); + } + + /** + * Checks if the user is equal to another. It compares ID, username, discriminator, avatar, and bot flags. + * It is recommended to compare equality by using `user.id === user2.id` unless you want to compare all properties. + * @param {User} user User to compare with + * @returns {boolean} + */ + equals(user) { + let equal = user && + this.id === user.id && + this.username === user.username && + this.discriminator === user.discriminator && + this.avatar === user.avatar && + this.bot === Boolean(user.bot); + + return equal; + } + + /** + * When concatenated with a string, this automatically concatenates the user's mention instead of the User object. + * @returns {string} + * @example + * // logs: Hello from <@123456789>! + * console.log(`Hello from ${user}!`); + */ + toString() { + return `<@${this.id}>`; + } + + // These are here only for documentation purposes - they are implemented by TextBasedChannel + /* eslint-disable no-empty-function */ + send() {} +} + +TextBasedChannel.applyToClass(User); + +module.exports = User; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports) { + +/** + * Represents a user's presence. + */ +class Presence { + constructor(data = {}) { + /** + * The status of the presence: + * + * * **`online`** - user is online + * * **`offline`** - user is offline or invisible + * * **`idle`** - user is AFK + * * **`dnd`** - user is in Do not Disturb + * @type {string} + */ + this.status = data.status || 'offline'; + + /** + * The game that the user is playing + * @type {?Game} + */ + this.game = data.game ? new Game(data.game) : null; + } + + update(data) { + this.status = data.status || this.status; + this.game = data.game ? new Game(data.game) : null; + } + + /** + * Whether this presence is equal to another + * @param {Presence} presence The presence to compare with + * @returns {boolean} + */ + equals(presence) { + return this === presence || ( + presence && + this.status === presence.status && + this.game ? this.game.equals(presence.game) : !presence.game + ); + } +} + +/** + * Represents a game that is part of a user's presence. + */ +class Game { + constructor(data) { + /** + * The name of the game being played + * @type {string} + */ + this.name = data.name; + + /** + * The type of the game status + * @type {number} + */ + this.type = data.type; + + /** + * If the game is being streamed, a link to the stream + * @type {?string} + */ + this.url = data.url || null; + } + + /** + * Whether or not the game is being streamed + * @type {boolean} + * @readonly + */ + get streaming() { + return this.type === 1; + } + + /** + * Whether this game is equal to another game + * @param {Game} game The game to compare with + * @returns {boolean} + */ + equals(game) { + return this === game || ( + game && + this.name === game.name && + this.type === game.type && + this.url === game.url + ); + } +} + +exports.Presence = Presence; +exports.Game = Game; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports) { + +// 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 @@ -6199,590 +4557,690 @@ module.exports = Message; // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -// NOTE: These type checking functions intentionally don't use `instanceof` -// because it is fragile and can be easily faked with `Object.create()`. +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; -function isArray(arg) { - if (Array.isArray) { - return Array.isArray(arg); +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } } - return objectToString(arg) === '[object Array]'; -} -exports.isArray = isArray; -function isBoolean(arg) { - return typeof arg === 'boolean'; -} -exports.isBoolean = isBoolean; + handler = this._events[type]; -function isNull(arg) { - return arg === null; -} -exports.isNull = isNull; + if (isUndefined(handler)) + return false; -function isNullOrUndefined(arg) { - return arg == null; -} -exports.isNullOrUndefined = isNullOrUndefined; + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } -function isNumber(arg) { - return typeof arg === 'number'; -} -exports.isNumber = isNumber; + return true; +}; -function isString(arg) { - return typeof arg === 'string'; -} -exports.isString = isString; +EventEmitter.prototype.addListener = function(type, listener) { + var m; -function isSymbol(arg) { - return typeof arg === 'symbol'; -} -exports.isSymbol = isSymbol; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); -function isUndefined(arg) { - return arg === void 0; -} -exports.isUndefined = isUndefined; + if (!this._events) + this._events = {}; -function isRegExp(re) { - return objectToString(re) === '[object RegExp]'; -} -exports.isRegExp = isRegExp; + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} -exports.isObject = isObject; + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; -function isDate(d) { - return objectToString(d) === '[object Date]'; -} -exports.isDate = isDate; + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } -function isError(e) { - return (objectToString(e) === '[object Error]' || e instanceof Error); -} -exports.isError = isError; + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; function isFunction(arg) { return typeof arg === 'function'; } -exports.isFunction = isFunction; -function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; -} -exports.isPrimitive = isPrimitive; - -exports.isBuffer = Buffer.isBuffer; - -function objectToString(o) { - return Object.prototype.toString.call(o); +function isNumber(arg) { + return typeof arg === 'number'; } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} -/***/ }), -/* 21 */ -/***/ (function(module, exports, __webpack_require__) { - -exports = module.exports = __webpack_require__(58); -exports.Stream = exports; -exports.Readable = exports; -exports.Writable = __webpack_require__(36); -exports.Duplex = __webpack_require__(13); -exports.Transform = __webpack_require__(59); -exports.PassThrough = __webpack_require__(84); +function isUndefined(arg) { + return arg === void 0; +} /***/ }), -/* 22 */ +/* 15 */ /***/ (function(module, exports, __webpack_require__) { -const path = __webpack_require__(27); -const Message = __webpack_require__(19); -const MessageCollector = __webpack_require__(47); -const Collection = __webpack_require__(3); +"use strict"; +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + + + +/**/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var processNextTick = __webpack_require__(35); +/**/ + +/**/ +var util = __webpack_require__(22); +util.inherits = __webpack_require__(11); +/**/ + +var Readable = __webpack_require__(58); +var Writable = __webpack_require__(37); + +util.inherits(Duplex, Readable); + +var keys = objectKeys(Writable.prototype); +for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + processNextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +const Snowflake = __webpack_require__(6); /** - * Interface for classes that have text-channel-like features. - * @interface + * Represents any channel on Discord. */ -class TextBasedChannel { - constructor() { +class Channel { + constructor(client, data) { /** - * A collection containing the messages sent to this channel - * @type {Collection} + * The client that instantiated the Channel + * @name Channel#client + * @type {Client} + * @readonly */ - this.messages = new Collection(); + Object.defineProperty(this, 'client', { value: client }); /** - * The ID of the last message in the channel, if one was sent - * @type {?Snowflake} + * The type of the channel, either: + * * `dm` - a DM channel + * * `group` - a Group DM channel + * * `text` - a guild text channel + * * `voice` - a guild voice channel + * @type {string} */ - this.lastMessageID = null; + this.type = null; + if (data) this.setup(data); + } + + setup(data) { /** - * The Message object of the last message in the channel, if one was sent - * @type {?Message} + * The unique ID of the channel + * @type {Snowflake} */ - this.lastMessage = null; + this.id = data.id; } /** - * Options provided when sending or editing a message. - * @typedef {Object} MessageOptions - * @property {boolean} [tts=false] Whether or not the message should be spoken aloud - * @property {string} [nonce=''] The nonce for the message - * @property {RichEmbed|Object} [embed] An embed for the message - * (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details) - * @property {boolean} [disableEveryone=this.client.options.disableEveryone] Whether or not @everyone and @here - * should be replaced with plain-text - * @property {FileOptions[]|string[]} [files] Files to send with the message - * @property {string|boolean} [code] Language for optional codeblock formatting to apply - * @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if - * it exceeds the character limit. If an object is provided, these are the options for splitting the message - * @property {UserResolvable} [reply] User to reply to (prefixes the message with a mention, except in DMs) - */ - - /** - * @typedef {Object} FileOptions - * @property {BufferResolvable} attachment File to attach - * @property {string} [name='file.jpg'] Filename of the attachment - */ - - /** - * Options for splitting a message. - * @typedef {Object} SplitOptions - * @property {number} [maxLength=1950] Maximum character length per message piece - * @property {string} [char='\n'] Character to split the message with - * @property {string} [prepend=''] Text to prepend to every piece except the first - * @property {string} [append=''] Text to append to every piece except the last - */ - - /** - * Send a message to this channel. - * @param {StringResolvable} [content] Text for the message - * @param {MessageOptions} [options={}] Options for the message - * @returns {Promise} - * @example - * // Send a message - * channel.send('hello!') - * .then(message => console.log(`Sent message: ${message.content}`)) - * .catch(console.error); - */ - send(content, options) { - if (!options && typeof content === 'object' && !(content instanceof Array)) { - options = content; - content = ''; - } else if (!options) { - options = {}; - } - - if (options.embed && options.embed.file) options.file = options.embed.file; - - if (options.file) { - if (options.files) options.files.push(options.file); - else options.files = [options.file]; - } - - if (options.files) { - for (let i = 0; i < options.files.length; i++) { - let file = options.files[i]; - if (typeof file === 'string') file = { attachment: file }; - if (!file.name) { - if (typeof file.attachment === 'string') { - file.name = path.basename(file.attachment); - } else if (file.attachment && file.attachment.path) { - file.name = path.basename(file.attachment.path); - } else { - file.name = 'file.jpg'; - } - } - options.files[i] = file; - } - - return Promise.all(options.files.map(file => - this.client.resolver.resolveBuffer(file.attachment).then(buffer => { - file.file = buffer; - return file; - }) - )).then(files => this.client.rest.methods.sendMessage(this, content, options, files)); - } - - return this.client.rest.methods.sendMessage(this, content, options); - } - - /** - * Gets a single message from this channel, regardless of it being cached or not. Since the single message fetching - * endpoint is reserved for bot accounts, this abstracts the `fetchMessages` method to obtain the single message when - * using a user account. - * @param {Snowflake} messageID ID of the message to get - * @returns {Promise} - * @example - * // Get message - * channel.fetchMessage('99539446449315840') - * .then(message => console.log(message.content)) - * .catch(console.error); - */ - fetchMessage(messageID) { - if (!this.client.user.bot) { - return this.fetchMessages({ limit: 1, around: messageID }).then(messages => { - const msg = messages.get(messageID); - if (!msg) throw new Error('Message not found.'); - return msg; - }); - } - return this.client.rest.methods.getChannelMessage(this, messageID).then(data => { - const msg = data instanceof Message ? data : new Message(this, data, this.client); - this._cacheMessage(msg); - return msg; - }); - } - - /** - * The parameters to pass in when requesting previous messages from a channel. `around`, `before` and - * `after` are mutually exclusive. All the parameters are optional. - * @typedef {Object} ChannelLogsQueryOptions - * @property {number} [limit=50] Number of messages to acquire - * @property {Snowflake} [before] ID of a message to get the messages that were posted before it - * @property {Snowflake} [after] ID of a message to get the messages that were posted after it - * @property {Snowflake} [around] ID of a message to get the messages that were posted around it - */ - - /** - * Gets the past messages sent in this channel. Resolves with a collection mapping message ID's to Message objects. - * @param {ChannelLogsQueryOptions} [options={}] Query parameters to pass in - * @returns {Promise>} - * @example - * // Get messages - * channel.fetchMessages({limit: 10}) - * .then(messages => console.log(`Received ${messages.size} messages`)) - * .catch(console.error); - */ - fetchMessages(options = {}) { - return this.client.rest.methods.getChannelMessages(this, options).then(data => { - const messages = new Collection(); - for (const message of data) { - const msg = new Message(this, message, this.client); - messages.set(message.id, msg); - this._cacheMessage(msg); - } - return messages; - }); - } - - /** - * Fetches the pinned messages of this channel and returns a collection of them. - * @returns {Promise>} - */ - fetchPinnedMessages() { - return this.client.rest.methods.getChannelPinnedMessages(this).then(data => { - const messages = new Collection(); - for (const message of data) { - const msg = new Message(this, message, this.client); - messages.set(message.id, msg); - this._cacheMessage(msg); - } - return messages; - }); - } - - /** - * @typedef {Object} MessageSearchOptions - * @property {string} [content] Message content - * @property {Snowflake} [maxID] Maximum ID for the filter - * @property {Snowflake} [minID] Minimum ID for the filter - * @property {string} [has] One of `link`, `embed`, `file`, `video`, `image`, or `sound`, - * or add `-` to negate (e.g. `-file`) - * @property {ChannelResolvable} [channel] Channel to limit search to (only for guild search endpoint) - * @property {UserResolvable} [author] Author to limit search - * @property {string} [authorType] One of `user`, `bot`, `webhook`, or add `-` to negate (e.g. `-webhook`) - * @property {string} [sortBy='recent'] `recent` or `relevant` - * @property {string} [sortOrder='desc'] `asc` or `desc` - * @property {number} [contextSize=2] How many messages to get around the matched message (0 to 2) - * @property {number} [limit=25] Maximum number of results to get (1 to 25) - * @property {number} [offset=0] Offset the "pages" of results (since you can only see 25 at a time) - * @property {UserResolvable} [mentions] Mentioned user filter - * @property {boolean} [mentionsEveryone] If everyone is mentioned - * @property {string} [linkHostname] Filter links by hostname - * @property {string} [embedProvider] The name of an embed provider - * @property {string} [embedType] one of `image`, `video`, `url`, `rich` - * @property {string} [attachmentFilename] The name of an attachment - * @property {string} [attachmentExtension] The extension of an attachment - * @property {Date} [before] Date to find messages before - * @property {Date} [after] Date to find messages before - * @property {Date} [during] Date to find messages during (range of date to date + 24 hours) - */ - - /** - * Performs a search within the channel. - * This is only available when using a user account. - * @param {MessageSearchOptions} [options={}] Options to pass to the search - * @returns {Promise>} - * An array containing arrays of messages. Each inner array is a search context cluster - * The message which has triggered the result will have the `hit` property set to `true` - * @example - * channel.search({ - * content: 'discord.js', - * before: '2016-11-17' - * }).then(res => { - * const hit = res.messages[0].find(m => m.hit).content; - * console.log(`I found: **${hit}**, total results: ${res.totalResults}`); - * }).catch(console.error); - */ - search(options = {}) { - return this.client.rest.methods.search(this, options); - } - - /** - * Starts a typing indicator in the channel. - * @param {number} [count] The number of times startTyping should be considered to have been called - * @example - * // Start typing in a channel - * channel.startTyping(); - */ - startTyping(count) { - if (typeof count !== 'undefined' && count < 1) throw new RangeError('Count must be at least 1.'); - if (!this.client.user._typing.has(this.id)) { - this.client.user._typing.set(this.id, { - count: count || 1, - interval: this.client.setInterval(() => { - this.client.rest.methods.sendTyping(this.id); - }, 9000), - }); - this.client.rest.methods.sendTyping(this.id); - } else { - const entry = this.client.user._typing.get(this.id); - entry.count = count || entry.count + 1; - } - } - - /** - * Stops the typing indicator in the channel. - * The indicator will only stop if this is called as many times as startTyping(). - * It can take a few seconds for the client user to stop typing. - * @param {boolean} [force=false] Whether or not to reset the call count and force the indicator to stop - * @example - * // Stop typing in a channel - * channel.stopTyping(); - * @example - * // Force typing to fully stop in a channel - * channel.stopTyping(true); - */ - stopTyping(force = false) { - if (this.client.user._typing.has(this.id)) { - const entry = this.client.user._typing.get(this.id); - entry.count--; - if (entry.count <= 0 || force) { - this.client.clearInterval(entry.interval); - this.client.user._typing.delete(this.id); - } - } - } - - /** - * Whether or not the typing indicator is being shown in the channel - * @type {boolean} - * @readonly - */ - get typing() { - return this.client.user._typing.has(this.id); - } - - /** - * Number of times `startTyping` has been called + * The timestamp the channel was created at * @type {number} * @readonly */ - get typingCount() { - if (this.client.user._typing.has(this.id)) return this.client.user._typing.get(this.id).count; - return 0; + get createdTimestamp() { + return Snowflake.deconstruct(this.id).timestamp; } /** - * Creates a Message Collector. - * @param {CollectorFilter} filter The filter to create the collector with - * @param {MessageCollectorOptions} [options={}] The options to pass to the collector - * @returns {MessageCollector} + * The time the channel was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * Deletes this channel. + * @returns {Promise} * @example - * // Create a message collector - * const collector = channel.createCollector( - * m => m.content.includes('discord'), - * { time: 15000 } - * ); - * collector.on('message', m => console.log(`Collected ${m.content}`)); - * collector.on('end', collected => console.log(`Collected ${collected.size} items`)); + * // Delete the channel + * channel.delete() + * .then() // Success + * .catch(console.error); // Log error */ - createMessageCollector(filter, options = {}) { - return new MessageCollector(this, filter, options); - } - - /** - * An object containing the same properties as CollectorOptions, but a few more: - * @typedef {MessageCollectorOptions} AwaitMessagesOptions - * @property {string[]} [errors] Stop/end reasons that cause the promise to reject - */ - - /** - * Similar to createCollector but in promise form. Resolves with a collection of messages that pass the specified - * filter. - * @param {CollectorFilter} filter The filter function to use - * @param {AwaitMessagesOptions} [options={}] Optional options to pass to the internal collector - * @returns {Promise>} - * @example - * // Await !vote messages - * const filter = m => m.content.startsWith('!vote'); - * // Errors: ['time'] treats ending because of the time limit as an error - * channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] }) - * .then(collected => console.log(collected.size)) - * .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`)); - */ - awaitMessages(filter, options = {}) { - return new Promise((resolve, reject) => { - const collector = this.createMessageCollector(filter, options); - collector.once('end', (collection, reason) => { - if (options.errors && options.errors.includes(reason)) { - reject(collection); - } else { - resolve(collection); - } - }); - }); - } - - /** - * Bulk delete given messages that are newer than two weeks. - * This is only available when using a bot account. - * @param {Collection|Message[]|number} messages Messages or number of messages to delete - * @param {boolean} [filterOld=false] Filter messages to remove those which are older than two weeks automatically - * @returns {Promise>} Deleted messages - */ - bulkDelete(messages, filterOld = false) { - if (!isNaN(messages)) return this.fetchMessages({ limit: messages }).then(msgs => this.bulkDelete(msgs, filterOld)); - if (messages instanceof Array || messages instanceof Collection) { - const messageIDs = messages instanceof Collection ? messages.keyArray() : messages.map(m => m.id); - return this.client.rest.methods.bulkDeleteMessages(this, messageIDs, filterOld); - } - throw new TypeError('The messages must be an Array, Collection, or number.'); - } - - /** - * Marks all messages in this channel as read. - * This is only available when using a user account. - * @returns {Promise} - */ - acknowledge() { - if (!this.lastMessageID) return Promise.resolve(this); - return this.client.rest.methods.ackTextChannel(this); - } - - _cacheMessage(message) { - const maxSize = this.client.options.messageCacheMaxSize; - if (maxSize === 0) return null; - if (this.messages.size >= maxSize && maxSize > 0) this.messages.delete(this.messages.firstKey()); - this.messages.set(message.id, message); - return message; + delete() { + return this.client.api.channels(this.id).delete().then(() => this); } } -exports.applyToClass = (structure, full = false, ignore = []) => { - const props = ['send']; - if (full) { - props.push( - '_cacheMessage', - 'acknowledge', - 'fetchMessages', - 'fetchMessage', - 'search', - 'bulkDelete', - 'startTyping', - 'stopTyping', - 'typing', - 'typingCount', - 'fetchPinnedMessages', - 'createMessageCollector', - 'awaitMessages' - ); - } - for (const prop of props) { - if (ignore.includes(prop)) continue; - Object.defineProperty(structure.prototype, prop, Object.getOwnPropertyDescriptor(TextBasedChannel.prototype, prop)); - } -}; +module.exports = Channel; /***/ }), -/* 23 */ -/***/ (function(module, exports) { - -exports.endianness = function () { return 'LE' }; - -exports.hostname = function () { - if (typeof location !== 'undefined') { - return location.hostname - } - else return ''; -}; - -exports.loadavg = function () { return [] }; - -exports.uptime = function () { return 0 }; - -exports.freemem = function () { - return Number.MAX_VALUE; -}; - -exports.totalmem = function () { - return Number.MAX_VALUE; -}; - -exports.cpus = function () { return [] }; - -exports.type = function () { return 'Browser' }; - -exports.release = function () { - if (typeof navigator !== 'undefined') { - return navigator.appVersion; - } - return ''; -}; - -exports.networkInterfaces -= exports.getNetworkInterfaces -= function () { return {} }; - -exports.arch = function () { return 'javascript' }; - -exports.platform = function () { return 'browser' }; - -exports.tmpdir = exports.tmpDir = function () { - return '/tmp'; -}; - -exports.EOL = '\n'; - - -/***/ }), -/* 24 */ +/* 17 */ /***/ (function(module, exports, __webpack_require__) { -const Long = __webpack_require__(33); -const User = __webpack_require__(16); -const Role = __webpack_require__(15); +const Constants = __webpack_require__(0); +const Collection = __webpack_require__(3); +const Snowflake = __webpack_require__(6); + +/** + * Represents a custom emoji. + */ +class Emoji { + constructor(guild, data) { + /** + * The client that instantiated this object + * @name Emoji#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: guild.client }); + + /** + * The guild this emoji is part of + * @type {Guild} + */ + this.guild = guild; + + this.setup(data); + } + + setup(data) { + /** + * The ID of the emoji + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The name of the emoji + * @type {string} + */ + this.name = data.name; + + /** + * Whether or not this emoji requires colons surrounding it + * @type {boolean} + */ + this.requiresColons = data.require_colons; + + /** + * Whether this emoji is managed by an external service + * @type {boolean} + */ + this.managed = data.managed; + + this._roles = data.roles; + } + + /** + * The timestamp the emoji was created at + * @type {number} + * @readonly + */ + get createdTimestamp() { + return Snowflake.deconstruct(this.id).timestamp; + } + + /** + * The time the emoji was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * A collection of roles this emoji is active for (empty if all), mapped by role ID + * @type {Collection} + * @readonly + */ + get roles() { + const roles = new Collection(); + for (const role of this._roles) { + if (this.guild.roles.has(role)) roles.set(role, this.guild.roles.get(role)); + } + return roles; + } + + /** + * The URL to the emoji file + * @type {string} + * @readonly + */ + get url() { + return Constants.Endpoints.CDN(this.client.options.http.cdn).Emoji(this.id); + } + + /** + * The identifier of this emoji, used for message reactions + * @type {string} + * @readonly + */ + get identifier() { + if (this.id) return `${this.name}:${this.id}`; + return encodeURIComponent(this.name); + } + + /** + * Data for editing an emoji. + * @typedef {Object} EmojiEditData + * @property {string} [name] The name of the emoji + * @property {Collection|Array} [roles] Roles to restrict emoji to + */ + + /** + * Edits the emoji. + * @param {EmojiEditData} data The new data for the emoji + * @param {string} [reason] Reason for editing this emoji + * @returns {Promise} + * @example + * // Edit a emoji + * emoji.edit({name: 'newemoji'}) + * .then(e => console.log(`Edited emoji ${e}`)) + * .catch(console.error); + */ + edit(data, reason) { + return this.client.api.guilds(this.guild.id).emojis(this.id) + .patch({ data: { + name: data.name, + roles: data.roles ? data.roles.map(r => r.id ? r.id : r) : [], + }, reason }) + .then(() => this); + } + + /** + * Set the name of the emoji. + * @param {string} name The new name for the emoji + * @returns {Promise} + */ + setName(name) { + return this.edit({ name }); + } + + /** + * Add a role to the list of roles that can use this emoji. + * @param {Role} role The role to add + * @returns {Promise} + */ + addRestrictedRole(role) { + return this.addRestrictedRoles([role]); + } + + /** + * Add multiple roles to the list of roles that can use this emoji. + * @param {Role[]} roles Roles to add + * @returns {Promise} + */ + addRestrictedRoles(roles) { + const newRoles = new Collection(this.roles); + for (const role of roles) { + if (this.guild.roles.has(role.id)) newRoles.set(role.id, role); + } + return this.edit({ roles: newRoles }); + } + + /** + * Remove a role from the list of roles that can use this emoji. + * @param {Role} role The role to remove + * @returns {Promise} + */ + removeRestrictedRole(role) { + return this.removeRestrictedRoles([role]); + } + + /** + * Remove multiple roles from the list of roles that can use this emoji. + * @param {Role[]} roles Roles to remove + * @returns {Promise} + */ + removeRestrictedRoles(roles) { + const newRoles = new Collection(this.roles); + for (const role of roles) { + if (newRoles.has(role.id)) newRoles.delete(role.id); + } + return this.edit({ roles: newRoles }); + } + + /** + * When concatenated with a string, this automatically returns the emoji mention rather than the object. + * @returns {string} + * @example + * // Send an emoji: + * const emoji = guild.emojis.first(); + * msg.reply(`Hello! ${emoji}`); + */ + toString() { + return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name; + } + + /** + * Whether this emoji is the same as another one. + * @param {Emoji|Object} other The emoji to compare it to + * @returns {boolean} Whether the emoji is equal to the given emoji or not + */ + equals(other) { + if (other instanceof Emoji) { + return ( + other.id === this.id && + other.name === this.name && + other.managed === this.managed && + other.requiresColons === this.requiresColons + ); + } else { + return ( + other.id === this.id && + other.name === this.name + ); + } + } +} + +module.exports = Emoji; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +const Long = __webpack_require__(34); +const User = __webpack_require__(12); +const Role = __webpack_require__(20); const Emoji = __webpack_require__(17); -const Presence = __webpack_require__(11).Presence; -const GuildMember = __webpack_require__(18); +const Invite = __webpack_require__(27); +const GuildAuditLogs = __webpack_require__(45); +const Webhook = __webpack_require__(21); +const Presence = __webpack_require__(13).Presence; +const GuildMember = __webpack_require__(19); +const VoiceRegion = __webpack_require__(70); const Constants = __webpack_require__(0); const Collection = __webpack_require__(3); const Util = __webpack_require__(4); const Snowflake = __webpack_require__(6); +const Permissions = __webpack_require__(10); +const Shared = __webpack_require__(71); /** * Represents a guild (or a server) on Discord. @@ -7039,7 +5497,7 @@ class Guild { size = format; format = 'default'; } - return Constants.Endpoints.Guild(this).Icon(this.client.options.http.cdn, this.icon, format, size); + return Constants.Endpoints.CDN(this.client.options.http.cdn).Icon(this.id, this.icon, format, size); } /** @@ -7058,7 +5516,7 @@ class Guild { */ get splashURL() { if (!this.splash) return null; - return Constants.Endpoints.Guild(this).Splash(this.client.options.http.cdn, this.splash); + return Constants.Endpoints.CDN(this.client.options.http.cdn).Splash(this.id, this.splash); } /** @@ -7145,13 +5603,15 @@ class Guild { * @returns {Promise>} */ fetchBans() { - return this.client.rest.methods.getGuildBans(this) - // This entire re-mapping can be removed in the next major release - .then(bans => { - const users = new Collection(); - for (const ban of bans.values()) users.set(ban.user.id, ban.user); - return users; - }); + return this.client.api.guilds(this.id).bans.get().then(bans => + bans.reduce((collection, ban) => { + collection.set(ban.user.id, { + reason: ban.reason, + user: this.client.dataManager.newUser(ban.user), + }); + return collection; + }, new Collection()) + ); } /** @@ -7159,7 +5619,15 @@ class Guild { * @returns {Promise>} */ fetchInvites() { - return this.client.rest.methods.getGuildInvites(this); + return this.client.api.guilds(this.id).invites.get() + .then(inviteItems => { + const invites = new Collection(); + for (const inviteItem of inviteItems) { + const invite = new Invite(this.client, inviteItem); + invites.set(invite.code, invite); + } + return invites; + }); } /** @@ -7167,7 +5635,11 @@ class Guild { * @returns {Collection} */ fetchWebhooks() { - return this.client.rest.methods.getGuildWebhooks(this); + return this.client.api.guilds(this.id).webhooks.get().then(data => { + const hooks = new Collection(); + for (const hook of data) hooks.set(hook.id, new Webhook(this.client, hook)); + return hooks; + }); } /** @@ -7175,7 +5647,11 @@ class Guild { * @returns {Collection} */ fetchVoiceRegions() { - return this.client.rest.methods.fetchVoiceRegions(this.id); + return this.client.api.guilds(this.id).regions.get().then(res => { + const regions = new Collection(); + for (const region of res) regions.set(region.id, new VoiceRegion(region)); + return regions; + }); } /** @@ -7188,8 +5664,19 @@ class Guild { * @param {string|number} [options.type] Only show entries involving this action type * @returns {Promise} */ - fetchAuditLogs(options) { - return this.client.rest.methods.getGuildAuditLogs(this, options); + fetchAuditLogs(options = {}) { + if (options.before && options.before instanceof GuildAuditLogs.Entry) options.before = options.before.id; + if (options.after && options.after instanceof GuildAuditLogs.Entry) options.after = options.after.id; + if (typeof options.type === 'string') options.type = GuildAuditLogs.Actions[options.type]; + + return this.client.api.guilds(this.id)['audit-logs'].get({ query: { + before: options.before, + after: options.after, + limit: options.limit, + user_id: this.client.resolver.resolveUserID(options.user), + action_type: options.type, + } }) + .then(data => GuildAuditLogs.build(this, data)); } /** @@ -7207,7 +5694,15 @@ class Guild { */ addMember(user, options) { if (this.members.has(user.id)) return Promise.resolve(this.members.get(user.id)); - return this.client.rest.methods.putGuildMember(this, user, options); + options.access_token = options.accessToken; + if (options.roles) { + const roles = options.roles; + if (roles instanceof Collection || (roles instanceof Array && roles[0] instanceof Role)) { + options.roles = roles.map(role => role.id); + } + } + return this.client.api.guilds(this.id).members(user.id).put({ data: options }) + .then(data => this.client.actions.GuildMemberGet.handle(this, data).member); } /** @@ -7220,7 +5715,11 @@ class Guild { user = this.client.resolver.resolveUser(user); if (!user) return Promise.reject(new Error('User is not cached. Use Client.fetchUser first.')); if (this.members.has(user.id)) return Promise.resolve(this.members.get(user.id)); - return this.client.rest.methods.getGuildMember(this, user, cache); + return this.client.api.guilds(this.id).members(user.id).get() + .then(data => { + if (cache) return this.client.actions.GuildMemberGet.handle(this, data).member; + else return new GuildMember(this, data); + }); } /** @@ -7277,7 +5776,7 @@ class Guild { * }).catch(console.error); */ search(options = {}) { - return this.client.rest.methods.search(this, options); + return Shared.search(this, options); } /** @@ -7296,6 +5795,7 @@ class Guild { /** * Updates the guild with new information - e.g. a new name. * @param {GuildEditData} data The data to update the guild with + * @param {string} [reason] Reason for editing this guild * @returns {Promise} * @example * // Set the guild name and region @@ -7306,8 +5806,18 @@ class Guild { * .then(updated => console.log(`New guild name ${updated.name} in region ${updated.region}`)) * .catch(console.error); */ - edit(data) { - return this.client.rest.methods.updateGuild(this, data); + edit(data, reason) { + const _data = {}; + if (data.name) _data.name = data.name; + if (data.region) _data.region = data.region; + if (data.verificationLevel) _data.verification_level = Number(data.verificationLevel); + if (data.afkChannel) _data.afk_channel_id = this.client.resolver.resolveChannel(data.afkChannel).id; + if (data.afkTimeout) _data.afk_timeout = Number(data.afkTimeout); + if (data.icon) _data.icon = this.client.resolver.resolveBase64(data.icon); + if (data.owner) _data.owner_id = this.client.resolver.resolveUser(data.owner).id; + if (data.splash) _data.splash = this.client.resolver.resolveBase64(data.splash); + return this.client.api.guilds(this.id).patch({ data: _data, reason }) + .then(newData => this.client.actions.GuildUpdate.handle(newData).updated); } /** @@ -7442,7 +5952,12 @@ class Guild { * @returns {Promise} */ acknowledge() { - return this.client.rest.methods.ackGuild(this); + return this.client.api.guilds(this.id).ack + .post({ data: { token: this.client.rest._ackToken } }) + .then(res => { + if (res.token) this.client.rest._ackToken = res.token; + return this; + }); } /** @@ -7472,19 +5987,26 @@ class Guild { * .then(user => console.log(`Banned ${user.username || user.id || user} from ${guild.name}`)) * .catch(console.error); */ - ban(user, options = {}) { - if (typeof options === 'number') { - options = { reason: null, 'delete-message-days': options }; - } else if (typeof options === 'string') { - options = { reason: options, 'delete-message-days': 0 }; - } + ban(user, options = { days: 0 }) { if (options.days) options['delete-message-days'] = options.days; - return this.client.rest.methods.banGuildMember(this, user, options); + const id = this.client.resolver.resolveUserID(user); + if (!id) return Promise.reject(new Error('Couldn\'t resolve the user ID to ban.')); + return this.client.api.guilds(this.id).bans(id).put({ query: options }) + .then(() => { + if (user instanceof GuildMember) return user; + const _user = this.client.resolver.resolveUser(id); + if (_user) { + const member = this.client.resolver.resolveGuildMember(this, _user); + return member || _user; + } + return id; + }); } /** * Unbans a user from the guild. * @param {UserResolvable} user The user to unban + * @param {string} [reason] Reason for unbanning user * @returns {Promise} * @example * // Unban a user by ID (or with a user/guild member object) @@ -7492,29 +6014,35 @@ class Guild { * .then(user => console.log(`Unbanned ${user.username} from ${guild.name}`)) * .catch(console.error); */ - unban(user) { - return this.client.rest.methods.unbanGuildMember(this, user); + unban(user, reason) { + const id = this.client.resolver.resolveUserID(user); + if (!id) throw new Error('Couldn\'t resolve the user ID to unban.'); + + return this.client.api.guilds(this.id).bans(id).delete({ reason }) + .then(() => user); } /** * Prunes members from the guild based on how long they have been inactive. - * @param {number} days Number of days of inactivity required to kick - * @param {boolean} [dry=false] If true, will return number of users that will be kicked, without actually doing it + * @param {number} [options.days=7] Number of days of inactivity required to kick + * @param {boolean} [options.dry=false] Get number of users that will be kicked, without actually kicking them + * @param {string} [options.reason] Reason for this prune * @returns {Promise} The number of members that were/will be kicked * @example * // See how many members will be pruned - * guild.pruneMembers(12, true) + * guild.pruneMembers({ dry: true }) * .then(pruned => console.log(`This will prune ${pruned} people!`)) * .catch(console.error); * @example * // Actually prune the members - * guild.pruneMembers(12) + * guild.pruneMembers({ days: 1, reason: 'too many people!' }) * .then(pruned => console.log(`I just pruned ${pruned} people!`)) * .catch(console.error); */ - pruneMembers(days, dry = false) { + pruneMembers({ days = 7, dry = false, reason } = {}) { if (typeof days !== 'number') throw new TypeError('Days must be a number.'); - return this.client.rest.methods.pruneGuildMembers(this, days, dry); + return this.client.api.guilds(this.id).prune[dry ? 'get' : 'post']({ query: { days }, reason }) + .then(data => data.pruned); } /** @@ -7529,7 +6057,9 @@ class Guild { * Creates a new channel in the guild. * @param {string} name The name of the new channel * @param {string} type The type of the new channel, either `text` or `voice` - * @param {Array} overwrites Permission overwrites to apply to the new channel + * @param {Object} options Options + * @param {Array} [options.overwrites] Permission overwrites to apply to the new channel + * @param {string} [options.reason] Reason for creating this channel * @returns {Promise} * @example * // Create a new text channel @@ -7537,8 +6067,14 @@ class Guild { * .then(channel => console.log(`Created new channel ${channel}`)) * .catch(console.error); */ - createChannel(name, type, overwrites) { - return this.client.rest.methods.createChannel(this, name, type, overwrites); + createChannel(name, type, { overwrites, reason } = {}) { + if (overwrites instanceof Collection) overwrites = overwrites.array(); + return this.client.api.guilds(this.id).channels.post({ + data: { + name, type, permission_overwrites: overwrites, + }, + reason, + }).then(data => this.client.actions.ChannelCreate.handle(data).channel); } /** @@ -7558,12 +6094,30 @@ class Guild { * .catch(console.error); */ setChannelPositions(channelPositions) { - return this.client.rest.methods.updateChannelPositions(this.id, channelPositions); + const data = new Array(channelPositions.length); + for (let i = 0; i < channelPositions.length; i++) { + data[i] = { + id: this.client.resolver.resolveChannelID(channelPositions[i].channel), + position: channelPositions[i].position, + }; + } + + return this.client.api.guilds(this.id).channels.patch({ data: { + guild_id: this.id, + channels: channelPositions, + } }).then(() => + this.client.actions.GuildChannelsPositionUpdate.handle({ + guild_id: this.id, + channels: channelPositions, + }).guild + ); } /** * Creates a new role in the guild with given information - * @param {RoleData} [data] The data to update the role with + * @param {Object} [options] Options + * @param {RoleData} [options.data] The data to update the role with + * @param {string} [options.reason] Reason for creating this role * @returns {Promise} * @example * // Create a new role @@ -7571,16 +6125,27 @@ class Guild { * .then(role => console.log(`Created role ${role}`)) * .catch(console.error); * @example - * // Create a new role with data + * // Create a new role with data and a reason * guild.createRole({ - * name: 'Super Cool People', - * color: 'BLUE', + * data: { + * name: 'Super Cool People', + * color: 'BLUE', + * }, + * reason: 'we needed a role for Super Cool People', * }) * .then(role => console.log(`Created role ${role}`)) * .catch(console.error) */ - createRole(data = {}) { - return this.client.rest.methods.createGuildRole(this, data); + createRole({ data = {}, reason } = {}) { + if (data.color) data.color = this.client.resolver.resolveColor(data.color); + if (data.permissions) data.permissions = Permissions.resolve(data.permissions); + + return this.client.api.guilds(this.id).roles.post({ data, reason }).then(role => + this.client.actions.GuildRoleCreate.handle({ + guild_id: this.id, + role, + }).role + ); } /** @@ -7601,16 +6166,18 @@ class Guild { * .catch(console.error); */ createEmoji(attachment, name, roles) { - return new Promise(resolve => { - if (typeof attachment === 'string' && attachment.startsWith('data:')) { - resolve(this.client.rest.methods.createEmoji(this, attachment, name, roles)); - } else { - this.client.resolver.resolveBuffer(attachment).then(data => { - const dataURI = this.client.resolver.resolveBase64(data); - resolve(this.client.rest.methods.createEmoji(this, dataURI, name, roles)); - }); - } - }); + if (typeof attahment === 'string' && attachment.startsWith('data:')) { + const data = { image: attachment, name }; + if (roles) data.roles = roles.map(r => r.id ? r.id : r); + return this.client.api.guilds(this.id).emojis.post({ data }) + .then(emoji => this.client.actions.GuildEmojiCreate.handle(this, emoji).emoji); + } else { + return this.client.resolver.resolveBuffer(attachment) + .then(data => { + const dataURI = this.client.resolver.resolveBase64(data); + return this.createEmoji(dataURI, name, roles); + }); + } } /** @@ -7620,7 +6187,8 @@ class Guild { */ deleteEmoji(emoji) { if (!(emoji instanceof Emoji)) emoji = this.emojis.get(emoji); - return this.client.rest.methods.deleteEmoji(emoji); + return this.client.api.guilds(this.id).emojis(this.id).delete() + .then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data); } /** @@ -7633,7 +6201,9 @@ class Guild { * .catch(console.error); */ leave() { - return this.client.rest.methods.leaveGuild(this); + if (this.ownerID === this.client.user.id) return Promise.reject(new Error('Guild is owned by the client.')); + return this.rest.api.users('@me').guilds(this.id).delete() + .then(() => this.client.actions.GuildDelete.handle({ id: this.id }).guild); } /** @@ -7646,7 +6216,8 @@ class Guild { * .catch(console.error); */ delete() { - return this.client.rest.methods.deleteGuild(this); + return this.client.api.guilds(this.id).delete() + .then(() => this.client.actions.GuildDelete.handle({ id: this.id }).guild); } /** @@ -7803,7 +6374,13 @@ class Guild { 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); + return this.client.api.guilds(this.id).roles.patch({ data: updatedRoles }) + .then(() => + this.client.actions.GuildRolesPositionUpdate.handle({ + guild_id: this.id, + roles: updatedRoles, + }).guild + ); } /** @@ -7827,7 +6404,13 @@ class Guild { 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); + return this.client.api.guilds(this.id).channels.patch({ data: updatedChannels }) + .then(() => + this.client.actions.GuildChannelsPositionUpdate.handle({ + guild_id: this.id, + roles: updatedChannels, + }).guild + ); } /** @@ -7864,13 +6447,1779 @@ module.exports = Guild; /***/ }), -/* 25 */ +/* 19 */ /***/ (function(module, exports, __webpack_require__) { -const Channel = __webpack_require__(14); -const Role = __webpack_require__(15); +const TextBasedChannel = __webpack_require__(24); +const Role = __webpack_require__(20); +const Permissions = __webpack_require__(10); +const Collection = __webpack_require__(3); +const Presence = __webpack_require__(13).Presence; + +/** + * Represents a member of a guild on Discord. + * @implements {TextBasedChannel} + */ +class GuildMember { + constructor(guild, data) { + /** + * The client that instantiated this GuildMember + * @name GuildMember#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: guild.client }); + + /** + * The guild that this member is part of + * @type {Guild} + */ + this.guild = guild; + + /** + * The user that this guild member instance Represents + * @type {User} + */ + this.user = {}; + + this._roles = []; + if (data) this.setup(data); + + /** + * The ID of the last message sent by the member in their guild, if one was sent + * @type {?Snowflake} + */ + this.lastMessageID = null; + + /** + * The Message object of the last message sent by the member in their guild, if one was sent + * @type {?Message} + */ + this.lastMessage = null; + } + + setup(data) { + /** + * Whether this member is deafened server-wide + * @type {boolean} + */ + this.serverDeaf = data.deaf; + + /** + * Whether this member is muted server-wide + * @type {boolean} + */ + this.serverMute = data.mute; + + /** + * Whether this member is self-muted + * @type {boolean} + */ + this.selfMute = data.self_mute; + + /** + * Whether this member is self-deafened + * @type {boolean} + */ + this.selfDeaf = data.self_deaf; + + /** + * The voice session ID of this member, if any + * @type {?Snowflake} + */ + this.voiceSessionID = data.session_id; + + /** + * The voice channel ID of this member, if any + * @type {?Snowflake} + */ + this.voiceChannelID = data.channel_id; + + /** + * Whether this member is speaking + * @type {boolean} + */ + this.speaking = false; + + /** + * The nickname of this guild member, if they have one + * @type {?string} + */ + this.nickname = data.nick || null; + + /** + * The timestamp the member joined the guild at + * @type {number} + */ + this.joinedTimestamp = new Date(data.joined_at).getTime(); + + this.user = data.user; + this._roles = data.roles; + } + + /** + * The time the member joined the guild + * @type {Date} + * @readonly + */ + get joinedAt() { + return new Date(this.joinedTimestamp); + } + + /** + * The presence of this guild member + * @type {Presence} + * @readonly + */ + get presence() { + return this.frozenPresence || this.guild.presences.get(this.id) || new Presence(); + } + + /** + * A list of roles that are applied to this GuildMember, mapped by the role ID + * @type {Collection} + * @readonly + */ + get roles() { + const list = new Collection(); + const everyoneRole = this.guild.roles.get(this.guild.id); + + if (everyoneRole) list.set(everyoneRole.id, everyoneRole); + + for (const roleID of this._roles) { + const role = this.guild.roles.get(roleID); + if (role) list.set(role.id, role); + } + + return list; + } + + /** + * The role of the member with the highest position + * @type {Role} + * @readonly + */ + get highestRole() { + return this.roles.reduce((prev, role) => !prev || role.comparePositionTo(prev) > 0 ? role : prev); + } + + /** + * The role of the member used to set their color + * @type {?Role} + * @readonly + */ + get colorRole() { + const coloredRoles = this.roles.filter(role => role.color); + if (!coloredRoles.size) return null; + return coloredRoles.reduce((prev, role) => !prev || role.comparePositionTo(prev) > 0 ? role : prev); + } + + /** + * The displayed color of the member in base 10 + * @type {number} + * @readonly + */ + get displayColor() { + const role = this.colorRole; + return (role && role.color) || 0; + } + + /** + * The displayed color of the member in hexadecimal + * @type {string} + * @readonly + */ + get displayHexColor() { + const role = this.colorRole; + return (role && role.hexColor) || '#000000'; + } + + /** + * The role of the member used to hoist them in a separate category in the users list + * @type {?Role} + * @readonly + */ + get hoistRole() { + const hoistedRoles = this.roles.filter(role => role.hoist); + if (!hoistedRoles.size) return null; + return hoistedRoles.reduce((prev, role) => !prev || role.comparePositionTo(prev) > 0 ? role : prev); + } + + /** + * Whether this member is muted in any way + * @type {boolean} + * @readonly + */ + get mute() { + return this.selfMute || this.serverMute; + } + + /** + * Whether this member is deafened in any way + * @type {boolean} + * @readonly + */ + get deaf() { + return this.selfDeaf || this.serverDeaf; + } + + /** + * The voice channel this member is in, if any + * @type {?VoiceChannel} + * @readonly + */ + get voiceChannel() { + return this.guild.channels.get(this.voiceChannelID); + } + + /** + * The ID of this user + * @type {Snowflake} + * @readonly + */ + get id() { + return this.user.id; + } + + /** + * The nickname of the member, or their username if they don't have one + * @type {string} + * @readonly + */ + get displayName() { + return this.nickname || this.user.username; + } + + /** + * The overall set of permissions for the guild member, taking only roles into account + * @type {Permissions} + * @readonly + */ + get permissions() { + if (this.user.id === this.guild.ownerID) return new Permissions(Permissions.ALL); + + let permissions = 0; + const roles = this.roles; + for (const role of roles.values()) permissions |= role.permissions; + + return new Permissions(permissions); + } + + /** + * Whether the member is kickable by the client user + * @type {boolean} + * @readonly + */ + get kickable() { + if (this.user.id === this.guild.ownerID) return false; + if (this.user.id === this.client.user.id) return false; + const clientMember = this.guild.member(this.client.user); + if (!clientMember.permissions.has(Permissions.FLAGS.KICK_MEMBERS)) return false; + return clientMember.highestRole.comparePositionTo(this.highestRole) > 0; + } + + /** + * Whether the member is bannable by the client user + * @type {boolean} + * @readonly + */ + get bannable() { + if (this.user.id === this.guild.ownerID) return false; + if (this.user.id === this.client.user.id) return false; + const clientMember = this.guild.member(this.client.user); + if (!clientMember.permissions.has(Permissions.FLAGS.BAN_MEMBERS)) return false; + return clientMember.highestRole.comparePositionTo(this.highestRole) > 0; + } + + /** + * Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel, + * taking into account roles and permission overwrites. + * @param {ChannelResolvable} channel The guild channel to use as context + * @returns {?Permissions} + */ + permissionsIn(channel) { + channel = this.client.resolver.resolveChannel(channel); + if (!channel || !channel.guild) throw new Error('Could not resolve channel to a guild channel.'); + return channel.permissionsFor(this); + } + + /** + * Checks if any of the member's roles have a permission. + * @param {PermissionResolvable|PermissionResolvable[]} permission Permission(s) to check for + * @param {boolean} [explicit=false] Whether to require the role to explicitly have the exact permission + * **(deprecated)** + * @param {boolean} [checkAdmin] Whether to allow the administrator permission to override + * (takes priority over `explicit`) + * @param {boolean} [checkOwner] Whether to allow being the guild's owner to override + * (takes priority over `explicit`) + * @returns {boolean} + */ + hasPermission(permission, explicit = false, checkAdmin, checkOwner) { + if (typeof checkAdmin === 'undefined') checkAdmin = !explicit; + if (typeof checkOwner === 'undefined') checkOwner = !explicit; + if (checkOwner && this.user.id === this.guild.ownerID) return true; + return this.roles.some(r => r.hasPermission(permission, undefined, checkAdmin)); + } + + /** + * Checks whether the roles of the member allows them to perform specific actions, and lists any missing permissions. + * @param {PermissionResolvable[]} permissions The permissions to check for + * @param {boolean} [explicit=false] Whether to require the member to explicitly have the exact permissions + * @returns {PermissionResolvable[]} + */ + missingPermissions(permissions, explicit = false) { + return permissions.missing(permissions, explicit); + } + + /** + * The data for editing a guild member. + * @typedef {Object} GuildMemberEditData + * @property {string} [nick] The nickname to set for the member + * @property {Collection|Role[]|Snowflake[]} [roles] The roles or role IDs to apply + * @property {boolean} [mute] Whether or not the member should be muted + * @property {boolean} [deaf] Whether or not the member should be deafened + * @property {ChannelResolvable} [channel] Channel to move member to (if they are connected to voice) + */ + + /** + * Edit a guild member. + * @param {GuildMemberEditData} data The data to edit the member with + * @param {string} [reason] Reason for editing this user + * @returns {Promise} + */ + edit(data, reason) { + if (data.channel) { + data.channel_id = this.client.resolver.resolveChannel(data.channel).id; + data.channel = null; + } + if (data.roles) data.roles = data.roles.map(role => role instanceof Role ? role.id : role); + let endpoint = this.client.api.guilds(this.guild.id); + if (this.user.id === this.client.user.id) { + const keys = Object.keys(data); + if (keys.length === 1 && keys[0] === 'nick') endpoint = endpoint.members('@me').nick; + else endpoint = endpoint.members(this.id); + } else { + endpoint = endpoint.members(this.id); + } + return endpoint.patch({ data, reason }).then(newData => this.guild._updateMember(this, newData).mem); + } + + /** + * Mute/unmute a user. + * @param {boolean} mute Whether or not the member should be muted + * @returns {Promise} + */ + setMute(mute) { + return this.edit({ mute }); + } + + /** + * Deafen/undeafen a user. + * @param {boolean} deaf Whether or not the member should be deafened + * @returns {Promise} + */ + setDeaf(deaf) { + return this.edit({ deaf }); + } + + /** + * Moves the guild member to the given channel. + * @param {ChannelResolvable} channel The channel to move the member to + * @returns {Promise} + */ + setVoiceChannel(channel) { + return this.edit({ channel }); + } + + /** + * Sets the roles applied to the member. + * @param {Collection|Role[]|Snowflake[]} roles The roles or role IDs to apply + * @returns {Promise} + */ + setRoles(roles) { + return this.edit({ roles }); + } + + /** + * Adds a single role to the member. + * @param {Role|Snowflake} role The role or ID of the role to add + * @returns {Promise} + */ + addRole(role) { + if (!(role instanceof Role)) role = this.guild.roles.get(role); + if (!role) return Promise.reject(new TypeError('Supplied parameter was neither a Role nor a Snowflake.')); + if (this._roles.includes(role.id)) return Promise.resolve(this); + return this.client.api.guilds(this.guild.id).members(this.user.id).roles(role.id) + .put() + .then(() => this); + } + + /** + * Adds multiple roles to the member. + * @param {Collection|Role[]|Snowflake[]} roles The roles or role IDs to add + * @returns {Promise} + */ + addRoles(roles) { + let allRoles; + if (roles instanceof Collection) { + allRoles = this._roles.slice(); + for (const role of roles.values()) allRoles.push(role.id ? role.id : role); + } else { + allRoles = this._roles.concat(roles.map(r => r.id ? r.id : r)); + } + return this.edit({ roles: allRoles }); + } + + /** + * Removes a single role from the member. + * @param {Role|Snowflake} role The role or ID of the role to remove + * @returns {Promise} + */ + removeRole(role) { + if (!(role instanceof Role)) role = this.guild.roles.get(role); + if (!role) return Promise.reject(new TypeError('Supplied parameter was neither a Role nor a Snowflake.')); + return this.client.api.guilds(this.guild.id).members(this.user.id).roles(role.id) + .delete() + .then(() => this); + } + + /** + * Removes multiple roles from the member. + * @param {Collection|Role[]|Snowflake[]} roles The roles or role IDs to remove + * @returns {Promise} + */ + removeRoles(roles) { + const allRoles = this._roles.slice(); + if (roles instanceof Collection) { + for (const role of roles.values()) { + const index = allRoles.indexOf(role.id); + if (index >= 0) allRoles.splice(index, 1); + } + } else { + for (const role of roles) { + const index = allRoles.indexOf(role instanceof Role ? role.id : role); + if (index >= 0) allRoles.splice(index, 1); + } + } + return this.edit({ roles: allRoles }); + } + + /** + * Set the nickname for the guild member. + * @param {string} nick The nickname for the guild member + * @returns {Promise} + */ + setNickname(nick) { + return this.edit({ nick }); + } + + /** + * Creates a DM channel between the client and the member. + * @returns {Promise} + */ + createDM() { + return this.user.createDM(); + } + + /** + * Deletes any DMs with this guild member. + * @returns {Promise} + */ + deleteDM() { + return this.user.deleteDM(); + } + + /** + * Kick this member from the guild. + * @param {string} [reason] Reason for kicking user + * @returns {Promise} + */ + kick(reason) { + return this.client.api.guilds(this.guild.id).members(this.user.id).delete({ reason }) + .then(() => + this.client.actions.GuildMemberRemove.handle({ + guild_id: this.guild.id, + user: this.user, + }).member + ); + } + + /** + * Ban this guild member + * @param {Object|number|string} [options] Ban options. If a number, the number of days to delete messages for, if a + * string, the ban reason. Supplying an object allows you to do both. + * @param {number} [options.days=0] Number of days of messages to delete + * @param {string} [options.reason] Reason for banning + * @returns {Promise} + * @example + * // ban a guild member + * guildMember.ban(7); + */ + ban(options) { + return this.guild.ban(this, options); + } + + /** + * When concatenated with a string, this automatically concatenates the user's mention instead of the Member object. + * @returns {string} + * @example + * // Logs: Hello from <@123456789>! + * console.log(`Hello from ${member}!`); + */ + toString() { + return `<@${this.nickname ? '!' : ''}${this.user.id}>`; + } + + // These are here only for documentation purposes - they are implemented by TextBasedChannel + /* eslint-disable no-empty-function */ + send() {} +} + +TextBasedChannel.applyToClass(GuildMember); + +module.exports = GuildMember; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +const Snowflake = __webpack_require__(6); +const Permissions = __webpack_require__(10); + +/** + * Represents a role on Discord. + */ +class Role { + constructor(guild, data) { + /** + * The client that instantiated the role + * @name Role#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: guild.client }); + + /** + * The guild that the role belongs to + * @type {Guild} + */ + this.guild = guild; + + if (data) this.setup(data); + } + + setup(data) { + /** + * The ID of the role (unique to the guild it is part of) + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The name of the role + * @type {string} + */ + this.name = data.name; + + /** + * The base 10 color of the role + * @type {number} + */ + this.color = data.color; + + /** + * If true, users that are part of this role will appear in a separate category in the users list + * @type {boolean} + */ + this.hoist = data.hoist; + + /** + * The position of the role from the API + * @type {number} + */ + this.position = data.position; + + /** + * The permissions bitfield of the role + * @type {number} + */ + this.permissions = data.permissions; + + /** + * Whether or not the role is managed by an external service + * @type {boolean} + */ + this.managed = data.managed; + + /** + * Whether or not the role can be mentioned by anyone + * @type {boolean} + */ + this.mentionable = data.mentionable; + } + + /** + * The timestamp the role was created at + * @type {number} + * @readonly + */ + get createdTimestamp() { + return Snowflake.deconstruct(this.id).timestamp; + } + + /** + * The time the role was created + * @type {Date} + * @readonly + */ + get createdAt() { + return new Date(this.createdTimestamp); + } + + /** + * The hexadecimal version of the role color, with a leading hashtag + * @type {string} + * @readonly + */ + get hexColor() { + let col = this.color.toString(16); + while (col.length < 6) col = `0${col}`; + return `#${col}`; + } + + /** + * The cached guild members that have this role + * @type {Collection} + * @readonly + */ + get members() { + return this.guild.members.filter(m => m.roles.has(this.id)); + } + + /** + * Whether the role is editable by the client user + * @type {boolean} + * @readonly + */ + get editable() { + if (this.managed) return false; + const clientMember = this.guild.member(this.client.user); + if (!clientMember.permissions.has(Permissions.FLAGS.MANAGE_ROLES_OR_PERMISSIONS)) return false; + return clientMember.highestRole.comparePositionTo(this) > 0; + } + + /** + * The position of the role in the role manager + * @type {number} + * @readonly + */ + get calculatedPosition() { + const sorted = this.guild._sortedRoles; + return sorted.array().indexOf(sorted.get(this.id)); + } + + /** + * Get an object mapping permission names to whether or not the role enables that permission + * @returns {Object} + * @example + * // Print the serialized role permissions + * console.log(role.serialize()); + */ + serialize() { + return new Permissions(this.permissions).serialize(); + } + + /** + * Checks if the role has a permission. + * @param {PermissionResolvable|PermissionResolvable[]} permission Permission(s) to check for + * @param {boolean} [explicit=false] Whether to require the role to explicitly have the exact permission + * **(deprecated)** + * @param {boolean} [checkAdmin] Whether to allow the administrator permission to override + * (takes priority over `explicit`) + * @returns {boolean} + * @example + * // See if a role can ban a member + * if (role.hasPermission('BAN_MEMBERS')) { + * console.log('This role can ban members'); + * } else { + * console.log('This role can\'t ban members'); + * } + */ + hasPermission(permission, explicit = false, checkAdmin) { + return new Permissions(this.permissions).has( + permission, typeof checkAdmin !== 'undefined' ? checkAdmin : !explicit + ); + } + + /** + * Compares this role's position to another role's. + * @param {Role} role Role to compare to this one + * @returns {number} Negative number if the this role's position is lower (other role's is higher), + * positive number if the this one is higher (other's is lower), 0 if equal + */ + comparePositionTo(role) { + return this.constructor.comparePositions(this, role); + } + + /** + * The data for a role. + * @typedef {Object} RoleData + * @property {string} [name] The name of the role + * @property {ColorResolvable} [color] The color of the role, either a hex string or a base 10 number + * @property {boolean} [hoist] Whether or not the role should be hoisted + * @property {number} [position] The position of the role + * @property {string[]} [permissions] The permissions of the role + * @property {boolean} [mentionable] Whether or not the role should be mentionable + */ + + /** + * Edits the role. + * @param {RoleData} data The new data for the role + * @param {string} [reason] Reason for editing this role + * @returns {Promise} + * @example + * // Edit a role + * role.edit({name: 'new role'}) + * .then(r => console.log(`Edited role ${r}`)) + * .catch(console.error); + */ + edit(data, reason) { + if (data.permissions) data.permissions = Permissions.resolve(data.permissions); + else data.permissions = this.permissions; + return this.client.api.guilds(this.guild.id).roles(this.id).patch({ + data: { + name: data.name || this.name, + position: typeof data.position !== 'undefined' ? data.position : this.position, + color: this.client.resolver.resolveColor(data.color || this.color), + hoist: typeof data.hoist !== 'undefined' ? data.hoist : this.hoist, + mentionable: typeof data.mentionable !== 'undefined' ? data.mentionable : this.mentionable, + }, + reason, + }) + .then(role => this.client.actions.GuildRoleUpdate.handle({ role, guild_id: this.guild.id }).updated); + } + + /** + * Set a new name for the role. + * @param {string} name The new name of the role + * @returns {Promise} + * @example + * // Set the name of the role + * role.setName('new role') + * .then(r => console.log(`Edited name of role ${r}`)) + * .catch(console.error); + */ + setName(name) { + return this.edit({ name }); + } + + /** + * Set a new color for the role. + * @param {ColorResolvable} color The color of the role + * @returns {Promise} + * @example + * // Set the color of a role + * role.setColor('#FF0000') + * .then(r => console.log(`Set color of role ${r}`)) + * .catch(console.error); + */ + setColor(color) { + return this.edit({ color }); + } + + /** + * Set whether or not the role should be hoisted. + * @param {boolean} hoist Whether or not to hoist the role + * @returns {Promise} + * @example + * // Set the hoist of the role + * role.setHoist(true) + * .then(r => console.log(`Role hoisted: ${r.hoist}`)) + * .catch(console.error); + */ + setHoist(hoist) { + return this.edit({ hoist }); + } + + /** + * Set the position of the role. + * @param {number} position The position of the role + * @param {boolean} [relative=false] Move the position relative to its current value + * @returns {Promise} + * @example + * // Set the position of the role + * role.setPosition(1) + * .then(r => console.log(`Role position: ${r.position}`)) + * .catch(console.error); + */ + setPosition(position, relative) { + return this.guild.setRolePosition(this, position, relative).then(() => this); + } + + /** + * Set the permissions of the role. + * @param {string[]} permissions The permissions of the role + * @returns {Promise} + * @example + * // Set the permissions of the role + * role.setPermissions(['KICK_MEMBERS', 'BAN_MEMBERS']) + * .then(r => console.log(`Role updated ${r}`)) + * .catch(console.error); + */ + setPermissions(permissions) { + return this.edit({ permissions }); + } + + /** + * Set whether this role is mentionable. + * @param {boolean} mentionable Whether this role should be mentionable + * @returns {Promise} + * @example + * // Make the role mentionable + * role.setMentionable(true) + * .then(r => console.log(`Role updated ${r}`)) + * .catch(console.error); + */ + setMentionable(mentionable) { + return this.edit({ mentionable }); + } + + /** + * Deletes the role. + * @param {string} [reason] Reason for deleting this role + * @returns {Promise} + * @example + * // Delete a role + * role.delete() + * .then(r => console.log(`Deleted role ${r}`)) + * .catch(console.error); + */ + delete(reason) { + return this.client.api.guilds(this.guild.id).roles(this.id).delete({ reason }) + .then(() => + this.client.actions.GuildRoleDelete.handle({ guild_id: this.guild.id, role_id: this.id }).role + ); + } + + /** + * Whether this role equals another role. It compares all properties, so for most operations + * it is advisable to just compare `role.id === role2.id` as it is much faster and is often + * what most users need. + * @param {Role} role Role to compare with + * @returns {boolean} + */ + equals(role) { + return role && + this.id === role.id && + this.name === role.name && + this.color === role.color && + this.hoist === role.hoist && + this.position === role.position && + this.permissions === role.permissions && + this.managed === role.managed; + } + + /** + * When concatenated with a string, this automatically concatenates the role mention rather than the Role object. + * @returns {string} + */ + toString() { + if (this.id === this.guild.id) return '@everyone'; + return `<@&${this.id}>`; + } + + /** + * Compares the positions of two roles. + * @param {Role} role1 First role to compare + * @param {Role} role2 Second role to compare + * @returns {number} Negative number if the first role's position is lower (second role's is higher), + * positive number if the first's is higher (second's is lower), 0 if equal + */ + static comparePositions(role1, role2) { + if (role1.position === role2.position) return role2.id - role1.id; + return role1.position - role2.position; + } +} + +module.exports = Role; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +const path = __webpack_require__(29); + +/** + * Represents a webhook. + */ +class Webhook { + constructor(client, dataOrID, token) { + if (client) { + /** + * The client that instantiated the webhook + * @name Webhook#client + * @type {Client} + * @readonly + */ + Object.defineProperty(this, 'client', { value: client }); + if (dataOrID) this.setup(dataOrID); + } else { + this.id = dataOrID; + this.token = token; + Object.defineProperty(this, 'client', { value: this }); + } + } + + setup(data) { + /** + * The name of the webhook + * @type {string} + */ + this.name = data.name; + + /** + * The token for the webhook + * @type {string} + */ + this.token = data.token; + + /** + * The avatar for the webhook + * @type {string} + */ + this.avatar = data.avatar; + + /** + * The ID of the webhook + * @type {Snowflake} + */ + this.id = data.id; + + /** + * The guild the webhook belongs to + * @type {Snowflake} + */ + this.guildID = data.guild_id; + + /** + * The channel the webhook belongs to + * @type {Snowflake} + */ + this.channelID = data.channel_id; + + if (data.user) { + /** + * The owner of the webhook + * @type {?User|Object} + */ + this.owner = this.client.users ? this.client.users.get(data.user.id) : data.user; + } else { + this.owner = null; + } + } + + /** + * Options that can be passed into send. + * @typedef {Object} WebhookMessageOptions + * @property {string} [username=this.name] Username override for the message + * @property {string} [avatarURL] Avatar URL override for the message + * @property {boolean} [tts=false] Whether or not the message should be spoken aloud + * @property {string} [nonce=''] The nonce for the message + * @property {Object[]} [embeds] An array of embeds for the message + * (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details) + * @property {boolean} [disableEveryone=this.client.options.disableEveryone] Whether or not @everyone and @here + * should be replaced with plain-text + * @property {FileOptions|string} [file] A file to send with the message + * @property {FileOptions[]|string[]} [files] Files to send with the message + * @property {string|boolean} [code] Language for optional codeblock formatting to apply + * @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if + * it exceeds the character limit. If an object is provided, these are the options for splitting the message. + */ + + /** + * Send a message with this webhook. + * @param {StringResolvable} [content] The content to send + * @param {WebhookMessageOptions} [options={}] The options to provide + * @returns {Promise} + * @example + * // Send a message + * webhook.send('hello!') + * .then(message => console.log(`Sent message: ${message.content}`)) + * .catch(console.error); + */ + send(content, options) { + if (!options && typeof content === 'object' && !(content instanceof Array)) { + options = content; + content = ''; + } else if (!options) { + options = {}; + } + + if (!options.username) options.username = this.name; + + if (options.avatarURL) { + options.avatar_url = options.avatarURL; + options.avatarURL = null; + } + + if (typeof content !== 'undefined') content = this.client.resolver.resolveString(content); + if (content) { + if (options.disableEveryone || + (typeof options.disableEveryone === 'undefined' && this.client.options.disableEveryone) + ) { + content = content.replace(/@(everyone|here)/g, '@\u200b$1'); + } + } + options.content = content; + + if (options.file) { + if (options.files) options.files.push(options.file); + else options.files = [options.file]; + } + + if (options.files) { + for (let i = 0; i < options.files.length; i++) { + let file = options.files[i]; + if (typeof file === 'string') file = { attachment: file }; + if (!file.name) { + if (typeof file.attachment === 'string') { + file.name = path.basename(file.attachment); + } else if (file.attachment && file.attachment.path) { + file.name = path.basename(file.attachment.path); + } else { + file.name = 'file.jpg'; + } + } + options.files[i] = file; + } + + return Promise.all(options.files.map(file => + this.client.resolver.resolveBuffer(file.attachment).then(buffer => { + file.file = buffer; + return file; + }) + )).then(files => this.client.api.webhooks(this.id, this.token).post({ + data: options, + query: { wait: true }, + files, + auth: false, + })); + } + + return this.client.api.webhooks(this.id, this.token).post({ + data: options, + query: { wait: true }, + auth: false, + }).then(data => { + if (!this.client.channels) return data; + const Message = __webpack_require__(8); + return new Message(this.client.channels.get(data.channel_id, data, this.client)); + }); + } + + /** + * Send a raw slack message with this webhook. + * @param {Object} body The raw body to send + * @returns {Promise} + * @example + * // Send a slack message + * webhook.sendSlackMessage({ + * 'username': 'Wumpus', + * 'attachments': [{ + * 'pretext': 'this looks pretty cool', + * 'color': '#F0F', + * 'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png', + * 'footer': 'Powered by sneks', + * 'ts': Date.now() / 1000 + * }] + * }).catch(console.error); + */ + sendSlackMessage(body) { + return this.client.api.webhooks(this.id, this.token).slack.post({ + query: { wait: true }, + auth: false, + data: body, + }).then(data => { + if (!this.client.channels) return data; + const Message = __webpack_require__(8); + return new Message(this.client.channels.get(data.channel_id, data, this.client)); + }); + } + + /** + * Edit the webhook. + * @param {Object} options Options + * @param {string} [options.name] New name for this webhook + * @param {BufferResolvable} [options.avatar] New avatar for this webhook + * @param {string} [reason] Reason for editing this webhook + * @returns {Promise} + */ + edit({ name = this.name, avatar }, reason) { + if (avatar && (typeof avatar === 'string' && !avatar.startsWith('data:'))) { + return this.client.resolver.resolveBuffer(avatar).then(file => { + const dataURI = this.client.resolver.resolveBase64(file); + return this.edit({ name, avatar: dataURI }, reason); + }); + } + return this.client.api.webhooks(this.id, this.token).patch({ + data: { name, avatar }, + reason, + }).then(data => { + this.name = data.name; + this.avatar = data.avatar; + return this; + }); + } + + /** + * Delete the webhook. + * @param {string} [reason] Reason for deleting this webhook + * @returns {Promise} + */ + delete(reason) { + return this.client.api.webhooks(this.id, this.token).delete({ reason }); + } +} + +module.exports = Webhook; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {// 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. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__(58); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = __webpack_require__(37); +exports.Duplex = __webpack_require__(15); +exports.Transform = __webpack_require__(59); +exports.PassThrough = __webpack_require__(86); + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +const path = __webpack_require__(29); +const MessageCollector = __webpack_require__(47); +const Shared = __webpack_require__(71); +const Collection = __webpack_require__(3); +const Snowflake = __webpack_require__(6); + +/** + * Interface for classes that have text-channel-like features. + * @interface + */ +class TextBasedChannel { + constructor() { + /** + * A collection containing the messages sent to this channel + * @type {Collection} + */ + this.messages = new Collection(); + + /** + * The ID of the last message in the channel, if one was sent + * @type {?Snowflake} + */ + this.lastMessageID = null; + + /** + * The Message object of the last message in the channel, if one was sent + * @type {?Message} + */ + this.lastMessage = null; + } + + /** + * Options provided when sending or editing a message. + * @typedef {Object} MessageOptions + * @property {boolean} [tts=false] Whether or not the message should be spoken aloud + * @property {string} [nonce=''] The nonce for the message + * @property {RichEmbed|Object} [embed] An embed for the message + * (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details) + * @property {boolean} [disableEveryone=this.client.options.disableEveryone] Whether or not @everyone and @here + * should be replaced with plain-text + * @property {FileOptions[]|string[]} [files] Files to send with the message + * @property {string|boolean} [code] Language for optional codeblock formatting to apply + * @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if + * it exceeds the character limit. If an object is provided, these are the options for splitting the message + * @property {UserResolvable} [reply] User to reply to (prefixes the message with a mention, except in DMs) + */ + + /** + * @typedef {Object} FileOptions + * @property {BufferResolvable} attachment File to attach + * @property {string} [name='file.jpg'] Filename of the attachment + */ + + /** + * Options for splitting a message. + * @typedef {Object} SplitOptions + * @property {number} [maxLength=1950] Maximum character length per message piece + * @property {string} [char='\n'] Character to split the message with + * @property {string} [prepend=''] Text to prepend to every piece except the first + * @property {string} [append=''] Text to append to every piece except the last + */ + + /** + * Send a message to this channel. + * @param {StringResolvable} [content] Text for the message + * @param {MessageOptions} [options={}] Options for the message + * @returns {Promise} + * @example + * // Send a message + * channel.send('hello!') + * .then(message => console.log(`Sent message: ${message.content}`)) + * .catch(console.error); + */ + send(content, options) { + if (!options && typeof content === 'object' && !(content instanceof Array)) { + options = content; + content = ''; + } else if (!options) { + options = {}; + } + + if (!options.content) options.content = content; + + if (options.embed && options.embed.file) options.file = options.embed.file; + + if (options.file) { + if (options.files) options.files.push(options.file); + else options.files = [options.file]; + } + + if (options.files) { + for (let i = 0; i < options.files.length; i++) { + let file = options.files[i]; + if (typeof file === 'string') file = { attachment: file }; + if (!file.name) { + if (typeof file.attachment === 'string') { + file.name = path.basename(file.attachment); + } else if (file.attachment && file.attachment.path) { + file.name = path.basename(file.attachment.path); + } else { + file.name = 'file.jpg'; + } + } + options.files[i] = file; + } + + return Promise.all(options.files.map(file => + this.client.resolver.resolveBuffer(file.attachment).then(buffer => { + file.file = buffer; + return file; + }) + )).then(files => { + options.files = files; + return Shared.sendMessage(this, options); + }); + } + + return Shared.sendMessage(this, options); + } + + /** + * Gets a single message from this channel, regardless of it being cached or not. Since the single message fetching + * endpoint is reserved for bot accounts, this abstracts the `fetchMessages` method to obtain the single message when + * using a user account. + * @param {Snowflake} messageID ID of the message to get + * @returns {Promise} + * @example + * // Get message + * channel.fetchMessage('99539446449315840') + * .then(message => console.log(message.content)) + * .catch(console.error); + */ + fetchMessage(messageID) { + const Message = __webpack_require__(8); + if (!this.client.user.bot) { + return this.fetchMessages({ limit: 1, around: messageID }) + .then(messages => { + const msg = messages.get(messageID); + if (!msg) throw new Error('Message not found.'); + return msg; + }); + } + return this.client.api.channels(this.id).messages(messageID).get() + .then(data => { + const msg = data instanceof Message ? data : new Message(this, data, this.client); + this._cacheMessage(msg); + return msg; + }); + } + + /** + * The parameters to pass in when requesting previous messages from a channel. `around`, `before` and + * `after` are mutually exclusive. All the parameters are optional. + * @typedef {Object} ChannelLogsQueryOptions + * @property {number} [limit=50] Number of messages to acquire + * @property {Snowflake} [before] ID of a message to get the messages that were posted before it + * @property {Snowflake} [after] ID of a message to get the messages that were posted after it + * @property {Snowflake} [around] ID of a message to get the messages that were posted around it + */ + + /** + * Gets the past messages sent in this channel. Resolves with a collection mapping message ID's to Message objects. + * @param {ChannelLogsQueryOptions} [options={}] Query parameters to pass in + * @returns {Promise>} + * @example + * // Get messages + * channel.fetchMessages({limit: 10}) + * .then(messages => console.log(`Received ${messages.size} messages`)) + * .catch(console.error); + */ + fetchMessages(options = {}) { + const Message = __webpack_require__(8); + return this.client.api.channels(this.id).messages.get({ query: options }) + .then(data => { + const messages = new Collection(); + for (const message of data) { + const msg = new Message(this, message, this.client); + messages.set(message.id, msg); + this._cacheMessage(msg); + } + return messages; + }); + } + + /** + * Fetches the pinned messages of this channel and returns a collection of them. + * @returns {Promise>} + */ + fetchPinnedMessages() { + const Message = __webpack_require__(8); + return this.client.api.channels(this.id).pins.get().then(data => { + const messages = new Collection(); + for (const message of data) { + const msg = new Message(this, message, this.client); + messages.set(message.id, msg); + this._cacheMessage(msg); + } + return messages; + }); + } + + /** + * @typedef {Object} MessageSearchOptions + * @property {string} [content] Message content + * @property {Snowflake} [maxID] Maximum ID for the filter + * @property {Snowflake} [minID] Minimum ID for the filter + * @property {string} [has] One of `link`, `embed`, `file`, `video`, `image`, or `sound`, + * or add `-` to negate (e.g. `-file`) + * @property {ChannelResolvable} [channel] Channel to limit search to (only for guild search endpoint) + * @property {UserResolvable} [author] Author to limit search + * @property {string} [authorType] One of `user`, `bot`, `webhook`, or add `-` to negate (e.g. `-webhook`) + * @property {string} [sortBy='recent'] `recent` or `relevant` + * @property {string} [sortOrder='desc'] `asc` or `desc` + * @property {number} [contextSize=2] How many messages to get around the matched message (0 to 2) + * @property {number} [limit=25] Maximum number of results to get (1 to 25) + * @property {number} [offset=0] Offset the "pages" of results (since you can only see 25 at a time) + * @property {UserResolvable} [mentions] Mentioned user filter + * @property {boolean} [mentionsEveryone] If everyone is mentioned + * @property {string} [linkHostname] Filter links by hostname + * @property {string} [embedProvider] The name of an embed provider + * @property {string} [embedType] one of `image`, `video`, `url`, `rich` + * @property {string} [attachmentFilename] The name of an attachment + * @property {string} [attachmentExtension] The extension of an attachment + * @property {Date} [before] Date to find messages before + * @property {Date} [after] Date to find messages before + * @property {Date} [during] Date to find messages during (range of date to date + 24 hours) + */ + + /** + * Performs a search within the channel. + * This is only available when using a user account. + * @param {MessageSearchOptions} [options={}] Options to pass to the search + * @returns {Promise>} + * An array containing arrays of messages. Each inner array is a search context cluster + * The message which has triggered the result will have the `hit` property set to `true` + * @example + * channel.search({ + * content: 'discord.js', + * before: '2016-11-17' + * }).then(res => { + * const hit = res.messages[0].find(m => m.hit).content; + * console.log(`I found: **${hit}**, total results: ${res.totalResults}`); + * }).catch(console.error); + */ + search(options = {}) { + return Shared.search(this, options); + } + + /** + * Starts a typing indicator in the channel. + * @param {number} [count] The number of times startTyping should be considered to have been called + * @example + * // Start typing in a channel + * channel.startTyping(); + */ + startTyping(count) { + if (typeof count !== 'undefined' && count < 1) throw new RangeError('Count must be at least 1.'); + if (!this.client.user._typing.has(this.id)) { + const endpoint = this.client.api.channels(this.id).typing; + this.client.user._typing.set(this.id, { + count: count || 1, + interval: this.client.setInterval(() => { + endpoint.post(); + }, 9000), + }); + endpoint.post(); + } else { + const entry = this.client.user._typing.get(this.id); + entry.count = count || entry.count + 1; + } + } + + /** + * Stops the typing indicator in the channel. + * The indicator will only stop if this is called as many times as startTyping(). + * It can take a few seconds for the client user to stop typing. + * @param {boolean} [force=false] Whether or not to reset the call count and force the indicator to stop + * @example + * // Stop typing in a channel + * channel.stopTyping(); + * @example + * // Force typing to fully stop in a channel + * channel.stopTyping(true); + */ + stopTyping(force = false) { + if (this.client.user._typing.has(this.id)) { + const entry = this.client.user._typing.get(this.id); + entry.count--; + if (entry.count <= 0 || force) { + this.client.clearInterval(entry.interval); + this.client.user._typing.delete(this.id); + } + } + } + + /** + * Whether or not the typing indicator is being shown in the channel + * @type {boolean} + * @readonly + */ + get typing() { + return this.client.user._typing.has(this.id); + } + + /** + * Number of times `startTyping` has been called + * @type {number} + * @readonly + */ + get typingCount() { + if (this.client.user._typing.has(this.id)) return this.client.user._typing.get(this.id).count; + return 0; + } + + /** + * Creates a Message Collector. + * @param {CollectorFilter} filter The filter to create the collector with + * @param {MessageCollectorOptions} [options={}] The options to pass to the collector + * @returns {MessageCollector} + * @example + * // Create a message collector + * const collector = channel.createCollector( + * m => m.content.includes('discord'), + * { time: 15000 } + * ); + * collector.on('message', m => console.log(`Collected ${m.content}`)); + * collector.on('end', collected => console.log(`Collected ${collected.size} items`)); + */ + createMessageCollector(filter, options = {}) { + return new MessageCollector(this, filter, options); + } + + /** + * An object containing the same properties as CollectorOptions, but a few more: + * @typedef {MessageCollectorOptions} AwaitMessagesOptions + * @property {string[]} [errors] Stop/end reasons that cause the promise to reject + */ + + /** + * Similar to createCollector but in promise form. Resolves with a collection of messages that pass the specified + * filter. + * @param {CollectorFilter} filter The filter function to use + * @param {AwaitMessagesOptions} [options={}] Optional options to pass to the internal collector + * @returns {Promise>} + * @example + * // Await !vote messages + * const filter = m => m.content.startsWith('!vote'); + * // Errors: ['time'] treats ending because of the time limit as an error + * channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] }) + * .then(collected => console.log(collected.size)) + * .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`)); + */ + awaitMessages(filter, options = {}) { + return new Promise((resolve, reject) => { + const collector = this.createMessageCollector(filter, options); + collector.once('end', (collection, reason) => { + if (options.errors && options.errors.includes(reason)) { + reject(collection); + } else { + resolve(collection); + } + }); + }); + } + + /** + * Bulk delete given messages that are newer than two weeks. + * This is only available when using a bot account. + * @param {Collection|Message[]|number} messages Messages or number of messages to delete + * @param {boolean} [filterOld=false] Filter messages to remove those which are older than two weeks automatically + * @returns {Promise>} Deleted messages + */ + bulkDelete(messages, filterOld = false) { + if (!isNaN(messages)) return this.fetchMessages({ limit: messages }).then(msgs => this.bulkDelete(msgs, filterOld)); + if (messages instanceof Array || messages instanceof Collection) { + let messageIDs = messages instanceof Collection ? messages.keyArray() : messages.map(m => m.id); + if (filterOld) { + messageIDs = messageIDs.filter(id => + Date.now() - Snowflake.deconstruct(id).date.getTime() < 1209600000 + ); + } + return this.rest.api.channels(this.id).messages['bulk-delete'] + .post({ data: { messages: messageIDs } }) + .then(() => + this.client.actions.MessageDeleteBulk.handle({ + channel_id: this.id, + ids: messageIDs, + }).messages + ); + } + throw new TypeError('The messages must be an Array, Collection, or number.'); + } + + /** + * Marks all messages in this channel as read. + * This is only available when using a user account. + * @returns {Promise} + */ + acknowledge() { + if (!this.lastMessageID) return Promise.resolve(this); + return this.client.api.channels(this.id).messages(this.lastMessageID) + .post({ data: { token: this.client.rest._ackToken } }) + .then(res => { + if (res.token) this.client.rest._ackToken = res.token; + return this; + }); + } + + _cacheMessage(message) { + const maxSize = this.client.options.messageCacheMaxSize; + if (maxSize === 0) return null; + if (this.messages.size >= maxSize && maxSize > 0) this.messages.delete(this.messages.firstKey()); + this.messages.set(message.id, message); + return message; + } +} + +exports.applyToClass = (structure, full = false, ignore = []) => { + const props = ['send']; + if (full) { + props.push( + '_cacheMessage', + 'acknowledge', + 'fetchMessages', + 'fetchMessage', + 'search', + 'bulkDelete', + 'startTyping', + 'stopTyping', + 'typing', + 'typingCount', + 'fetchPinnedMessages', + 'createMessageCollector', + 'awaitMessages' + ); + } + for (const prop of props) { + if (ignore.includes(prop)) continue; + Object.defineProperty(structure.prototype, prop, Object.getOwnPropertyDescriptor(TextBasedChannel.prototype, prop)); + } +}; + + +/***/ }), +/* 25 */ +/***/ (function(module, exports) { + +exports.endianness = function () { return 'LE' }; + +exports.hostname = function () { + if (typeof location !== 'undefined') { + return location.hostname + } + else return ''; +}; + +exports.loadavg = function () { return [] }; + +exports.uptime = function () { return 0 }; + +exports.freemem = function () { + return Number.MAX_VALUE; +}; + +exports.totalmem = function () { + return Number.MAX_VALUE; +}; + +exports.cpus = function () { return [] }; + +exports.type = function () { return 'Browser' }; + +exports.release = function () { + if (typeof navigator !== 'undefined') { + return navigator.appVersion; + } + return ''; +}; + +exports.networkInterfaces += exports.getNetworkInterfaces += function () { return {} }; + +exports.arch = function () { return 'javascript' }; + +exports.platform = function () { return 'browser' }; + +exports.tmpdir = exports.tmpDir = function () { + return '/tmp'; +}; + +exports.EOL = '\n'; + + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +const Channel = __webpack_require__(16); +const Role = __webpack_require__(20); +const Invite = __webpack_require__(27); const PermissionOverwrites = __webpack_require__(53); -const Permissions = __webpack_require__(8); +const Permissions = __webpack_require__(10); const Collection = __webpack_require__(3); /** @@ -8007,7 +8356,8 @@ class GuildChannel extends Channel { * Overwrites the permissions for a user or role in this channel. * @param {RoleResolvable|UserResolvable} userOrRole The user or role to update * @param {PermissionOverwriteOptions} options The configuration for the update - * @returns {Promise} + * @param {string} [reason] Reason for creating/editing this overwrite + * @returns {Promise} * @example * // Overwrite permissions for a message author * message.channel.overwritePermissions(message.author, { @@ -8016,7 +8366,7 @@ class GuildChannel extends Channel { * .then(() => console.log('Done!')) * .catch(console.error); */ - overwritePermissions(userOrRole, options) { + overwritePermissions(userOrRole, options, reason) { const payload = { allow: 0, deny: 0, @@ -8055,7 +8405,9 @@ class GuildChannel extends Channel { } } - return this.client.rest.methods.setChannelOverwrite(this, payload); + return this.client.api.channels(this.id).permissions(payload.id) + .put({ data: payload, reason }) + .then(() => this); } /** @@ -8071,6 +8423,7 @@ class GuildChannel extends Channel { /** * Edits the channel. * @param {ChannelData} data The new data for the channel + * @param {string} [reason] Reason for editing this channel * @returns {Promise} * @example * // Edit a channel @@ -8078,8 +8431,17 @@ class GuildChannel extends Channel { * .then(c => console.log(`Edited channel ${c}`)) * .catch(console.error); */ - edit(data) { - return this.client.rest.methods.updateChannel(this, data); + edit(data, reason) { + return this.client.api.channels(this.id).patch({ + data: { + name: (data.name || this.name).trim(), + topic: data.topic || this.topic, + position: data.position || this.position, + bitrate: data.bitrate || this.bitrate, + user_limit: data.userLimit || this.userLimit, + }, + reason, + }).then(newData => this.client.actions.ChannelUpdate.handle(newData).updated); } /** @@ -8122,7 +8484,7 @@ class GuildChannel extends Channel { * .catch(console.error); */ setTopic(topic) { - return this.client.rest.methods.updateChannel(this, { topic }); + return this.edit({ topic }); } /** @@ -8138,10 +8500,14 @@ class GuildChannel extends Channel { * kicked after 24 hours if they have not yet received a role * @param {number} [options.maxAge=86400] How long the invite should last (in seconds, 0 for forever) * @param {number} [options.maxUses=0] Maximum number of uses + * @param {string} [reason] Reason for creating this * @returns {Promise} */ - createInvite(options = {}) { - return this.client.rest.methods.createChannelInvite(this, options); + createInvite({ temporary = false, maxAge = 86400, maxUses = 0 }, reason) { + return this.client.api.channels(this.id).invites.post({ data: { + temporary, max_age: maxAge, max_uses: maxUses, + }, reason }) + .then(invite => new Invite(this.client, invite)); } /** @@ -8191,6 +8557,20 @@ class GuildChannel extends Channel { this.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS); } + /** + * Deletes this channel. + * @param {string} [reason] Reason for deleting this channel + * @returns {Promise} + * @example + * // Delete the channel + * channel.delete('making room for new channels') + * .then() // Success + * .catch(console.error); // Log error + */ + delete(reason) { + return this.client.api.channels(this.id).delete({ reason }).then(() => this); + } + /** * When concatenated with a string, this automatically returns the channel's mention instead of the Channel object. * @returns {string} @@ -8210,7 +8590,176 @@ module.exports = GuildChannel; /***/ }), -/* 26 */ +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +const PartialGuild = __webpack_require__(51); +const PartialGuildChannel = __webpack_require__(52); +const Constants = __webpack_require__(0); + +/** + * 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; + + /** + * The approximate number of online members of the guild this invite is for + * @type {number} + */ + this.presenceCount = data.approximate_presence_count; + + /** + * The approximate total number of members of the guild this invite is for + * @type {number} + */ + this.memberCount = data.approximate_member_count; + + /** + * The number of text channels the guild this invite goes to has + * @type {number} + */ + this.textChannelCount = data.guild.text_channel_count; + + /** + * The number of voice channels the guild this invite goes to has + * @type {number} + */ + this.voiceChannelCount = data.guild.voice_channel_count; + + /** + * 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.invite(this.code); + } + + /** + * Deletes this invite. + * @param {string} [reason] Reason for deleting this invite + * @returns {Promise} + */ + delete(reason) { + return this.client.api.invites(this.code).delete({ reason }).then(() => 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; + + +/***/ }), +/* 28 */ /***/ (function(module, exports, __webpack_require__) { const Snowflake = __webpack_require__(6); @@ -8352,7 +8901,8 @@ class OAuth2Application { * @returns {OAuth2Application} */ reset() { - return this.client.rest.methods.resetApplication(this.id); + return this.rest.api.oauth2.applications(this.id).reset.post() + .then(app => new OAuth2Application(this.client, app)); } /** @@ -8368,7 +8918,7 @@ module.exports = OAuth2Application; /***/ }), -/* 27 */ +/* 29 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. @@ -8599,11 +9149,11 @@ var substr = 'ab'.substr(-1) === 'b' /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) /***/ }), -/* 28 */ +/* 30 */ /***/ (function(module, exports, __webpack_require__) { -const Channel = __webpack_require__(14); -const TextBasedChannel = __webpack_require__(22); +const Channel = __webpack_require__(16); +const TextBasedChannel = __webpack_require__(24); const Collection = __webpack_require__(3); /* @@ -8730,16 +9280,17 @@ class GroupDMChannel extends Channel { /** * Add a user to the DM - * @param {UserResolvable|string} accessTokenOrID Access token or user resolvable + * @param {UserResolvable|string} accessTokenOrUser Access token or user resolvable * @param {string} [nick] Permanent nickname to give the user (only available if a bot is creating the DM) + * @returns {Promise} */ - - addUser(accessTokenOrID, nick) { - return this.client.rest.methods.addUserToGroupDM(this, { - nick, - id: this.client.resolver.resolveUserID(accessTokenOrID), - accessToken: accessTokenOrID, - }); + addUser(accessTokenOrUser, nick) { + const id = this.client.resolver.resolveUserID(accessTokenOrUser); + const data = this.client.user.bot ? + { nick, access_token: accessTokenOrUser } : + { recipient: id }; + return this.client.api.channels(this.id).recipients(id).put({ data }) + .then(() => this); } /** @@ -8780,7 +9331,7 @@ module.exports = GroupDMChannel; /***/ }), -/* 29 */ +/* 31 */ /***/ (function(module, exports) { /** @@ -8835,207 +9386,11 @@ module.exports = ReactionEmoji; /***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { - -const path = __webpack_require__(27); - -/** - * Represents a webhook. - */ -class Webhook { - constructor(client, dataOrID, token) { - if (client) { - /** - * The client that instantiated the webhook - * @name Webhook#client - * @type {Client} - * @readonly - */ - Object.defineProperty(this, 'client', { value: client }); - if (dataOrID) this.setup(dataOrID); - } else { - this.id = dataOrID; - this.token = token; - Object.defineProperty(this, 'client', { value: this }); - } - } - - setup(data) { - /** - * The name of the webhook - * @type {string} - */ - this.name = data.name; - - /** - * The token for the webhook - * @type {string} - */ - this.token = data.token; - - /** - * The avatar for the webhook - * @type {string} - */ - this.avatar = data.avatar; - - /** - * The ID of the webhook - * @type {Snowflake} - */ - this.id = data.id; - - /** - * The guild the webhook belongs to - * @type {Snowflake} - */ - this.guildID = data.guild_id; - - /** - * The channel the webhook belongs to - * @type {Snowflake} - */ - this.channelID = data.channel_id; - - if (data.user) { - /** - * The owner of the webhook - * @type {?User|Object} - */ - this.owner = this.client.users ? this.client.users.get(data.user.id) : data.user; - } else { - this.owner = null; - } - } - - /** - * Options that can be passed into send. - * @typedef {Object} WebhookMessageOptions - * @property {string} [username=this.name] Username override for the message - * @property {string} [avatarURL] Avatar URL override for the message - * @property {boolean} [tts=false] Whether or not the message should be spoken aloud - * @property {string} [nonce=''] The nonce for the message - * @property {Object[]} [embeds] An array of embeds for the message - * (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details) - * @property {boolean} [disableEveryone=this.client.options.disableEveryone] Whether or not @everyone and @here - * should be replaced with plain-text - * @property {FileOptions|string} [file] A file to send with the message - * @property {FileOptions[]|string[]} [files] Files to send with the message - * @property {string|boolean} [code] Language for optional codeblock formatting to apply - * @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if - * it exceeds the character limit. If an object is provided, these are the options for splitting the message. - */ - - /** - * Send a message with this webhook. - * @param {StringResolvable} [content] The content to send - * @param {WebhookMessageOptions} [options={}] The options to provide - * @returns {Promise} - * @example - * // Send a message - * webhook.send('hello!') - * .then(message => console.log(`Sent message: ${message.content}`)) - * .catch(console.error); - */ - send(content, options) { - if (!options && typeof content === 'object' && !(content instanceof Array)) { - options = content; - content = ''; - } else if (!options) { - options = {}; - } - - if (options.file) { - if (options.files) options.files.push(options.file); - else options.files = [options.file]; - } - - if (options.files) { - for (let i = 0; i < options.files.length; i++) { - let file = options.files[i]; - if (typeof file === 'string') file = { attachment: file }; - if (!file.name) { - if (typeof file.attachment === 'string') { - file.name = path.basename(file.attachment); - } else if (file.attachment && file.attachment.path) { - file.name = path.basename(file.attachment.path); - } else { - file.name = 'file.jpg'; - } - } - options.files[i] = file; - } - - return Promise.all(options.files.map(file => - this.client.resolver.resolveBuffer(file.attachment).then(buffer => { - file.file = buffer; - return file; - }) - )).then(files => this.client.rest.methods.sendWebhookMessage(this, content, options, files)); - } - - return this.client.rest.methods.sendWebhookMessage(this, content, options); - } - - /** - * Send a raw slack message with this webhook. - * @param {Object} body The raw body to send - * @returns {Promise} - * @example - * // Send a slack message - * webhook.sendSlackMessage({ - * 'username': 'Wumpus', - * 'attachments': [{ - * 'pretext': 'this looks pretty cool', - * 'color': '#F0F', - * 'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png', - * 'footer': 'Powered by sneks', - * 'ts': Date.now() / 1000 - * }] - * }).catch(console.error); - */ - sendSlackMessage(body) { - return this.client.rest.methods.sendSlackWebhookMessage(this, body); - } - - /** - * Edit the webhook. - * @param {string} name The new name for the webhook - * @param {BufferResolvable} avatar The new avatar for the webhook - * @returns {Promise} - */ - edit(name = this.name, avatar) { - if (avatar) { - return this.client.resolver.resolveBuffer(avatar).then(file => { - const dataURI = this.client.resolver.resolveBase64(file); - return this.client.rest.methods.editWebhook(this, name, dataURI); - }); - } - return this.client.rest.methods.editWebhook(this, name).then(data => { - this.setup(data); - return this; - }); - } - - /** - * Delete the webhook. - * @returns {Promise} - */ - delete() { - return this.client.rest.methods.deleteWebhook(this); - } -} - -module.exports = Webhook; - - -/***/ }), -/* 31 */ +/* 32 */ /***/ (function(module, exports, __webpack_require__) { const Collection = __webpack_require__(3); -const EventEmitter = __webpack_require__(12).EventEmitter; +const EventEmitter = __webpack_require__(14).EventEmitter; /** * Filter to be applied to the collector. @@ -9215,7 +9570,7 @@ module.exports = Collector; /***/ }), -/* 32 */ +/* 33 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -9331,7 +9686,7 @@ exports.allocUnsafeSlow = function allocUnsafeSlow(size) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) /***/ }), -/* 33 */ +/* 34 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* @@ -10549,7 +10904,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ /***/ }), -/* 34 */ +/* 35 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10600,18 +10955,18 @@ function nextTick(fn, arg1, arg2, arg3) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) /***/ }), -/* 35 */ +/* 36 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -exports.decode = exports.parse = __webpack_require__(81); -exports.encode = exports.stringify = __webpack_require__(82); +exports.decode = exports.parse = __webpack_require__(83); +exports.encode = exports.stringify = __webpack_require__(84); /***/ }), -/* 36 */ +/* 37 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -10624,7 +10979,7 @@ exports.encode = exports.stringify = __webpack_require__(82); module.exports = Writable; /**/ -var processNextTick = __webpack_require__(34); +var processNextTick = __webpack_require__(35); /**/ /**/ @@ -10638,13 +10993,13 @@ var Duplex; Writable.WritableState = WritableState; /**/ -var util = __webpack_require__(20); -util.inherits = __webpack_require__(10); +var util = __webpack_require__(22); +util.inherits = __webpack_require__(11); /**/ /**/ var internalUtil = { - deprecate: __webpack_require__(101) + deprecate: __webpack_require__(103) }; /**/ @@ -10654,7 +11009,7 @@ var Stream = __webpack_require__(60); var Buffer = __webpack_require__(5).Buffer; /**/ -var bufferShim = __webpack_require__(32); +var bufferShim = __webpack_require__(33); /**/ util.inherits(Writable, Stream); @@ -10669,7 +11024,7 @@ function WriteReq(chunk, encoding, cb) { } function WritableState(options, stream) { - Duplex = Duplex || __webpack_require__(13); + Duplex = Duplex || __webpack_require__(15); options = options || {}; @@ -10803,7 +11158,7 @@ if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.protot } function Writable(options) { - Duplex = Duplex || __webpack_require__(13); + Duplex = Duplex || __webpack_require__(15); // Writable ctor is applied to Duplexes, too. // `realHasInstance` is necessary because using plain `instanceof` @@ -11159,13 +11514,13 @@ function CorkedRequest(state) { } }; } -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7), __webpack_require__(98).setImmediate)) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7), __webpack_require__(100).setImmediate)) /***/ }), -/* 37 */ +/* 38 */ /***/ (function(module, exports, __webpack_require__) { -const Snekfetch = __webpack_require__(92); +const Snekfetch = __webpack_require__(94); // const ENV_VAR = '__SNEKFETCH_SYNC_REQUEST'; // let first = true; @@ -11228,28 +11583,28 @@ module.exports = Snekfetch; /***/ }), -/* 38 */ +/* 39 */ /***/ (function(module, exports) { /***/ }), -/* 39 */ +/* 40 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(27); -const fs = __webpack_require__(38); -const snekfetch = __webpack_require__(37); +/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(29); +const fs = __webpack_require__(39); +const snekfetch = __webpack_require__(38); const Constants = __webpack_require__(0); const convertToBuffer = __webpack_require__(4).convertToBuffer; -const User = __webpack_require__(16); -const Message = __webpack_require__(19); -const Guild = __webpack_require__(24); -const Channel = __webpack_require__(14); -const GuildMember = __webpack_require__(18); +const User = __webpack_require__(12); +const Message = __webpack_require__(8); +const Guild = __webpack_require__(18); +const Channel = __webpack_require__(16); +const GuildMember = __webpack_require__(19); const Emoji = __webpack_require__(17); -const ReactionEmoji = __webpack_require__(29); +const ReactionEmoji = __webpack_require__(31); /** * The DataResolver identifies different objects and tries to resolve a specific piece of information from them, e.g. @@ -11569,7 +11924,7 @@ module.exports = ClientDataResolver; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) /***/ }), -/* 40 */ +/* 41 */ /***/ (function(module, exports) { module.exports = { @@ -11668,13 +12023,17 @@ module.exports = { }; /***/ }), -/* 41 */ +/* 42 */ /***/ (function(module, exports, __webpack_require__) { -const User = __webpack_require__(16); +const User = __webpack_require__(12); const Collection = __webpack_require__(3); -const ClientUserSettings = __webpack_require__(42); +const ClientUserSettings = __webpack_require__(43); const Constants = __webpack_require__(0); +const Util = __webpack_require__(4); +const Guild = __webpack_require__(18); +const Message = __webpack_require__(8); +const GroupDMChannel = __webpack_require__(30); /** * Represents the logged in client's Discord user. @@ -11748,8 +12107,18 @@ class ClientUser extends User { if (data.user_settings) this.settings = new ClientUserSettings(this, data.user_settings); } - edit(data) { - return this.client.rest.methods.updateCurrentUser(data); + edit(data, password) { + const _data = {}; + _data.username = data.username || this.username; + _data.avatar = this.client.resolver.resolveBase64(data.avatar) || this.avatar; + if (!this.bot) { + _data.email = data.email || this.email; + _data.password = password; + if (data.new_password) _data.new_password = data.newPassword; + } + + return this.client.api.users('@me').patch({ data }) + .then(newData => this.client.actions.UserUpdate.handle(newData).updated); } /** @@ -11766,7 +12135,7 @@ class ClientUser extends User { * .catch(console.error); */ setUsername(username, password) { - return this.client.rest.methods.updateCurrentUser({ username }, password); + return this.edit({ username }, password); } /** @@ -11782,7 +12151,7 @@ class ClientUser extends User { * .catch(console.error); */ setEmail(email, password) { - return this.client.rest.methods.updateCurrentUser({ email }, password); + return this.edit({ email }, password); } /** @@ -11798,7 +12167,7 @@ class ClientUser extends User { * .catch(console.error); */ setPassword(newPassword, oldPassword) { - return this.client.rest.methods.updateCurrentUser({ password: newPassword }, oldPassword); + return this.edit({ password: newPassword }, oldPassword); } /** @@ -11813,11 +12182,10 @@ class ClientUser extends User { */ setAvatar(avatar) { if (typeof avatar === 'string' && avatar.startsWith('data:')) { - return this.client.rest.methods.updateCurrentUser({ avatar }); + return this.edit({ avatar }); } else { - return this.client.resolver.resolveBuffer(avatar).then(data => - this.client.rest.methods.updateCurrentUser({ avatar: data }) - ); + return this.client.resolver.resolveBuffer(avatar) + .then(data => this.edit({ avatar: this.client.resolver.resolveBase64(data) || null })); } } @@ -11939,58 +12307,42 @@ class ClientUser extends User { * @returns {Promise} */ fetchMentions(options = {}) { - return this.client.rest.methods.fetchMentions(options); - } + if (options.guild instanceof Guild) options.guild = options.guild.id; + Util.mergeDefault({ limit: 25, roles: true, everyone: true, guild: null }, 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); + return this.client.api.users('@me').mentions.get({ query: options }) + .then(data => data.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client))); } /** * 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 + * @param {Object} [options] Options for the creating + * @param {string} [options.region] The region for the server, defaults to the closest one available + * @param {BufferResolvable|Base64Resolvable} [options.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 }); + createGuild(name, { region, icon = null } = {}) { + if (!icon || (typeof icon === 'string' && icon.startsWith('data:'))) { + return this.client.api.guilds.post({ data: { name, region, icon } }) + .then(data => this.client.dataManager.newGuild(data)); } else { - return this.client.resolver.resolveBuffer(icon).then(data => - this.client.rest.methods.createGuild({ name, icon: data, region }) - ); + return this.client.resolver.resolveBuffer(icon) + .then(data => this.createGuild(name, region, this.client.resolver.resolveBase64(data) || null)); } } /** * 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 + * @property {UserResolvable} [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) + * @property {string} [id] If no user resolveable is provided and you want to assign nicknames + * you must provide user ids instead */ /** @@ -11999,21 +12351,15 @@ class ClientUser extends User { * @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); + const data = this.bot ? { + access_tokens: recipients.map(u => u.accessToken), + nicks: recipients.reduce((o, r) => { + if (r.nick) o[r.user ? r.user.id : r.id] = r.nick; + return o; + }, {}), + } : { recipients: recipients.map(u => this.client.resolver.resolveUserID(u)) }; + return this.client.api.users('@me').channels.post({ data }) + .then(res => new GroupDMChannel(this.client, res)); } } @@ -12021,7 +12367,7 @@ module.exports = ClientUser; /***/ }), -/* 42 */ +/* 43 */ /***/ (function(module, exports, __webpack_require__) { const Constants = __webpack_require__(0); @@ -12059,7 +12405,7 @@ class ClientUserSettings { * @returns {Promise} */ update(name, value) { - return this.user.client.rest.methods.patchUserSettings({ [name]: value }); + return this.user.client.api.users('@me').settings.patch({ data: { [name]: value } }); } /** @@ -12104,11 +12450,11 @@ module.exports = ClientUserSettings; /***/ }), -/* 43 */ +/* 44 */ /***/ (function(module, exports, __webpack_require__) { -const Channel = __webpack_require__(14); -const TextBasedChannel = __webpack_require__(22); +const Channel = __webpack_require__(16); +const TextBasedChannel = __webpack_require__(24); const Collection = __webpack_require__(3); /** @@ -12169,7 +12515,7 @@ module.exports = DMChannel; /***/ }), -/* 44 */ +/* 45 */ /***/ (function(module, exports, __webpack_require__) { const Collection = __webpack_require__(3); @@ -12184,6 +12530,7 @@ const Targets = { WEBHOOK: 'WEBHOOK', EMOJI: 'EMOJI', MESSAGE: 'MESSAGE', + UNKNOWN: 'UNKNOWN', }; const Actions = { @@ -12257,7 +12604,7 @@ class GuildAuditLogs { if (target < 60) return Targets.WEBHOOK; if (target < 70) return Targets.EMOJI; if (target < 80) return Targets.MESSAGE; - return null; + return Targets.UNKNOWN; } @@ -12393,11 +12740,14 @@ class GuildAuditLogsEntry { } } - if ([Targets.USER, Targets.GUILD].includes(targetType)) { + + if (targetType === Targets.UNKNOWN) { /** * The target of this entry - * @type {?Guild|User|Role|Emoji|Invite|Webhook} + * @type {Snowflake|Guild|User|Role|Emoji|Invite|Webhook} */ + this.target = data.target_id; + } else if ([Targets.USER, Targets.GUILD].includes(targetType)) { this.target = guild.client[`${targetType.toLowerCase()}s`].get(data.target_id); } else if (targetType === Targets.WEBHOOK) { this.target = guild.fetchWebhooks() @@ -12445,174 +12795,6 @@ GuildAuditLogs.Entry = GuildAuditLogsEntry; module.exports = GuildAuditLogs; -/***/ }), -/* 45 */ -/***/ (function(module, exports, __webpack_require__) { - -const PartialGuild = __webpack_require__(51); -const PartialGuildChannel = __webpack_require__(52); -const Constants = __webpack_require__(0); - -/** - * 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; - - /** - * The approximate number of online members of the guild this invite is for - * @type {number} - */ - this.presenceCount = data.approximate_presence_count; - - /** - * The approximate total number of members of the guild this invite is for - * @type {number} - */ - this.memberCount = data.approximate_member_count; - - /** - * The number of text channels the guild this invite goes to has - * @type {number} - */ - this.textChannelCount = data.guild.text_channel_count; - - /** - * The number of voice channels the guild this invite goes to has - * @type {number} - */ - this.voiceChannelCount = data.guild.voice_channel_count; - - /** - * 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; - - /***/ }), /* 46 */ /***/ (function(module, exports) { @@ -12691,7 +12873,7 @@ module.exports = MessageAttachment; /* 47 */ /***/ (function(module, exports, __webpack_require__) { -const Collector = __webpack_require__(31); +const Collector = __webpack_require__(32); /** * @typedef {CollectorOptions} MessageCollectorOptions @@ -13313,7 +13495,7 @@ module.exports = MessageMentions; const Collection = __webpack_require__(3); const Emoji = __webpack_require__(17); -const ReactionEmoji = __webpack_require__(29); +const ReactionEmoji = __webpack_require__(31); /** * Represents a reaction to a message. @@ -13374,12 +13556,19 @@ class MessageReaction { * @returns {Promise} */ remove(user = this.message.client.user) { - const message = this.message; const userID = this.message.client.resolver.resolveUserID(user); if (!userID) 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, userID - ); + return this.message.client.api.channels(this.message.channel.id).messages(this.message.id) + .reactions(this.emoji.identifier)[userID === this.message.client.user.id ? '@me' : userID] + .delete() + .then(() => + this.message.client.actions.MessageReactionRemove.handle({ + user_id: userID, + message_id: this.message.id, + emoji: this.emoji, + channel_id: this.message.channel.id, + }).reaction + ); } /** @@ -13389,17 +13578,18 @@ class MessageReaction { */ 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; - }); + return message.client.api.channels(message.channel.id).messages(message.id) + .reactions(this.emoji.identifier) + .get({ query: { limit } }) + .then(users => { + this.users = new Collection(); + for (const rawUser of users) { + const user = message.client.dataManager.newUser(rawUser); + this.users.set(user.id, user); + } + this.count = this.users.size; + return this.users; + }); } } @@ -13552,10 +13742,13 @@ class PermissionOverwrites { /** * Delete this Permission Overwrite. + * @param {string} [reason] Reason for deleting this overwrite * @returns {Promise} */ - delete() { - return this.channel.client.rest.methods.deletePermissionOverwrites(this); + delete(reason) { + return this.channel.client.api.channels(this.channel.id).permissions(this.id) + .delete({ reason }) + .then(() => this); } } @@ -13566,7 +13759,7 @@ module.exports = PermissionOverwrites; /* 54 */ /***/ (function(module, exports, __webpack_require__) { -const Collector = __webpack_require__(31); +const Collector = __webpack_require__(32); const Collection = __webpack_require__(3); /** @@ -13656,8 +13849,9 @@ module.exports = ReactionCollector; /* 55 */ /***/ (function(module, exports, __webpack_require__) { -const GuildChannel = __webpack_require__(25); -const TextBasedChannel = __webpack_require__(22); +const GuildChannel = __webpack_require__(26); +const Webhook = __webpack_require__(21); +const TextBasedChannel = __webpack_require__(24); const Collection = __webpack_require__(3); /** @@ -13714,7 +13908,11 @@ class TextChannel extends GuildChannel { * @returns {Promise>} */ fetchWebhooks() { - return this.client.rest.methods.getChannelWebhooks(this); + return this.client.api.channels(this.id).webhooks.get().then(data => { + const hooks = new Collection(); + for (const hook of data) hooks.set(hook.id, new Webhook(this.client, hook)); + return hooks; + }); } /** @@ -13728,15 +13926,14 @@ class TextChannel extends GuildChannel { * .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)) - ); - } - }); + if (typeof avatar === 'string' && avatar.startsWith('data:')) { + return this.client.api.channels(this.id).webhooks.post({ data: { + name, avatar, + } }).then(data => new Webhook(this.client, data)); + } else { + return this.client.resolver.resolveBuffer(avatar).then(data => + this.createWebhook(name, this.client.resolver.resolveBase64(data) || null)); + } } // These are here only for documentation purposes - they are implemented by TextBasedChannel @@ -13767,7 +13964,7 @@ module.exports = TextChannel; /* 56 */ /***/ (function(module, exports, __webpack_require__) { -const GuildChannel = __webpack_require__(25); +const GuildChannel = __webpack_require__(26); const Collection = __webpack_require__(3); /** @@ -13923,7 +14120,7 @@ module.exports = Array.isArray || function (arr) { module.exports = Readable; /**/ -var processNextTick = __webpack_require__(34); +var processNextTick = __webpack_require__(35); /**/ /**/ @@ -13937,7 +14134,7 @@ var Duplex; Readable.ReadableState = ReadableState; /**/ -var EE = __webpack_require__(12).EventEmitter; +var EE = __webpack_require__(14).EventEmitter; var EElistenerCount = function (emitter, type) { return emitter.listeners(type).length; @@ -13950,16 +14147,16 @@ var Stream = __webpack_require__(60); var Buffer = __webpack_require__(5).Buffer; /**/ -var bufferShim = __webpack_require__(32); +var bufferShim = __webpack_require__(33); /**/ /**/ -var util = __webpack_require__(20); -util.inherits = __webpack_require__(10); +var util = __webpack_require__(22); +util.inherits = __webpack_require__(11); /**/ /**/ -var debugUtil = __webpack_require__(182); +var debugUtil = __webpack_require__(188); var debug = void 0; if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); @@ -13968,7 +14165,7 @@ if (debugUtil && debugUtil.debuglog) { } /**/ -var BufferList = __webpack_require__(85); +var BufferList = __webpack_require__(87); var StringDecoder; util.inherits(Readable, Stream); @@ -13990,7 +14187,7 @@ function prependListener(emitter, event, fn) { } function ReadableState(options, stream) { - Duplex = Duplex || __webpack_require__(13); + Duplex = Duplex || __webpack_require__(15); options = options || {}; @@ -14059,7 +14256,7 @@ function ReadableState(options, stream) { } function Readable(options) { - Duplex = Duplex || __webpack_require__(13); + Duplex = Duplex || __webpack_require__(15); if (!(this instanceof Readable)) return new Readable(options); @@ -14906,11 +15103,11 @@ function indexOf(xs, x) { module.exports = Transform; -var Duplex = __webpack_require__(13); +var Duplex = __webpack_require__(15); /**/ -var util = __webpack_require__(20); -util.inherits = __webpack_require__(10); +var util = __webpack_require__(22); +util.inherits = __webpack_require__(11); /**/ util.inherits(Transform, Duplex); @@ -15047,7 +15244,7 @@ function done(stream, er, data) { /* 60 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(12).EventEmitter; +module.exports = __webpack_require__(14).EventEmitter; /***/ }), @@ -15077,15 +15274,15 @@ module.exports = __webpack_require__(12).EventEmitter; module.exports = Stream; -var EE = __webpack_require__(12).EventEmitter; -var inherits = __webpack_require__(10); +var EE = __webpack_require__(14).EventEmitter; +var inherits = __webpack_require__(11); inherits(Stream, EE); -Stream.Readable = __webpack_require__(21); -Stream.Writable = __webpack_require__(88); -Stream.Duplex = __webpack_require__(83); -Stream.Transform = __webpack_require__(87); -Stream.PassThrough = __webpack_require__(86); +Stream.Readable = __webpack_require__(23); +Stream.Writable = __webpack_require__(90); +Stream.Duplex = __webpack_require__(85); +Stream.Transform = __webpack_require__(89); +Stream.PassThrough = __webpack_require__(88); // Backwards-compat with node 0.4.x Stream.Stream = Stream; @@ -15187,9 +15384,9 @@ Stream.prototype.pipe = function(dest, options) { /* 62 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(global) {var ClientRequest = __webpack_require__(96) -var extend = __webpack_require__(103) -var statusCodes = __webpack_require__(77) +/* WEBPACK VAR INJECTION */(function(global) {var ClientRequest = __webpack_require__(98) +var extend = __webpack_require__(108) +var statusCodes = __webpack_require__(79) var url = __webpack_require__(64) var http = exports @@ -15372,8 +15569,8 @@ xhr = null // Help gc -var punycode = __webpack_require__(80); -var util = __webpack_require__(100); +var punycode = __webpack_require__(82); +var util = __webpack_require__(102); exports.parse = urlParse; exports.resolve = urlResolve; @@ -15448,7 +15645,7 @@ var protocolPattern = /^([a-z0-9.+-]+:)/i, 'gopher:': true, 'file:': true }, - querystring = __webpack_require__(35); + querystring = __webpack_require__(36); function urlParse(url, parseQueryString, slashesDenoteHost) { if (url && util.isObject(url) && url instanceof Url) return url; @@ -16345,8 +16542,8 @@ class DiscordAPIError extends Error { if (obj[k]._errors) { messages.push(`${newKey}: ${obj[k]._errors.map(e => e.message).join(' ')}`); - } else if (obj[k].code && obj[k].message) { - messages.push(`${obj[k].code}: ${obj[k].message}`); + } else if (obj[k].code || obj[k].message) { + messages.push(`${obj[k].code ? `${obj[k].code}: ` : ''}${obj[k].message}`.trim()); } else { messages = messages.concat(this.flattenErrors(obj[k], newKey)); } @@ -16363,11 +16560,11 @@ module.exports = DiscordAPIError; /* 67 */ /***/ (function(module, exports, __webpack_require__) { -const UserAgentManager = __webpack_require__(139); -const RESTMethods = __webpack_require__(136); -const SequentialRequestHandler = __webpack_require__(138); -const BurstRequestHandler = __webpack_require__(137); -const APIRequest = __webpack_require__(135); +const UserAgentManager = __webpack_require__(144); +const SequentialRequestHandler = __webpack_require__(143); +const BurstRequestHandler = __webpack_require__(142); +const APIRequest = __webpack_require__(140); +const mountApi = __webpack_require__(141); const Constants = __webpack_require__(0); class RESTManager { @@ -16375,9 +16572,10 @@ class RESTManager { this.client = client; this.handlers = {}; this.userAgentManager = new UserAgentManager(this); - this.methods = new RESTMethods(this); this.rateLimitedEndpoints = {}; this.globallyRateLimited = false; + + this.api = mountApi(this); } destroy() { @@ -16407,8 +16605,8 @@ class RESTManager { } } - makeRequest(method, url, auth, data, file) { - const apiRequest = new APIRequest(this, method, url, auth, data, file); + request(method, url, options = {}) { + const apiRequest = new APIRequest(this, method, url, options); if (!this.handlers[apiRequest.route]) { const RequestHandlerType = this.getRequestHandler(); this.handlers[apiRequest.route] = new RequestHandlerType(this, apiRequest.route); @@ -16485,14 +16683,14 @@ module.exports = RequestHandler; /* 69 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {const browser = __webpack_require__(23).platform() === 'browser'; -const EventEmitter = __webpack_require__(12); +/* WEBPACK VAR INJECTION */(function(Buffer) {const browser = __webpack_require__(25).platform() === 'browser'; +const EventEmitter = __webpack_require__(14); const Constants = __webpack_require__(0); -const zlib = __webpack_require__(38); -const PacketManager = __webpack_require__(141); +const zlib = __webpack_require__(39); +const PacketManager = __webpack_require__(146); const erlpack = (function findErlpack() { try { - const e = __webpack_require__(186); + const e = __webpack_require__(192); if (!e.pack) return null; return e; } catch (e) { @@ -16503,9 +16701,9 @@ const erlpack = (function findErlpack() { const WebSocket = (function findWebSocket() { if (browser) return window.WebSocket; // eslint-disable-line no-undef try { - return __webpack_require__(187); + return __webpack_require__(193); } catch (e) { - return __webpack_require__(188); + return __webpack_require__(194); } }()); @@ -16990,24 +17188,95 @@ module.exports = WebSocketConnection; /***/ }), /* 70 */ +/***/ (function(module, exports) { + +/** + * Represents a Discord voice region for guilds. + */ +class VoiceRegion { + constructor(data) { + /** + * The ID of the region + * @type {string} + */ + this.id = data.id; + + /** + * Name of the region + * @type {string} + */ + this.name = data.name; + + /** + * Whether the region is VIP-only + * @type {boolean} + */ + this.vip = data.vip; + + /** + * Whether the region is deprecated + * @type {boolean} + */ + this.deprecated = data.deprecated; + + /** + * Whether the region is optimal + * @type {boolean} + */ + this.optimal = data.optimal; + + /** + * Whether the region is custom + * @type {boolean} + */ + this.custom = data.custom; + + /** + * A sample hostname for what a connection might look like + * @type {string} + */ + this.sampleHostname = data.sample_hostname; + } +} + +module.exports = VoiceRegion; + + +/***/ }), +/* 71 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(process) {const os = __webpack_require__(23); -const EventEmitter = __webpack_require__(12).EventEmitter; +module.exports = { + search: __webpack_require__(186), + sendMessage: __webpack_require__(187), +}; + + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {const os = __webpack_require__(25); +const EventEmitter = __webpack_require__(14).EventEmitter; const Constants = __webpack_require__(0); -const Permissions = __webpack_require__(8); +const Permissions = __webpack_require__(10); const Util = __webpack_require__(4); const RESTManager = __webpack_require__(67); -const ClientDataManager = __webpack_require__(104); -const ClientManager = __webpack_require__(105); -const ClientDataResolver = __webpack_require__(39); -const ClientVoiceManager = __webpack_require__(184); -const WebSocketManager = __webpack_require__(140); -const ActionsManager = __webpack_require__(106); +const ClientDataManager = __webpack_require__(109); +const ClientManager = __webpack_require__(110); +const ClientDataResolver = __webpack_require__(40); +const ClientVoiceManager = __webpack_require__(190); +const WebSocketManager = __webpack_require__(145); +const ActionsManager = __webpack_require__(111); const Collection = __webpack_require__(3); -const Presence = __webpack_require__(11).Presence; -const ShardClientUtil = __webpack_require__(183); -const VoiceBroadcast = __webpack_require__(185); +const Presence = __webpack_require__(13).Presence; +const VoiceRegion = __webpack_require__(70); +const Webhook = __webpack_require__(21); +const User = __webpack_require__(12); +const Invite = __webpack_require__(27); +const OAuth2Application = __webpack_require__(28); +const ShardClientUtil = __webpack_require__(189); +const VoiceBroadcast = __webpack_require__(191); /** * The main hub for interacting with the Discord API, and the starting point for any bot. @@ -17038,6 +17307,13 @@ class Client extends EventEmitter { */ this.rest = new RESTManager(this); + /** + * API shortcut + * @type {Object} + * @private + */ + this.api = this.rest.api; + /** * The data manager of the client * @type {ClientDataManager} @@ -17268,7 +17544,11 @@ class Client extends EventEmitter { * client.login('my token'); */ login(token) { - return this.rest.methods.login(token); + return new Promise((resolve, reject) => { + if (typeof token !== 'string') throw new Error(Constants.Errors.INVALID_TOKEN); + token = token.replace(/^Bot\s*/i, ''); + this.manager.connectToWebSocket(token, resolve, reject); + }); } /** @@ -17306,7 +17586,9 @@ class Client extends EventEmitter { */ fetchUser(id, cache = true) { if (this.users.has(id)) return Promise.resolve(this.users.get(id)); - return this.rest.methods.getUser(id, cache); + return this.api.users(id).get().then(data => + cache ? this.dataManager.newUser(data) : new User(this, data) + ); } /** @@ -17316,7 +17598,8 @@ class Client extends EventEmitter { */ fetchInvite(invite) { const code = this.resolver.resolveInviteCode(invite); - return this.rest.methods.getInvite(code); + return this.api.invites(code).get({ query: { with_counts: true } }) + .then(data => new Invite(this, data)); } /** @@ -17326,7 +17609,7 @@ class Client extends EventEmitter { * @returns {Promise} */ fetchWebhook(id, token) { - return this.rest.methods.getWebhook(id, token); + return this.api.webhooks(id, token).get().then(data => new Webhook(this.client, data)); } /** @@ -17334,7 +17617,11 @@ class Client extends EventEmitter { * @returns {Collection} */ fetchVoiceRegions() { - return this.rest.methods.fetchVoiceRegions(); + return this.rest.api.voice.regions.get().then(res => { + const regions = new Collection(); + for (const region of res) regions.set(region.id, new VoiceRegion(region)); + return regions; + }); } /** @@ -17379,7 +17666,8 @@ class Client extends EventEmitter { * @returns {Promise} */ fetchApplication(id = '@me') { - return this.rest.methods.getApplication(id); + return this.rest.api.oauth2.applications(id).get() + .then(app => new OAuth2Application(this.client, app)); } /** @@ -17543,12 +17831,12 @@ module.exports = Client; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) /***/ }), -/* 71 */ +/* 73 */ /***/ (function(module, exports, __webpack_require__) { -const Webhook = __webpack_require__(30); +const Webhook = __webpack_require__(21); const RESTManager = __webpack_require__(67); -const ClientDataResolver = __webpack_require__(39); +const ClientDataResolver = __webpack_require__(40); const Constants = __webpack_require__(0); const Util = __webpack_require__(4); @@ -17582,6 +17870,13 @@ class WebhookClient extends Webhook { */ this.rest = new RESTManager(this); + /** + * API shortcut + * @type {Object} + * @private + */ + this.api = this.rest.api; + /** * The data resolver of the client * @type {ClientDataResolver} @@ -17667,10 +17962,10 @@ module.exports = WebhookClient; /***/ }), -/* 72 */ +/* 74 */ /***/ (function(module, exports, __webpack_require__) { -const ClientDataResolver = __webpack_require__(39); +const ClientDataResolver = __webpack_require__(40); /** * A rich embed to be sent with a message with a fluent interface for creation. @@ -17894,18 +18189,6 @@ function resolveString(data) { } -/***/ }), -/* 73 */ -/***/ (function(module, exports) { - -/* (ignored) */ - -/***/ }), -/* 74 */ -/***/ (function(module, exports) { - -/* (ignored) */ - /***/ }), /* 75 */ /***/ (function(module, exports) { @@ -17914,6 +18197,18 @@ function resolveString(data) { /***/ }), /* 76 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 77 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 78 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18034,7 +18329,7 @@ function fromByteArray (uint8) { /***/ }), -/* 77 */ +/* 79 */ /***/ (function(module, exports) { module.exports = { @@ -18104,7 +18399,7 @@ module.exports = { /***/ }), -/* 78 */ +/* 80 */ /***/ (function(module, exports, __webpack_require__) { var http = __webpack_require__(62); @@ -18124,7 +18419,7 @@ https.request = function (params, cb) { /***/ }), -/* 79 */ +/* 81 */ /***/ (function(module, exports) { exports.read = function (buffer, offset, isLE, mLen, nBytes) { @@ -18214,7 +18509,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { /***/ }), -/* 80 */ +/* 82 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */ @@ -18750,10 +19045,10 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { }(this)); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(102)(module), __webpack_require__(9))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(107)(module), __webpack_require__(9))) /***/ }), -/* 81 */ +/* 83 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18844,7 +19139,7 @@ var isArray = Array.isArray || function (xs) { /***/ }), -/* 82 */ +/* 84 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18936,14 +19231,14 @@ var objectKeys = Object.keys || function (obj) { /***/ }), -/* 83 */ +/* 85 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(13); +module.exports = __webpack_require__(15); /***/ }), -/* 84 */ +/* 86 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18958,8 +19253,8 @@ module.exports = PassThrough; var Transform = __webpack_require__(59); /**/ -var util = __webpack_require__(20); -util.inherits = __webpack_require__(10); +var util = __webpack_require__(22); +util.inherits = __webpack_require__(11); /**/ util.inherits(PassThrough, Transform); @@ -18975,7 +19270,7 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { }; /***/ }), -/* 85 */ +/* 87 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -18983,7 +19278,7 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { var Buffer = __webpack_require__(5).Buffer; /**/ -var bufferShim = __webpack_require__(32); +var bufferShim = __webpack_require__(33); /**/ module.exports = BufferList; @@ -19044,31 +19339,31 @@ BufferList.prototype.concat = function (n) { return ret; }; -/***/ }), -/* 86 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = __webpack_require__(21).PassThrough - - -/***/ }), -/* 87 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = __webpack_require__(21).Transform - - /***/ }), /* 88 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = __webpack_require__(36); +module.exports = __webpack_require__(23).PassThrough /***/ }), /* 89 */ /***/ (function(module, exports, __webpack_require__) { +module.exports = __webpack_require__(23).Transform + + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(37); + + +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { "use strict"; @@ -19259,7 +19554,7 @@ module.exports = __webpack_require__(36); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9), __webpack_require__(7))) /***/ }), -/* 90 */ +/* 92 */ /***/ (function(module, exports) { module.exports = { @@ -19354,11 +19649,11 @@ module.exports = { }; /***/ }), -/* 91 */ +/* 93 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(27); -const mime = __webpack_require__(93); +/* WEBPACK VAR INJECTION */(function(Buffer) {const path = __webpack_require__(29); +const mime = __webpack_require__(95); class FormData { constructor() { @@ -19408,18 +19703,18 @@ module.exports = FormData; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) /***/ }), -/* 92 */ +/* 94 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {__webpack_require__(61); -const zlib = __webpack_require__(38); -const qs = __webpack_require__(35); +const zlib = __webpack_require__(39); +const qs = __webpack_require__(36); const http = __webpack_require__(62); -const https = __webpack_require__(78); +const https = __webpack_require__(80); const URL = __webpack_require__(64); -const Package = __webpack_require__(90); +const Package = __webpack_require__(92); const Stream = __webpack_require__(61); -const FormData = __webpack_require__(91); +const FormData = __webpack_require__(93); class Snekfetch extends Stream.Readable { constructor(method, url, opts = { headers: {}, data: null }) { @@ -19662,11 +19957,11 @@ function makeURLFromRequest(request) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer)) /***/ }), -/* 93 */ +/* 95 */ /***/ (function(module, exports, __webpack_require__) { -const mimes = __webpack_require__(95); -const mimeOfBuffer = __webpack_require__(94); +const mimes = __webpack_require__(97); +const mimeOfBuffer = __webpack_require__(96); function lookupMime(ext) { return mimes[ext] || mimes.bin; @@ -19683,7 +19978,7 @@ module.exports = { /***/ }), -/* 94 */ +/* 96 */ /***/ (function(module, exports) { /* eslint complexity: 0 */ @@ -20235,7 +20530,7 @@ module.exports = mimeOfBuffer; /***/ }), -/* 95 */ +/* 97 */ /***/ (function(module, exports) { module.exports = { @@ -21289,14 +21584,14 @@ module.exports = { }; /***/ }), -/* 96 */ +/* 98 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer, global, process) {var capability = __webpack_require__(63) -var inherits = __webpack_require__(10) -var response = __webpack_require__(97) -var stream = __webpack_require__(21) -var toArrayBuffer = __webpack_require__(99) +var inherits = __webpack_require__(11) +var response = __webpack_require__(99) +var stream = __webpack_require__(23) +var toArrayBuffer = __webpack_require__(101) var IncomingMessage = response.IncomingMessage var rStates = response.readyStates @@ -21602,12 +21897,12 @@ var unsafeHeaders = [ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5).Buffer, __webpack_require__(9), __webpack_require__(7))) /***/ }), -/* 97 */ +/* 99 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process, Buffer, global) {var capability = __webpack_require__(63) -var inherits = __webpack_require__(10) -var stream = __webpack_require__(21) +var inherits = __webpack_require__(11) +var stream = __webpack_require__(23) var rStates = exports.readyStates = { UNSENT: 0, @@ -21791,7 +22086,7 @@ IncomingMessage.prototype._onXHRProgress = function () { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7), __webpack_require__(5).Buffer, __webpack_require__(9))) /***/ }), -/* 98 */ +/* 100 */ /***/ (function(module, exports, __webpack_require__) { var apply = Function.prototype.apply; @@ -21844,13 +22139,13 @@ exports._unrefActive = exports.active = function(item) { }; // setimmediate attaches itself to the global object -__webpack_require__(89); +__webpack_require__(91); exports.setImmediate = setImmediate; exports.clearImmediate = clearImmediate; /***/ }), -/* 99 */ +/* 101 */ /***/ (function(module, exports, __webpack_require__) { var Buffer = __webpack_require__(5).Buffer @@ -21883,7 +22178,7 @@ module.exports = function (buf) { /***/ }), -/* 100 */ +/* 102 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -21906,7 +22201,7 @@ module.exports = { /***/ }), -/* 101 */ +/* 103 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) { @@ -21980,7 +22275,640 @@ function config (name) { /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) /***/ }), -/* 102 */ +/* 104 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 105 */ +/***/ (function(module, exports) { + +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, 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. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; + + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = __webpack_require__(105); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = __webpack_require__(104); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9), __webpack_require__(7))) + +/***/ }), +/* 107 */ /***/ (function(module, exports) { module.exports = function(module) { @@ -22008,7 +22936,7 @@ module.exports = function(module) { /***/ }), -/* 103 */ +/* 108 */ /***/ (function(module, exports) { module.exports = extend @@ -22033,19 +22961,19 @@ function extend() { /***/ }), -/* 104 */ +/* 109 */ /***/ (function(module, exports, __webpack_require__) { const Constants = __webpack_require__(0); const Util = __webpack_require__(4); -const Guild = __webpack_require__(24); -const User = __webpack_require__(16); -const DMChannel = __webpack_require__(43); +const Guild = __webpack_require__(18); +const User = __webpack_require__(12); +const DMChannel = __webpack_require__(44); const Emoji = __webpack_require__(17); const TextChannel = __webpack_require__(55); const VoiceChannel = __webpack_require__(56); -const GuildChannel = __webpack_require__(25); -const GroupDMChannel = __webpack_require__(28); +const GuildChannel = __webpack_require__(26); +const GroupDMChannel = __webpack_require__(30); class ClientDataManager { constructor(client) { @@ -22169,7 +23097,7 @@ module.exports = ClientDataManager; /***/ }), -/* 105 */ +/* 110 */ /***/ (function(module, exports, __webpack_require__) { const Constants = __webpack_require__(0); @@ -22212,7 +23140,7 @@ class ClientManager { this.client.emit(Constants.Events.DEBUG, `Authenticated using token ${token}`); this.client.token = token; const timeout = this.client.setTimeout(() => reject(new Error(Constants.Errors.TOOK_TOO_LONG)), 1000 * 300); - this.client.rest.methods.getGateway().then(res => { + this.client.api.gateway.get().then(res => { const protocolVersion = Constants.DefaultOptions.ws.version; const gateway = `${res.url}/?v=${protocolVersion}&encoding=${WebSocketConnection.ENCODING}`; this.client.emit(Constants.Events.DEBUG, `Using gateway ${gateway}`); @@ -22237,7 +23165,7 @@ class ClientManager { this.client.token = null; return Promise.resolve(); } else { - return this.client.rest.methods.logout().then(() => { + return this.client.api.logout.post().then(() => { this.client.token = null; }); } @@ -22248,41 +23176,41 @@ module.exports = ClientManager; /***/ }), -/* 106 */ +/* 111 */ /***/ (function(module, exports, __webpack_require__) { class ActionsManager { constructor(client) { this.client = client; + this.register(__webpack_require__(130)); + this.register(__webpack_require__(131)); + this.register(__webpack_require__(132)); + this.register(__webpack_require__(136)); + this.register(__webpack_require__(133)); + this.register(__webpack_require__(134)); + this.register(__webpack_require__(135)); + this.register(__webpack_require__(112)); + this.register(__webpack_require__(113)); + this.register(__webpack_require__(114)); + this.register(__webpack_require__(117)); + this.register(__webpack_require__(129)); + this.register(__webpack_require__(122)); + this.register(__webpack_require__(123)); + this.register(__webpack_require__(115)); + this.register(__webpack_require__(124)); this.register(__webpack_require__(125)); this.register(__webpack_require__(126)); - this.register(__webpack_require__(127)); - this.register(__webpack_require__(131)); + this.register(__webpack_require__(137)); + this.register(__webpack_require__(139)); + this.register(__webpack_require__(138)); this.register(__webpack_require__(128)); - this.register(__webpack_require__(129)); - this.register(__webpack_require__(130)); - this.register(__webpack_require__(107)); - this.register(__webpack_require__(108)); - this.register(__webpack_require__(109)); - this.register(__webpack_require__(112)); - this.register(__webpack_require__(124)); - this.register(__webpack_require__(117)); this.register(__webpack_require__(118)); - this.register(__webpack_require__(110)); this.register(__webpack_require__(119)); this.register(__webpack_require__(120)); this.register(__webpack_require__(121)); - this.register(__webpack_require__(132)); - this.register(__webpack_require__(134)); - this.register(__webpack_require__(133)); - this.register(__webpack_require__(123)); - this.register(__webpack_require__(113)); - this.register(__webpack_require__(114)); - this.register(__webpack_require__(115)); + this.register(__webpack_require__(127)); this.register(__webpack_require__(116)); - this.register(__webpack_require__(122)); - this.register(__webpack_require__(111)); } register(Action) { @@ -22294,7 +23222,7 @@ module.exports = ActionsManager; /***/ }), -/* 107 */ +/* 112 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22311,7 +23239,7 @@ module.exports = ChannelCreateAction; /***/ }), -/* 108 */ +/* 113 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22346,7 +23274,7 @@ module.exports = ChannelDeleteAction; /***/ }), -/* 109 */ +/* 114 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22386,7 +23314,7 @@ module.exports = ChannelUpdateAction; /***/ }), -/* 110 */ +/* 115 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22405,7 +23333,7 @@ module.exports = GuildBanRemove; /***/ }), -/* 111 */ +/* 116 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22430,7 +23358,7 @@ module.exports = GuildChannelsPositionUpdate; /***/ }), -/* 112 */ +/* 117 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22489,7 +23417,7 @@ module.exports = GuildDeleteAction; /***/ }), -/* 113 */ +/* 118 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22512,7 +23440,7 @@ module.exports = GuildEmojiCreateAction; /***/ }), -/* 114 */ +/* 119 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22535,7 +23463,7 @@ module.exports = GuildEmojiDeleteAction; /***/ }), -/* 115 */ +/* 120 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22558,7 +23486,7 @@ module.exports = GuildEmojiUpdateAction; /***/ }), -/* 116 */ +/* 121 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22602,7 +23530,7 @@ module.exports = GuildEmojisUpdateAction; /***/ }), -/* 117 */ +/* 122 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22618,7 +23546,7 @@ module.exports = GuildMemberGetAction; /***/ }), -/* 118 */ +/* 123 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22664,12 +23592,12 @@ module.exports = GuildMemberRemoveAction; /***/ }), -/* 119 */ +/* 124 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); const Constants = __webpack_require__(0); -const Role = __webpack_require__(15); +const Role = __webpack_require__(20); class GuildRoleCreate extends Action { handle(data) { @@ -22696,7 +23624,7 @@ module.exports = GuildRoleCreate; /***/ }), -/* 120 */ +/* 125 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22743,7 +23671,7 @@ module.exports = GuildRoleDeleteAction; /***/ }), -/* 121 */ +/* 126 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22790,7 +23718,7 @@ module.exports = GuildRoleUpdateAction; /***/ }), -/* 122 */ +/* 127 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22815,7 +23743,7 @@ module.exports = GuildRolesPositionUpdate; /***/ }), -/* 123 */ +/* 128 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22850,7 +23778,7 @@ module.exports = GuildSync; /***/ }), -/* 124 */ +/* 129 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22890,11 +23818,11 @@ module.exports = GuildUpdateAction; /***/ }), -/* 125 */ +/* 130 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); -const Message = __webpack_require__(19); +const Message = __webpack_require__(8); class MessageCreateAction extends Action { handle(data) { @@ -22951,7 +23879,7 @@ module.exports = MessageCreateAction; /***/ }), -/* 126 */ +/* 131 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -22991,7 +23919,7 @@ module.exports = MessageDeleteAction; /***/ }), -/* 127 */ +/* 132 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23019,7 +23947,7 @@ module.exports = MessageDeleteBulkAction; /***/ }), -/* 128 */ +/* 133 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23062,7 +23990,7 @@ module.exports = MessageReactionAdd; /***/ }), -/* 129 */ +/* 134 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23105,7 +24033,7 @@ module.exports = MessageReactionRemove; /***/ }), -/* 130 */ +/* 135 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23136,7 +24064,7 @@ module.exports = MessageReactionRemoveAll; /***/ }), -/* 131 */ +/* 136 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23182,7 +24110,7 @@ module.exports = MessageUpdateAction; /***/ }), -/* 132 */ +/* 137 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23199,7 +24127,7 @@ module.exports = UserGetAction; /***/ }), -/* 133 */ +/* 138 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23235,7 +24163,7 @@ module.exports = UserNoteUpdateAction; /***/ }), -/* 134 */ +/* 139 */ /***/ (function(module, exports, __webpack_require__) { const Action = __webpack_require__(2); @@ -23274,22 +24202,21 @@ module.exports = UserUpdateAction; /***/ }), -/* 135 */ +/* 140 */ /***/ (function(module, exports, __webpack_require__) { -const snekfetch = __webpack_require__(37); +const querystring = __webpack_require__(36); +const snekfetch = __webpack_require__(38); const Constants = __webpack_require__(0); class APIRequest { - constructor(rest, method, path, auth, data, files) { + constructor(rest, method, path, options) { this.rest = rest; this.client = rest.client; this.method = method; this.path = path.toString(); - this.auth = auth; - this.data = data; - this.files = files; this.route = this.getRoute(this.path); + this.options = options; } getRoute(url) { @@ -23313,14 +24240,23 @@ class APIRequest { gen() { const API = `${this.client.options.http.host}/api/v${this.client.options.http.version}`; + + if (this.options.query) { + const queryString = (querystring.stringify(this.options.query).match(/[^=&?]+=[^=&?]+/g) || []).join('&'); + this.path += `?${queryString}`; + } + const request = snekfetch[this.method](`${API}${this.path}`); - if (this.auth) request.set('Authorization', this.getAuth()); + + if (this.options.auth !== false) request.set('Authorization', this.getAuth()); + if (this.options.reason) request.set('X-Audit-Log-Reason', this.options.reason); if (!this.rest.client.browser) request.set('User-Agent', this.rest.userAgentManager.userAgent); - if (this.files) { - for (const file of this.files) if (file && file.file) request.attach(file.name, file.file, file.name); - if (typeof this.data !== 'undefined') request.attach('payload_json', JSON.stringify(this.data)); - } else if (this.data) { - request.send(this.data); + + if (this.options.files) { + for (const file of this.options.files) if (file && file.file) request.attach(file.name, file.file, file.name); + if (typeof this.options.data !== 'undefined') request.attach('payload_json', JSON.stringify(this.options.data)); + } else if (typeof this.options.data !== 'undefined') { + request.send(this.options.data); } return request; } @@ -23330,916 +24266,52 @@ module.exports = APIRequest; /***/ }), -/* 136 */ +/* 141 */ /***/ (function(module, exports, __webpack_require__) { -const querystring = __webpack_require__(35); -const long = __webpack_require__(33); -const Permissions = __webpack_require__(8); -const Constants = __webpack_require__(0); -const Endpoints = Constants.Endpoints; -const Collection = __webpack_require__(3); -const Snowflake = __webpack_require__(6); -const Util = __webpack_require__(4); +const util = __webpack_require__(106); -const User = __webpack_require__(16); -const GuildMember = __webpack_require__(18); -const Message = __webpack_require__(19); -const Role = __webpack_require__(15); -const Invite = __webpack_require__(45); -const Webhook = __webpack_require__(30); -const UserProfile = __webpack_require__(180); -const OAuth2Application = __webpack_require__(26); -const Channel = __webpack_require__(14); -const GroupDMChannel = __webpack_require__(28); -const Guild = __webpack_require__(24); -const VoiceRegion = __webpack_require__(181); -const GuildAuditLogs = __webpack_require__(44); +const methods = ['get', 'post', 'delete', 'patch', 'put']; +// Paramable exists so we don't return a function unless we actually need one #savingmemory +const paramable = [ + 'channels', 'users', 'guilds', 'members', + 'bans', 'emojis', 'pins', 'permissions', + 'reactions', 'webhooks', 'messages', + 'notes', 'roles', 'applications', + 'invites', +]; +const reflectors = ['toString', 'valueOf', 'inspect', Symbol.toPrimitive, util.inspect.custom]; -class RESTMethods { - constructor(restManager) { - this.rest = restManager; - this.client = restManager.client; - this._ackToken = null; - } - - login(token = this.client.token) { - return new Promise((resolve, reject) => { - if (typeof token !== 'string') throw new Error(Constants.Errors.INVALID_TOKEN); - token = token.replace(/^Bot\s*/i, ''); - this.client.manager.connectToWebSocket(token, resolve, reject); - }); - } - - logout() { - return this.rest.makeRequest('post', Endpoints.logout, true, {}); - } - - getGateway(bot = false) { - return this.rest.makeRequest('get', bot ? Endpoints.gateway.bot : Endpoints.gateway, true); - } - - fetchVoiceRegions(guildID) { - let endpoint; - if (guildID) endpoint = Endpoints.Guild(guildID).voiceRegions; - else endpoint = Endpoints.voiceRegions; - return this.rest.makeRequest('get', endpoint, true).then(res => { - const regions = new Collection(); - for (const region of res) regions.set(region.id, new VoiceRegion(region)); - return regions; - }); - } - - sendMessage(channel, content, { tts, nonce, embed, disableEveryone, split, code, reply } = {}, files = null) { - return new Promise((resolve, reject) => { // eslint-disable-line complexity - if (typeof content !== 'undefined') content = this.client.resolver.resolveString(content); - - // The nonce has to be a uint64 :< - if (typeof nonce !== 'undefined') { - nonce = parseInt(nonce); - if (isNaN(nonce) || nonce < 0) throw new RangeError('Message nonce must fit in an unsigned 64-bit integer.'); - } - - if (content) { - if (split && typeof split !== 'object') split = {}; - - // Wrap everything in a code block - if (typeof code !== 'undefined' && (typeof code !== 'boolean' || code === true)) { - content = Util.escapeMarkdown(this.client.resolver.resolveString(content), true); - content = `\`\`\`${typeof code !== 'boolean' ? code || '' : ''}\n${content}\n\`\`\``; - if (split) { - split.prepend = `\`\`\`${typeof code !== 'boolean' ? code || '' : ''}\n`; - split.append = '\n```'; +module.exports = restManager => { + const handler = { + get(list, name) { + if (reflectors.includes(name)) return () => list.join('/'); + if (paramable.includes(name)) { + function toReturn(...args) { // eslint-disable-line no-inner-declarations + list = list.concat(name); + for (const arg of args) { + if (arg !== null && typeof arg !== 'undefined') list = list.concat(arg); } + return new Proxy(list, handler); } - - // Add zero-width spaces to @everyone/@here - if (disableEveryone || (typeof disableEveryone === 'undefined' && this.client.options.disableEveryone)) { - content = content.replace(/@(everyone|here)/g, '@\u200b$1'); + const directJoin = () => `${list.join('/')}/${name}`; + for (const r of reflectors) toReturn[r] = directJoin; + for (const method of methods) { + toReturn[method] = options => restManager.request(method, `${list.join('/')}/${name}`, options); } - - // Add the reply prefix - if (reply && !(channel instanceof User || channel instanceof GuildMember) && channel.type !== 'dm') { - const id = this.client.resolver.resolveUserID(reply); - const mention = `<@${reply instanceof GuildMember && reply.nickname ? '!' : ''}${id}>`; - content = `${mention}${content ? `, ${content}` : ''}`; - if (split) split.prepend = `${mention}, ${split.prepend || ''}`; - } - - // Split the content - if (split) content = Util.splitMessage(content, split); - } else if (reply && !(channel instanceof User || channel instanceof GuildMember) && channel.type !== 'dm') { - const id = this.client.resolver.resolveUserID(reply); - content = `<@${reply instanceof GuildMember && reply.nickname ? '!' : ''}${id}>`; + return toReturn; } + if (methods.includes(name)) return options => restManager.request(name, list.join('/'), options); + return new Proxy(list.concat(name), handler); + }, + }; - const send = chan => { - if (content instanceof Array) { - const messages = []; - (function sendChunk(list, index) { - const options = index === list.length ? { tts, embed } : { tts }; - chan.send(list[index], options, index === list.length ? files : null).then(message => { - messages.push(message); - if (index >= list.length - 1) return resolve(messages); - return sendChunk(list, ++index); - }); - }(content, 0)); - } else { - this.rest.makeRequest('post', Endpoints.Channel(chan).messages, true, { - content, tts, nonce, embed, - }, files).then(data => resolve(this.client.actions.MessageCreate.handle(data).message), reject); - } - }; - - if (channel instanceof User || channel instanceof GuildMember) this.createDM(channel).then(send, reject); - else send(channel); - }); - } - - updateMessage(message, content, { embed, code, reply } = {}) { - if (typeof content !== 'undefined') content = this.client.resolver.resolveString(content); - - // Wrap everything in a code block - if (typeof code !== 'undefined' && (typeof code !== 'boolean' || code === true)) { - content = Util.escapeMarkdown(this.client.resolver.resolveString(content), true); - content = `\`\`\`${typeof code !== 'boolean' ? code || '' : ''}\n${content}\n\`\`\``; - } - - // Add the reply prefix - if (reply && message.channel.type !== 'dm') { - const id = this.client.resolver.resolveUserID(reply); - const mention = `<@${reply instanceof GuildMember && reply.nickname ? '!' : ''}${id}>`; - content = `${mention}${content ? `, ${content}` : ''}`; - } - - return this.rest.makeRequest('patch', Endpoints.Message(message), true, { - content, embed, - }).then(data => this.client.actions.MessageUpdate.handle(data).updated); - } - - deleteMessage(message) { - return this.rest.makeRequest('delete', Endpoints.Message(message), true) - .then(() => - this.client.actions.MessageDelete.handle({ - id: message.id, - channel_id: message.channel.id, - }).message - ); - } - - ackMessage(message) { - return this.rest.makeRequest('post', Endpoints.Message(message).ack, true, { token: this._ackToken }).then(res => { - if (res.token) this._ackToken = res.token; - return message; - }); - } - - ackTextChannel(channel) { - return this.rest.makeRequest('post', Endpoints.Channel(channel).Message(channel.lastMessageID).ack, true, { - token: this._ackToken, - }).then(res => { - if (res.token) this._ackToken = res.token; - return channel; - }); - } - - ackGuild(guild) { - return this.rest.makeRequest('post', Endpoints.Guild(guild).ack, true).then(() => guild); - } - - bulkDeleteMessages(channel, messages, filterOld) { - if (filterOld) { - messages = messages.filter(id => - Date.now() - Snowflake.deconstruct(id).date.getTime() < 1209600000 - ); - } - return this.rest.makeRequest('post', Endpoints.Channel(channel).messages.bulkDelete, true, { - messages, - }).then(() => - this.client.actions.MessageDeleteBulk.handle({ - channel_id: channel.id, - ids: messages, - }).messages - ); - } - - search(target, options) { - if (typeof options === 'string') options = { content: options }; - if (options.before) { - if (!(options.before instanceof Date)) options.before = new Date(options.before); - options.maxID = long.fromNumber(options.before.getTime() - 14200704e5).shiftLeft(22).toString(); - } - if (options.after) { - if (!(options.after instanceof Date)) options.after = new Date(options.after); - options.minID = long.fromNumber(options.after.getTime() - 14200704e5).shiftLeft(22).toString(); - } - if (options.during) { - if (!(options.during instanceof Date)) options.during = new Date(options.during); - const t = options.during.getTime() - 14200704e5; - options.minID = long.fromNumber(t).shiftLeft(22).toString(); - options.maxID = long.fromNumber(t + 86400000).shiftLeft(22).toString(); - } - if (options.channel) options.channel = this.client.resolver.resolveChannelID(options.channel); - if (options.author) options.author = this.client.resolver.resolveUserID(options.author); - if (options.mentions) options.mentions = this.client.resolver.resolveUserID(options.options.mentions); - options = { - content: options.content, - max_id: options.maxID, - min_id: options.minID, - has: options.has, - channel_id: options.channel, - author_id: options.author, - author_type: options.authorType, - context_size: options.contextSize, - sort_by: options.sortBy, - sort_order: options.sortOrder, - limit: options.limit, - offset: options.offset, - mentions: options.mentions, - mentions_everyone: options.mentionsEveryone, - link_hostname: options.linkHostname, - embed_provider: options.embedProvider, - embed_type: options.embedType, - attachment_filename: options.attachmentFilename, - attachment_extension: options.attachmentExtension, - }; - - for (const key in options) if (options[key] === undefined) delete options[key]; - const queryString = (querystring.stringify(options).match(/[^=&?]+=[^=&?]+/g) || []).join('&'); - - let endpoint; - if (target instanceof Channel) { - endpoint = Endpoints.Channel(target).search; - } else if (target instanceof Guild) { - endpoint = Endpoints.Guild(target).search; - } else { - throw new TypeError('Target must be a TextChannel, DMChannel, GroupDMChannel, or Guild.'); - } - return this.rest.makeRequest('get', `${endpoint}?${queryString}`, true).then(body => { - const messages = body.messages.map(x => - x.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client)) - ); - return { - totalResults: body.total_results, - messages, - }; - }); - } - - createChannel(guild, channelName, channelType, overwrites) { - if (overwrites instanceof Collection) overwrites = overwrites.array(); - return this.rest.makeRequest('post', Endpoints.Guild(guild).channels, true, { - name: channelName, - type: channelType, - permission_overwrites: overwrites, - }).then(data => this.client.actions.ChannelCreate.handle(data).channel); - } - - createDM(recipient) { - const dmChannel = this.getExistingDM(recipient); - if (dmChannel) return Promise.resolve(dmChannel); - return this.rest.makeRequest('post', Endpoints.User(this.client.user).channels, true, { - recipient_id: recipient.id, - }).then(data => this.client.actions.ChannelCreate.handle(data).channel); - } - - createGroupDM(options) { - const data = this.client.user.bot ? - { access_tokens: options.accessTokens, nicks: options.nicks } : - { recipients: options.recipients }; - return this.rest.makeRequest('post', Endpoints.User('@me').channels, true, data) - .then(res => new GroupDMChannel(this.client, res)); - } - - addUserToGroupDM(channel, options) { - const data = this.client.user.bot ? - { nick: options.nick, access_token: options.accessToken } : - { recipient: options.id }; - return this.rest.makeRequest('put', Endpoints.Channel(channel).Recipient(options.id), true, data) - .then(() => channel); - } - - getExistingDM(recipient) { - return this.client.channels.find(channel => - channel.recipient && channel.recipient.id === recipient.id - ); - } - - deleteChannel(channel) { - if (channel instanceof User || channel instanceof GuildMember) channel = this.getExistingDM(channel); - if (!channel) return Promise.reject(new Error('No channel to delete.')); - return this.rest.makeRequest('delete', Endpoints.Channel(channel), true).then(data => { - data.id = channel.id; - return this.client.actions.ChannelDelete.handle(data).channel; - }); - } - - updateChannel(channel, _data) { - const data = {}; - data.name = (_data.name || channel.name).trim(); - data.topic = _data.topic || channel.topic; - data.position = _data.position || channel.position; - data.bitrate = _data.bitrate || channel.bitrate; - data.user_limit = _data.userLimit || channel.userLimit; - return this.rest.makeRequest('patch', Endpoints.Channel(channel), true, data).then(newData => - this.client.actions.ChannelUpdate.handle(newData).updated - ); - } - - leaveGuild(guild) { - if (guild.ownerID === this.client.user.id) return Promise.reject(new Error('Guild is owned by the client.')); - return this.rest.makeRequest('delete', Endpoints.User('@me').Guild(guild.id), true).then(() => - this.client.actions.GuildDelete.handle({ id: guild.id }).guild - ); - } - - createGuild(options) { - options.icon = this.client.resolver.resolveBase64(options.icon) || null; - options.region = options.region || 'us-central'; - return new Promise((resolve, reject) => { - this.rest.makeRequest('post', Endpoints.guilds, true, options).then(data => { - if (this.client.guilds.has(data.id)) return resolve(this.client.guilds.get(data.id)); - - const handleGuild = guild => { - if (guild.id === data.id) { - this.client.removeListener(Constants.Events.GUILD_CREATE, handleGuild); - this.client.clearTimeout(timeout); - resolve(guild); - } - }; - this.client.on(Constants.Events.GUILD_CREATE, handleGuild); - - const timeout = this.client.setTimeout(() => { - this.client.removeListener(Constants.Events.GUILD_CREATE, handleGuild); - reject(new Error('Took too long to receive guild data.')); - }, 10000); - return undefined; - }, reject); - }); - } - - // Untested but probably will work - deleteGuild(guild) { - return this.rest.makeRequest('delete', Endpoints.Guild(guild), true).then(() => - this.client.actions.GuildDelete.handle({ id: guild.id }).guild - ); - } - - getUser(userID, cache) { - return this.rest.makeRequest('get', Endpoints.User(userID), true).then(data => { - if (cache) return this.client.actions.UserGet.handle(data).user; - else return new User(this.client, data); - }); - } - - updateCurrentUser(_data, password) { - const user = this.client.user; - const data = {}; - data.username = _data.username || user.username; - data.avatar = this.client.resolver.resolveBase64(_data.avatar) || user.avatar; - if (!user.bot) { - data.email = _data.email || user.email; - data.password = password; - if (_data.new_password) data.new_password = _data.newPassword; - } - return this.rest.makeRequest('patch', Endpoints.User('@me'), true, data).then(newData => - this.client.actions.UserUpdate.handle(newData).updated - ); - } - - updateGuild(guild, _data) { - const data = {}; - if (_data.name) data.name = _data.name; - if (_data.region) data.region = _data.region; - if (_data.verificationLevel) data.verification_level = Number(_data.verificationLevel); - if (_data.afkChannel) data.afk_channel_id = this.client.resolver.resolveChannel(_data.afkChannel).id; - if (_data.afkTimeout) data.afk_timeout = Number(_data.afkTimeout); - if (_data.icon) data.icon = this.client.resolver.resolveBase64(_data.icon); - if (_data.owner) data.owner_id = this.client.resolver.resolveUser(_data.owner).id; - if (_data.splash) data.splash = this.client.resolver.resolveBase64(_data.splash); - return this.rest.makeRequest('patch', Endpoints.Guild(guild), true, data).then(newData => - this.client.actions.GuildUpdate.handle(newData).updated - ); - } - - kickGuildMember(guild, member, reason) { - const url = `${Endpoints.Guild(guild).Member(member)}?reason=${reason}`; - return this.rest.makeRequest('delete', url, true).then(() => - this.client.actions.GuildMemberRemove.handle({ - guild_id: guild.id, - user: member.user, - }).member - ); - } - - createGuildRole(guild, data) { - if (data.color) data.color = this.client.resolver.resolveColor(data.color); - if (data.permissions) data.permissions = Permissions.resolve(data.permissions); - return this.rest.makeRequest('post', Endpoints.Guild(guild).roles, true, data).then(role => - this.client.actions.GuildRoleCreate.handle({ - guild_id: guild.id, - role, - }).role - ); - } - - deleteGuildRole(role) { - return this.rest.makeRequest('delete', Endpoints.Guild(role.guild).Role(role.id), true).then(() => - this.client.actions.GuildRoleDelete.handle({ - guild_id: role.guild.id, - role_id: role.id, - }).role - ); - } - - setChannelOverwrite(channel, payload) { - return this.rest.makeRequest('put', `${Endpoints.Channel(channel).permissions}/${payload.id}`, true, payload); - } - - deletePermissionOverwrites(overwrite) { - return this.rest.makeRequest( - 'delete', `${Endpoints.Channel(overwrite.channel).permissions}/${overwrite.id}`, true - ).then(() => overwrite); - } - - getChannelMessages(channel, payload = {}) { - const params = []; - if (payload.limit) params.push(`limit=${payload.limit}`); - if (payload.around) params.push(`around=${payload.around}`); - else if (payload.before) params.push(`before=${payload.before}`); - else if (payload.after) params.push(`after=${payload.after}`); - - let endpoint = Endpoints.Channel(channel).messages; - if (params.length > 0) endpoint += `?${params.join('&')}`; - return this.rest.makeRequest('get', endpoint, true); - } - - getChannelMessage(channel, messageID) { - const msg = channel.messages.get(messageID); - if (msg) return Promise.resolve(msg); - return this.rest.makeRequest('get', Endpoints.Channel(channel).Message(messageID), true); - } - - putGuildMember(guild, user, options) { - options.access_token = options.accessToken; - if (options.roles) { - const roles = options.roles; - if (roles instanceof Collection || (roles instanceof Array && roles[0] instanceof Role)) { - options.roles = roles.map(role => role.id); - } - } - return this.rest.makeRequest('put', Endpoints.Guild(guild).Member(user.id), true, options) - .then(data => this.client.actions.GuildMemberGet.handle(guild, data).member); - } - - getGuildMember(guild, user, cache) { - return this.rest.makeRequest('get', Endpoints.Guild(guild).Member(user.id), true).then(data => { - if (cache) return this.client.actions.GuildMemberGet.handle(guild, data).member; - else return new GuildMember(guild, data); - }); - } - - updateGuildMember(member, data) { - if (data.channel) { - data.channel_id = this.client.resolver.resolveChannel(data.channel).id; - data.channel = null; - } - if (data.roles) data.roles = data.roles.map(role => role instanceof Role ? role.id : role); - - let endpoint = Endpoints.Member(member); - // Fix your endpoints, discord ;-; - if (member.id === this.client.user.id) { - const keys = Object.keys(data); - if (keys.length === 1 && keys[0] === 'nick') { - endpoint = Endpoints.Member(member).nickname; - } - } - - return this.rest.makeRequest('patch', endpoint, true, data).then(newData => - member.guild._updateMember(member, newData).mem - ); - } - - addMemberRole(member, role) { - return new Promise((resolve, reject) => { - if (member._roles.includes(role.id)) return resolve(member); - - const listener = (oldMember, newMember) => { - if (!oldMember._roles.includes(role.id) && newMember._roles.includes(role.id)) { - this.client.removeListener(Constants.Events.GUILD_MEMBER_UPDATE, listener); - resolve(newMember); - } - }; - - this.client.on(Constants.Events.GUILD_MEMBER_UPDATE, listener); - const timeout = this.client.setTimeout(() => - this.client.removeListener(Constants.Events.GUILD_MEMBER_UPDATE, listener), 10e3); - - return this.rest.makeRequest('put', Endpoints.Member(member).Role(role.id), true).catch(err => { - this.client.removeListener(Constants.Events.GUILD_BAN_REMOVE, listener); - this.client.clearTimeout(timeout); - reject(err); - }); - }); - } - - removeMemberRole(member, role) { - return new Promise((resolve, reject) => { - if (!member._roles.includes(role.id)) return resolve(member); - - const listener = (oldMember, newMember) => { - if (oldMember._roles.includes(role.id) && !newMember._roles.includes(role.id)) { - this.client.removeListener(Constants.Events.GUILD_MEMBER_UPDATE, listener); - resolve(newMember); - } - }; - - this.client.on(Constants.Events.GUILD_MEMBER_UPDATE, listener); - const timeout = this.client.setTimeout(() => - this.client.removeListener(Constants.Events.GUILD_MEMBER_UPDATE, listener), 10e3); - - return this.rest.makeRequest('delete', Endpoints.Member(member).Role(role.id), true).catch(err => { - this.client.removeListener(Constants.Events.GUILD_BAN_REMOVE, listener); - this.client.clearTimeout(timeout); - reject(err); - }); - }); - } - - sendTyping(channelID) { - return this.rest.makeRequest('post', Endpoints.Channel(channelID).typing, true); - } - - banGuildMember(guild, member, options) { - const id = this.client.resolver.resolveUserID(member); - if (!id) return Promise.reject(new Error('Couldn\'t resolve the user ID to ban.')); - - const url = `${Endpoints.Guild(guild).bans}/${id}?${querystring.stringify(options)}`; - return this.rest.makeRequest('put', url, true).then(() => { - if (member instanceof GuildMember) return member; - const user = this.client.resolver.resolveUser(id); - if (user) { - member = this.client.resolver.resolveGuildMember(guild, user); - return member || user; - } - return id; - }); - } - - unbanGuildMember(guild, member) { - return new Promise((resolve, reject) => { - const id = this.client.resolver.resolveUserID(member); - if (!id) throw new Error('Couldn\'t resolve the user ID to unban.'); - - const listener = (eGuild, eUser) => { - if (eGuild.id === guild.id && eUser.id === id) { - this.client.removeListener(Constants.Events.GUILD_BAN_REMOVE, listener); - this.client.clearTimeout(timeout); - resolve(eUser); - } - }; - this.client.on(Constants.Events.GUILD_BAN_REMOVE, listener); - - const timeout = this.client.setTimeout(() => { - this.client.removeListener(Constants.Events.GUILD_BAN_REMOVE, listener); - reject(new Error('Took too long to receive the ban remove event.')); - }, 10000); - - this.rest.makeRequest('delete', `${Endpoints.Guild(guild).bans}/${id}`, true).catch(err => { - this.client.removeListener(Constants.Events.GUILD_BAN_REMOVE, listener); - this.client.clearTimeout(timeout); - reject(err); - }); - }); - } - - getGuildBans(guild) { - return this.rest.makeRequest('get', Endpoints.Guild(guild).bans, true).then(bans => - bans.reduce((collection, ban) => { - collection.set(ban.user.id, { - reason: ban.reason, - user: this.client.dataManager.newUser(ban.user), - }); - return collection; - }, new Collection()) - ); - } - - updateGuildRole(role, _data) { - const data = {}; - data.name = _data.name || role.name; - data.position = typeof _data.position !== 'undefined' ? _data.position : role.position; - data.color = this.client.resolver.resolveColor(_data.color || role.color); - data.hoist = typeof _data.hoist !== 'undefined' ? _data.hoist : role.hoist; - data.mentionable = typeof _data.mentionable !== 'undefined' ? _data.mentionable : role.mentionable; - - if (_data.permissions) data.permissions = Permissions.resolve(_data.permissions); - else data.permissions = role.permissions; - - return this.rest.makeRequest('patch', Endpoints.Guild(role.guild).Role(role.id), true, data).then(_role => - this.client.actions.GuildRoleUpdate.handle({ - role: _role, - guild_id: role.guild.id, - }).updated - ); - } - - pinMessage(message) { - return this.rest.makeRequest('put', Endpoints.Channel(message.channel).Pin(message.id), true) - .then(() => message); - } - - unpinMessage(message) { - return this.rest.makeRequest('delete', Endpoints.Channel(message.channel).Pin(message.id), true) - .then(() => message); - } - - getChannelPinnedMessages(channel) { - return this.rest.makeRequest('get', Endpoints.Channel(channel).pins, true); - } - - createChannelInvite(channel, options) { - const payload = {}; - payload.temporary = options.temporary; - payload.max_age = options.maxAge; - payload.max_uses = options.maxUses; - return this.rest.makeRequest('post', Endpoints.Channel(channel).invites, true, payload) - .then(invite => new Invite(this.client, invite)); - } - - deleteInvite(invite) { - return this.rest.makeRequest('delete', Endpoints.Invite(invite.code), true).then(() => invite); - } - - getInvite(code) { - return this.rest.makeRequest('get', Endpoints.Invite(code), true).then(invite => - new Invite(this.client, invite) - ); - } - - getGuildInvites(guild) { - return this.rest.makeRequest('get', Endpoints.Guild(guild).invites, true).then(inviteItems => { - const invites = new Collection(); - for (const inviteItem of inviteItems) { - const invite = new Invite(this.client, inviteItem); - invites.set(invite.code, invite); - } - return invites; - }); - } - - pruneGuildMembers(guild, days, dry) { - return this.rest.makeRequest(dry ? 'get' : 'post', `${Endpoints.Guild(guild).prune}?days=${days}`, true) - .then(data => data.pruned); - } - - createEmoji(guild, image, name, roles) { - const data = { image, name }; - if (roles) data.roles = roles.map(r => r.id ? r.id : r); - return this.rest.makeRequest('post', Endpoints.Guild(guild).emojis, true, data) - .then(emoji => this.client.actions.GuildEmojiCreate.handle(guild, emoji).emoji); - } - - updateEmoji(emoji, _data) { - const data = {}; - if (_data.name) data.name = _data.name; - if (_data.roles) data.roles = _data.roles.map(r => r.id ? r.id : r); - return this.rest.makeRequest('patch', Endpoints.Guild(emoji.guild).Emoji(emoji.id), true, data) - .then(newEmoji => this.client.actions.GuildEmojiUpdate.handle(emoji, newEmoji).emoji); - } - - deleteEmoji(emoji) { - return this.rest.makeRequest('delete', Endpoints.Guild(emoji.guild).Emoji(emoji.id), true) - .then(() => this.client.actions.GuildEmojiDelete.handle(emoji).data); - } - - getGuildAuditLogs(guild, options = {}) { - if (options.before && options.before instanceof GuildAuditLogs.Entry) options.before = options.before.id; - if (options.after && options.after instanceof GuildAuditLogs.Entry) options.after = options.after.id; - if (typeof options.type === 'string') options.type = GuildAuditLogs.Actions[options.type]; - - const queryString = (querystring.stringify({ - before: options.before, - after: options.after, - limit: options.limit, - user_id: this.client.resolver.resolveUserID(options.user), - action_type: options.type, - }).match(/[^=&?]+=[^=&?]+/g) || []).join('&'); - - return this.rest.makeRequest('get', `${Endpoints.Guild(guild).auditLogs}?${queryString}`, true) - .then(data => GuildAuditLogs.build(guild, data)); - } - - getWebhook(id, token) { - return this.rest.makeRequest('get', Endpoints.Webhook(id, token), !token).then(data => - new Webhook(this.client, data) - ); - } - - getGuildWebhooks(guild) { - return this.rest.makeRequest('get', Endpoints.Guild(guild).webhooks, true).then(data => { - const hooks = new Collection(); - for (const hook of data) hooks.set(hook.id, new Webhook(this.client, hook)); - return hooks; - }); - } - - getChannelWebhooks(channel) { - return this.rest.makeRequest('get', Endpoints.Channel(channel).webhooks, true).then(data => { - const hooks = new Collection(); - for (const hook of data) hooks.set(hook.id, new Webhook(this.client, hook)); - return hooks; - }); - } - - createWebhook(channel, name, avatar) { - return this.rest.makeRequest('post', Endpoints.Channel(channel).webhooks, true, { name, avatar }) - .then(data => new Webhook(this.client, data)); - } - - editWebhook(webhook, name, avatar) { - return this.rest.makeRequest('patch', Endpoints.Webhook(webhook.id, webhook.token), false, { - name, - avatar, - }).then(data => { - webhook.name = data.name; - webhook.avatar = data.avatar; - return webhook; - }); - } - - deleteWebhook(webhook) { - return this.rest.makeRequest('delete', Endpoints.Webhook(webhook.id, webhook.token), false); - } - - sendWebhookMessage(webhook, content, { avatarURL, tts, disableEveryone, embeds, username } = {}, file = null) { - username = username || webhook.name; - if (typeof content !== 'undefined') content = this.client.resolver.resolveString(content); - if (content) { - if (disableEveryone || (typeof disableEveryone === 'undefined' && this.client.options.disableEveryone)) { - content = content.replace(/@(everyone|here)/g, '@\u200b$1'); - } - } - return this.rest.makeRequest('post', `${Endpoints.Webhook(webhook.id, webhook.token)}?wait=true`, false, { - username, - avatar_url: avatarURL, - content, - tts, - embeds, - }, file); - } - - sendSlackWebhookMessage(webhook, body) { - return this.rest.makeRequest( - 'post', `${Endpoints.Webhook(webhook.id, webhook.token)}/slack?wait=true`, false, body - ); - } - - fetchUserProfile(user) { - return this.rest.makeRequest('get', Endpoints.User(user).profile, true).then(data => - new UserProfile(user, data) - ); - } - - fetchMentions(options) { - if (options.guild instanceof Guild) options.guild = options.guild.id; - Util.mergeDefault({ limit: 25, roles: true, everyone: true, guild: null }, options); - - return this.rest.makeRequest( - 'get', Endpoints.User('@me').Mentions(options.limit, options.roles, options.everyone, options.guild), true - ).then(data => data.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client))); - } - - addFriend(user) { - return this.rest.makeRequest('post', Endpoints.User('@me'), true, { - username: user.username, - discriminator: user.discriminator, - }).then(() => user); - } - - removeFriend(user) { - return this.rest.makeRequest('delete', Endpoints.User('@me').Relationship(user.id), true) - .then(() => user); - } - - blockUser(user) { - return this.rest.makeRequest('put', Endpoints.User('@me').Relationship(user.id), true, { type: 2 }) - .then(() => user); - } - - unblockUser(user) { - return this.rest.makeRequest('delete', Endpoints.User('@me').Relationship(user.id), true) - .then(() => user); - } - - updateChannelPositions(guildID, channels) { - const data = new Array(channels.length); - for (let i = 0; i < channels.length; i++) { - data[i] = { - id: this.client.resolver.resolveChannelID(channels[i].channel), - position: channels[i].position, - }; - } - - return this.rest.makeRequest('patch', Endpoints.Guild(guildID).channels, true, data).then(() => - this.client.actions.GuildChannelsPositionUpdate.handle({ - guild_id: guildID, - channels, - }).guild - ); - } - - setRolePositions(guildID, roles) { - return this.rest.makeRequest('patch', Endpoints.Guild(guildID).roles, true, roles).then(() => - this.client.actions.GuildRolesPositionUpdate.handle({ - guild_id: guildID, - roles, - }).guild - ); - } - - 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 - ).then(() => - message._addReaction(Util.parseEmoji(emoji), message.client.user) - ); - } - - removeMessageReaction(message, emoji, userID) { - const endpoint = Endpoints.Message(message).Reaction(emoji).User(userID === this.client.user.id ? '@me' : userID); - return this.rest.makeRequest('delete', endpoint, true).then(() => - this.client.actions.MessageReactionRemove.handle({ - user_id: userID, - message_id: message.id, - emoji: Util.parseEmoji(emoji), - channel_id: message.channel.id, - }).reaction - ); - } - - removeMessageReactions(message) { - return this.rest.makeRequest('delete', Endpoints.Message(message).reactions, true) - .then(() => message); - } - - getMessageReactionUsers(message, emoji, limit = 100) { - return this.rest.makeRequest('get', Endpoints.Message(message).Reaction(emoji, limit), true); - } - - getApplication(id) { - return this.rest.makeRequest('get', Endpoints.OAUTH2.Application(id), true).then(app => - new OAuth2Application(this.client, app) - ); - } - - resetApplication(id) { - return this.rest.makeRequest('post', Endpoints.OAUTH2.Application(id).reset, true) - .then(app => new OAuth2Application(this.client, app)); - } - - setNote(user, note) { - return this.rest.makeRequest('put', Endpoints.User(user).note, true, { note }).then(() => user); - } - - acceptInvite(code) { - if (code.id) code = code.id; - return new Promise((resolve, reject) => - this.rest.makeRequest('post', Endpoints.Invite(code), true).then(res => { - const handler = guild => { - if (guild.id === res.id) { - resolve(guild); - this.client.removeListener(Constants.Events.GUILD_CREATE, handler); - } - }; - this.client.on(Constants.Events.GUILD_CREATE, handler); - this.client.setTimeout(() => { - this.client.removeListener(Constants.Events.GUILD_CREATE, handler); - reject(new Error('Accepting invite timed out')); - }, 120e3); - }) - ); - } - - patchUserSettings(data) { - return this.rest.makeRequest('patch', Constants.Endpoints.User('@me').settings, true, data); - } -} - -module.exports = RESTMethods; + return new Proxy([''], handler); +}; /***/ }), -/* 137 */ +/* 142 */ /***/ (function(module, exports, __webpack_require__) { const RequestHandler = __webpack_require__(68); @@ -24310,7 +24382,7 @@ module.exports = BurstRequestHandler; /***/ }), -/* 138 */ +/* 143 */ /***/ (function(module, exports, __webpack_require__) { const RequestHandler = __webpack_require__(68); @@ -24414,7 +24486,7 @@ module.exports = SequentialRequestHandler; /***/ }), -/* 139 */ +/* 144 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {const Constants = __webpack_require__(0); @@ -24446,10 +24518,10 @@ module.exports = UserAgentManager; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) /***/ }), -/* 140 */ +/* 145 */ /***/ (function(module, exports, __webpack_require__) { -const EventEmitter = __webpack_require__(12).EventEmitter; +const EventEmitter = __webpack_require__(14).EventEmitter; const Constants = __webpack_require__(0); const WebSocketConnection = __webpack_require__(69); @@ -24542,7 +24614,7 @@ module.exports = WebSocketManager; /***/ }), -/* 141 */ +/* 146 */ /***/ (function(module, exports, __webpack_require__) { const Constants = __webpack_require__(0); @@ -24563,42 +24635,42 @@ class WebSocketPacketManager { this.handlers = {}; this.queue = []; - this.register(Constants.WSEvents.READY, __webpack_require__(168)); - this.register(Constants.WSEvents.RESUMED, __webpack_require__(171)); - this.register(Constants.WSEvents.GUILD_CREATE, __webpack_require__(148)); - this.register(Constants.WSEvents.GUILD_DELETE, __webpack_require__(149)); - this.register(Constants.WSEvents.GUILD_UPDATE, __webpack_require__(159)); - this.register(Constants.WSEvents.GUILD_BAN_ADD, __webpack_require__(146)); - this.register(Constants.WSEvents.GUILD_BAN_REMOVE, __webpack_require__(147)); - this.register(Constants.WSEvents.GUILD_MEMBER_ADD, __webpack_require__(151)); - this.register(Constants.WSEvents.GUILD_MEMBER_REMOVE, __webpack_require__(152)); - this.register(Constants.WSEvents.GUILD_MEMBER_UPDATE, __webpack_require__(153)); - this.register(Constants.WSEvents.GUILD_ROLE_CREATE, __webpack_require__(155)); - this.register(Constants.WSEvents.GUILD_ROLE_DELETE, __webpack_require__(156)); - this.register(Constants.WSEvents.GUILD_ROLE_UPDATE, __webpack_require__(157)); - this.register(Constants.WSEvents.GUILD_EMOJIS_UPDATE, __webpack_require__(150)); - this.register(Constants.WSEvents.GUILD_MEMBERS_CHUNK, __webpack_require__(154)); - this.register(Constants.WSEvents.CHANNEL_CREATE, __webpack_require__(142)); - this.register(Constants.WSEvents.CHANNEL_DELETE, __webpack_require__(143)); - this.register(Constants.WSEvents.CHANNEL_UPDATE, __webpack_require__(145)); - this.register(Constants.WSEvents.CHANNEL_PINS_UPDATE, __webpack_require__(144)); - this.register(Constants.WSEvents.PRESENCE_UPDATE, __webpack_require__(167)); - this.register(Constants.WSEvents.USER_UPDATE, __webpack_require__(175)); - this.register(Constants.WSEvents.USER_NOTE_UPDATE, __webpack_require__(173)); - this.register(Constants.WSEvents.USER_SETTINGS_UPDATE, __webpack_require__(174)); - this.register(Constants.WSEvents.VOICE_STATE_UPDATE, __webpack_require__(177)); - this.register(Constants.WSEvents.TYPING_START, __webpack_require__(172)); - this.register(Constants.WSEvents.MESSAGE_CREATE, __webpack_require__(160)); - this.register(Constants.WSEvents.MESSAGE_DELETE, __webpack_require__(161)); - this.register(Constants.WSEvents.MESSAGE_UPDATE, __webpack_require__(166)); - this.register(Constants.WSEvents.MESSAGE_DELETE_BULK, __webpack_require__(162)); - this.register(Constants.WSEvents.VOICE_SERVER_UPDATE, __webpack_require__(176)); - this.register(Constants.WSEvents.GUILD_SYNC, __webpack_require__(158)); - this.register(Constants.WSEvents.RELATIONSHIP_ADD, __webpack_require__(169)); - this.register(Constants.WSEvents.RELATIONSHIP_REMOVE, __webpack_require__(170)); - this.register(Constants.WSEvents.MESSAGE_REACTION_ADD, __webpack_require__(163)); - this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, __webpack_require__(164)); - this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_ALL, __webpack_require__(165)); + this.register(Constants.WSEvents.READY, __webpack_require__(173)); + this.register(Constants.WSEvents.RESUMED, __webpack_require__(176)); + this.register(Constants.WSEvents.GUILD_CREATE, __webpack_require__(153)); + this.register(Constants.WSEvents.GUILD_DELETE, __webpack_require__(154)); + this.register(Constants.WSEvents.GUILD_UPDATE, __webpack_require__(164)); + this.register(Constants.WSEvents.GUILD_BAN_ADD, __webpack_require__(151)); + this.register(Constants.WSEvents.GUILD_BAN_REMOVE, __webpack_require__(152)); + this.register(Constants.WSEvents.GUILD_MEMBER_ADD, __webpack_require__(156)); + this.register(Constants.WSEvents.GUILD_MEMBER_REMOVE, __webpack_require__(157)); + this.register(Constants.WSEvents.GUILD_MEMBER_UPDATE, __webpack_require__(158)); + this.register(Constants.WSEvents.GUILD_ROLE_CREATE, __webpack_require__(160)); + this.register(Constants.WSEvents.GUILD_ROLE_DELETE, __webpack_require__(161)); + this.register(Constants.WSEvents.GUILD_ROLE_UPDATE, __webpack_require__(162)); + this.register(Constants.WSEvents.GUILD_EMOJIS_UPDATE, __webpack_require__(155)); + this.register(Constants.WSEvents.GUILD_MEMBERS_CHUNK, __webpack_require__(159)); + this.register(Constants.WSEvents.CHANNEL_CREATE, __webpack_require__(147)); + this.register(Constants.WSEvents.CHANNEL_DELETE, __webpack_require__(148)); + this.register(Constants.WSEvents.CHANNEL_UPDATE, __webpack_require__(150)); + this.register(Constants.WSEvents.CHANNEL_PINS_UPDATE, __webpack_require__(149)); + this.register(Constants.WSEvents.PRESENCE_UPDATE, __webpack_require__(172)); + this.register(Constants.WSEvents.USER_UPDATE, __webpack_require__(180)); + this.register(Constants.WSEvents.USER_NOTE_UPDATE, __webpack_require__(178)); + this.register(Constants.WSEvents.USER_SETTINGS_UPDATE, __webpack_require__(179)); + this.register(Constants.WSEvents.VOICE_STATE_UPDATE, __webpack_require__(182)); + this.register(Constants.WSEvents.TYPING_START, __webpack_require__(177)); + this.register(Constants.WSEvents.MESSAGE_CREATE, __webpack_require__(165)); + this.register(Constants.WSEvents.MESSAGE_DELETE, __webpack_require__(166)); + this.register(Constants.WSEvents.MESSAGE_UPDATE, __webpack_require__(171)); + this.register(Constants.WSEvents.MESSAGE_DELETE_BULK, __webpack_require__(167)); + this.register(Constants.WSEvents.VOICE_SERVER_UPDATE, __webpack_require__(181)); + this.register(Constants.WSEvents.GUILD_SYNC, __webpack_require__(163)); + this.register(Constants.WSEvents.RELATIONSHIP_ADD, __webpack_require__(174)); + this.register(Constants.WSEvents.RELATIONSHIP_REMOVE, __webpack_require__(175)); + this.register(Constants.WSEvents.MESSAGE_REACTION_ADD, __webpack_require__(168)); + this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, __webpack_require__(169)); + this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_ALL, __webpack_require__(170)); } get client() { @@ -24655,7 +24727,7 @@ module.exports = WebSocketPacketManager; /***/ }), -/* 142 */ +/* 147 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24678,7 +24750,7 @@ module.exports = ChannelCreateHandler; /***/ }), -/* 143 */ +/* 148 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24704,7 +24776,7 @@ module.exports = ChannelDeleteHandler; /***/ }), -/* 144 */ +/* 149 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24741,7 +24813,7 @@ module.exports = ChannelPinsUpdate; /***/ }), -/* 145 */ +/* 150 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24758,7 +24830,7 @@ module.exports = ChannelUpdateHandler; /***/ }), -/* 146 */ +/* 151 */ /***/ (function(module, exports, __webpack_require__) { // ##untested handler## @@ -24787,7 +24859,7 @@ module.exports = GuildBanAddHandler; /***/ }), -/* 147 */ +/* 152 */ /***/ (function(module, exports, __webpack_require__) { // ##untested handler## @@ -24813,7 +24885,7 @@ module.exports = GuildBanRemoveHandler; /***/ }), -/* 148 */ +/* 153 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24841,7 +24913,7 @@ module.exports = GuildCreateHandler; /***/ }), -/* 149 */ +/* 154 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24866,7 +24938,7 @@ module.exports = GuildDeleteHandler; /***/ }), -/* 150 */ +/* 155 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24883,7 +24955,7 @@ module.exports = GuildEmojisUpdate; /***/ }), -/* 151 */ +/* 156 */ /***/ (function(module, exports, __webpack_require__) { // ##untested handler## @@ -24906,7 +24978,7 @@ module.exports = GuildMemberAddHandler; /***/ }), -/* 152 */ +/* 157 */ /***/ (function(module, exports, __webpack_require__) { // ##untested handler## @@ -24925,7 +24997,7 @@ module.exports = GuildMemberRemoveHandler; /***/ }), -/* 153 */ +/* 158 */ /***/ (function(module, exports, __webpack_require__) { // ##untested handler## @@ -24949,7 +25021,7 @@ module.exports = GuildMemberUpdateHandler; /***/ }), -/* 154 */ +/* 159 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -24988,7 +25060,7 @@ module.exports = GuildMembersChunkHandler; /***/ }), -/* 155 */ +/* 160 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25005,7 +25077,7 @@ module.exports = GuildRoleCreateHandler; /***/ }), -/* 156 */ +/* 161 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25022,7 +25094,7 @@ module.exports = GuildRoleDeleteHandler; /***/ }), -/* 157 */ +/* 162 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25039,7 +25111,7 @@ module.exports = GuildRoleUpdateHandler; /***/ }), -/* 158 */ +/* 163 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25056,7 +25128,7 @@ module.exports = GuildSyncHandler; /***/ }), -/* 159 */ +/* 164 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25073,7 +25145,7 @@ module.exports = GuildUpdateHandler; /***/ }), -/* 160 */ +/* 165 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25098,7 +25170,7 @@ module.exports = MessageCreateHandler; /***/ }), -/* 161 */ +/* 166 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25123,7 +25195,7 @@ module.exports = MessageDeleteHandler; /***/ }), -/* 162 */ +/* 167 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25146,7 +25218,7 @@ module.exports = MessageDeleteBulkHandler; /***/ }), -/* 163 */ +/* 168 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25163,7 +25235,7 @@ module.exports = MessageReactionAddHandler; /***/ }), -/* 164 */ +/* 169 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25180,7 +25252,7 @@ module.exports = MessageReactionRemove; /***/ }), -/* 165 */ +/* 170 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25197,7 +25269,7 @@ module.exports = MessageReactionRemoveAll; /***/ }), -/* 166 */ +/* 171 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25214,7 +25286,7 @@ module.exports = MessageUpdateHandler; /***/ }), -/* 167 */ +/* 172 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25296,12 +25368,12 @@ module.exports = PresenceUpdateHandler; /***/ }), -/* 168 */ +/* 173 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); -const ClientUser = __webpack_require__(41); +const ClientUser = __webpack_require__(42); class ReadyHandler extends AbstractHandler { handle(packet) { @@ -25384,7 +25456,7 @@ module.exports = ReadyHandler; /***/ }), -/* 169 */ +/* 174 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25409,7 +25481,7 @@ module.exports = RelationshipAddHandler; /***/ }), -/* 170 */ +/* 175 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25434,7 +25506,7 @@ module.exports = RelationshipRemoveHandler; /***/ }), -/* 171 */ +/* 176 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25468,7 +25540,7 @@ module.exports = ResumedHandler; /***/ }), -/* 172 */ +/* 177 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25542,7 +25614,7 @@ module.exports = TypingStartHandler; /***/ }), -/* 173 */ +/* 178 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25560,7 +25632,7 @@ module.exports = UserNoteUpdateHandler; /***/ }), -/* 174 */ +/* 179 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25584,7 +25656,7 @@ module.exports = UserSettingsUpdateHandler; /***/ }), -/* 175 */ +/* 180 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25601,7 +25673,7 @@ module.exports = UserUpdateHandler; /***/ }), -/* 176 */ +/* 181 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25626,7 +25698,7 @@ module.exports = VoiceServerUpdate; /***/ }), -/* 177 */ +/* 182 */ /***/ (function(module, exports, __webpack_require__) { const AbstractHandler = __webpack_require__(1); @@ -25681,29 +25753,29 @@ module.exports = VoiceStateUpdateHandler; /***/ }), -/* 178 */ +/* 183 */ /***/ (function(module, exports, __webpack_require__) { const Util = __webpack_require__(4); module.exports = { // "Root" classes (starting points) - Client: __webpack_require__(70), - Shard: __webpack_require__(73), - ShardClientUtil: __webpack_require__(74), - ShardingManager: __webpack_require__(75), - WebhookClient: __webpack_require__(71), + Client: __webpack_require__(72), + Shard: __webpack_require__(75), + ShardClientUtil: __webpack_require__(76), + ShardingManager: __webpack_require__(77), + WebhookClient: __webpack_require__(73), // Utilities Collection: __webpack_require__(3), Constants: __webpack_require__(0), - EvaluatedPermissions: __webpack_require__(8), - Permissions: __webpack_require__(8), + EvaluatedPermissions: __webpack_require__(10), + Permissions: __webpack_require__(10), Snowflake: __webpack_require__(6), SnowflakeUtil: __webpack_require__(6), Util: Util, util: Util, - version: __webpack_require__(40).version, + version: __webpack_require__(41).version, // Shortcuts to Util methods escapeMarkdown: Util.escapeMarkdown, @@ -25711,46 +25783,46 @@ module.exports = { splitMessage: Util.splitMessage, // Structures - Channel: __webpack_require__(14), - ClientUser: __webpack_require__(41), - ClientUserSettings: __webpack_require__(42), - Collector: __webpack_require__(31), - DMChannel: __webpack_require__(43), + Channel: __webpack_require__(16), + ClientUser: __webpack_require__(42), + ClientUserSettings: __webpack_require__(43), + Collector: __webpack_require__(32), + DMChannel: __webpack_require__(44), Emoji: __webpack_require__(17), - Game: __webpack_require__(11).Game, - GroupDMChannel: __webpack_require__(28), - Guild: __webpack_require__(24), - GuildAuditLogs: __webpack_require__(44), - GuildChannel: __webpack_require__(25), - GuildMember: __webpack_require__(18), - Invite: __webpack_require__(45), - Message: __webpack_require__(19), + Game: __webpack_require__(13).Game, + GroupDMChannel: __webpack_require__(30), + Guild: __webpack_require__(18), + GuildAuditLogs: __webpack_require__(45), + GuildChannel: __webpack_require__(26), + GuildMember: __webpack_require__(19), + Invite: __webpack_require__(27), + Message: __webpack_require__(8), MessageAttachment: __webpack_require__(46), MessageCollector: __webpack_require__(47), MessageEmbed: __webpack_require__(48), MessageMentions: __webpack_require__(49), MessageReaction: __webpack_require__(50), - OAuth2Application: __webpack_require__(26), - ClientOAuth2Application: __webpack_require__(26), + OAuth2Application: __webpack_require__(28), + ClientOAuth2Application: __webpack_require__(28), PartialGuild: __webpack_require__(51), PartialGuildChannel: __webpack_require__(52), PermissionOverwrites: __webpack_require__(53), - Presence: __webpack_require__(11).Presence, - ReactionEmoji: __webpack_require__(29), + Presence: __webpack_require__(13).Presence, + ReactionEmoji: __webpack_require__(31), ReactionCollector: __webpack_require__(54), - RichEmbed: __webpack_require__(72), - Role: __webpack_require__(15), + RichEmbed: __webpack_require__(74), + Role: __webpack_require__(20), TextChannel: __webpack_require__(55), - User: __webpack_require__(16), + User: __webpack_require__(12), VoiceChannel: __webpack_require__(56), - Webhook: __webpack_require__(30), + Webhook: __webpack_require__(21), }; -if (__webpack_require__(23).platform() === 'browser') window.Discord = module.exports; // eslint-disable-line no-undef +if (__webpack_require__(25).platform() === 'browser') window.Discord = module.exports; // eslint-disable-line no-undef /***/ }), -/* 179 */ +/* 184 */ /***/ (function(module, exports) { /** @@ -25804,11 +25876,11 @@ module.exports = UserConnection; /***/ }), -/* 180 */ +/* 185 */ /***/ (function(module, exports, __webpack_require__) { const Collection = __webpack_require__(3); -const UserConnection = __webpack_require__(179); +const UserConnection = __webpack_require__(184); /** * Represents a user's profile on Discord. @@ -25871,97 +25943,140 @@ class UserProfile { module.exports = UserProfile; -/***/ }), -/* 181 */ -/***/ (function(module, exports) { - -/** - * Represents a Discord voice region for guilds. - */ -class VoiceRegion { - constructor(data) { - /** - * The ID of the region - * @type {string} - */ - this.id = data.id; - - /** - * Name of the region - * @type {string} - */ - this.name = data.name; - - /** - * Whether the region is VIP-only - * @type {boolean} - */ - this.vip = data.vip; - - /** - * Whether the region is deprecated - * @type {boolean} - */ - this.deprecated = data.deprecated; - - /** - * Whether the region is optimal - * @type {boolean} - */ - this.optimal = data.optimal; - - /** - * Whether the region is custom - * @type {boolean} - */ - this.custom = data.custom; - - /** - * A sample hostname for what a connection might look like - * @type {string} - */ - this.sampleHostname = data.sample_hostname; - } -} - -module.exports = VoiceRegion; - - -/***/ }), -/* 182 */ -/***/ (function(module, exports) { - -/* (ignored) */ - -/***/ }), -/* 183 */ -/***/ (function(module, exports) { - -/* (ignored) */ - -/***/ }), -/* 184 */ -/***/ (function(module, exports) { - -/* (ignored) */ - -/***/ }), -/* 185 */ -/***/ (function(module, exports) { - -/* (ignored) */ - /***/ }), /* 186 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +const long = __webpack_require__(34); + +module.exports = function search(target, options) { + if (typeof options === 'string') options = { content: options }; + if (options.before) { + if (!(options.before instanceof Date)) options.before = new Date(options.before); + options.maxID = long.fromNumber(options.before.getTime() - 14200704e5).shiftLeft(22).toString(); + } + if (options.after) { + if (!(options.after instanceof Date)) options.after = new Date(options.after); + options.minID = long.fromNumber(options.after.getTime() - 14200704e5).shiftLeft(22).toString(); + } + if (options.during) { + if (!(options.during instanceof Date)) options.during = new Date(options.during); + const t = options.during.getTime() - 14200704e5; + options.minID = long.fromNumber(t).shiftLeft(22).toString(); + options.maxID = long.fromNumber(t + 86400000).shiftLeft(22).toString(); + } + if (options.channel) options.channel = target.client.resolver.resolveChannelID(options.channel); + if (options.author) options.author = target.client.resolver.resolveUserID(options.author); + if (options.mentions) options.mentions = target.client.resolver.resolveUserID(options.options.mentions); + options = { + content: options.content, + max_id: options.maxID, + min_id: options.minID, + has: options.has, + channel_id: options.channel, + author_id: options.author, + author_type: options.authorType, + context_size: options.contextSize, + sort_by: options.sortBy, + sort_order: options.sortOrder, + limit: options.limit, + offset: options.offset, + mentions: options.mentions, + mentions_everyone: options.mentionsEveryone, + link_hostname: options.linkHostname, + embed_provider: options.embedProvider, + embed_type: options.embedType, + attachment_filename: options.attachmentFilename, + attachment_extension: options.attachmentExtension, + }; + + // Lazy load these because some of them use util + const Channel = __webpack_require__(16); + const Guild = __webpack_require__(18); + const Message = __webpack_require__(8); + + if (!(target instanceof Channel || target instanceof Guild)) { + throw new TypeError('Target must be a TextChannel, DMChannel, GroupDMChannel, or Guild.'); + } + + let endpoint = target.client.api[target instanceof Channel ? 'channels' : 'guilds'](target.id).messages().search; + return endpoint.get({ query: options }).then(body => { + const messages = body.messages.map(x => + x.map(m => new Message(target.client.channels.get(m.channel_id), m, target.client)) + ); + return { + totalResults: body.total_results, + messages, + }; + }); +}; -/* (ignored) */ /***/ }), /* 187 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +const Util = __webpack_require__(4); + +module.exports = function sendMessage(channel, options) { + const User = __webpack_require__(12); + if (channel instanceof User) return channel.createDM().then(dm => dm.send(options)); + const GuildMember = __webpack_require__(19); + let { content, nonce, reply, code, disableEveryone, tts, embed, files, split } = options; + + if (typeof nonce !== 'undefined') { + nonce = parseInt(nonce); + if (isNaN(nonce) || nonce < 0) throw new RangeError('Message nonce must fit in an unsigned 64-bit integer.'); + } + + if (content) { + if (split && typeof split !== 'object') split = {}; + // Wrap everything in a code block + if (typeof code !== 'undefined' && (typeof code !== 'boolean' || code === true)) { + content = Util.escapeMarkdown(channel.client.resolver.resolveString(content), true); + content = `\`\`\`${typeof code !== 'boolean' ? code || '' : ''}\n${content}\n\`\`\``; + if (split) { + split.prepend = `\`\`\`${typeof code !== 'boolean' ? code || '' : ''}\n`; + split.append = '\n```'; + } + } + + // Add zero-width spaces to @everyone/@here + if (disableEveryone || (typeof disableEveryone === 'undefined' && channel.client.options.disableEveryone)) { + content = content.replace(/@(everyone|here)/g, '@\u200b$1'); + } + + if (split) content = Util.splitMessage(content, split); + } + + // Add the reply prefix + if (reply && !(channel instanceof User || channel instanceof GuildMember) && channel.type !== 'dm') { + const id = channel.client.resolver.resolveUserID(reply); + const mention = `<@${reply instanceof GuildMember && reply.nickname ? '!' : ''}${id}>`; + if (split) split.prepend = `${mention}, ${split.prepend || ''}`; + content = `${mention}${typeof content !== 'undefined' ? `, ${content}` : ''}`; + } + + if (content instanceof Array) { + return new Promise((resolve, reject) => { + const messages = []; + (function sendChunk() { + const opt = content.length ? { tts } : { tts, embed, files }; + channel.send(content.shift(), opt).then(message => { + messages.push(message); + if (content.length === 0) return resolve(messages); + return sendChunk(); + }).catch(reject); + }()); + }); + } + + return channel.client.api.channels(channel.id).messages.post({ + data: { content, tts, nonce, embed }, + files, + }).then(data => channel.client.actions.MessageCreate.handle(data).message); +}; -/* (ignored) */ /***/ }), /* 188 */ @@ -25969,5 +26084,41 @@ module.exports = VoiceRegion; /* (ignored) */ +/***/ }), +/* 189 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 190 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 191 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 192 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 193 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 194 */ +/***/ (function(module, exports) { + +/* (ignored) */ + /***/ }) /******/ ]); \ No newline at end of file diff --git a/discord.master.min.js b/discord.master.min.js index a4327ed0..bf9aedcf 100644 --- a/discord.master.min.js +++ b/discord.master.min.js @@ -1,24 +1,24 @@ -!function(e){function t(i){if(n[i])return n[i].exports;var s=n[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=178)}([function(e,t,n){(function(e){t.Package=n(40),t.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(23).platform(),properties:{$os:e?e.platform:"discord.js",$browser:"discord.js",$device:"discord.js",$referrer:"",$referring_domain:""},version:6},http:{version:7,host:"https://discordapp.com",cdn:"https://cdn.discordapp.com"}},t.WSCodes={1e3:"Connection gracefully closed",4004:"Tried to identify with an invalid token",4010:"Sharding data provided was invalid",4011:"Shard would be on too many guilds if connected"},t.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=["webp","png","jpg","gif"],s=[128,256,512,1024,2048],r=t.Endpoints={User:e=>{e.id&&(e=e.id);const t=`/users/${e}`;return{toString:()=>t,channels:`${t}/channels`,profile:`${t}/profile`,relationships:`${t}/relationships`,settings:`${t}/settings`,Relationship:e=>`${t}/relationships/${e}`,Guild:e=>`${t}/guilds/${e}`,Note:e=>`${t}/notes/${e}`,Mentions:(e,n,i,s)=>`${t}/mentions?limit=${e}&roles=${n}&everyone=${i}${s?`&guild_id=${s}`:""}`,Avatar:(t,n,i,s)=>{if("1"===e)return n;return r.CDN(t).Avatar(e,n,i,s)}}},guilds:"/guilds",Guild:e=>{e.id&&(e=e.id);const t=`/guilds/${e}`;return{toString:()=>t,prune:`${t}/prune`,embed:`${t}/embed`,bans:`${t}/bans`,integrations:`${t}/integrations`,members:`${t}/members`,channels:`${t}/channels`,invites:`${t}/invites`,roles:`${t}/roles`,emojis:`${t}/emojis`,search:`${t}/messages/search`,voiceRegions:`${t}/regions`,webhooks:`${t}/webhooks`,ack:`${t}/ack`,settings:`${t}/settings`,auditLogs:`${t}/audit-logs`,Emoji:e=>`${t}/emojis/${e}`,Icon:(t,n,i,s)=>r.CDN(t).Icon(e,n,i,s),Splash:(t,n)=>r.CDN(t).Splash(e,n),Role:e=>`${t}/roles/${e}`,Member:e=>{e.id&&(e=e.id);const n=`${t}/members/${e}`;return{toString:()=>n,Role:e=>`${n}/roles/${e}`,nickname:`${t}/members/@me/nick`}}}},channels:"/channels",Channel:e=>{e.id&&(e=e.id);const t=`/channels/${e}`;return{toString:()=>t,messages:{toString:()=>`${t}/messages`,bulkDelete:`${t}/messages/bulk-delete`},invites:`${t}/invites`,typing:`${t}/typing`,permissions:`${t}/permissions`,webhooks:`${t}/webhooks`,search:`${t}/messages/search`,pins:`${t}/pins`,Pin:e=>`${t}/pins/${e}`,Recipient:e=>`${t}/recipients/${e}`,Message:e=>{e.id&&(e=e.id);const n=`${t}/messages/${e}`;return{toString:()=>n,reactions:`${n}/reactions`,ack:`${n}/ack`,Reaction:(e,t)=>{const i=`${n}/reactions/${e}${t?`?limit=${t}`:""}`;return{toString:()=>i,User:e=>`${i}/${e}`}}}}}},Message:e=>t.Endpoints.Channel(e.channel).Message(e),Member:e=>t.Endpoints.Guild(e.guild).Member(e),CDN(e){return{Emoji:t=>`${e}/emojis/${t}.png`,Asset:t=>`${e}/assets/${t}`,DefaultAvatar:t=>`${e}/embed/avatars/${t}.png`,Avatar:(t,n,r="default",o)=>{"default"===r&&(r=n.startsWith("a_")?"gif":"webp");if(!i.includes(r))throw new Error(`Invalid image format: ${r}`);if(o&&!s.includes(o))throw new RangeError(`Invalid size: ${o}`);return`${e}/avatars/${t}/${n}.${r}${o?`?size=${o}`:""}`},Icon:(t,n,r="default",o)=>{"default"===r&&(r="webp");if(!i.includes(r))throw new Error(`Invalid image format: ${r}`);if(o&&!s.includes(o))throw new RangeError(`Invalid size: ${o}`);return`${e}/icons/${t}/${n}.${r}${o?`?size=${o}`:""}`},AppIcon:(t,n,r="default",o)=>{"default"===r&&(r="webp");if(!i.includes(r))throw new Error(`Invalid image format: ${r}`);if(o&&!s.includes(o))throw new RangeError(`Invalid size: ${o}`);return`${e}/app-icons/${t}/${n}.${r}${o?`?size=${o}`:""}`},Splash:(t,n)=>`${e}/splashes/${t}/${n}.jpg`}},OAUTH2:{Application:e=>{const t=`/oauth2/applications/${e}`;return{toString:()=>t,reset:`${t}/reset`}},App:e=>`/oauth2/authorize?client_id=${e}`},login:"/auth/login",logout:"/auth/logout",voiceRegions:"/voice/regions",gateway:{toString:()=>"/gateway",bot:"/gateway/bot"},Invite:e=>`/invite/${e}?with_counts=true`,inviteLink:e=>`https://discord.gg/${e}`,Webhook:(e,t)=>`/webhooks/${e}${t?`/${t}`:""}`};t.Status={READY:0,CONNECTING:1,RECONNECTING:2,IDLE:3,NEARLY:4,DISCONNECTED:5},t.VoiceStatus={CONNECTED:0,CONNECTING:1,AUTHENTICATING:2,RECONNECTING:3,DISCONNECTED:4},t.ChannelTypes={TEXT:0,DM:1,VOICE:2,GROUP_DM:3},t.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},t.VoiceOPCodes={IDENTIFY:0,SELECT_PROTOCOL:1,READY:2,HEARTBEAT:3,SESSION_DESCRIPTION:4,SPEAKING:5},t.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",USER_SETTINGS_UPDATE:"clientUserSettingsUpdate",PRESENCE_UPDATE:"presenceUpdate",VOICE_STATE_UPDATE:"voiceStateUpdate",TYPING_START:"typingStart",TYPING_STOP:"typingStop",DISCONNECT:"disconnect",RECONNECTING:"reconnecting",ERROR:"error",WARN:"warn",DEBUG:"debug"},t.WSEvents={READY:"READY",RESUMED:"RESUMED",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",USER_SETTINGS_UPDATE:"USER_SETTINGS_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"},t.MessageTypes=["DEFAULT","RECIPIENT_ADD","RECIPIENT_REMOVE","CALL","CHANNEL_NAME_CHANGE","CHANNEL_ICON_CHANGE","PINS_ADD","GUILD_MEMBER_JOIN"],t.ExplicitContentFilterTypes=["DISABLED","NON_FRIENDS","FRIENDS_AND_NON_FRIENDS"],t.UserSettingsMap={convert_emoticons:"convertEmoticons",default_guilds_restricted:"defaultGuildsRestricted",detect_platform_accounts:"detectPlatformAccounts",developer_mode:"developerMode",enable_tts_command:"enableTTSCommand",theme:"theme",status:"status",show_current_game:"showCurrentGame",inline_attachment_media:"inlineAttachmentMedia",inline_embed_media:"inlineEmbedMedia",locale:"locale",message_display_compact:"messageDisplayCompact",render_reactions:"renderReactions",guild_positions:"guildPositions",restricted_guilds:"restrictedGuilds",explicit_content_filter:function(e){return t.ExplicitContentFilterTypes[e]},friend_source_flags:function(e){return{all:e.all||!1,mutualGuilds:!!e.all||(e.mutual_guilds||!1),mutualFriends:!!e.all||(e.mutualFriends||!1)}}},t.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(t,n(7))},function(e,t){class n{constructor(e){this.packetManager=e}handle(e){return e}}e.exports=n},function(e,t){class n{constructor(e){this.client=e}handle(e){return e}}e.exports=n},function(e,t){class n extends Map{constructor(e){super(e),Object.defineProperty(this,"_array",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"_keyArray",{value:null,writable:!0,configurable:!0})}set(e,t){return this._array=null,this._keyArray=null,super.set(e,t)}delete(e){return this._array=null,this._keyArray=null,super.delete(e)}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 e=this.array();return e[e.length-1]}lastKey(){const e=this.keyArray();return e[e.length-1]}random(){const e=this.array();return e[Math.floor(Math.random()*e.length)]}randomKey(){const e=this.keyArray();return e[Math.floor(Math.random()*e.length)]}findAll(e,t){if("string"!=typeof e)throw new TypeError("Key must be a string.");if(void 0===t)throw new Error("Value must be specified.");const n=[];for(const i of this.values())i[e]===t&&n.push(i);return n}find(e,t){if("string"==typeof e){if(void 0===t)throw new Error("Value must be specified.");for(const n of this.values())if(n[e]===t)return n;return null}if("function"==typeof e){for(const[t,n]of this)if(e(n,t,this))return n;return null}throw new Error("First argument must be a property string or a function.")}findKey(e,t){if("string"==typeof e){if(void 0===t)throw new Error("Value must be specified.");for(const[n,i]of this)if(i[e]===t)return n;return null}if("function"==typeof e){for(const[t,n]of this)if(e(n,t,this))return t;return null}throw new Error("First argument must be a property string or a function.")}exists(e,t){return Boolean(this.find(e,t))}filter(e,t){t&&(e=e.bind(t));const i=new n;for(const[t,n]of this)e(n,t,this)&&i.set(t,n);return i}filterArray(e,t){t&&(e=e.bind(t));const n=[];for(const[t,i]of this)e(i,t,this)&&n.push(i);return n}map(e,t){t&&(e=e.bind(t));const n=new Array(this.size);let i=0;for(const[t,s]of this)n[i++]=e(s,t,this);return n}some(e,t){t&&(e=e.bind(t));for(const[t,n]of this)if(e(n,t,this))return!0;return!1}every(e,t){t&&(e=e.bind(t));for(const[t,n]of this)if(!e(n,t,this))return!1;return!0}reduce(e,t){let n;if(void 0!==t){n=t;for(const[t,i]of this)n=e(n,i,t,this)}else{let t=!0;for(const[i,s]of this)t?(n=s,t=!1):n=e(n,s,i,this)}return n}clone(){return new this.constructor(this)}concat(...e){const t=this.clone();for(const n of e)for(const[e,i]of n)t.set(e,i);return t}deleteAll(){const e=[];for(const t of this.values())t.delete&&e.push(t.delete());return e}equals(e){return!!e&&(this===e||this.size===e.size&&!this.find((t,n)=>{const i=e.get(n);return i!==t||void 0===i&&!e.has(n)}))}sort(e=((e,t)=>+(e>t)||+(e===t)-1)){return new n(Array.from(this.entries()).sort((t,n)=>e(t[1],n[1],t[0],n[0])))}}e.exports=n},function(e,t,n){(function(t){const i=n(37),s=n(0),r=s.DefaultOptions.http;class o{constructor(){throw new Error(`The ${this.constructor.name} class may not be instantiated.`)}static splitMessage(e,{maxLength:maxLength=1950,char:char="\n",prepend:prepend="",append:append=""}={}){if(e.length<=maxLength)return e;const t=e.split(char);if(1===t.length)throw new Error("Message exceeds the max length and contains no split characters.");const n=[""];let i=0;for(let e=0;emaxLength&&(n[i]+=append,n.push(prepend),i++),n[i]+=(n[i].length>0&&n[i]!==prepend?char:"")+t[e];return n}static escapeMarkdown(e,t=!1,n=!1){return t?e.replace(/```/g,"`​``"):n?e.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):e.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}static fetchRecommendedShards(e,t=1e3){return new Promise((n,o)=>{if(!e)throw new Error("A token must be provided.");i.get(`${r.host}/api/v${r.version}${s.Endpoints.gateway.bot}`).set("Authorization",`Bot ${e.replace(/^Bot\s*/i,"")}`).end((e,i)=>{e&&o(e);n(i.body.shards*(1e3/t))})})}static parseEmoji(e){if(e.includes("%")&&(e=decodeURIComponent(e)),e.includes(":")){const[t,n]=e.split(":");return{name:t,id:n}}return{name:e,id:null}}static arraysEqual(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(const n of e){const e=t.indexOf(n);-1!==e&&t.splice(e,1)}return 0===t.length}static cloneObject(e){return Object.assign(Object.create(e),e)}static mergeDefault(e,t){if(!t)return e;for(const n in e)!{}.hasOwnProperty.call(t,n)?t[n]=e[n]:t[n]===Object(t[n])&&(t[n]=this.mergeDefault(e[n],t[n]));return t}static convertToBuffer(e){return"string"==typeof e&&(e=this.str2ab(e)),t.from(e)}static str2ab(e){const t=new ArrayBuffer(2*e.length),n=new Uint16Array(t);for(var i=0,s=e.length;i-1&&n=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),r.alloc(+e)}function g(e,t){if(r.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Y(e).length;default:if(i)return W(e).length;t=(""+t).toLowerCase(),i=!0}}function v(e,t,n){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return D(this,t,n);case"ascii":return M(this,t,n);case"latin1":case"binary":return C(this,t,n);case"base64":return k(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,n);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function E(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function b(e,t,n,i,s){if(0===e.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:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(s)return-1;n=e.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof t&&(t=r.from(t,i)),r.isBuffer(t))return 0===t.length?-1:w(e,t,n,i,s);if("number"==typeof t)return t&=255,r.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):w(e,[t],n,i,s);throw new TypeError("val must be string, number or Buffer")}function w(e,t,n,i,s){function r(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,n/=2}var u;if(s){var l=-1;for(u=n;ua&&(n=a-c),u=n;u>=0;u--){for(var h=!0,p=0;ps&&(i=s):i=s;var r=t.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+a<=n){var c,u,l,h;switch(a){case 1:r<128&&(o=r);break;case 2:c=e[s+1],128==(192&c)&&(h=(31&r)<<6|63&c)>127&&(o=h);break;case 3:c=e[s+1],u=e[s+2],128==(192&c)&&128==(192&u)&&(h=(15&r)<<12|(63&c)<<6|63&u)>2047&&(h<55296||h>57343)&&(o=h);break;case 4:c=e[s+1],u=e[s+2],l=e[s+3],128==(192&c)&&128==(192&u)&&128==(192&l)&&(h=(15&r)<<18|(63&c)<<12|(63&u)<<6|63&l)>65535&&h<1114112&&(o=h)}}null===o?(o=65533,a=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),s+=a}return S(i)}function S(e){var t=e.length;if(t<=Q)return String.fromCharCode.apply(String,e);for(var n="",i=0;ii)&&(n=i);for(var s="",r=t;rn)throw new RangeError("Trying to access beyond buffer length")}function O(e,t,n,i,s,o){if(!r.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>s||te.length)throw new RangeError("Index out of range")}function N(e,t,n,i){t<0&&(t=65535+t+1);for(var s=0,r=Math.min(e.length-n,2);s>>8*(i?s:1-s)}function P(e,t,n,i){t<0&&(t=4294967295+t+1);for(var s=0,r=Math.min(e.length-n,4);s>>8*(i?s:3-s)&255}function j(e,t,n,i,s,r){if(n+i>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function G(e,t,n,i,s){return s||j(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,n,i,23,4),n+4}function q(e,t,n,i,s){return s||j(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,n,i,52,8),n+8}function B(e){if(e=z(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function z(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function W(e,t){t=t||1/0;for(var n,i=e.length,s=null,r=[],o=0;o55295&&n<57344){if(!s){if(n>56319){(t-=3)>-1&&r.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&r.push(239,191,189);continue}s=n;continue}if(n<56320){(t-=3)>-1&&r.push(239,191,189),s=n;continue}n=65536+(s-55296<<10|n-56320)}else s&&(t-=3)>-1&&r.push(239,191,189);if(s=null,n<128){if((t-=1)<0)break;r.push(n)}else if(n<2048){if((t-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=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((t-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function V(e){for(var t=[],n=0;n>8,s=n%256,r.push(s),r.push(i);return r}function Y(e){return $.toByteArray(B(e))}function K(e,t,n,i){for(var s=0;s=t.length||s>=e.length);++s)t[s+n]=e[s];return s}function J(e){return e!==e}/*! +!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={};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=183)}([function(t,e,n){(function(t){e.Package=n(41),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(25).platform(),properties:{$os:t?t.platform:"discord.js",$browser:"discord.js",$device:"discord.js",$referrer:"",$referring_domain:""},version:6},http:{version:7,host:"https://discordapp.com",cdn:"https://cdn.discordapp.com"}},e.WSCodes={1e3:"Connection gracefully closed",4004:"Tried to identify with an invalid token",4010:"Sharding data provided was invalid",4011:"Shard would be on too many guilds if connected"},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=["webp","png","jpg","gif"],s=[128,256,512,1024,2048];e.Endpoints={CDN(t){return{Emoji:e=>`${t}/emojis/${e}.png`,Asset:e=>`${t}/assets/${e}`,DefaultAvatar:e=>`${t}/embed/avatars/${e}.png`,Avatar:(e,n,r="default",o)=>{"default"===r&&(r=n.startsWith("a_")?"gif":"webp");if(!i.includes(r))throw new Error(`Invalid image format: ${r}`);if(o&&!s.includes(o))throw new RangeError(`Invalid size: ${o}`);return`${t}/avatars/${e}/${n}.${r}${o?`?size=${o}`:""}`},Icon:(e,n,r="default",o)=>{"default"===r&&(r="webp");if(!i.includes(r))throw new Error(`Invalid image format: ${r}`);if(o&&!s.includes(o))throw new RangeError(`Invalid size: ${o}`);return`${t}/icons/${e}/${n}.${r}${o?`?size=${o}`:""}`},AppIcon:(e,n,r="default",o)=>{"default"===r&&(r="webp");if(!i.includes(r))throw new Error(`Invalid image format: ${r}`);if(o&&!s.includes(o))throw new RangeError(`Invalid size: ${o}`);return`${t}/app-icons/${e}/${n}.${r}${o?`?size=${o}`:""}`},Splash:(e,n)=>`${t}/splashes/${e}/${n}.jpg`}},invite:t=>`https://discord.gg/${t}`},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",USER_SETTINGS_UPDATE:"clientUserSettingsUpdate",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",RESUMED:"RESUMED",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",USER_SETTINGS_UPDATE:"USER_SETTINGS_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.ExplicitContentFilterTypes=["DISABLED","NON_FRIENDS","FRIENDS_AND_NON_FRIENDS"],e.UserSettingsMap={convert_emoticons:"convertEmoticons",default_guilds_restricted:"defaultGuildsRestricted",detect_platform_accounts:"detectPlatformAccounts",developer_mode:"developerMode",enable_tts_command:"enableTTSCommand",theme:"theme",status:"status",show_current_game:"showCurrentGame",inline_attachment_media:"inlineAttachmentMedia",inline_embed_media:"inlineEmbedMedia",locale:"locale",message_display_compact:"messageDisplayCompact",render_reactions:"renderReactions",guild_positions:"guildPositions",restricted_guilds:"restrictedGuilds",explicit_content_filter:function(t){return e.ExplicitContentFilterTypes[t]},friend_source_flags:function(t){return{all:t.all||!1,mutualGuilds:!!t.all||(t.mutual_guilds||!1),mutualFriends:!!t.all||(t.mutualFriends||!1)}}},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(7))},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(void 0===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(void 0===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(void 0===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[e,n]of this)t(n,e,this)&&i.set(e,n);return i}filterArray(t,e){e&&(t=t.bind(e));const n=[];for(const[e,i]of this)t(i,e,this)&&n.push(i);return n}map(t,e){e&&(t=t.bind(e));const n=new Array(this.size);let i=0;for(const[e,s]of this)n[i++]=t(s,e,this);return n}some(t,e){e&&(t=t.bind(e));for(const[e,n]of this)if(t(n,e,this))return!0;return!1}every(t,e){e&&(t=t.bind(e));for(const[e,n]of this)if(!t(n,e,this))return!1;return!0}reduce(t,e){let n;if(void 0!==e){n=e;for(const[e,i]of this)n=t(n,i,e,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[t,i]of n)e.set(t,i);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(38),s=n(0),r=s.DefaultOptions.http;class o{constructor(){throw new Error(`The ${this.constructor.name} class may not be instantiated.`)}static splitMessage(t,{maxLength:maxLength=1950,char:char="\n",prepend:prepend="",append: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 t=0;tmaxLength&&(n[i]+=append,n.push(prepend),i++),n[i]+=(n[i].length>0&&n[i]!==prepend?char:"")+e[t];return n.filter(t=>t)}static escapeMarkdown(t,e=!1,n=!1){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,o)=>{if(!t)throw new Error("A token must be provided.");i.get(`${r.host}/api/v${r.version}${s.Endpoints.gateway.bot}`).set("Authorization",`Bot ${t.replace(/^Bot\s*/i,"")}`).end((t,i)=>{t&&o(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 of t){const t=e.indexOf(n);-1!==t&&e.splice(t,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]=t[n]:e[n]===Object(e[n])&&(e[n]=this.mergeDefault(t[n],e[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=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function m(t){return+t!=t&&(t=0),r.alloc(+t)}function g(t,e){if(r.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 Y(t).length;default:if(i)return W(t).length;e=(""+e).toLowerCase(),i=!0}}function v(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 I(this,e,n);case"utf8":case"utf-8":return k(this,e,n);case"ascii":return M(this,e,n);case"latin1":case"binary":return C(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function E(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function b(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=r.from(e,i)),r.isBuffer(e))return 0===e.length?-1:w(t,e,n,i,s);if("number"==typeof e)return e&=255,r.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,a=t.length,c=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,n/=2}var l;if(s){var u=-1;for(l=n;la&&(n=a-c),l=n;l>=0;l--){for(var h=!0,p=0;ps&&(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+a<=n){var c,l,u,h;switch(a){case 1:r<128&&(o=r);break;case 2:c=t[s+1],128==(192&c)&&(h=(31&r)<<6|63&c)>127&&(o=h);break;case 3:c=t[s+1],l=t[s+2],128==(192&c)&&128==(192&l)&&(h=(15&r)<<12|(63&c)<<6|63&l)>2047&&(h<55296||h>57343)&&(o=h);break;case 4:c=t[s+1],l=t[s+2],u=t[s+3],128==(192&c)&&128==(192&l)&&128==(192&u)&&(h=(15&r)<<18|(63&c)<<12|(63&l)<<6|63&u)>65535&&h<1114112&&(o=h)}}null===o?(o=65533,a=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),s+=a}return D(i)}function D(t){var e=t.length;if(e<=Q)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 N(t,e,n,i,s,o){if(!r.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 U(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 j(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 P(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 G(t,e,n,i,s){return s||P(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(t,e,n,i,23,4),n+4}function B(t,e,n,i,s){return s||P(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(t,e,n,i,52,8),n+8}function q(t){if(t=z(t).replace(tt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function z(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function H(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=65536+(s-55296<<10|n-56320)}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 V(t){for(var e=[],n=0;n>8,s=n%256,r.push(s),r.push(i);return r}function Y(t){return $.toByteArray(q(t))}function K(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(76),X=n(79),Z=n(57);t.Buffer=r,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,r.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=i(),r.poolSize=8192,r._augment=function(e){return e.__proto__=r.prototype,e},r.from=function(e,t,n){return o(null,e,t,n)},r.TYPED_ARRAY_SUPPORT&&(r.prototype.__proto__=Uint8Array.prototype,r.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&r[Symbol.species]===r&&Object.defineProperty(r,Symbol.species,{value:null,configurable:!0})),r.alloc=function(e,t,n){return c(null,e,t,n)},r.allocUnsafe=function(e){return u(null,e)},r.allocUnsafeSlow=function(e){return u(null,e)},r.isBuffer=function(e){return!(null==e||!e._isBuffer)},r.compare=function(e,t){if(!r.isBuffer(e)||!r.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,i=t.length,s=0,o=Math.min(n,i);s0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},r.prototype.compare=function(e,t,n,i,s){if(!r.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),t<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&t>=n)return 0;if(i>=s)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;for(var o=s-i,a=n-t,c=Math.min(o,a),u=this.slice(i,s),l=e.slice(t,n),h=0;hs)&&(n=s),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var r=!1;;)switch(i){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return y(this,e,t,n);case"ascii":return x(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return R(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;r.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(s*=256);)i+=this[e+--t]*s;return i},r.prototype.readUInt8=function(e,t){return t||U(e,1,this.length),this[e]},r.prototype.readUInt16LE=function(e,t){return t||U(e,2,this.length),this[e]|this[e+1]<<8},r.prototype.readUInt16BE=function(e,t){return t||U(e,2,this.length),this[e]<<8|this[e+1]},r.prototype.readUInt32LE=function(e,t){return t||U(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},r.prototype.readUInt32BE=function(e,t){return t||U(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},r.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var i=this[e],s=1,r=0;++r=s&&(i-=Math.pow(2,8*t)),i},r.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||U(e,t,this.length);for(var i=t,s=1,r=this[e+--i];i>0&&(s*=256);)r+=this[e+--i]*s;return s*=128,r>=s&&(r-=Math.pow(2,8*t)),r},r.prototype.readInt8=function(e,t){return t||U(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},r.prototype.readInt16LE=function(e,t){t||U(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt16BE=function(e,t){t||U(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt32LE=function(e,t){return t||U(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},r.prototype.readInt32BE=function(e,t){return t||U(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},r.prototype.readFloatLE=function(e,t){return t||U(e,4,this.length),X.read(this,e,!0,23,4)},r.prototype.readFloatBE=function(e,t){return t||U(e,4,this.length),X.read(this,e,!1,23,4)},r.prototype.readDoubleLE=function(e,t){return t||U(e,8,this.length),X.read(this,e,!0,52,8)},r.prototype.readDoubleBE=function(e,t){return t||U(e,8,this.length),X.read(this,e,!1,52,8)},r.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t|=0,n|=0,!i){O(this,e,t,n,Math.pow(2,8*n)-1,0)}var s=1,r=0;for(this[t]=255&e;++r=0&&(r*=256);)this[t+s]=e/r&255;return t+n},r.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,1,255,0),r.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},r.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},r.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},r.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):P(this,e,t,!0),t+4},r.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):P(this,e,t,!1),t+4},r.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t|=0,!i){var s=Math.pow(2,8*n-1);O(this,e,t,n,s-1,-s)}var r=0,o=1,a=0;for(this[t]=255&e;++r>0)-a&255;return t+n},r.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t|=0,!i){var s=Math.pow(2,8*n-1);O(this,e,t,n,s-1,-s)}var r=n-1,o=1,a=0;for(this[t+r]=255&e;--r>=0&&(o*=256);)e<0&&0===a&&0!==this[t+r+1]&&(a=1),this[t+r]=(e/o>>0)-a&255;return t+n},r.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,1,127,-128),r.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},r.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},r.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},r.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,2147483647,-2147483648),r.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):P(this,e,t,!0),t+4},r.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):P(this,e,t,!1),t+4},r.prototype.writeFloatLE=function(e,t,n){return G(this,e,t,!0,n)},r.prototype.writeFloatBE=function(e,t,n){return G(this,e,t,!1,n)},r.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},r.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},r.prototype.copy=function(e,t,n,i){if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=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),e.length-t=0;--s)e[s+t]=this[s+n];else if(o<1e3||!r.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var o;if("number"==typeof e)for(o=t;o=t?String(e):(String(n).repeat(t)+e).slice(-t)}const s=n(33);let r=0;class o{constructor(){throw new Error(`The ${this.constructor.name} class may not be instantiated.`)}static generate(){r>=4095&&(r=0);const e=`${i((Date.now()-14200704e5).toString(2),42)}0000100000${i((r++).toString(2),12)}`;return s.fromString(e,2).toString()}static deconstruct(e){const t=i(s.fromString(e).toString(2),64),n={timestamp:parseInt(t.substring(0,42),2)+14200704e5,workerID:parseInt(t.substring(42,47),2),processID:parseInt(t.substring(47,52),2),increment:parseInt(t.substring(52,64),2),binary:t};return Object.defineProperty(n,"date",{get:function(){return new Date(this.timestamp)},enumerable:!0}),n}}e.exports=o},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function r(e){if(h===clearTimeout)return clearTimeout(e);if((h===i||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{return h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}function o(){m&&d&&(m=!1,d.length?f=d.concat(f):g=-1,f.length&&a())}function a(){if(!m){var e=s(o);m=!0;for(var t=f.length;t;){for(d=f,f=[];++g1)for(var n=1;nthis.has(e,t)):(e=this.constructor.resolve(e),!!(t&&(this.bitfield&this.constructor.FLAGS.ADMINISTRATOR)>0)||(this.bitfield&e)===e)}missing(e,t=!0){return e.filter(e=>!this.has(e,t))}add(...e){let t=0;for(let n=0;nthis.resolve(e)).reduce((e,t)=>e|t,0);if("string"==typeof e&&(e=this.FLAGS[e]),"number"!=typeof e||e<1)throw new RangeError(i.Errors.NOT_A_PERMISSION);return e}}s.FLAGS={CREATE_INSTANT_INVITE:1,KICK_MEMBERS:2,BAN_MEMBERS:4,ADMINISTRATOR:8,MANAGE_CHANNELS:16,MANAGE_GUILD:32,ADD_REACTIONS:64,VIEW_AUDIT_LOG:128,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,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_WEBHOOKS:1<<29,MANAGE_EMOJIS:1<<30},s.ALL=Object.keys(s.FLAGS).reduce((e,t)=>e|s.FLAGS[t],0),s.DEFAULT=104324097,e.exports=s},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t){class n{constructor(e={}){this.status=e.status||"offline",this.game=e.game?new i(e.game):null}update(e){this.status=e.status||this.status,this.game=e.game?new i(e.game):null}equals(e){return this===e||(e&&this.status===e.status&&this.game?this.game.equals(e.game):!e.game)}}class i{constructor(e){this.name=e.name,this.type=e.type,this.url=e.url||null}get streaming(){return 1===this.type}equals(e){return this===e||e&&this.name===e.name&&this.type===e.type&&this.url===e.url}}t.Presence=n,t.Game=i},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function s(e){return"number"==typeof e}function r(e){return"object"==typeof e&&null!==e}function o(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,s,a,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(n=this._events[e],o(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(r(n))for(a=Array.prototype.slice.call(arguments,1),u=n.slice(),s=u.length,c=0;c0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),s||(s=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var s=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,s,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],o=n.length,s=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(r(n)){for(a=o;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){s=a;break}if(s<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";function i(e){if(!(this instanceof i))return new i(e);u.call(this,e),l.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",s)}function s(){this.allowHalfOpen||this._writableState.ended||a(r,this)}function r(e){e.end()}var o=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};e.exports=i;var a=n(34),c=n(20);c.inherits=n(10);var u=n(58),l=n(36);c.inherits(i,u);for(var h=o(l.prototype),p=0;pe.roles.has(this.id))}get editable(){if(this.managed)return!1;const e=this.guild.member(this.client.user);return!!e.permissions.has(s.FLAGS.MANAGE_ROLES_OR_PERMISSIONS)&&e.highestRole.comparePositionTo(this)>0}get calculatedPosition(){const e=this.guild._sortedRoles;return e.array().indexOf(e.get(this.id))}serialize(){return new s(this.permissions).serialize()}hasPermission(e,t=!1,n){return new s(this.permissions).has(e,void 0!==n?n:!t)}comparePositionTo(e){return this.constructor.comparePositions(this,e)}edit(e){return this.client.rest.methods.updateGuildRole(this,e)}setName(e){return this.edit({name:e})}setColor(e){return this.edit({color:e})}setHoist(e){return this.edit({hoist:e})}setPosition(e,t){return this.guild.setRolePosition(this,e,t).then(()=>this)}setPermissions(e){return this.edit({permissions:e})}setMentionable(e){return this.edit({mentionable:e})}delete(){return this.client.rest.methods.deleteGuildRole(this)}equals(e){return e&&this.id===e.id&&this.name===e.name&&this.color===e.color&&this.hoist===e.hoist&&this.position===e.position&&this.permissions===e.permissions&&this.managed===e.managed}toString(){return this.id===this.guild.id?"@everyone":`<@&${this.id}>`}static comparePositions(e,t){return e.position===t.position?t.id-e.id:e.position-t.position}}e.exports=r},function(e,t,n){const i=n(22),s=n(0),r=n(11).Presence,o=n(6);class a{constructor(e,t){Object.defineProperty(this,"client",{value:e}),t&&this.setup(t)}setup(e){this.id=e.id,this.username=e.username,this.discriminator=e.discriminator,this.avatar=e.avatar,this.bot=Boolean(e.bot),this.lastMessageID=null,this.lastMessage=null}patch(e){for(const t of["id","username","discriminator","avatar","bot"])void 0!==e[t]&&(this[t]=e[t]);e.token&&(this.client.token=e.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 e of this.client.guilds.values())if(e.presences.has(this.id))return e.presences.get(this.id);return new r}avatarURL(e,t){return this.avatar?("number"==typeof e&&(t=e,e="default"),s.Endpoints.User(this).Avatar(this.client.options.http.cdn,this.avatar,e,t)):null}get defaultAvatarURL(){return s.Endpoints.CDN(this.client.options.http.host).DefaultAvatar(this.discriminator%5)}get displayAvatarURL(){return this.avatarURL()||this.defaultAvatarURL}get tag(){return`${this.username}#${this.discriminator}`}get note(){return this.client.user.notes.get(this.id)||null}typingIn(e){return e=this.client.resolver.resolveChannel(e),e._typing.has(this.id)}typingSinceIn(e){return e=this.client.resolver.resolveChannel(e),e._typing.has(this.id)?new Date(e._typing.get(this.id).since):null}typingDurationIn(e){return e=this.client.resolver.resolveChannel(e),e._typing.has(this.id)?e._typing.get(this.id).elapsedTime:-1}get dmChannel(){return this.client.channels.filter(e=>"dm"===e.type).find(e=>e.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(e){return this.client.rest.methods.setNote(this,e)}equals(e){return e&&this.id===e.id&&this.username===e.username&&this.discriminator===e.discriminator&&this.avatar===e.avatar&&this.bot===Boolean(e.bot)}toString(){return`<@${this.id}>`}send(){}}i.applyToClass(a),e.exports=a},function(e,t,n){const i=n(0),s=n(3),r=n(6);class o{constructor(e,t){Object.defineProperty(this,"client",{value:e.client}),this.guild=e,this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.requiresColons=e.require_colons,this.managed=e.managed,this._roles=e.roles}get createdTimestamp(){return r.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get roles(){const e=new s;for(const t of this._roles)this.guild.roles.has(t)&&e.set(t,this.guild.roles.get(t));return e}get url(){return i.Endpoints.CDN(this.client.options.http.cdn).Emoji(this.id)}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}edit(e){return this.client.rest.methods.updateEmoji(this,e)}setName(e){return this.edit({name:e})}addRestrictedRole(e){return this.addRestrictedRoles([e])}addRestrictedRoles(e){const t=new s(this.roles);for(const n of e)this.guild.roles.has(n.id)&&t.set(n.id,n);return this.edit({roles:t})}removeRestrictedRole(e){return this.removeRestrictedRoles([e])}removeRestrictedRoles(e){const t=new s(this.roles);for(const n of e)t.has(n.id)&&t.delete(n.id);return this.edit({roles:t})}toString(){return this.requiresColons?`<:${this.name}:${this.id}>`:this.name}equals(e){return e instanceof o?e.id===this.id&&e.name===this.name&&e.managed===this.managed&&e.requiresColons===this.requiresColons:e.id===this.id&&e.name===this.name}}e.exports=o},function(e,t,n){const i=n(22),s=n(15),r=n(8),o=n(3),a=n(11).Presence;class c{constructor(e,t){Object.defineProperty(this,"client",{value:e.client}),this.guild=e,this.user={},this._roles=[],t&&this.setup(t),this.lastMessageID=null,this.lastMessage=null}setup(e){this.serverDeaf=e.deaf,this.serverMute=e.mute,this.selfMute=e.self_mute,this.selfDeaf=e.self_deaf,this.voiceSessionID=e.session_id,this.voiceChannelID=e.channel_id,this.speaking=!1,this.nickname=e.nick||null,this.joinedTimestamp=new Date(e.joined_at).getTime(),this.user=e.user,this._roles=e.roles}get joinedAt(){return new Date(this.joinedTimestamp)}get presence(){return this.frozenPresence||this.guild.presences.get(this.id)||new a}get roles(){const e=new o,t=this.guild.roles.get(this.guild.id);t&&e.set(t.id,t);for(const t of this._roles){const n=this.guild.roles.get(t);n&&e.set(n.id,n)}return e}get highestRole(){return this.roles.reduce((e,t)=>!e||t.comparePositionTo(e)>0?t:e)}get colorRole(){const e=this.roles.filter(e=>e.color);return e.size?e.reduce((e,t)=>!e||t.comparePositionTo(e)>0?t:e):null}get displayColor(){const e=this.colorRole;return e&&e.color||0}get displayHexColor(){const e=this.colorRole;return e&&e.hexColor||"#000000"}get hoistRole(){const e=this.roles.filter(e=>e.hoist);return e.size?e.reduce((e,t)=>!e||t.comparePositionTo(e)>0?t:e):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(r.ALL);let e=0;const t=this.roles;for(const n of t.values())e|=n.permissions;return new r(e)}get kickable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const e=this.guild.member(this.client.user);return!!e.permissions.has(r.FLAGS.KICK_MEMBERS)&&e.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 e=this.guild.member(this.client.user);return!!e.permissions.has(r.FLAGS.BAN_MEMBERS)&&e.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(e){if(!(e=this.client.resolver.resolveChannel(e))||!e.guild)throw new Error("Could not resolve channel to a guild channel.");return e.permissionsFor(this)}hasPermission(e,t=!1,n,i){return void 0===n&&(n=!t),void 0===i&&(i=!t),!(!i||this.user.id!==this.guild.ownerID)||this.roles.some(t=>t.hasPermission(e,void 0,n))}missingPermissions(e,t=!1){return e.missing(e,t)}edit(e){return this.client.rest.methods.updateGuildMember(this,e)}setMute(e){return this.edit({mute:e})}setDeaf(e){return this.edit({deaf:e})}setVoiceChannel(e){return this.edit({channel:e})}setRoles(e){return this.edit({roles:e})}addRole(e){return e instanceof s||(e=this.guild.roles.get(e)),e?this.client.rest.methods.addMemberRole(this,e):Promise.reject(new TypeError("Supplied parameter was neither a Role nor a Snowflake."))}addRoles(e){let t;if(e instanceof o){t=this._roles.slice();for(const n of e.values())t.push(n.id)}else t=this._roles.concat(e);return this.edit({roles:t})}removeRole(e){return e instanceof s||(e=this.guild.roles.get(e)),e?this.client.rest.methods.removeMemberRole(this,e):Promise.reject(new TypeError("Supplied parameter was neither a Role nor a Snowflake."))}removeRoles(e){const t=this._roles.slice();if(e instanceof o)for(const n of e.values()){const e=t.indexOf(n.id);e>=0&&t.splice(e,1)}else for(const n of e){const e=t.indexOf(n instanceof s?n.id:n);e>=0&&t.splice(e,1)}return this.edit({roles:t})}setNickname(e){return this.edit({nick:e})}createDM(){return this.user.createDM()}deleteDM(){return this.user.deleteDM()}kick(e){return this.client.rest.methods.kickGuildMember(this.guild,this,e)}ban(e){return this.guild.ban(this,e)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}send(){}}i.applyToClass(c),e.exports=c},function(e,t,n){const i=n(49),s=n(46),r=n(48),o=n(50),a=n(54),c=n(4),u=n(3),l=n(0),h=n(8);let p;class d{constructor(e,t,n){Object.defineProperty(this,"client",{value:n}),this.channel=e,t&&this.setup(t)}setup(e){this.id=e.id,this.type=l.MessageTypes[e.type],this.content=e.content,this.author=this.client.dataManager.newUser(e.author),this.member=this.guild?this.guild.member(this.author)||null:null,this.pinned=e.pinned,this.tts=e.tts,this.nonce=e.nonce,this.system=6===e.type,this.embeds=e.embeds.map(e=>new r(this,e)),this.attachments=new u;for(const t of e.attachments)this.attachments.set(t.id,new s(this,t));if(this.createdTimestamp=new Date(e.timestamp).getTime(),this.editedTimestamp=e.edited_timestamp?new Date(e.edited_timestamp).getTime():null,this.reactions=new u,e.reactions&&e.reactions.length>0)for(const t of e.reactions){const e=t.emoji.id?`${t.emoji.name}:${t.emoji.id}`:t.emoji.name;this.reactions.set(e,new o(this,t.emoji,t.count,t.me))}this.mentions=new i(this,e.mentions,e.mention_roles,e.mention_everyone),this.webhookID=e.webhook_id||null,this.hit="boolean"==typeof e.hit?e.hit:null,this._edits=[]}patch(e){const t=c.cloneObject(this);if(this._edits.unshift(t),this.editedTimestamp=new Date(e.edited_timestamp).getTime(),"content"in e&&(this.content=e.content),"pinned"in e&&(this.pinned=e.pinned),"tts"in e&&(this.tts=e.tts),this.embeds="embeds"in e?e.embeds.map(e=>new r(this,e)):this.embeds.slice(),"attachments"in e){this.attachments=new u;for(const t of e.attachments)this.attachments.set(t.id,new s(this,t))}else this.attachments=new u(this.attachments);this.mentions=new i(this,"mentions"in e?e.mentions:this.mentions.users,"mentions_roles"in e?e.mentions_roles:this.mentions.roles,"mention_everyone"in e?e.mention_everyone:this.mentions.everyone)}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,e=>{const t=e.replace(/<|!|>|@/g,"");if("dm"===this.channel.type||"group"===this.channel.type)return this.client.users.has(t)?`@${this.client.users.get(t).username}`:e;const n=this.channel.guild.members.get(t);if(n)return n.nickname?`@${n.nickname}`:`@${n.user.username}`;{const n=this.client.users.get(t);return n?`@${n.username}`:e}}).replace(/<#[0-9]+>/g,e=>{const t=this.client.channels.get(e.replace(/<|#|>/g,""));if(t)return`#${t.name}`;return e}).replace(/<@&[0-9]+>/g,e=>{if("dm"===this.channel.type||"group"===this.channel.type)return e;const t=this.guild.roles.get(e.replace(/<|@|>|&/g,""));if(t)return`@${t.name}`;return e})}createReactionCollector(e,t={}){return new a(this,e,t)}awaitReactions(e,t={}){return new Promise((n,i)=>{const s=this.createReactionCollector(e,t);s.once("end",(e,s)=>{t.errors&&t.errors.includes(s)?i(e):n(e)})})}get edits(){const e=this._edits.slice();return e.unshift(this),e}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).has(h.FLAGS.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).has(h.FLAGS.MANAGE_MESSAGES)}isMentioned(e){return e=e&&e.id?e.id:e,this.mentions.users.has(e)||this.mentions.channels.has(e)||this.mentions.roles.has(e)}isMemberMentioned(e){return p||(p=n(18)),!!this.mentions.everyone||(!!this.mentions.users.has(e.id)||!!(e instanceof p&&e.roles.some(e=>this.mentions.roles.has(e.id))))}edit(e,t){return t||"object"!=typeof e||e instanceof Array?t||(t={}):(t=e,e=""),this.client.rest.methods.updateMessage(this,e,t)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(e){if(!(e=this.client.resolver.resolveEmojiIdentifier(e)))throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,e)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(e=0){return e<=0?this.client.rest.methods.deleteMessage(this):new Promise(t=>{this.client.setTimeout(()=>{t(this.delete())},e)})}reply(e,t){return t||"object"!=typeof e||e instanceof Array?t||(t={}):(t=e,e=""),this.channel.send(e,Object.assign(t,{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(e,t){if(!e)return!1;if(!e.author&&!e.attachments)return this.id===e.id&&this.embeds.length===e.embeds.length;let n=this.id===e.id&&this.author.id===e.author.id&&this.content===e.content&&this.tts===e.tts&&this.nonce===e.nonce&&this.embeds.length===e.embeds.length&&this.attachments.length===e.attachments.length;return n&&t&&(n=this.mentions.everyone===e.mentions.everyone&&this.createdTimestamp===new Date(t.timestamp).getTime()&&this.editedTimestamp===new Date(t.edited_timestamp).getTime()),n}toString(){return this.content}_addReaction(e,t){const n=e.id?`${e.name}:${e.id}`:encodeURIComponent(e.name);let i;return this.reactions.has(n)?(i=this.reactions.get(n),i.me||(i.me=t.id===this.client.user.id)):(i=new o(this,e,0,t.id===this.client.user.id),this.reactions.set(n,i)),i.users.has(t.id)||i.users.set(t.id,t),i.count++,i}_removeReaction(e,t){const n=e.id?`${e.name}:${e.id}`:encodeURIComponent(e.name);if(this.reactions.has(n)){const e=this.reactions.get(n);if(e.users.has(t.id))return e.users.delete(t.id),e.count--,t.id===this.client.user.id&&(e.me=!1),e.count<=0&&this.reactions.delete(n),e}return null}_clearReactions(){this.reactions.clear()}}e.exports=d},function(e,t,n){(function(e){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===g(e)}function i(e){return"boolean"==typeof e}function s(e){return null===e}function r(e){return null==e}function o(e){return"number"==typeof e}function a(e){return"string"==typeof e}function c(e){return"symbol"==typeof e}function u(e){return void 0===e}function l(e){return"[object RegExp]"===g(e)}function h(e){return"object"==typeof e&&null!==e}function p(e){return"[object Date]"===g(e)}function d(e){return"[object Error]"===g(e)||e instanceof Error}function f(e){return"function"==typeof e}function m(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function g(e){return Object.prototype.toString.call(e)}t.isArray=n,t.isBoolean=i,t.isNull=s,t.isNullOrUndefined=r,t.isNumber=o,t.isString=a,t.isSymbol=c,t.isUndefined=u,t.isRegExp=l,t.isObject=h,t.isDate=p,t.isError=d,t.isFunction=f,t.isPrimitive=m,t.isBuffer=e.isBuffer}).call(t,n(5).Buffer)},function(e,t,n){t=e.exports=n(58),t.Stream=t,t.Readable=t,t.Writable=n(36),t.Duplex=n(13),t.Transform=n(59),t.PassThrough=n(84)},function(e,t,n){const i=n(27),s=n(19),r=n(47),o=n(3);class a{constructor(){this.messages=new o,this.lastMessageID=null,this.lastMessage=null}send(e,t){if(t||"object"!=typeof e||e instanceof Array?t||(t={}):(t=e,e=""),t.embed&&t.embed.file&&(t.file=t.embed.file),t.file&&(t.files?t.files.push(t.file):t.files=[t.file]),t.files){for(let e=0;ethis.client.resolver.resolveBuffer(e.attachment).then(t=>{e.file=t;return e}))).then(n=>this.client.rest.methods.sendMessage(this,e,t,n))}return this.client.rest.methods.sendMessage(this,e,t)}fetchMessage(e){return this.client.user.bot?this.client.rest.methods.getChannelMessage(this,e).then(e=>{const t=e instanceof s?e:new s(this,e,this.client);this._cacheMessage(t);return t}):this.fetchMessages({limit:1,around:e}).then(t=>{const n=t.get(e);if(!n)throw new Error("Message not found.");return n})}fetchMessages(e={}){return this.client.rest.methods.getChannelMessages(this,e).then(e=>{const t=new o;for(const n of e){const e=new s(this,n,this.client);t.set(n.id,e),this._cacheMessage(e)}return t})}fetchPinnedMessages(){return this.client.rest.methods.getChannelPinnedMessages(this).then(e=>{const t=new o;for(const n of e){const e=new s(this,n,this.client);t.set(n.id,e),this._cacheMessage(e)}return t})}search(e={}){return this.client.rest.methods.search(this,e)}startTyping(e){if(void 0!==e&&e<1)throw new RangeError("Count must be at least 1.");if(this.client.user._typing.has(this.id)){const t=this.client.user._typing.get(this.id);t.count=e||t.count+1}else this.client.user._typing.set(this.id,{count:e||1,interval:this.client.setInterval(()=>{this.client.rest.methods.sendTyping(this.id)},9e3)}),this.client.rest.methods.sendTyping(this.id)}stopTyping(e=!1){if(this.client.user._typing.has(this.id)){const t=this.client.user._typing.get(this.id);t.count--,(t.count<=0||e)&&(this.client.clearInterval(t.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}createMessageCollector(e,t={}){return new r(this,e,t)}awaitMessages(e,t={}){return new Promise((n,i)=>{const s=this.createMessageCollector(e,t);s.once("end",(e,s)=>{t.errors&&t.errors.includes(s)?i(e):n(e)})})}bulkDelete(e,t=!1){if(!isNaN(e))return this.fetchMessages({limit:e}).then(e=>this.bulkDelete(e,t));if(e instanceof Array||e instanceof o){const n=e instanceof o?e.keyArray():e.map(e=>e.id);return this.client.rest.methods.bulkDeleteMessages(this,n,t)}throw new TypeError("The messages must be an Array, Collection, or number.")}acknowledge(){return this.lastMessageID?this.client.rest.methods.ackTextChannel(this):Promise.resolve(this)}_cacheMessage(e){const t=this.client.options.messageCacheMaxSize;return 0===t?null:(this.messages.size>=t&&t>0&&this.messages.delete(this.messages.firstKey()),this.messages.set(e.id,e),e)}}t.applyToClass=((e,t=!1,n=[])=>{const i=["send"];t&&i.push("_cacheMessage","acknowledge","fetchMessages","fetchMessage","search","bulkDelete","startTyping","stopTyping","typing","typingCount","fetchPinnedMessages","createMessageCollector","awaitMessages");for(const t of i)n.includes(t)||Object.defineProperty(e.prototype,t,Object.getOwnPropertyDescriptor(a.prototype,t))})},function(e,t){t.endianness=function(){return"LE"},t.hostname=function(){return"undefined"!=typeof location?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL="\n"},function(e,t,n){const i=n(33),s=n(16),r=n(15),o=n(17),a=n(11).Presence,c=n(18),u=n(0),l=n(3),h=n(4),p=n(6);class d{constructor(e,t){Object.defineProperty(this,"client",{value:e}),this.members=new l,this.channels=new l,this.roles=new l,this.presences=new l,t&&(t.unavailable?(this.available=!1,this.id=t.id):(this.available=!0,this.setup(t)))}setup(e){if(this.name=e.name,this.icon=e.icon,this.splash=e.splash,this.region=e.region,this.memberCount=e.member_count||this.memberCount,this.large=Boolean("large"in e?e.large:this.large),this.features=e.features,this.applicationID=e.application_id,this.afkTimeout=e.afk_timeout,this.afkChannelID=e.afk_channel_id,this.embedEnabled=e.embed_enabled,this.verificationLevel=e.verification_level,this.explicitContentFilter=e.explicit_content_filter,this.joinedTimestamp=e.joined_at?new Date(e.joined_at).getTime():this.joinedTimestamp,this.id=e.id,this.available=!e.unavailable,this.features=e.features||this.features||[],e.members){this.members.clear();for(const t of e.members)this._addMember(t,!1)}if(e.owner_id&&(this.ownerID=e.owner_id),e.channels){this.channels.clear();for(const t of e.channels)this.client.dataManager.newChannel(t,this)}if(e.roles){this.roles.clear();for(const t of e.roles){const e=new r(this,t);this.roles.set(e.id,e)}}if(e.presences)for(const t of e.presences)this._setPresence(t.user.id,t);if(this._rawVoiceStates=new l,e.voice_states)for(const t of e.voice_states){this._rawVoiceStates.set(t.user_id,t);const e=this.members.get(t.user_id);e&&(e.serverMute=t.mute,e.serverDeaf=t.deaf,e.selfMute=t.self_mute,e.selfDeaf=t.self_deaf,e.voiceSessionID=t.session_id,e.voiceChannelID=t.channel_id,this.channels.get(t.channel_id).members.set(e.user.id,e))}if(this.emojis)this.client.actions.GuildEmojisUpdate.handle({guild_id:this.id,emojis:e.emojis});else{this.emojis=new l;for(const t of e.emojis)this.emojis.set(t.id,new o(this,t))}}get createdTimestamp(){return p.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}iconURL(e,t){return this.icon?("number"==typeof e&&(t=e,e="default"),u.Endpoints.Guild(this).Icon(this.client.options.http.cdn,this.icon,e,t)):null}get nameAcronym(){return this.name.replace(/\w+/g,e=>e[0]).replace(/\s/g,"")}get splashURL(){return this.splash?u.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 position(){return this.client.user.bot?null:this.client.user.settings.guildPositions?this.client.user.settings.guildPositions.indexOf(this.id):null}get defaultRole(){return this.roles.get(this.id)}get me(){return this.members.get(this.client.user.id)}get _sortedRoles(){return this._sortPositionWithID(this.roles)}member(e){return this.client.resolver.resolveGuildMember(this,e)}fetchBans(){return this.client.rest.methods.getGuildBans(this).then(e=>{const t=new l;for(const n of e.values())t.set(n.user.id,n.user);return t})}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)}fetchAuditLogs(e){return this.client.rest.methods.getGuildAuditLogs(this,e)}addMember(e,t){return this.members.has(e.id)?Promise.resolve(this.members.get(e.id)):this.client.rest.methods.putGuildMember(this,e,t)}fetchMember(e,t=!0){return e=this.client.resolver.resolveUser(e),e?this.members.has(e.id)?Promise.resolve(this.members.get(e.id)):this.client.rest.methods.getGuildMember(this,e,t):Promise.reject(new Error("User is not cached. Use Client.fetchUser first."))}fetchMembers(e="",t=0){return new Promise((n,i)=>{if(this.memberCount===this.members.size)return void n(this);this.client.ws.send({op:u.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:e,limit:t}});const s=(e,t)=>{if(t.id!==this.id)return;(this.memberCount===this.members.size||e.length<1e3)&&(this.client.removeListener(u.Events.GUILD_MEMBERS_CHUNK,s),n(this))};this.client.on(u.Events.GUILD_MEMBERS_CHUNK,s);this.client.setTimeout(()=>i(new Error("Members didn't arrive in time.")),12e4)})}search(e={}){return this.client.rest.methods.search(this,e)}edit(e){return this.client.rest.methods.updateGuild(this,e)}setName(e){return this.edit({name:e})}setRegion(e){return this.edit({region:e})}setVerificationLevel(e){return this.edit({verificationLevel:e})}setAFKChannel(e){return this.edit({afkChannel:e})}setAFKTimeout(e){return this.edit({afkTimeout:e})}setIcon(e){return this.edit({icon:e})}setOwner(e){return this.edit({owner:e})}setSplash(e){return this.edit({splash:e})}setPosition(e,t){return this.client.user.bot?Promise.reject(new Error("Setting guild position is only available for user accounts")):this.client.user.settings.setGuildPosition(this,e,t)}acknowledge(){return this.client.rest.methods.ackGuild(this)}allowDMs(e){const t=this.client.user.settings;return e?t.removeRestrictedGuild(this):t.addRestrictedGuild(this)}ban(e,t={}){return"number"==typeof t?t={reason:null,"delete-message-days":t}:"string"==typeof t&&(t={reason:t,"delete-message-days":0}),t.days&&(t["delete-message-days"]=t.days),this.client.rest.methods.banGuildMember(this,e,t)}unban(e){return this.client.rest.methods.unbanGuildMember(this,e)}pruneMembers(e,t=!1){if("number"!=typeof e)throw new TypeError("Days must be a number.");return this.client.rest.methods.pruneGuildMembers(this,e,t)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(e,t,n){return this.client.rest.methods.createChannel(this,e,t,n)}setChannelPositions(e){return this.client.rest.methods.updateChannelPositions(this.id,e)}createRole(e={}){return this.client.rest.methods.createGuildRole(this,e)}createEmoji(e,t,n){return new Promise(i=>{"string"==typeof e&&e.startsWith("data:")?i(this.client.rest.methods.createEmoji(this,e,t,n)):this.client.resolver.resolveBuffer(e).then(e=>{const s=this.client.resolver.resolveBase64(e);i(this.client.rest.methods.createEmoji(this,s,t,n))})})}deleteEmoji(e){return e instanceof o||(e=this.emojis.get(e)),this.client.rest.methods.deleteEmoji(e)}leave(){return this.client.rest.methods.leaveGuild(this)}delete(){return this.client.rest.methods.deleteGuild(this)}equals(e){let t=e&&this.id===e.id&&this.available===!e.unavailable&&this.splash===e.splash&&this.region===e.region&&this.name===e.name&&this.memberCount===e.member_count&&this.large===e.large&&this.icon===e.icon&&h.arraysEqual(this.features,e.features)&&this.ownerID===e.owner_id&&this.verificationLevel===e.verification_level&&this.embedEnabled===e.embed_enabled;return t&&(this.embedChannel?this.embedChannel.id!==e.embed_channel_id&&(t=!1):e.embed_channel_id&&(t=!1)),t}toString(){return this.name}_addMember(e,t=!0){const n=this.members.has(e.user.id);e.user instanceof s||(e.user=this.client.dataManager.newUser(e.user)),e.joined_at=e.joined_at||0;const i=new c(this,e);if(this.members.set(i.id,i),this._rawVoiceStates&&this._rawVoiceStates.has(i.user.id)){const e=this._rawVoiceStates.get(i.user.id);i.serverMute=e.mute,i.serverDeaf=e.deaf,i.selfMute=e.self_mute,i.selfDeaf=e.self_deaf,i.voiceSessionID=e.session_id,i.voiceChannelID=e.channel_id,this.client.channels.has(e.channel_id)?this.client.channels.get(e.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.connection.status===u.Status.READY&&t&&!n&&this.client.emit(u.Events.GUILD_MEMBER_ADD,i),i}_updateMember(e,t){const n=h.cloneObject(e);t.roles&&(e._roles=t.roles),void 0!==t.nick&&(e.nickname=t.nick);const i=e.nickname!==n.nickname||!h.arraysEqual(e._roles,n._roles);return this.client.ws.connection.status===u.Status.READY&&i&&this.client.emit(u.Events.GUILD_MEMBER_UPDATE,n,e),{old:n,mem:e}}_removeMember(e){this.members.delete(e.id)}_memberSpeakUpdate(e,t){const n=this.members.get(e);n&&n.speaking!==t&&(n.speaking=t,this.client.emit(u.Events.GUILD_MEMBER_SPEAKING,n,t))}_setPresence(e,t){if(this.presences.get(e))return void this.presences.get(e).update(t);this.presences.set(e,new a(t))}setRolePosition(e,t,n=!1){if("string"==typeof e&&!(e=this.roles.get(e)))return Promise.reject(new Error("Supplied role is not a role or snowflake."));if(t=Number(t),isNaN(t))return Promise.reject(new Error("Supplied position is not a number."));let i=this._sortedRoles.array();return h.moveElementInArray(i,e,t,n),i=i.map((e,t)=>({id:e.id,position:t})),this.client.rest.methods.setRolePositions(this.id,i)}setChannelPosition(e,t,n=!1){if("string"==typeof e&&!(e=this.channels.get(e)))return Promise.reject(new Error("Supplied channel is not a channel or snowflake."));if(t=Number(t),isNaN(t))return Promise.reject(new Error("Supplied position is not a number."));let i=this._sortedChannels(e.type).array();return h.moveElementInArray(i,e,t,n),i=i.map((e,t)=>({id:e.id,position:t})),this.client.rest.methods.setChannelPositions(this.id,i)}_sortedChannels(e){return this._sortPositionWithID(this.channels.filter(t=>"voice"===e&&"voice"===t.type||("voice"!==e&&"voice"!==t.type||e===t.type)))}_sortPositionWithID(e){return e.sort((e,t)=>e.position!==t.position?e.position-t.position:i.fromString(e.id).sub(i.fromString(t.id)).toNumber())}}e.exports=d},function(e,t,n){const i=n(14),s=n(15),r=n(53),o=n(8),a=n(3);class c extends i{constructor(e,t){super(e.client,t),this.guild=e}setup(e){if(super.setup(e),this.name=e.name,this.position=e.position,this.permissionOverwrites=new a,e.permission_overwrites)for(const t of e.permission_overwrites)this.permissionOverwrites.set(t.id,new r(this,t))}get calculatedPosition(){const e=this.guild._sortedChannels(this.type);return e.array().indexOf(e.get(this.id))}permissionsFor(e){if(!(e=this.client.resolver.resolveGuildMember(this.guild,e)))return null;if(e.id===this.guild.ownerID)return new o(o.ALL);let t=0;const n=e.roles;for(const e of n.values())t|=e.permissions;const i=this.overwritesFor(e,!0,n);i.everyone&&(t&=~i.everyone.deny,t|=i.everyone.allow);let s=0;for(const e of i.roles)t&=~e.deny,s|=e.allow;return t|=s,i.member&&(t&=~i.member.deny,t|=i.member.allow),Boolean(t&o.FLAGS.ADMINISTRATOR)&&(t=o.ALL),new o(t)}overwritesFor(e,t=!1,n=null){if(t||(e=this.client.resolver.resolveGuildMember(this.guild,e)),!e)return[];n=n||e.roles;const i=[];let s,r;for(const t of this.permissionOverwrites.values())t.id===this.guild.id?r=t:n.has(t.id)?i.push(t):t.id===e.id&&(s=t);return{everyone:r,roles:i,member:s}}overwritePermissions(e,t){const n={allow:0,deny:0};if(e instanceof s)n.type="role";else if(this.guild.roles.has(e))e=this.guild.roles.get(e),n.type="role";else if(e=this.client.resolver.resolveUser(e),n.type="member",!e)return Promise.reject(new TypeError("Supplied parameter was neither a User nor a Role."));n.id=e.id;const i=this.permissionOverwrites.get(e.id);i&&(n.allow=i.allow,n.deny=i.deny);for(const e in t)!0===t[e]?(n.allow|=o.FLAGS[e]||0,n.deny&=~(o.FLAGS[e]||0)):!1===t[e]?(n.allow&=~(o.FLAGS[e]||0),n.deny|=o.FLAGS[e]||0):null===t[e]&&(n.allow&=~(o.FLAGS[e]||0),n.deny&=~(o.FLAGS[e]||0));return this.client.rest.methods.setChannelOverwrite(this,n)}edit(e){return this.client.rest.methods.updateChannel(this,e)}setName(e){return this.edit({name:e})}setPosition(e,t){return this.guild.setChannelPosition(this,e,t).then(()=>this)}setTopic(e){return this.client.rest.methods.updateChannel(this,{topic:e})}createInvite(e={}){return this.client.rest.methods.createChannelInvite(this,e)}clone(e=this.name,t=!0,n=!0){return this.guild.createChannel(e,this.type,t?this.permissionOverwrites:[]).then(e=>n?e.setTopic(this.topic):e)}equals(e){let t=e&&this.id===e.id&&this.type===e.type&&this.topic===e.topic&&this.position===e.position&&this.name===e.name;return t&&(t=this.permissionOverwrites&&e.permissionOverwrites?this.permissionOverwrites.equals(e.permissionOverwrites):!this.permissionOverwrites&&!e.permissionOverwrites),t}get deletable(){return this.id!==this.guild.id&&this.permissionsFor(this.client.user).has(o.FLAGS.MANAGE_CHANNELS)}toString(){return`<#${this.id}>`}}e.exports=c},function(e,t,n){const i=n(6),s=n(0);class r{constructor(e,t){Object.defineProperty(this,"client",{value:e}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.description=e.description,this.icon=e.icon,this.rpcOrigins=e.rpc_origins,this.redirectURIs=e.redirect_uris,this.botRequireCodeGrant=e.bot_require_code_grant,this.botPublic=e.bot_public,this.rpcApplicationState=e.rpc_application_state,this.bot=e.bot,this.flags=e.flags,this.secret=e.secret,e.owner&&(this.owner=this.client.dataManager.newUser(e.owner))}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}iconURL(e,t){return this.icon?("number"==typeof e&&(t=e,e="default"),s.Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id,this.icon,e,t)):null}reset(){return this.client.rest.methods.resetApplication(this.id)}toString(){return this.name}}e.exports=r},function(e,t,n){(function(e){function n(e,t){for(var n=0,i=e.length-1;i>=0;i--){var s=e[i];"."===s?e.splice(i,1):".."===s?(e.splice(i,1),n++):n&&(e.splice(i,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function i(e,t){if(e.filter)return e.filter(t);for(var n=[],i=0;i=-1&&!s;r--){var o=r>=0?arguments[r]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,s="/"===o.charAt(0))}return t=n(i(t.split("/"),function(e){return!!e}),!s).join("/"),(s?"/":"")+t||"."},t.normalize=function(e){var s=t.isAbsolute(e),r="/"===o(e,-1);return e=n(i(e.split("/"),function(e){return!!e}),!s).join("/"),e||s||(e="."),e&&r&&(e+="/"),(s?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(i(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function i(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var s=i(e.split("/")),r=i(n.split("/")),o=Math.min(s.length,r.length),a=o,c=0;c[e.id,e.nick]))),this.recipients||(this.recipients=new r),e.recipients)for(const t of e.recipients){const e=this.client.dataManager.newUser(t);this.recipients.set(e.id,e)}this.lastMessageID=e.last_message_id}get owner(){return this.client.users.get(this.ownerID)}equals(e){const t=e&&this.id===e.id&&this.name===e.name&&this.icon===e.icon&&this.ownerID===e.ownerID;return t?this.recipients.equals(e.recipients):t}addUser(e,t){return this.client.rest.methods.addUserToGroupDM(this,{nick:t,id:this.client.resolver.resolveUserID(e),accessToken:e})}toString(){return this.name}send(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0,["bulkDelete"]),e.exports=o},function(e,t){class n{constructor(e,t,n){this.reaction=e,this.name=t,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}}e.exports=n},function(e,t,n){const i=n(27);class s{constructor(e,t,n){e?(Object.defineProperty(this,"client",{value:e}),t&&this.setup(t)):(this.id=t,this.token=n,Object.defineProperty(this,"client",{value:this}))}setup(e){this.name=e.name,this.token=e.token,this.avatar=e.avatar,this.id=e.id,this.guildID=e.guild_id,this.channelID=e.channel_id,e.user?this.owner=this.client.users?this.client.users.get(e.user.id):e.user:this.owner=null}send(e,t){if(t||"object"!=typeof e||e instanceof Array?t||(t={}):(t=e,e=""),t.file&&(t.files?t.files.push(t.file):t.files=[t.file]),t.files){for(let e=0;ethis.client.resolver.resolveBuffer(e.attachment).then(t=>{e.file=t;return e}))).then(n=>this.client.rest.methods.sendWebhookMessage(this,e,t,n))}return this.client.rest.methods.sendWebhookMessage(this,e,t)}sendSlackMessage(e){return this.client.rest.methods.sendSlackWebhookMessage(this,e)}edit(e=this.name,t){return t?this.client.resolver.resolveBuffer(t).then(t=>{const n=this.client.resolver.resolveBase64(t);return this.client.rest.methods.editWebhook(this,e,n)}):this.client.rest.methods.editWebhook(this,e).then(e=>{this.setup(e);return this})}delete(){return this.client.rest.methods.deleteWebhook(this)}}e.exports=s},function(e,t,n){const i=n(3),s=n(12).EventEmitter;class r extends s{constructor(e,t,n={}){super(),Object.defineProperty(this,"client",{value:e}),this.filter=t,this.options=n,this.collected=new i,this.ended=!1,this._timeout=null,this.listener=this._handle.bind(this),n.time&&(this._timeout=this.client.setTimeout(()=>this.stop("time"),n.time))}_handle(...e){const t=this.handle(...e);if(t&&this.filter(...e)){this.collected.set(t.key,t.value),this.emit("collect",t.value,this);const n=this.postCheck(...e);n&&this.stop(n)}}get next(){return new Promise((e,t)=>{if(this.ended)return void t(this.collected);const n=()=>{this.removeListener("collect",i);this.removeListener("end",s)};const i=t=>{n();e(t)};const s=()=>{n();t(this.collected)};this.on("collect",i);this.on("end",s)})}stop(e="user"){this.ended||(this._timeout&&this.client.clearTimeout(this._timeout),this.ended=!0,this.cleanup(),this.emit("end",this.collected,e))}handle(){}postCheck(){}cleanup(){}}e.exports=r},function(e,t,n){"use strict";(function(e){var i=n(5),s=i.Buffer,r=i.SlowBuffer,o=i.kMaxLength||2147483647;t.alloc=function(e,t,n){if("function"==typeof s.alloc)return s.alloc(e,t,n);if("number"==typeof n)throw new TypeError("encoding must not be number");if("number"!=typeof e)throw new TypeError("size must be a number");if(e>o)throw new RangeError("size is too large");var i=n,r=t;void 0===r&&(i=void 0,r=0);var a=new s(e);if("string"==typeof r)for(var c=new s(r,i),u=c.length,l=-1;++lo)throw new RangeError("size is too large");return new s(e)},t.from=function(t,n,i){if("function"==typeof s.from&&(!e.Uint8Array||Uint8Array.from!==s.from))return s.from(t,n,i);if("number"==typeof t)throw new TypeError('"value" argument must not be a number');if("string"==typeof t)return new s(t,n);if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer){var r=n;if(1===arguments.length)return new s(t);void 0===r&&(r=0);var o=i;if(void 0===o&&(o=t.byteLength-r),r>=t.byteLength)throw new RangeError("'offset' is out of bounds");if(o>t.byteLength-r)throw new RangeError("'length' is out of bounds");return new s(t.slice(r,r+o))}if(s.isBuffer(t)){var a=new s(t.length);return t.copy(a,0,0,t.length),a}if(t){if(Array.isArray(t)||"undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return new s(t);if("Buffer"===t.type&&Array.isArray(t.data))return new s(t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},t.allocUnsafeSlow=function(e){if("function"==typeof s.allocUnsafeSlow)return s.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=o)throw new RangeError("size is too large");return new r(e)}}).call(t,n(9))},function(e,t,n){var i,s,r;/** +var $=n(78),X=n(81),Z=n(57);e.Buffer=r,e.SlowBuffer=m,e.INSPECT_MAX_BYTES=50,r.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){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}}(),e.kMaxLength=i(),r.poolSize=8192,r._augment=function(t){return t.__proto__=r.prototype,t},r.from=function(t,e,n){return o(null,t,e,n)},r.TYPED_ARRAY_SUPPORT&&(r.prototype.__proto__=Uint8Array.prototype,r.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&r[Symbol.species]===r&&Object.defineProperty(r,Symbol.species,{value:null,configurable:!0})),r.alloc=function(t,e,n){return c(null,t,e,n)},r.allocUnsafe=function(t){return l(null,t)},r.allocUnsafeSlow=function(t){return l(null,t)},r.isBuffer=function(t){return!(null==t||!t._isBuffer)},r.compare=function(t,e){if(!r.isBuffer(t)||!r.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,i=e.length,s=0,o=Math.min(n,i);s0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},r.prototype.compare=function(t,e,n,i,s){if(!r.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 o=s-i,a=n-e,c=Math.min(o,a),l=this.slice(i,s),u=t.slice(e,n),h=0;hs)&&(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 y(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return x(this,t,e,n);case"latin1":case"binary":return A(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,e,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;r.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(s*=256);)i+=this[t+--e]*s;return i},r.prototype.readUInt8=function(t,e){return e||O(t,1,this.length),this[t]},r.prototype.readUInt16LE=function(t,e){return e||O(t,2,this.length),this[t]|this[t+1]<<8},r.prototype.readUInt16BE=function(t,e){return e||O(t,2,this.length),this[t]<<8|this[t+1]},r.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]},r.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])},r.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},r.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},r.prototype.readInt8=function(t,e){return e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},r.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},r.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},r.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},r.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]},r.prototype.readFloatLE=function(t,e){return e||O(t,4,this.length),X.read(this,t,!0,23,4)},r.prototype.readFloatBE=function(t,e){return e||O(t,4,this.length),X.read(this,t,!1,23,4)},r.prototype.readDoubleLE=function(t,e){return e||O(t,8,this.length),X.read(this,t,!0,52,8)},r.prototype.readDoubleBE=function(t,e){return e||O(t,8,this.length),X.read(this,t,!1,52,8)},r.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e|=0,n|=0,!i){N(this,t,e,n,Math.pow(2,8*n)-1,0)}var s=1,r=0;for(this[e]=255&t;++r=0&&(r*=256);)this[e+s]=t/r&255;return e+n},r.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,255,0),r.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},r.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},r.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},r.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},r.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},r.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e|=0,!i){var s=Math.pow(2,8*n-1);N(this,t,e,n,s-1,-s)}var r=0,o=1,a=0;for(this[e]=255&t;++r>0)-a&255;return e+n},r.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e|=0,!i){var s=Math.pow(2,8*n-1);N(this,t,e,n,s-1,-s)}var r=n-1,o=1,a=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===a&&0!==this[e+r+1]&&(a=1),this[e+r]=(t/o>>0)-a&255;return e+n},r.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,127,-128),r.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},r.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},r.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},r.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),r.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},r.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),r.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},r.prototype.writeFloatLE=function(t,e,n){return G(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return G(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},r.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(o<1e3||!r.TYPED_ARRAY_SUPPORT)for(s=0;s>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var o;if("number"==typeof t)for(o=e;o=e?String(t):(String(n).repeat(e)+t).slice(-e)}const s=n(34);let r=0;class o{constructor(){throw new Error(`The ${this.constructor.name} class may not be instantiated.`)}static generate(){r>=4095&&(r=0);const t=`${i((Date.now()-14200704e5).toString(2),42)}0000100000${i((r++).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)+14200704e5,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=o},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(u===setTimeout)return setTimeout(t,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(e){try{return u.call(null,t,0)}catch(e){return u.call(this,t,0)}}}function r(t){if(h===clearTimeout)return clearTimeout(t);if((h===i||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(t);try{return h(t)}catch(e){try{return h.call(null,t)}catch(e){return h.call(this,t)}}}function o(){m&&d&&(m=!1,d.length?f=d.concat(f):g=-1,f.length&&a())}function a(){if(!m){var t=s(o);m=!0;for(var e=f.length;e;){for(d=f,f=[];++g1)for(var n=1;nnew r(this,t)),this.attachments=new l;for(const e of t.attachments)this.attachments.set(e.id,new s(this,e));if(this.createdTimestamp=new Date(t.timestamp).getTime(),this.editedTimestamp=t.edited_timestamp?new Date(t.edited_timestamp).getTime():null,this.reactions=new l,t.reactions&&t.reactions.length>0)for(const e of t.reactions){const t=e.emoji.id?`${e.emoji.name}:${e.emoji.id}`:e.emoji.name;this.reactions.set(t,new o(this,e.emoji,e.count,e.me))}this.mentions=new i(this,t.mentions,t.mention_roles,t.mention_everyone),this.webhookID=t.webhook_id||null,this.hit="boolean"==typeof t.hit?t.hit:null,this._edits=[]}patch(t){const e=c.cloneObject(this);if(this._edits.unshift(e),this.editedTimestamp=new Date(t.edited_timestamp).getTime(),"content"in t&&(this.content=t.content),"pinned"in t&&(this.pinned=t.pinned),"tts"in t&&(this.tts=t.tts),this.embeds="embeds"in t?t.embeds.map(t=>new r(this,t)):this.embeds.slice(),"attachments"in t){this.attachments=new l;for(const e of t.attachments)this.attachments.set(e.id,new s(this,e))}else this.attachments=new l(this.attachments);this.mentions=new i(this,"mentions"in t?t.mentions:this.mentions.users,"mentions_roles"in t?t.mentions_roles:this.mentions.roles,"mention_everyone"in t?t.mention_everyone:this.mentions.everyone)}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,""));if(e)return`#${e.name}`;return 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,""));if(e)return`@${e.name}`;return t})}createReactionCollector(t,e={}){return new a(this,t,e)}awaitReactions(t,e={}){return new Promise((n,i)=>{const s=this.createReactionCollector(t,e);s.once("end",(t,s)=>{e.errors&&e.errors.includes(s)?i(t):n(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).has(h.FLAGS.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).has(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 p||(p=n(19)),!!this.mentions.everyone||(!!this.mentions.users.has(t.id)||!!(t instanceof p&&t.roles.some(t=>this.mentions.roles.has(t.id))))}edit(t,e){e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),void 0!==t&&(t=this.client.resolver.resolveString(t));const{embed:embed,code:code,reply:reply}=e;if(void 0===code||"boolean"==typeof code&&!0!==code||(t=c.escapeMarkdown(this.client.resolver.resolveString(t),!0),t=`\`\`\`${"boolean"!=typeof code?code||"":""} +${t} +\`\`\``),reply&&"dm"!==this.channel.type){const e=this.client.resolver.resolveUserID(reply),n=`<@${reply instanceof p&&reply.nickname?"!":""}${e}>`;t=`${n}${t?`, ${t}`:""}`}return this.client.api.channels(this.channel.id).messages(this.id).patch({data:{content:t,embed:embed}}).then(t=>this.client.actions.MessageUpdate.handle(t).updated)}pin(){return this.client.api.channels(this.channel.id).pins(this.id).put().then(()=>this)}unpin(){return this.client.api.channels(this.channel.id).pins(this.id).delete().then(()=>this)}react(t){if(!(t=this.client.resolver.resolveEmojiIdentifier(t)))throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.api.channels(this.channel.id).messages(this.id).reactions(t)["@me"].put().then(()=>this._addReaction(c.parseEmoji(t),this.client.user))}clearReactions(){return this.client.api.channels(this.channel.id).messages(this.id).reactions.delete().then(()=>this)}delete({timeout:timeout=0,reason:reason}={}){return timeout<=0?this.client.api.channels(this.channel.id).messages(this.id).delete({reason:reason}).then(()=>this.client.actions.MessageDelete.handle({id:this.id,channel_id:this.channel.id}).message):new Promise(t=>{this.client.setTimeout(()=>{t(this.delete({reason:reason}))},timeout)})}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.api.channels(this.channel.id).messages(this.id).ack.post({data:{token:this.client.rest._ackToken}}).then(t=>{t.token&&(this.client.rest._ackToken=t.token);return 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;if(!t.author&&!t.attachments)return this.id===t.id&&this.embeds.length===t.embeds.length;let n=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 n&&e&&(n=this.mentions.everyone===t.mentions.everyone&&this.createdTimestamp===new Date(e.timestamp).getTime()&&this.editedTimestamp===new Date(e.edited_timestamp).getTime()),n}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 o(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.count<=0&&this.reactions.delete(n),t}return null}_clearReactions(){this.reactions.clear()}}t.exports=d},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);class s{constructor(t){this.bitfield="number"==typeof t?t:this.constructor.resolve(t)}has(t,e=!0){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=!0){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,VIEW_AUDIT_LOG:128,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,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_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){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},function(t,e,n){const i=n(24),s=n(0),r=n(13).Presence,o=n(185),a=n(6);class c{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"])void 0!==t[e]&&(this[e]=t[e]);t.token&&(this.client.token=t.token)}get createdTimestamp(){return a.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}avatarURL(t,e){return this.avatar?("number"==typeof t&&(e=t,t="default"),s.Endpoints.CDN(this.client.options.http.cdn).Avatar(this.id,this.avatar,t,e)):null}get defaultAvatarURL(){return s.Endpoints.CDN(this.client.options.http.host).DefaultAvatar(this.discriminator%5)}get displayAvatarURL(){return this.avatarURL()||this.defaultAvatarURL}get tag(){return`${this.username}#${this.discriminator}`}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.dmChannel?Promise.resolve(this.dmChannel):this.client.api.users(this.client.user.id).channels.post({data:{recipient_id:this.id}}).then(t=>this.client.actions.ChannelCreate.handle(t).channel)}deleteDM(){return this.dmChannel?this.client.api.channels(this.dmChannel.id).delete().then(t=>this.client.actions.ChannelDelete.handle(t).channel):Promise.reject(new Error("No DM Channel exists!"))}fetchProfile(){return this.client.api.users(this.id).profile.get().then(t=>new o(t))}setNote(t){return this.client.api.users("@me").notes(this.id).put({data:{note:t}}).then(()=>this)}equals(t){return t&&this.id===t.id&&this.username===t.username&&this.discriminator===t.discriminator&&this.avatar===t.avatar&&this.bot===Boolean(t.bot)}toString(){return`<@${this.id}>`}send(){}}i.applyToClass(c),t.exports=c},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){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function s(t){return"number"==typeof t}function r(t){return"object"==typeof t&&null!==t}function o(t){return void 0===t}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!s(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,n,s,a,c,l;if(this._events||(this._events={}),"error"===t&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(n=this._events[t],o(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(r(n))for(a=Array.prototype.slice.call(arguments,1),l=n.slice(),s=l.length,c=0;c0&&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,a;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(a=o;a-- >0;)if(n[a]===e||n[a].listener&&n[a].listener===e){s=a;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){return 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){"use strict";function i(t){if(!(this instanceof i))return new i(t);l.call(this,t),u.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",s)}function s(){this.allowHalfOpen||this._writableState.ended||a(r,this)}function r(t){t.end()}var o=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=i;var a=n(35),c=n(22);c.inherits=n(11);var l=n(58),u=n(37);c.inherits(i,l);for(var h=o(u.prototype),p=0;pthis)}}t.exports=s},function(t,e,n){const i=n(0),s=n(3),r=n(6);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.CDN(this.client.options.http.cdn).Emoji(this.id)}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}edit(t,e){return this.client.api.guilds(this.guild.id).emojis(this.id).patch({data:{name:t.name,roles:t.roles?t.roles.map(t=>t.id?t.id:t):[]},reason:e}).then(()=>this)}setName(t){return this.edit({name:t})}addRestrictedRole(t){return this.addRestrictedRoles([t])}addRestrictedRoles(t){const e=new s(this.roles);for(const n of t)this.guild.roles.has(n.id)&&e.set(n.id,n);return this.edit({roles:e})}removeRestrictedRole(t){return this.removeRestrictedRoles([t])}removeRestrictedRoles(t){const e=new s(this.roles);for(const n of t)e.has(n.id)&&e.delete(n.id);return this.edit({roles:e})}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(34),s=n(12),r=n(20),o=n(17),a=n(27),c=n(45),l=n(21),u=n(13).Presence,h=n(19),p=n(70),d=n(0),f=n(3),m=n(4),g=n(6),v=n(10),E=n(71);class b{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.members=new f,this.channels=new f,this.roles=new f,this.presences=new f,e&&(e.unavailable?(this.available=!1,this.id=e.id):(this.available=!0,this.setup(e)))}setup(t){if(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.afkTimeout=t.afk_timeout,this.afkChannelID=t.afk_channel_id,this.embedEnabled=t.embed_enabled,this.verificationLevel=t.verification_level,this.explicitContentFilter=t.explicit_content_filter,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 e of t.presences)this._setPresence(e.user.id,e);if(this._rawVoiceStates=new f,t.voice_states)for(const e of t.voice_states){this._rawVoiceStates.set(e.user_id,e);const t=this.members.get(e.user_id);t&&(t.serverMute=e.mute,t.serverDeaf=e.deaf,t.selfMute=e.self_mute,t.selfDeaf=e.self_deaf,t.voiceSessionID=e.session_id,t.voiceChannelID=e.channel_id,this.channels.get(e.channel_id).members.set(t.user.id,t))}if(this.emojis)this.client.actions.GuildEmojisUpdate.handle({guild_id:this.id,emojis:t.emojis});else{this.emojis=new f;for(const e of t.emojis)this.emojis.set(e.id,new o(this,e))}}get createdTimestamp(){return g.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}iconURL(t,e){return this.icon?("number"==typeof t&&(e=t,t="default"),d.Endpoints.CDN(this.client.options.http.cdn).Icon(this.id,this.icon,t,e)):null}get nameAcronym(){return this.name.replace(/\w+/g,t=>t[0]).replace(/\s/g,"")}get splashURL(){return this.splash?d.Endpoints.CDN(this.client.options.http.cdn).Splash(this.id,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 position(){return this.client.user.bot?null:this.client.user.settings.guildPositions?this.client.user.settings.guildPositions.indexOf(this.id):null}get defaultRole(){return this.roles.get(this.id)}get me(){return this.members.get(this.client.user.id)}get _sortedRoles(){return this._sortPositionWithID(this.roles)}member(t){return this.client.resolver.resolveGuildMember(this,t)}fetchBans(){return this.client.api.guilds(this.id).bans.get().then(t=>t.reduce((t,e)=>{t.set(e.user.id,{reason:e.reason,user:this.client.dataManager.newUser(e.user)});return t},new f))}fetchInvites(){return this.client.api.guilds(this.id).invites.get().then(t=>{const e=new f;for(const n of t){const t=new a(this.client,n);e.set(t.code,t)}return e})}fetchWebhooks(){return this.client.api.guilds(this.id).webhooks.get().then(t=>{const e=new f;for(const n of t)e.set(n.id,new l(this.client,n));return e})}fetchVoiceRegions(){return this.client.api.guilds(this.id).regions.get().then(t=>{const e=new f;for(const n of t)e.set(n.id,new p(n));return e})}fetchAuditLogs(t={}){return t.before&&t.before instanceof c.Entry&&(t.before=t.before.id),t.after&&t.after instanceof c.Entry&&(t.after=t.after.id),"string"==typeof t.type&&(t.type=c.Actions[t.type]),this.client.api.guilds(this.id)["audit-logs"].get({query:{before:t.before,after:t.after,limit:t.limit,user_id:this.client.resolver.resolveUserID(t.user),action_type:t.type}}).then(t=>c.build(this,t))}addMember(t,e){if(this.members.has(t.id))return Promise.resolve(this.members.get(t.id));if(e.access_token=e.accessToken,e.roles){const t=e.roles;(t instanceof f||t instanceof Array&&t[0]instanceof r)&&(e.roles=t.map(t=>t.id))}return this.client.api.guilds(this.id).members(t.id).put({data:e}).then(t=>this.client.actions.GuildMemberGet.handle(this,t).member)}fetchMember(t,e=!0){return t=this.client.resolver.resolveUser(t),t?this.members.has(t.id)?Promise.resolve(this.members.get(t.id)):this.client.api.guilds(this.id).members(t.id).get().then(t=>e?this.client.actions.GuildMemberGet.handle(this,t).member:new h(this,t)):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:d.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:t,limit:e}});const s=(t,e)=>{if(e.id!==this.id)return;(this.memberCount===this.members.size||t.length<1e3)&&(this.client.removeListener(d.Events.GUILD_MEMBERS_CHUNK,s),n(this))};this.client.on(d.Events.GUILD_MEMBERS_CHUNK,s);this.client.setTimeout(()=>i(new Error("Members didn't arrive in time.")),12e4)})}search(t={}){return E.search(this,t)}edit(t,e){const n={};return t.name&&(n.name=t.name),t.region&&(n.region=t.region),t.verificationLevel&&(n.verification_level=Number(t.verificationLevel)),t.afkChannel&&(n.afk_channel_id=this.client.resolver.resolveChannel(t.afkChannel).id),t.afkTimeout&&(n.afk_timeout=Number(t.afkTimeout)),t.icon&&(n.icon=this.client.resolver.resolveBase64(t.icon)),t.owner&&(n.owner_id=this.client.resolver.resolveUser(t.owner).id),t.splash&&(n.splash=this.client.resolver.resolveBase64(t.splash)),this.client.api.guilds(this.id).patch({data:n,reason:e}).then(t=>this.client.actions.GuildUpdate.handle(t).updated)}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})}setPosition(t,e){return this.client.user.bot?Promise.reject(new Error("Setting guild position is only available for user accounts")):this.client.user.settings.setGuildPosition(this,t,e)}acknowledge(){return this.client.api.guilds(this.id).ack.post({data:{token:this.client.rest._ackToken}}).then(t=>{t.token&&(this.client.rest._ackToken=t.token);return this})}allowDMs(t){const e=this.client.user.settings;return t?e.removeRestrictedGuild(this):e.addRestrictedGuild(this)}ban(t,e={days:0}){e.days&&(e["delete-message-days"]=e.days);const n=this.client.resolver.resolveUserID(t);return n?this.client.api.guilds(this.id).bans(n).put({query:e}).then(()=>{if(t instanceof h)return t;const e=this.client.resolver.resolveUser(n);if(e){const t=this.client.resolver.resolveGuildMember(this,e);return t||e}return n}):Promise.reject(new Error("Couldn't resolve the user ID to ban."))}unban(t,e){const n=this.client.resolver.resolveUserID(t);if(!n)throw new Error("Couldn't resolve the user ID to unban.");return this.client.api.guilds(this.id).bans(n).delete({reason:e}).then(()=>t)}pruneMembers({days:days=7,dry:dry=!1,reason:reason}={}){if("number"!=typeof days)throw new TypeError("Days must be a number.");return this.client.api.guilds(this.id).prune[dry?"get":"post"]({query:{days:days},reason:reason}).then(t=>t.pruned)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(t,e,{overwrites:overwrites,reason:reason}={}){return overwrites instanceof f&&(overwrites=overwrites.array()),this.client.api.guilds(this.id).channels.post({data:{name:t,type:e,permission_overwrites:overwrites},reason:reason}).then(t=>this.client.actions.ChannelCreate.handle(t).channel)}setChannelPositions(t){const e=new Array(t.length);for(let n=0;nthis.client.actions.GuildChannelsPositionUpdate.handle({guild_id:this.id,channels:t}).guild)}createRole({data:data={},reason:reason}={}){return data.color&&(data.color=this.client.resolver.resolveColor(data.color)),data.permissions&&(data.permissions=v.resolve(data.permissions)),this.client.api.guilds(this.id).roles.post({data:data,reason:reason}).then(t=>this.client.actions.GuildRoleCreate.handle({guild_id:this.id,role:t}).role)}createEmoji(t,e,n){if("string"==typeof attahment&&t.startsWith("data:")){const i={image:t,name:e};return n&&(i.roles=n.map(t=>t.id?t.id:t)),this.client.api.guilds(this.id).emojis.post({data:i}).then(t=>this.client.actions.GuildEmojiCreate.handle(this,t).emoji)}return this.client.resolver.resolveBuffer(t).then(t=>{const i=this.client.resolver.resolveBase64(t);return this.createEmoji(i,e,n)})}deleteEmoji(t){return t instanceof o||(t=this.emojis.get(t)),this.client.api.guilds(this.id).emojis(this.id).delete().then(()=>this.client.actions.GuildEmojiDelete.handle(t).data)}leave(){return this.ownerID===this.client.user.id?Promise.reject(new Error("Guild is owned by the client.")):this.rest.api.users("@me").guilds(this.id).delete().then(()=>this.client.actions.GuildDelete.handle({id:this.id}).guild)}delete(){return this.client.api.guilds(this.id).delete().then(()=>this.client.actions.GuildDelete.handle({id:this.id}).guild)}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&&m.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=!0){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 h(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.connection.status===d.Status.READY&&e&&!n&&this.client.emit(d.Events.GUILD_MEMBER_ADD,i),i}_updateMember(t,e){const n=m.cloneObject(t);e.roles&&(t._roles=e.roles),void 0!==e.nick&&(t.nickname=e.nick);const i=t.nickname!==n.nickname||!m.arraysEqual(t._roles,n._roles);return this.client.ws.connection.status===d.Status.READY&&i&&this.client.emit(d.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(d.Events.GUILD_MEMBER_SPEAKING,n,e))}_setPresence(t,e){if(this.presences.get(t))return void this.presences.get(t).update(e);this.presences.set(t,new u(e))}setRolePosition(t,e,n=!1){if("string"==typeof t&&!(t=this.roles.get(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 m.moveElementInArray(i,t,e,n),i=i.map((t,e)=>({id:t.id,position:e})),this.client.api.guilds(this.id).roles.patch({data:i}).then(()=>this.client.actions.GuildRolesPositionUpdate.handle({guild_id:this.id,roles:i}).guild)}setChannelPosition(t,e,n=!1){if("string"==typeof t&&!(t=this.channels.get(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 m.moveElementInArray(i,t,e,n),i=i.map((t,e)=>({id:t.id,position:e})),this.client.api.guilds(this.id).channels.patch({data:i}).then(()=>this.client.actions.GuildChannelsPositionUpdate.handle({guild_id:this.id,roles:i}).guild)}_sortedChannels(t){return this._sortPositionWithID(this.channels.filter(e=>"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=b},function(t,e,n){const i=n(24),s=n(20),r=n(10),o=n(3),a=n(13).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 a}get roles(){const t=new o,e=this.guild.roles.get(this.guild.id);e&&t.set(e.id,e);for(const e of this._roles){const n=this.guild.roles.get(e);n&&t.set(n.id,n)}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(r.ALL);let t=0;const e=this.roles;for(const n of e.values())t|=n.permissions;return new r(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.permissions.has(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.permissions.has(r.FLAGS.BAN_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(t){if(!(t=this.client.resolver.resolveChannel(t))||!t.guild)throw new Error("Could not resolve channel to a guild channel.");return t.permissionsFor(this)}hasPermission(t,e=!1,n,i){return void 0===n&&(n=!e),void 0===i&&(i=!e),!(!i||this.user.id!==this.guild.ownerID)||this.roles.some(e=>e.hasPermission(t,void 0,n))}missingPermissions(t,e=!1){return t.missing(t,e)}edit(t,e){t.channel&&(t.channel_id=this.client.resolver.resolveChannel(t.channel).id,t.channel=null),t.roles&&(t.roles=t.roles.map(t=>t instanceof s?t.id:t));let n=this.client.api.guilds(this.guild.id);if(this.user.id===this.client.user.id){const e=Object.keys(t);n=1===e.length&&"nick"===e[0]?n.members("@me").nick:n.members(this.id)}else n=n.members(this.id);return n.patch({data:t,reason:e}).then(t=>this.guild._updateMember(this,t).mem)}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)),t?this._roles.includes(t.id)?Promise.resolve(this):this.client.api.guilds(this.guild.id).members(this.user.id).roles(t.id).put().then(()=>this):Promise.reject(new TypeError("Supplied parameter was neither a Role nor a Snowflake."))}addRoles(t){let e;if(t instanceof o){e=this._roles.slice();for(const n of t.values())e.push(n.id?n.id:n)}else e=this._roles.concat(t.map(t=>t.id?t.id:t));return this.edit({roles:e})}removeRole(t){return t instanceof s||(t=this.guild.roles.get(t)),t?this.client.api.guilds(this.guild.id).members(this.user.id).roles(t.id).delete().then(()=>this):Promise.reject(new TypeError("Supplied parameter was neither a Role nor a Snowflake."))}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(t){return this.client.api.guilds(this.guild.id).members(this.user.id).delete({reason:t}).then(()=>this.client.actions.GuildMemberRemove.handle({guild_id:this.guild.id,user:this.user}).member)}ban(t){return this.guild.ban(this,t)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}send(){}}i.applyToClass(c),t.exports=c},function(t,e,n){const i=n(6),s=n(10);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.permissions.has(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=!1,n){return new s(this.permissions).has(t,void 0!==n?n:!e)}comparePositionTo(t){return this.constructor.comparePositions(this,t)}edit(t,e){return t.permissions?t.permissions=s.resolve(t.permissions):t.permissions=this.permissions,this.client.api.guilds(this.guild.id).roles(this.id).patch({data:{name:t.name||this.name,position:void 0!==t.position?t.position:this.position,color:this.client.resolver.resolveColor(t.color||this.color),hoist:void 0!==t.hoist?t.hoist:this.hoist,mentionable:void 0!==t.mentionable?t.mentionable:this.mentionable},reason:e}).then(t=>this.client.actions.GuildRoleUpdate.handle({role:t,guild_id:this.guild.id}).updated)}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(t){return this.client.api.guilds(this.guild.id).roles(this.id).delete({reason:t}).then(()=>this.client.actions.GuildRoleDelete.handle({guild_id:this.guild.id,role_id:this.id}).role)}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(29);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){if(e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),e.username||(e.username=this.name),e.avatarURL&&(e.avatar_url=e.avatarURL,e.avatarURL=null),void 0!==t&&(t=this.client.resolver.resolveString(t)),t&&(e.disableEveryone||void 0===e.disableEveryone&&this.client.options.disableEveryone)&&(t=t.replace(/@(everyone|here)/g,"@​$1")),e.content=t,e.file&&(e.files?e.files.push(e.file):e.files=[e.file]),e.files){for(let t=0;tthis.client.resolver.resolveBuffer(t.attachment).then(e=>{t.file=e;return t}))).then(t=>this.client.api.webhooks(this.id,this.token).post({data:e,query:{wait:!0},files:t,auth:!1}))}return this.client.api.webhooks(this.id,this.token).post({data:e,query:{wait:!0},auth:!1}).then(t=>{if(!this.client.channels)return t;const e=n(8);return new e(this.client.channels.get(t.channel_id,t,this.client))})}sendSlackMessage(t){return this.client.api.webhooks(this.id,this.token).slack.post({query:{wait:!0},auth:!1,data:t}).then(t=>{if(!this.client.channels)return t;const e=n(8);return new e(this.client.channels.get(t.channel_id,t,this.client))})}edit({name:name=this.name,avatar:avatar},t){return avatar&&"string"==typeof avatar&&!avatar.startsWith("data:")?this.client.resolver.resolveBuffer(avatar).then(e=>{const n=this.client.resolver.resolveBase64(e);return this.edit({name:name,avatar:n},t)}):this.client.api.webhooks(this.id,this.token).patch({data:{name:name,avatar:avatar},reason:t}).then(t=>{this.name=t.name;this.avatar=t.avatar;return this})}delete(t){return this.client.api.webhooks(this.id,this.token).delete({reason:t})}}t.exports=s},function(t,e,n){(function(t){function n(t){return Array.isArray?Array.isArray(t):"[object Array]"===g(t)}function i(t){return"boolean"==typeof t}function s(t){return null===t}function r(t){return null==t}function o(t){return"number"==typeof t}function a(t){return"string"==typeof t}function c(t){return"symbol"==typeof t}function l(t){return void 0===t}function u(t){return"[object RegExp]"===g(t)}function h(t){return"object"==typeof t&&null!==t}function p(t){return"[object Date]"===g(t)}function d(t){return"[object Error]"===g(t)||t instanceof Error}function f(t){return"function"==typeof t}function m(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function g(t){return Object.prototype.toString.call(t)}e.isArray=n,e.isBoolean=i,e.isNull=s,e.isNullOrUndefined=r,e.isNumber=o,e.isString=a,e.isSymbol=c,e.isUndefined=l,e.isRegExp=u,e.isObject=h,e.isDate=p,e.isError=d,e.isFunction=f,e.isPrimitive=m,e.isBuffer=t.isBuffer}).call(e,n(5).Buffer)},function(t,e,n){e=t.exports=n(58),e.Stream=e,e.Readable=e,e.Writable=n(37),e.Duplex=n(15),e.Transform=n(59),e.PassThrough=n(86)},function(t,e,n){const i=n(29),s=n(47),r=n(71),o=n(3),a=n(6);class c{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.content||(e.content=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(let t=0;tthis.client.resolver.resolveBuffer(t.attachment).then(e=>{t.file=e;return t}))).then(t=>{e.files=t;return r.sendMessage(this,e)})}return r.sendMessage(this,e)}fetchMessage(t){const e=n(8);return this.client.user.bot?this.client.api.channels(this.id).messages(t).get().then(t=>{const n=t instanceof e?t:new e(this,t,this.client);this._cacheMessage(n);return n}):this.fetchMessages({limit:1,around:t}).then(e=>{const n=e.get(t);if(!n)throw new Error("Message not found.");return n})}fetchMessages(t={}){const e=n(8);return this.client.api.channels(this.id).messages.get({query:t}).then(t=>{const n=new o;for(const i of t){const t=new e(this,i,this.client);n.set(i.id,t),this._cacheMessage(t)}return n})}fetchPinnedMessages(){const t=n(8);return this.client.api.channels(this.id).pins.get().then(e=>{const n=new o;for(const i of e){const e=new t(this,i,this.client);n.set(i.id,e),this._cacheMessage(e)}return n})}search(t={}){return r.search(this,t)}startTyping(t){if(void 0!==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{const e=this.client.api.channels(this.id).typing;this.client.user._typing.set(this.id,{count:t||1,interval:this.client.setInterval(()=>{e.post()},9e3)}),e.post()}}stopTyping(t=!1){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}createMessageCollector(t,e={}){return new s(this,t,e)}awaitMessages(t,e={}){return new Promise((n,i)=>{const s=this.createMessageCollector(t,e);s.once("end",(t,s)=>{e.errors&&e.errors.includes(s)?i(t):n(t)})})}bulkDelete(t,e=!1){if(!isNaN(t))return this.fetchMessages({limit:t}).then(t=>this.bulkDelete(t,e));if(t instanceof Array||t instanceof o){let n=t instanceof o?t.keyArray():t.map(t=>t.id);return e&&(n=n.filter(t=>Date.now()-a.deconstruct(t).date.getTime()<12096e5)),this.rest.api.channels(this.id).messages["bulk-delete"].post({data:{messages:n}}).then(()=>this.client.actions.MessageDeleteBulk.handle({channel_id:this.id,ids:n}).messages)}throw new TypeError("The messages must be an Array, Collection, or number.")}acknowledge(){return this.lastMessageID?this.client.api.channels(this.id).messages(this.lastMessageID).post({data:{token:this.client.rest._ackToken}}).then(t=>{t.token&&(this.client.rest._ackToken=t.token);return this}):Promise.resolve(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=!1,n=[])=>{const i=["send"];e&&i.push("_cacheMessage","acknowledge","fetchMessages","fetchMessage","search","bulkDelete","startTyping","stopTyping","typing","typingCount","fetchPinnedMessages","createMessageCollector","awaitMessages");for(const e of i)n.includes(e)||Object.defineProperty(t.prototype,e,Object.getOwnPropertyDescriptor(c.prototype,e))})},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(16),s=n(20),r=n(27),o=n(53),a=n(10),c=n(3);class l 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 c,t.permission_overwrites)for(const e of t.permission_overwrites)this.permissionOverwrites.set(e.id,new o(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)))return null;if(t.id===this.guild.ownerID)return new a(a.ALL);let e=0;const n=t.roles;for(const t of n.values())e|=t.permissions;const i=this.overwritesFor(t,!0,n);i.everyone&&(e&=~i.everyone.deny,e|=i.everyone.allow);let s=0;for(const t of i.roles)e&=~t.deny,s|=t.allow;return e|=s,i.member&&(e&=~i.member.deny,e|=i.member.allow),Boolean(e&a.FLAGS.ADMINISTRATOR)&&(e=a.ALL),new a(e)}overwritesFor(t,e=!1,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 e of this.permissionOverwrites.values())e.id===this.guild.id?r=e:n.has(e.id)?i.push(e):e.id===t.id&&(s=e);return{everyone:r,roles:i,member:s}}overwritePermissions(t,e,n){const i={allow:0,deny:0};if(t instanceof s)i.type="role";else if(this.guild.roles.has(t))t=this.guild.roles.get(t),i.type="role";else if(t=this.client.resolver.resolveUser(t),i.type="member",!t)return Promise.reject(new TypeError("Supplied parameter was neither a User nor a Role."));i.id=t.id;const r=this.permissionOverwrites.get(t.id);r&&(i.allow=r.allow,i.deny=r.deny);for(const t in e)!0===e[t]?(i.allow|=a.FLAGS[t]||0,i.deny&=~(a.FLAGS[t]||0)):!1===e[t]?(i.allow&=~(a.FLAGS[t]||0),i.deny|=a.FLAGS[t]||0):null===e[t]&&(i.allow&=~(a.FLAGS[t]||0),i.deny&=~(a.FLAGS[t]||0));return this.client.api.channels(this.id).permissions(i.id).put({data:i,reason:n}).then(()=>this)}edit(t,e){return this.client.api.channels(this.id).patch({data:{name:(t.name||this.name).trim(),topic:t.topic||this.topic,position:t.position||this.position,bitrate:t.bitrate||this.bitrate,user_limit:t.userLimit||this.userLimit},reason:e}).then(t=>this.client.actions.ChannelUpdate.handle(t).updated)}setName(t){return this.edit({name:t})}setPosition(t,e){return this.guild.setChannelPosition(this,t,e).then(()=>this)}setTopic(t){return this.edit({topic:t})}createInvite({temporary:temporary=!1,maxAge:maxAge=86400,maxUses:maxUses=0},t){return this.client.api.channels(this.id).invites.post({data:{temporary:temporary,max_age:maxAge,max_uses:maxUses},reason:t}).then(t=>new r(this.client,t))}clone(t=this.name,e=!0,n=!0){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).has(a.FLAGS.MANAGE_CHANNELS)}delete(t){return this.client.api.channels(this.id).delete({reason:t}).then(()=>this)}toString(){return`<#${this.id}>`}}t.exports=l},function(t,e,n){const i=n(51),s=n(52),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.presenceCount=t.approximate_presence_count,this.memberCount=t.approximate_member_count,this.textChannelCount=t.guild.text_channel_count,this.voiceChannelCount=t.guild.voice_channel_count,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.invite(this.code)}delete(t){return this.client.api.invites(this.code).delete({reason:t}).then(()=>this)}toString(){return this.url}}t.exports=o},function(t,e,n){const i=n(6),s=n(0);class r{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.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,t.owner&&(this.owner=this.client.dataManager.newUser(t.owner))}get createdTimestamp(){return i.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}iconURL(t,e){return this.icon?("number"==typeof t&&(e=t,t="default"),s.Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id,this.icon,t,e)):null}reset(){return this.rest.api.oauth2.applications(this.id).reset.post().then(t=>new r(this.client,t))}toString(){return this.name}}t.exports=r},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),a=o,c=0;c[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){const n=this.client.resolver.resolveUserID(t),i=this.client.user.bot?{nick:e,access_token:t}:{recipient:n};return this.client.api.channels(this.id).recipients(n).put({data:i}).then(()=>this)}toString(){return this.name}send(){}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(3),s=n(14).EventEmitter;class r extends s{constructor(t,e,n={}){super(),Object.defineProperty(this,"client",{value:t}),this.filter=e,this.options=n,this.collected=new i,this.ended=!1,this._timeout=null,this.listener=this._handle.bind(this),n.time&&(this._timeout=this.client.setTimeout(()=>this.stop("time"),n.time))}_handle(...t){const e=this.handle(...t);if(e&&this.filter(...t)){this.collected.set(e.key,e.value),this.emit("collect",e.value,this);const n=this.postCheck(...t);n&&this.stop(n)}}get next(){return new Promise((t,e)=>{if(this.ended)return void e(this.collected);const n=()=>{this.removeListener("collect",i);this.removeListener("end",s)};const i=e=>{n();t(e)};const s=()=>{n();e(this.collected)};this.on("collect",i);this.on("end",s)})}stop(t="user"){this.ended||(this._timeout&&this.client.clearTimeout(this._timeout),this.ended=!0,this.cleanup(),this.emit("end",this.collected,t))}handle(){}postCheck(){}cleanup(){}}t.exports=r},function(t,e,n){"use strict";(function(t){var i=n(5),s=i.Buffer,r=i.SlowBuffer,o=i.kMaxLength||2147483647;e.alloc=function(t,e,n){if("function"==typeof s.alloc)return s.alloc(t,e,n);if("number"==typeof n)throw new TypeError("encoding must not be number");if("number"!=typeof t)throw new TypeError("size must be a number");if(t>o)throw new RangeError("size is too large");var i=n,r=e;void 0===r&&(i=void 0,r=0);var a=new s(t);if("string"==typeof r)for(var c=new s(r,i),l=c.length,u=-1;++uo)throw new RangeError("size is too large");return new s(t)},e.from=function(e,n,i){if("function"==typeof s.from&&(!t.Uint8Array||Uint8Array.from!==s.from))return s.from(e,n,i);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new s(e,n);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var r=n;if(1===arguments.length)return new s(e);void 0===r&&(r=0);var o=i;if(void 0===o&&(o=e.byteLength-r),r>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(o>e.byteLength-r)throw new RangeError("'length' is out of bounds");return new s(e.slice(r,r+o))}if(s.isBuffer(e)){var a=new s(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new s(e);if("Buffer"===e.type&&Array.isArray(e.data))return new s(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},e.allocUnsafeSlow=function(t){if("function"==typeof s.allocUnsafeSlow)return s.allocUnsafeSlow(t);if("number"!=typeof t)throw new TypeError("size must be a number");if(t>=o)throw new RangeError("size is too large");return new r(t)}}).call(e,n(9))},function(t,e,n){var i,s,r;/** * @license long.js (c) 2013 Daniel Wirtz * Released under the Apache License, Version 2.0 * see: https://github.com/dcodeIO/long.js for details */ -!function(n,o){s=[],i=o,void 0!==(r="function"==typeof i?i.apply(t,s):i)&&(e.exports=r)}(0,function(){"use strict";function e(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function t(e){return!0===(e&&e.__isLong__)}function n(e,t){var n,i,r;return t?(e>>>=0,(r=0<=e&&e<256)&&(i=c[e])?i:(n=s(e,(0|e)<0?-1:0,!0),r&&(c[e]=n),n)):(e|=0,(r=-128<=e&&e<128)&&(i=a[e])?i:(n=s(e,e<0?-1:0,!1),r&&(a[e]=n),n))}function i(e,t){if(isNaN(e)||!isFinite(e))return t?m:f;if(t){if(e<0)return m;if(e>=h)return w}else{if(e<=-p)return _;if(e+1>=p)return b}return e<0?i(-e,t).neg():s(e%l|0,e/l|0,t)}function s(t,n,i){return new e(t,n,i)}function r(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return f;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===s)return r(e.substring(1),t,n).neg();for(var o=i(u(n,8)),a=f,c=0;c>>0:this.low},y.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)},y.toString=function(e){if((e=e||10)<2||36>>0,h=l.toString(e);if(o=c,o.isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}},y.getHighBits=function(){return this.high},y.getHighBitsUnsigned=function(){return this.high>>>0},y.getLowBits=function(){return this.low},y.getLowBitsUnsigned=function(){return this.low>>>0},y.getNumBitsAbs=function(){if(this.isNegative())return this.eq(_)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},y.isOdd=function(){return 1==(1&this.low)},y.isEven=function(){return 0==(1&this.low)},y.equals=function(e){return t(e)||(e=o(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},y.eq=y.equals,y.notEquals=function(e){return!this.eq(e)},y.neq=y.notEquals,y.lessThan=function(e){return this.comp(e)<0},y.lt=y.lessThan,y.lessThanOrEqual=function(e){return this.comp(e)<=0},y.lte=y.lessThanOrEqual,y.greaterThan=function(e){return this.comp(e)>0},y.gt=y.greaterThan,y.greaterThanOrEqual=function(e){return this.comp(e)>=0},y.gte=y.greaterThanOrEqual,y.compare=function(e){if(t(e)||(e=o(e)),this.eq(e))return 0;var n=this.isNegative(),i=e.isNegative();return n&&!i?-1:!n&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},y.comp=y.compare,y.negate=function(){return!this.unsigned&&this.eq(_)?_:this.not().add(g)},y.neg=y.negate,y.add=function(e){t(e)||(e=o(e));var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,a=65535&this.low,c=e.high>>>16,u=65535&e.high,l=e.low>>>16,h=65535&e.low,p=0,d=0,f=0,m=0;return m+=a+h,f+=m>>>16,m&=65535,f+=r+l,d+=f>>>16,f&=65535,d+=i+u,p+=d>>>16,d&=65535,p+=n+c,p&=65535,s(f<<16|m,p<<16|d,this.unsigned)},y.subtract=function(e){return t(e)||(e=o(e)),this.add(e.neg())},y.sub=y.subtract,y.multiply=function(e){if(this.isZero())return f;if(t(e)||(e=o(e)),e.isZero())return f;if(this.eq(_))return e.isOdd()?_:f;if(e.eq(_))return this.isOdd()?_:f;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(d)&&e.lt(d))return i(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,r=65535&this.high,a=this.low>>>16,c=65535&this.low,u=e.high>>>16,l=65535&e.high,h=e.low>>>16,p=65535&e.low,m=0,g=0,v=0,E=0;return E+=c*p,v+=E>>>16,E&=65535,v+=a*p,g+=v>>>16,v&=65535,v+=c*h,g+=v>>>16,v&=65535,g+=r*p,m+=g>>>16,g&=65535,g+=a*h,m+=g>>>16,g&=65535,g+=c*l,m+=g>>>16,g&=65535,m+=n*p+r*h+a*l+c*u,m&=65535,s(v<<16|E,m<<16|g,this.unsigned)},y.mul=y.multiply,y.divide=function(e){if(t(e)||(e=o(e)),e.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:f;var n,s,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return m;if(e.gt(this.shru(1)))return v;r=m}else{if(this.eq(_)){if(e.eq(g)||e.eq(E))return _;if(e.eq(_))return g;return n=this.shr(1).div(e).shl(1),n.eq(f)?e.isNegative()?g:E:(s=this.sub(e.mul(n)),r=n.add(s.div(e)))}if(e.eq(_))return this.unsigned?m:f;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=f}for(s=this;s.gte(e);){n=Math.max(1,Math.floor(s.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:u(2,a-48),l=i(n),h=l.mul(e);h.isNegative()||h.gt(s);)n-=c,l=i(n,this.unsigned),h=l.mul(e);l.isZero()&&(l=g),r=r.add(l),s=s.sub(h)}return r},y.div=y.divide,y.modulo=function(e){return t(e)||(e=o(e)),this.sub(this.div(e).mul(e))},y.mod=y.modulo,y.not=function(){return s(~this.low,~this.high,this.unsigned)},y.and=function(e){return t(e)||(e=o(e)),s(this.low&e.low,this.high&e.high,this.unsigned)},y.or=function(e){return t(e)||(e=o(e)),s(this.low|e.low,this.high|e.high,this.unsigned)},y.xor=function(e){return t(e)||(e=o(e)),s(this.low^e.low,this.high^e.high,this.unsigned)},y.shiftLeft=function(e){return t(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?s(this.low<>>32-e,this.unsigned):s(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):s(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},y.shr=y.shiftRight,y.shiftRightUnsigned=function(e){if(t(e)&&(e=e.toInt()),0===(e&=63))return this;var n=this.high;if(e<32){return s(this.low>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?s(n,0,this.unsigned):s(n>>>e-32,0,this.unsigned)},y.shru=y.shiftRightUnsigned,y.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},y.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},y.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},y.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255]},y.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t]},e})},function(e,t,n){"use strict";(function(t){function n(e,n,i,s){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var r,o,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,n)});case 3:return t.nextTick(function(){e.call(null,n,i)});case 4:return t.nextTick(function(){e.call(null,n,i,s)});default:for(r=new Array(a-1),o=0;o-1?i:R;a.WritableState=o;var k=n(20);k.inherits=n(10);var D={deprecate:n(101)},S=n(60),M=n(5).Buffer,C=n(32);k.inherits(a,S),o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:D.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var I;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(I=Function.prototype[Symbol.hasInstance],Object.defineProperty(a,Symbol.hasInstance,{value:function(e){return!!I.call(this,e)||e&&e._writableState instanceof o}})):I=function(e){return e instanceof this},a.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},a.prototype.write=function(e,t,n){var i=this._writableState,r=!1,o=M.isBuffer(e);return"function"==typeof t&&(n=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=s),i.ended?c(this,n):(o||u(this,i,e,n))&&(i.pendingcb++,r=h(this,i,o,e,t,n)),r},a.prototype.cork=function(){this._writableState.corked++},a.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||E(this,e))},a.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},a.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},a.prototype._writev=null,a.prototype.end=function(e,t,n){var i=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||y(this,i,n)}}).call(t,n(7),n(98).setImmediate)},function(e,t,n){const i=n(92);e.exports=i},function(e,t){},function(e,t,n){(function(t){const i=n(27),s=n(38),r=n(37),o=n(0),a=n(4).convertToBuffer,c=n(16),u=n(19),l=n(24),h=n(14),p=n(18),d=n(17),f=n(29);class m{constructor(e){this.client=e}resolveUser(e){return e instanceof c?e:"string"==typeof e?this.client.users.get(e)||null:e instanceof p?e.user:e instanceof u?e.author:e instanceof l?e.owner:null}resolveUserID(e){return e instanceof c||e instanceof p?e.id:"string"==typeof e?e||null:e instanceof u?e.author.id:e instanceof l?e.ownerID:null}resolveGuild(e){return e instanceof l?e:"string"==typeof e?this.client.guilds.get(e)||null:null}resolveGuildMember(e,t){return t instanceof p?t:(e=this.resolveGuild(e),t=this.resolveUser(t),e&&t?e.members.get(t.id)||null:null)}resolveChannel(e){return e instanceof h?e:"string"==typeof e?this.client.channels.get(e)||null:e instanceof u?e.channel:e instanceof l?e.channels.get(e.id)||null:null}resolveChannelID(e){return e instanceof h?e.id:"string"==typeof e?e:e instanceof u?e.channel.id:e instanceof l?e.defaultChannel.id:null}resolveInviteCode(e){const t=/discord(?:app\.com\/invite|\.gg)\/([\w-]{2,255})/i,n=t.exec(e);return n&&n[1]?n[1]:e}resolveString(e){return"string"==typeof e?e:e instanceof Array?e.join("\n"):String(e)}resolveBase64(e){return e instanceof t?`data:image/jpg;base64,${e.toString("base64")}`:e}resolveBuffer(e){return e instanceof t?Promise.resolve(e):this.client.browser&&e instanceof ArrayBuffer?Promise.resolve(a(e)):"string"==typeof e?new Promise((n,o)=>{if(/^https?:\/\//.test(e))r.get(e).end((e,i)=>{if(e)return o(e);if(!(i.body instanceof t))return o(new TypeError("The response body isn't a Buffer."));return n(i.body)});else{const t=i.resolve(e);s.stat(t,(e,i)=>{if(e)return o(e);if(!i||!i.isFile())return o(new Error(`The file could not be found: ${t}`));s.readFile(t,(e,t)=>{e?o(e):n(t)});return null})}}):Promise.reject(new TypeError("The resource must be a string or Buffer."))}resolveEmojiIdentifier(e){return e instanceof d||e instanceof f?e.identifier:"string"==typeof e?this.client.emojis.has(e)?this.client.emojis.get(e).identifier:e.includes("%")?e:encodeURIComponent(e):null}static resolveColor(e){if("string"==typeof e){if("RANDOM"===e)return Math.floor(16777216*Math.random());e=o.Colors[e]||parseInt(e.replace("#",""),16)}else e instanceof Array&&(e=(e[0]<<16)+(e[1]<<8)+e[2]);if(e<0||e>16777215)throw new RangeError("Color must be within the range 0 - 16777215 (0xFFFFFF).");if(e&&isNaN(e))throw new TypeError("Unable to convert color to a number.");return e}resolveColor(e){return this.constructor.resolveColor(e)}}e.exports=m}).call(t,n(5).Buffer)},function(e,t){e.exports={name:"discord.js",version:"12.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:{long:"^3.2.0","prism-media":"^0.0.1",snekfetch:"^3.1.0",tweetnacl:"^0.14.0",ws:"^2.0.0"},peerDependencies:{bufferutil:"^3.0.0",erlpack:"hammerandchisel/erlpack","node-opus":"^0.2.5",opusscript:"^0.0.3",sodium:"^2.0.1","libsodium-wrappers":"^0.5.1",uws:"^0.14.1"},devDependencies:{"@types/node":"^7.0.0","discord.js-docgen":"hydrabolt/discord.js-docgen",eslint:"^3.19.0","parallel-webpack":"^1.6.0","uglify-js":"mishoo/UglifyJS2#harmony-v2.8.22","uglifyjs-webpack-plugin":"^0.4.3",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(e,t,n){const i=n(16),s=n(3),r=n(42),o=n(0);class a extends i{setup(e){super.setup(e),this.verified=e.verified,this.email=e.email,this.localPresence={},this._typing=new Map,this.friends=new s,this.blocked=new s,this.notes=new s,this.premium="boolean"==typeof e.premium?e.premium:null,this.mfaEnabled="boolean"==typeof e.mfa_enabled?e.mfa_enabled:null,this.mobile="boolean"==typeof e.mobile?e.mobile:null,e.user_settings&&(this.settings=new r(this,e.user_settings))}edit(e){return this.client.rest.methods.updateCurrentUser(e)}setUsername(e,t){return this.client.rest.methods.updateCurrentUser({username:e},t)}setEmail(e,t){return this.client.rest.methods.updateCurrentUser({email:e},t)}setPassword(e,t){return this.client.rest.methods.updateCurrentUser({password:e},t)}setAvatar(e){return"string"==typeof e&&e.startsWith("data:")?this.client.rest.methods.updateCurrentUser({avatar:e}):this.client.resolver.resolveBuffer(e).then(e=>this.client.rest.methods.updateCurrentUser({avatar:e}))}setPresence(e){return new Promise(t=>{let n=this.localPresence.status||this.presence.status;let i=this.localPresence.game;let s=this.localPresence.afk||this.presence.afk;!i&&this.presence.game&&(i={name:this.presence.game.name,type:this.presence.game.type,url:this.presence.game.url});if(e.status){if("string"!=typeof e.status)throw new TypeError("Status must be a string");this.bot?n=e.status:(this.settings.update(o.UserSettingsMap.status,e.status),n="invisible")}e.game?(i=e.game,i.url&&(i.type=1)):void 0!==e.game&&(i=null);void 0!==e.afk&&(s=e.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);t(this)})}setStatus(e){return this.setPresence({status:e})}setGame(e,t){return e?this.setPresence({game:{name:e,url:t}}):this.setPresence({game:null})}setAFK(e){return this.setPresence({afk:e})}fetchMentions(e={}){return this.client.rest.methods.fetchMentions(e)}addFriend(e){return e=this.client.resolver.resolveUser(e),this.client.rest.methods.addFriend(e)}removeFriend(e){return e=this.client.resolver.resolveUser(e),this.client.rest.methods.removeFriend(e)}createGuild(e,t,n=null){return n?"string"==typeof n&&n.startsWith("data:")?this.client.rest.methods.createGuild({name:e,icon:n,region:t}):this.client.resolver.resolveBuffer(n).then(n=>this.client.rest.methods.createGuild({name:e,icon:n,region:t})):this.client.rest.methods.createGuild({name:e,icon:n,region:t})}createGroupDM(e){return this.client.rest.methods.createGroupDM({recipients:e.map(e=>this.client.resolver.resolveUserID(e.user)),accessTokens:e.map(e=>e.accessToken),nicks:e.map(e=>e.nick)})}acceptInvite(e){return this.client.rest.methods.acceptInvite(e)}}e.exports=a},function(e,t,n){const i=n(0),s=n(4);class r{constructor(e,t){this.user=e,this.patch(t)}patch(e){for(const t of Object.keys(i.UserSettingsMap)){const n=i.UserSettingsMap[t];e.hasOwnProperty(t)&&("function"==typeof n?this[n.name]=n(e[t]):this[n]=e[t])}}update(e,t){return this.user.client.rest.methods.patchUserSettings({[e]:t})}setGuildPosition(e,t,n){const i=Object.assign([],this.guildPositions);return s.moveElementInArray(i,e.id,t,n),this.update("guild_positions",i).then(()=>e)}addRestrictedGuild(e){const t=Object.assign([],this.restrictedGuilds);return t.includes(e.id)?Promise.reject(new Error("Guild is already restricted")):(t.push(e.id),this.update("restricted_guilds",t).then(()=>e))}removeRestrictedGuild(e){const t=Object.assign([],this.restrictedGuilds),n=t.indexOf(e.id);return n<0?Promise.reject(new Error("Guild is not restricted")):(t.splice(n,1),this.update("restricted_guilds",t).then(()=>e))}}e.exports=r},function(e,t,n){const i=n(14),s=n(22),r=n(3);class o extends i{constructor(e,t){super(e,t),this.type="dm",this.messages=new r,this._typing=new Map}setup(e){super.setup(e),this.recipient=this.client.dataManager.newUser(e.recipients[0]),this.lastMessageID=e.last_message_id}toString(){return this.recipient.toString()}send(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0,["bulkDelete"]),e.exports=o},function(e,t,n){const i=n(3),s=n(6),r={GUILD:"GUILD",CHANNEL:"CHANNEL",USER:"USER",ROLE:"ROLE",INVITE:"INVITE",WEBHOOK:"WEBHOOK",EMOJI:"EMOJI",MESSAGE:"MESSAGE"},o={GUILD_UPDATE:1,CHANNEL_CREATE:10,CHANNEL_UPDATE:11,CHANNEL_DELETE:12,CHANNEL_OVERWRITE_CREATE:13,CHANNEL_OVERWRITE_UPDATE:14,CHANNEL_OVERWRITE_DELETE:15,MEMBER_KICK:20,MEMBER_PRUNE:21,MEMBER_BAN_ADD:22,MEMBER_BAN_REMOVE:23,MEMBER_UPDATE:24,MEMBER_ROLE_UPDATE:25,ROLE_CREATE:30,ROLE_UPDATE:31,ROLE_DELETE:32,INVITE_CREATE:40,INVITE_UPDATE:41,INVITE_DELETE:42,WEBHOOK_CREATE:50,WEBHOOK_UPDATE:51,WEBHOOK_DELETE:52,EMOJI_CREATE:60,EMOJI_UPDATE:61,EMOJI_DELETE:62,MESSAGE_DELETE:72};class a{constructor(e,t){if(t.users)for(const n of t.users)e.client.dataManager.newUser(n);this.entries=new i;for(const n of t.audit_log_entries){const t=new c(e,n);this.entries.set(t.id,t)}}static build(...e){const t=new a(...e);return Promise.all(t.entries.map(e=>e.target)).then(()=>t)}static targetType(e){return e<10?r.GUILD:e<20?r.CHANNEL:e<30?r.USER:e<40?r.ROLE:e<50?r.INVITE:e<60?r.WEBHOOK:e<70?r.EMOJI:e<80?r.MESSAGE:null}static actionType(e){return[o.CHANNEL_CREATE,o.CHANNEL_OVERWRITE_CREATE,o.MEMBER_BAN_REMOVE,o.ROLE_CREATE,o.INVITE_CREATE,o.WEBHOOK_CREATE,o.EMOJI_CREATE].includes(e)?"CREATE":[o.CHANNEL_DELETE,o.CHANNEL_OVERWRITE_DELETE,o.MEMBER_KICK,o.MEMBER_PRUNE,o.MEMBER_BAN_ADD,o.ROLE_DELETE,o.INVITE_DELETE,o.WEBHOOK_DELETE,o.EMOJI_DELETE,o.MESSAGE_DELETE].includes(e)?"DELETE":[o.GUILD_UPDATE,o.CHANNEL_UPDATE,o.CHANNEL_OVERWRITE_UPDATE,o.MEMBER_UPDATE,o.ROLE_UPDATE,o.INVITE_UPDATE,o.WEBHOOK_UPDATE,o.EMOJI_UPDATE].includes(e)?"UPDATE":"ALL"}}class c{constructor(e,t){const n=a.targetType(t.action_type);if(this.targetType=n,this.actionType=a.actionType(t.action_type),this.action=Object.keys(o).find(e=>o[e]===t.action_type),this.reason=t.reason||null,this.executor=e.client.users.get(t.user_id),this.changes=t.changes?t.changes.map(e=>({key:e.key,old:e.old_value,new:e.new_value})):null,this.id=t.id,this.extra=null,t.options)if(t.action_type===o.MEMBER_PRUNE)this.extra={removed:t.options.members_removed,days:t.options.delete_member_days};else if(t.action_type===o.MESSAGE_DELETE)this.extra={count:t.options.count,channel:e.channels.get(t.options.channel_id)};else switch(t.options.type){case"member":this.extra=e.members.get(t.options.id),this.extra||(this.extra={id:t.options.id});break;case"role":this.extra=e.roles.get(t.options.id),this.extra||(this.extra={id:t.options.id,name:t.options.role_name})}if([r.USER,r.GUILD].includes(n))this.target=e.client[`${n.toLowerCase()}s`].get(t.target_id);else if(n===r.WEBHOOK)this.target=e.fetchWebhooks().then(e=>{this.target=e.find(e=>e.id===t.target_id);return this.target});else if(n===r.INVITE){const t=this.changes.find(e=>"code"===e.key);this.target=e.fetchInvites().then(e=>{this.target=e.find(e=>e.code===(t.new_value||t.old_value));return this.target})}else this.target=n===r.MESSAGE?e.client.users.get(t.target_id):e[`${n.toLowerCase()}s`].get(t.target_id)}get createdTimestamp(){return s.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}}a.Actions=o,a.Targets=r,a.Entry=c,e.exports=a},function(e,t,n){const i=n(51),s=n(52),r=n(0);class o{constructor(e,t){Object.defineProperty(this,"client",{value:e}),this.setup(t)}setup(e){this.guild=this.client.guilds.get(e.guild.id)||new i(this.client,e.guild),this.code=e.code,this.presenceCount=e.approximate_presence_count,this.memberCount=e.approximate_member_count,this.textChannelCount=e.guild.text_channel_count,this.voiceChannelCount=e.guild.voice_channel_count,this.temporary=e.temporary,this.maxAge=e.max_age,this.uses=e.uses,this.maxUses=e.max_uses,e.inviter&&(this.inviter=this.client.dataManager.newUser(e.inviter)),this.channel=this.client.channels.get(e.channel.id)||new s(this.client,e.channel),this.createdTimestamp=new Date(e.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}}e.exports=o},function(e,t){class n{constructor(e,t){Object.defineProperty(this,"client",{value:e.client}),this.message=e,this.setup(t)}setup(e){this.id=e.id,this.filename=e.filename,this.filesize=e.size,this.url=e.url,this.proxyURL=e.proxy_url,this.height=e.height,this.width=e.width}}e.exports=n},function(e,t,n){const i=n(31);class s extends i{constructor(e,t,n={}){super(e.client,t,n),this.channel=e,this.received=0,this.client.on("message",this.listener)}handle(e){return e.channel.id!==this.channel.id?null:(this.received++,{key:e.id,value:e})}postCheck(){return this.options.max&&this.collected.size>=this.options.max?"limit":this.options.maxProcessed&&this.received===this.options.maxProcessed?"processedLimit":null}cleanup(){this.client.removeListener("message",this.listener)}}e.exports=s},function(e,t){class n{constructor(e,t){Object.defineProperty(this,"client",{value:e.client}),this.message=e,this.setup(t)}setup(e){if(this.type=e.type,this.title=e.title,this.description=e.description,this.url=e.url,this.color=e.color,this.fields=[],e.fields)for(const t of e.fields)this.fields.push(new c(this,t));this.createdTimestamp=e.timestamp,this.thumbnail=e.thumbnail?new i(this,e.thumbnail):null,this.image=e.image?new s(this,e.image):null,this.video=e.video?new r(this,e.video):null,this.author=e.author?new a(this,e.author):null,this.provider=e.provider?new o(this,e.provider):null,this.footer=e.footer?new u(this,e.footer):null}get createdAt(){return new Date(this.createdTimestamp)}get hexColor(){let e=this.color.toString(16);for(;e.length<6;)e=`0${e}`;return`#${e}`}}class i{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.url=e.url,this.proxyURL=e.proxy_url,this.height=e.height,this.width=e.width}}class s{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.url=e.url,this.proxyURL=e.proxy_url,this.height=e.height,this.width=e.width}}class r{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.url=e.url,this.height=e.height,this.width=e.width}}class o{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.url=e.url}}class a{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.url=e.url,this.iconURL=e.icon_url}}class c{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.name=e.name,this.value=e.value,this.inline=e.inline}}class u{constructor(e,t){this.embed=e,this.setup(t)}setup(e){this.text=e.text,this.iconURL=e.icon_url,this.proxyIconUrl=e.proxy_icon_url}}n.Thumbnail=i,n.Image=s,n.Video=r,n.Provider=o,n.Author=a,n.Field=c,n.Footer=u,e.exports=n},function(e,t,n){const i=n(3);class s{constructor(e,t,n,s){if(this.everyone=Boolean(s),t)if(t instanceof i)this.users=new i(t);else{this.users=new i;for(const n of t){let t=e.client.users.get(n.id);t||(t=e.client.dataManager.newUser(n)),this.users.set(t.id,t)}}else this.users=new i;if(n)if(n instanceof i)this.roles=new i(n);else{this.roles=new i;for(const t of n){const n=e.channel.guild.roles.get(t);n&&this.roles.set(n.id,n)}}else this.roles=new i;this._content=e.content,this._client=e.client,this._guild=e.channel.guild,this._members=null,this._channels=null}get members(){return this._members?this._members:this._guild?(this._members=new i,this.users.forEach(e=>{const t=this._guild.member(e);t&&this._members.set(t.user.id,t)}),this._members):null}get channels(){if(this._channels)return this._channels;this._channels=new i;let e;for(;null!==(e=this.constructor.CHANNELS_PATTERN.exec(this._content));){const t=this._client.channels.get(e[1]);t&&this._channels.set(t.id,t)}return this._channels}}s.EVERYONE_PATTERN=/@(everyone|here)/g,s.USERS_PATTERN=/<@!?[0-9]+>/g,s.ROLES_PATTERN=/<@&[0-9]+>/g,s.CHANNELS_PATTERN=/<#([0-9]+)>/g,e.exports=s},function(e,t,n){const i=n(3),s=n(17),r=n(29);class o{constructor(e,t,n,s){this.message=e,this.me=s,this.count=n||0,this.users=new i,this._emoji=new r(this,t.name,t.id)}get emoji(){if(this._emoji instanceof s)return this._emoji;if(this._emoji.id){const e=this.message.client.emojis;if(e.has(this._emoji.id)){const t=e.get(this._emoji.id);return this._emoji=t,t}}return this._emoji}remove(e=this.message.client.user){const t=this.message,n=this.message.client.resolver.resolveUserID(e);return n?t.client.rest.methods.removeMessageReaction(t,this.emoji.identifier,n):Promise.reject(new Error("Couldn't resolve the user ID to remove from the reaction."))}fetchUsers(e=100){const t=this.message;return t.client.rest.methods.getMessageReactionUsers(t,this.emoji.identifier,e).then(e=>{this.users=new i;for(const t of e){const e=this.message.client.dataManager.newUser(t);this.users.set(e.id,e)}this.count=this.users.size;return this.users})}}e.exports=o},function(e,t){class n{constructor(e,t){Object.defineProperty(this,"client",{value:e}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.icon=e.icon,this.splash=e.splash}}e.exports=n},function(e,t,n){const i=n(0);class s{constructor(e,t){Object.defineProperty(this,"client",{value:e}),this.setup(t)}setup(e){this.id=e.id,this.name=e.name,this.type=i.ChannelTypes.TEXT===e.type?"text":"voice"}}e.exports=s},function(e,t){class n{constructor(e,t){Object.defineProperty(this,"channel",{value:e}),t&&this.setup(t)}setup(e){this.id=e.id,this.type=e.type,this.deny=e.deny,this.allow=e.allow}delete(){return this.channel.client.rest.methods.deletePermissionOverwrites(this)}}e.exports=n},function(e,t,n){const i=n(31),s=n(3);class r extends i{constructor(e,t,n={}){super(e.client,t,n),this.message=e,this.users=new s,this.total=0,this.client.on("messageReactionAdd",this.listener)}handle(e){return e.message.id!==this.message.id?null:{key:e.emoji.id||e.emoji.name,value:e}}postCheck(e,t){return this.users.set(t.id,t),this.options.max&&++this.total>=this.options.max?"limit":this.options.maxEmojis&&this.collected.size>=this.options.maxEmojis?"emojiLimit":this.options.maxUsers&&this.users.size>=this.options.maxUsers?"userLimit":null}cleanup(){this.client.removeListener("messageReactionAdd",this.listener)}}e.exports=r},function(e,t,n){const i=n(25),s=n(22),r=n(3);class o extends i{constructor(e,t){super(e,t),this.type="text",this.messages=new r,this._typing=new Map}setup(e){super.setup(e),this.topic=e.topic,this.lastMessageID=e.last_message_id}get members(){const e=new r;for(const t of this.guild.members.values())this.permissionsFor(t).has("READ_MESSAGES")&&e.set(t.id,t);return e}get nsfw(){return/^nsfw(-|$)/.test(this.name)}fetchWebhooks(){return this.client.rest.methods.getChannelWebhooks(this)}createWebhook(e,t){return new Promise(n=>{"string"==typeof t&&t.startsWith("data:")?n(this.client.rest.methods.createWebhook(this,e,t)):this.client.resolver.resolveBuffer(t).then(t=>n(this.client.rest.methods.createWebhook(this,e,t)))})}send(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}createMessageCollector(){}awaitMessages(){}bulkDelete(){}acknowledge(){}_cacheMessage(){}}s.applyToClass(o,!0),e.exports=o},function(e,t,n){const i=n(25),s=n(3);class r extends i{constructor(e,t){super(e,t),this.members=new s,this.type="voice"}setup(e){super.setup(e),this.bitrate=e.bitrate,this.userLimit=e.user_limit}get connection(){const e=this.guild.voiceConnection;return e&&e.channel.id===this.id?e:null}get full(){return this.userLimit>0&&this.members.size>=this.userLimit}get joinable(){return!this.client.browser&&(!!this.permissionsFor(this.client.user).has("CONNECT")&&!(this.full&&!this.permissionsFor(this.client.user).has("MOVE_MEMBERS")))}get speakable(){return this.permissionsFor(this.client.user).has("SPEAK")}setBitrate(e){return this.edit({bitrate:e})}setUserLimit(e){return this.edit({userLimit:e})}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 e=this.client.voice.connections.get(this.guild.id);e&&e.channel.id===this.id&&e.disconnect()}}}e.exports=r},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";(function(t){function i(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?M(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function s(e,t){D=D||n(13),e=e||{},this.objectMode=!!e.objectMode,t instanceof D&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:s,this.highWaterMark=~~this.highWaterMark,this.buffer=new G,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(j||(j=n(65).StringDecoder),this.decoder=new j(e.encoding),this.encoding=e.encoding)}function r(e){if(D=D||n(13),!(this instanceof r))return new r(e);this._readableState=new s(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),I.call(this)}function o(e,t,n,i,s){var r=l(t,n);if(r)e.emit("error",r);else if(null===n)t.reading=!1,h(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!s){var o=new Error("stream.push() after EOF");e.emit("error",o)}else if(t.endEmitted&&s){var c=new Error("stream.unshift() after end event");e.emit("error",c)}else{var u;!t.decoder||s||i||(n=t.decoder.write(n),u=!t.objectMode&&0===n.length),s||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,s?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&p(e))),f(e,t)}else s||(t.reading=!1);return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=B?e=B:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function u(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=c(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function l(e,t){var n=null;return L.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function h(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,p(e)}}function p(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(P("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?S(d,e):d(e))}function d(e){P("emit readable"),e.emit("readable"),w(e)}function f(e,t){t.readingMore||(t.readingMore=!0,S(m,e,t))}function m(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=y(e,t.buffer,t.decoder),n}function y(e,t,n){var i;return er.length?r.length:e;if(o===r.length?s+=r:s+=r.slice(0,e),0===(e-=o)){o===r.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=r.slice(o));break}++i}return t.length-=i,s}function A(e,t){var n=U.allocUnsafe(e),i=t.head,s=1;for(i.data.copy(n),e-=i.data.length;i=i.next;){var r=i.data,o=e>r.length?r.length:e;if(r.copy(n,n.length-e,0,o),0===(e-=o)){o===r.length?(++s,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=r.slice(o));break}++s}return t.length-=s,n}function R(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,S(T,t,e))}function T(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function k(e,t){for(var n=0,i=e.length;n=t.highWaterMark||t.ended))return P("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):p(this),null;if(0===(e=u(e,t))&&t.ended)return 0===t.length&&R(this),null;var i=t.needReadable;P("need readable",i),(0===t.length||t.length-e0?_(e,t):null,null===s?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&R(this)),null!==s&&this.emit("data",s),s},r.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},r.prototype.pipe=function(e,n){function s(e){P("onunpipe"),e===p&&o()}function r(){P("onend"),e.end()}function o(){P("cleanup"),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("drain",v),e.removeListener("error",c),e.removeListener("unpipe",s),p.removeListener("end",r),p.removeListener("end",o),p.removeListener("data",a),E=!0,!d.awaitDrain||e._writableState&&!e._writableState.needDrain||v()}function a(t){P("ondata"),b=!1,!1!==e.write(t)||b||((1===d.pipesCount&&d.pipes===e||d.pipesCount>1&&-1!==k(d.pipes,e))&&!E&&(P("false write response, pause",p._readableState.awaitDrain),p._readableState.awaitDrain++,b=!0),p.pause())}function c(t){P("onerror",t),h(),e.removeListener("error",c),0===C(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",l),h()}function l(){P("onfinish"),e.removeListener("close",u),h()}function h(){P("unpipe"),p.unpipe(e)}var p=this,d=this._readableState;switch(d.pipesCount){case 0:d.pipes=e;break;case 1:d.pipes=[d.pipes,e];break;default:d.pipes.push(e)}d.pipesCount+=1,P("pipe count=%d opts=%j",d.pipesCount,n);var f=(!n||!1!==n.end)&&e!==t.stdout&&e!==t.stderr,m=f?r:o;d.endEmitted?S(m):p.once("end",m),e.on("unpipe",s);var v=g(p);e.on("drain",v);var E=!1,b=!1;return p.on("data",a),i(e,"error",c),e.once("close",u),e.once("finish",l),e.emit("pipe",p),d.flowing||(P("pipe resume"),p.resume()),e},r.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s",'"',"`"," ","\r","\n","\t"],f=["{","}","|","\\","^","`"].concat(d),m=["'"].concat(f),g=["%","/","?",";","#"].concat(m),v=["/","?","#"],E={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},w={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},_=n(35);i.prototype.parse=function(e,t,n){if(!u.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),s=-1!==i&&i127?C+="x":C+=M[I];if(!C.match(/^[+a-z0-9A-Z_-]{0,63}$/)){var U=D.slice(0,x),O=D.slice(x+1),N=M.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);N&&(U.push(N[1]),O.unshift(N[2])),O.length&&(o="/"+O.join(".")+o),this.hostname=U.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),k||(this.hostname=c.toASCII(this.hostname));var P=this.port?":"+this.port:"",j=this.hostname||"";this.host=j+P,this.href+=this.host,k&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!E[d])for(var x=0,S=m.length;x0)&&n.host.split("@");R&&(n.auth=R.shift(),n.host=n.hostname=R.shift())}return n.search=e.search,n.query=e.query,u.isNull(n.pathname)&&u.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!x.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var T=x.slice(-1)[0],k=(n.host||e.host||x.length>1)&&("."===T||".."===T)||""===T,D=0,S=x.length;S>=0;S--)T=x[S],"."===T?x.splice(S,1):".."===T?(x.splice(S,1),D++):D&&(x.splice(S,1),D--);if(!_&&!y)for(;D--;D)x.unshift("..");!_||""===x[0]||x[0]&&"/"===x[0].charAt(0)||x.unshift(""),k&&"/"!==x.join("/").substr(-1)&&x.push("");var M=""===x[0]||x[0]&&"/"===x[0].charAt(0);if(A){n.hostname=n.host=M?"":x.length?x.shift():"";var R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");R&&(n.auth=R.shift(),n.host=n.hostname=R.shift())}return _=_||n.host&&x.length,_&&!M&&x.unshift(""),x.length?n.pathname=x.join("/"):(n.pathname=null,n.path=null),u.isNull(n.pathname)&&u.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=h.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,n){function i(e){if(e&&!c(e))throw new Error("Unknown encoding: "+e)}function s(e){return e.toString(this.encoding)}function r(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function o(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=n(5).Buffer,c=a.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},u=t.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),i(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=r;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=o;break;default:return void(this.write=s)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};u.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var s=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,s),s-=this.charReceived),t+=e.toString(this.encoding,0,s);var s=t.length-1,i=t.charCodeAt(s);if(i>=55296&&i<=56319){var r=this.surrogateSize;return this.charLength+=r,this.charReceived+=r,this.charBuffer.copy(this.charBuffer,r,0,r),e.copy(this.charBuffer,0,0,r),t.substring(0,s)}return t},u.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},u.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,i=this.charBuffer,s=this.encoding;t+=i.slice(0,n).toString(s)}return t}},function(e,t){class n extends Error{constructor(e){super();const t=e.errors?` -${this.constructor.flattenErrors(e.errors).join("\n")}`:"";this.name="DiscordAPIError",this.message=`${e.message}${t}`,this.code=e.code}static flattenErrors(e,t=""){let n=[];for(const i of Object.keys(e)){const s=t?isNaN(i)?`${t}.${i}`:`${t}[${i}]`:i;e[i]._errors?n.push(`${s}: ${e[i]._errors.map(e=>e.message).join(" ")}`):e[i].code&&e[i].message?n.push(`${e[i].code}: ${e[i].message}`):n=n.concat(this.flattenErrors(e[i],s))}return n}}e.exports=n},function(e,t,n){const i=n(139),s=n(136),r=n(138),o=n(137),a=n(135),c=n(0);class u{constructor(e){this.client=e,this.handlers={},this.userAgentManager=new i(this),this.methods=new s(this),this.rateLimitedEndpoints={},this.globallyRateLimited=!1}destroy(){for(const e in this.handlers)this.handlers[e].destroy()}push(e,t){return new Promise((n,i)=>{e.push({request:t,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(e,t,n,i,s){const r=new a(this,e,t,n,i,s);if(!this.handlers[r.route]){const e=this.getRequestHandler();this.handlers[r.route]=new e(this,r.route)}return this.push(this.handlers[r.route],r)}}e.exports=u},function(e,t){class n{constructor(e){this.restManager=e,this.queue=[]}get globalLimit(){return this.restManager.globallyRateLimited}set globalLimit(e){this.restManager.globallyRateLimited=e}push(e){this.queue.push(e)}handle(){}destroy(){this.queue=[]}}e.exports=n},function(e,t,n){(function(t){const i="browser"===n(23).platform(),s=n(12),r=n(0),o=n(38),a=n(141),c=function(){try{const e=n(186);return e.pack?e:null}catch(e){return null}}(),u=function(){if(i)return window.WebSocket;try{return n(187)}catch(e){return n(188)}}();class l extends s{constructor(e,t){super(),this.manager=e,this.client=e.client,this.ws=null,this.sequence=-1,this.status=r.Status.IDLE,this.packetManager=new a(this),this.lastPingTimestamp=0,this.ratelimit={queue:[],remaining:120,resetTime:-1},this.connect(t),this.disabledEvents={},this.closeSequence=0,this.expectingClose=!1;for(const e of this.client.options.disabledEvents)this.disabledEvents[e]=!0}triggerReady(){if(this.status===r.Status.READY)return void this.debug("Tried to mark self as ready, but already ready");this.status=r.Status.READY,this.client.emit(r.Events.READY),this.packetManager.handleQueue()}checkIfReady(){if(this.status===r.Status.READY||this.status===r.Status.NEARLY)return!1;let e=0;for(const t of this.client.guilds.values())t.available||e++;if(0===e){if(this.status=r.Status.NEARLY,!this.client.options.fetchAllMembers)return this.triggerReady();const e=this.client.guilds.map(e=>e.fetchMembers());Promise.all(e).then(()=>this.triggerReady()).catch(e=>{this.debug(`Failed to fetch all members before ready! ${e}`);this.triggerReady()})}return!0}debug(e){return e instanceof Error&&(e=e.stack),this.manager.debug(`[connection] ${e}`)}unpack(e){return e instanceof ArrayBuffer&&(e=t.from(new Uint8Array(e))),c&&"string"!=typeof e?c.unpack(e):(e instanceof t&&(e=o.inflateSync(e).toString()),JSON.parse(e))}pack(e){return c?c.pack(e):JSON.stringify(e)}processQueue(){if(0!==this.ratelimit.remaining&&0!==this.ratelimit.queue.length)for(120===this.ratelimit.remaining&&(this.ratelimit.resetTimer=setTimeout(()=>{this.ratelimit.remaining=120;this.processQueue()},12e4));this.ratelimit.remaining>0;){const e=this.ratelimit.queue.shift();if(!e)return;this._send(e),this.ratelimit.remaining--}}_send(e){if(!this.ws||this.ws.readyState!==u.OPEN)return void this.debug(`Tried to send packet ${e} but no WebSocket is available!`);this.ws.send(this.pack(e))}send(e){if(!this.ws||this.ws.readyState!==u.OPEN)return void this.debug(`Tried to send packet ${e} but no WebSocket is available!`);this.ratelimit.queue.push(e),this.processQueue()}connect(e=this.gateway,t=0,n=!1){if(t)return this.client.setTimeout(()=>this.connect(e,0,n),t);if(this.ws&&!n)return this.debug("WebSocket connection already exists"),!1;if("string"!=typeof e)return this.debug(`Tried to connect to an invalid gateway: ${e}`),!1;this.expectingClose=!1,this.gateway=e,this.debug(`Connecting to ${e}`);const s=this.ws=new u(e);return i&&(s.binaryType="arraybuffer"),s.onmessage=this.onMessage.bind(this),s.onopen=this.onOpen.bind(this),s.onerror=this.onError.bind(this),s.onclose=this.onClose.bind(this),this.status=r.Status.CONNECTING,!0}destroy(){const e=this.ws;return e?(this.heartbeat(-1),this.expectingClose=!0,e.close(1e3),this.packetManager.handleQueue(),this.ws=null,this.status=r.Status.DISCONNECTED,!0):(this.debug("Attempted to destroy WebSocket but no connection exists!"),!1)}onMessage(e){let t;try{t=this.unpack(e.data)}catch(e){this.emit("debug",e)}return this.onPacket(t)}setSequence(e){this.sequence=e>this.sequence?e:this.sequence}onPacket(e){if(!e)return this.debug("Received null packet"),!1;switch(this.client.emit("raw",e),e.op){case r.OPCodes.HELLO:return this.heartbeat(e.d.heartbeat_interval);case r.OPCodes.RECONNECT:return this.reconnect();case r.OPCodes.INVALID_SESSION:return e.d||(this.sessionID=null),this.sequence=-1,this.debug("Session invalidated -- will identify with a new session"),this.identify(e.d?2500:0);case r.OPCodes.HEARTBEAT_ACK:return this.ackHeartbeat();case r.OPCodes.HEARTBEAT:return this.heartbeat();default:return this.packetManager.handle(e)}}onOpen(e){e&&e.target&&e.target.url&&(this.gateway=e.target.url),this.debug(`Connected to gateway ${this.gateway}`),this.identify()}reconnect(){this.debug("Attemping to reconnect in 5500ms..."),this.client.emit(r.Events.RECONNECTING),this.connect(this.gateway,5500,!0)}onError(e){this.client.emit(r.Events.ERROR,e),"uWs client connection error"===e.message&&this.reconnect()}onClose(e){if(this.debug(`${this.expectingClose?"Client":"Server"} closed the WebSocket connection: ${e.code}`),this.closeSequence=this.sequence,this.emit("close",e),this.heartbeat(-1),1e3===e.code?this.expectingClose:r.WSCodes[e.code])return this.expectingClose=!1,this.client.emit(r.Events.DISCONNECT,e),this.debug(r.WSCodes[e.code]),void this.destroy();this.expectingClose=!1,this.reconnect()}ackHeartbeat(){this.debug(`Heartbeat acknowledged, latency of ${Date.now()-this.lastPingTimestamp}ms`),this.client._pong(this.lastPingTimestamp)}heartbeat(e){if(!isNaN(e))return void(-1===e?(this.debug("Clearing heartbeat interval"),this.client.clearInterval(this.heartbeatInterval),this.heartbeatInterval=null):(this.debug(`Setting a heartbeat interval for ${e}ms`),this.heartbeatInterval=this.client.setInterval(()=>this.heartbeat(),e)));this.debug("Sending a heartbeat"),this.lastPingTimestamp=Date.now(),this.send({op:r.OPCodes.HEARTBEAT,d:this.sequence})}identify(e){return e?this.client.setTimeout(this.identify.apply(this),e):this.sessionID?this.identifyResume():this.identifyNew()}identifyNew(){if(!this.client.token)return void this.debug("No token available to identify a new session with");const e=Object.assign({token:this.client.token},this.client.options.ws),{shardId:shardId,shardCount:shardCount}=this.client.options;shardCount>0&&(e.shard=[Number(shardId),Number(shardCount)]),this.debug("Identifying as a new session"),this.send({op:r.OPCodes.IDENTIFY,d:e})}identifyResume(){if(!this.sessionID)return this.debug("Warning: wanted to resume but session ID not available; identifying as a new session instead"),this.identifyNew();this.debug(`Attempting to resume session ${this.sessionID}`);const e={token:this.client.token,session_id:this.sessionID,seq:this.sequence};return this.send({op:r.OPCodes.RESUME,d:e})}}l.ENCODING=c?"etf":"json",l.WebSocket=u,e.exports=l}).call(t,n(5).Buffer)},function(module,exports,__webpack_require__){(function(process){const os=__webpack_require__(23),EventEmitter=__webpack_require__(12).EventEmitter,Constants=__webpack_require__(0),Permissions=__webpack_require__(8),Util=__webpack_require__(4),RESTManager=__webpack_require__(67),ClientDataManager=__webpack_require__(104),ClientManager=__webpack_require__(105),ClientDataResolver=__webpack_require__(39),ClientVoiceManager=__webpack_require__(184),WebSocketManager=__webpack_require__(140),ActionsManager=__webpack_require__(106),Collection=__webpack_require__(3),Presence=__webpack_require__(11).Presence,ShardClientUtil=__webpack_require__(183),VoiceBroadcast=__webpack_require__(185);class Client extends EventEmitter{constructor(e={}){super(),!e.shardId&&"SHARD_ID"in process.env&&(e.shardId=Number(process.env.SHARD_ID)),!e.shardCount&&"SHARD_COUNT"in process.env&&(e.shardCount=Number(process.env.SHARD_COUNT)),this.options=Util.mergeDefault(Constants.DefaultOptions,e),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._timeouts=new Set,this._intervals=new Set,this.options.messageSweepInterval>0&&this.setInterval(this.sweepMessages.bind(this),1e3*this.options.messageSweepInterval)}get _pingTimestamp(){return this.ws.connection?this.ws.connection.lastPingTimestamp:0}get status(){return this.ws.connection.status}get uptime(){return this.readyAt?Date.now()-this.readyAt:null}get ping(){return this.pings.reduce((e,t)=>e+t,0)/this.pings.length}get voiceConnections(){return this.browser?new Collection:this.voice.connections}get emojis(){const e=new Collection;for(const t of this.guilds.values())for(const n of t.emojis.values())e.set(n.id,n);return e}get readyTimestamp(){return this.readyAt?this.readyAt.getTime():null}get browser(){return"browser"===os.platform()}createVoiceBroadcast(){const e=new VoiceBroadcast(this);return this.broadcasts.push(e),e}login(e){return this.rest.methods.login(e)}destroy(){for(const e of this._timeouts)clearTimeout(e);for(const e of this._intervals)clearInterval(e);return this._timeouts.clear(),this._intervals.clear(),this.manager.destroy()}syncGuilds(e=this.guilds){this.user.bot||this.ws.send({op:12,d:e instanceof Collection?e.keyArray():e.map(e=>e.id)})}fetchUser(e,t=!0){return this.users.has(e)?Promise.resolve(this.users.get(e)):this.rest.methods.getUser(e,t)}fetchInvite(e){const t=this.resolver.resolveInviteCode(e);return this.rest.methods.getInvite(t)}fetchWebhook(e,t){return this.rest.methods.getWebhook(e,t)}fetchVoiceRegions(){return this.rest.methods.fetchVoiceRegions()}sweepMessages(e=this.options.messageCacheLifetime){if("number"!=typeof e||isNaN(e))throw new TypeError("The lifetime must be a number.");if(e<=0)return this.emit("debug","Didn't sweep messages - lifetime is unlimited"),-1;const t=1e3*e,n=Date.now();let i=0,s=0;for(const e of this.channels.values())if(e.messages){i++;for(const i of e.messages.values())n-(i.editedTimestamp||i.createdTimestamp)>t&&(e.messages.delete(i.id),s++)}return this.emit("debug",`Swept ${s} messages older than ${e} seconds in ${i} text-based channels`),s}fetchApplication(e="@me"){return this.rest.methods.getApplication(e)}generateInvite(e){return e?e instanceof Array&&(e=Permissions.resolve(e)):e=0,this.fetchApplication().then(t=>`https://discordapp.com/oauth2/authorize?client_id=${t.id}&permissions=${e}&scope=bot`)}setTimeout(e,t,...n){const i=setTimeout(()=>{e();this._timeouts.delete(i)},t,...n);return this._timeouts.add(i),i}clearTimeout(e){clearTimeout(e),this._timeouts.delete(e)}setInterval(e,t,...n){const i=setInterval(e,t,...n);return this._intervals.add(i),i}clearInterval(e){clearInterval(e),this._intervals.delete(e)}_pong(e){this.pings.unshift(Date.now()-e),this.pings.length>3&&(this.pings.length=3),this.ws.lastHeartbeatAck=!0}_setPresence(e,t){if(this.presences.has(e))return void this.presences.get(e).update(t);this.presences.set(e,new Presence(t))}_eval(script){return eval(script)}_validateOptions(e=this.options){if("number"!=typeof e.shardCount||isNaN(e.shardCount))throw new TypeError("The shardCount option must be a number.");if("number"!=typeof e.shardId||isNaN(e.shardId))throw new TypeError("The shardId option must be a number.");if(e.shardCount<0)throw new RangeError("The shardCount option must be at least 0.");if(e.shardId<0)throw new RangeError("The shardId option must be at least 0.");if(0!==e.shardId&&e.shardId>=e.shardCount)throw new RangeError("The shardId option must be less than shardCount.");if("number"!=typeof e.messageCacheMaxSize||isNaN(e.messageCacheMaxSize))throw new TypeError("The messageCacheMaxSize option must be a number.");if("number"!=typeof e.messageCacheLifetime||isNaN(e.messageCacheLifetime))throw new TypeError("The messageCacheLifetime option must be a number.");if("number"!=typeof e.messageSweepInterval||isNaN(e.messageSweepInterval))throw new TypeError("The messageSweepInterval option must be a number.");if("boolean"!=typeof e.fetchAllMembers)throw new TypeError("The fetchAllMembers option must be a boolean.");if("boolean"!=typeof e.disableEveryone)throw new TypeError("The disableEveryone option must be a boolean.");if("number"!=typeof e.restWsBridgeTimeout||isNaN(e.restWsBridgeTimeout))throw new TypeError("The restWsBridgeTimeout option must be a number.");if(!(e.disabledEvents instanceof Array))throw new TypeError("The disabledEvents option must be an Array.")}}module.exports=Client}).call(exports,__webpack_require__(7))},function(e,t,n){const i=n(30),s=n(67),r=n(39),o=n(0),a=n(4);class c extends i{constructor(e,t,n){super(null,e,t),this.options=a.mergeDefault(o.DefaultOptions,n),this.rest=new s(this),this.resolver=new r(this),this._timeouts=new Set,this._intervals=new Set}setTimeout(e,t,...n){const i=setTimeout(()=>{e();this._timeouts.delete(i)},t,...n);return this._timeouts.add(i),i}clearTimeout(e){clearTimeout(e),this._timeouts.delete(e)}setInterval(e,t,...n){const i=setInterval(e,t,...n);return this._intervals.add(i),i}clearInterval(e){clearInterval(e),this._intervals.delete(e)}destroy(){for(const e of this._timeouts)clearTimeout(e);for(const e of this._intervals)clearInterval(e);this._timeouts.clear(),this._intervals.clear()}}e.exports=c},function(e,t,n){function i(e){return"string"==typeof e?e:e instanceof Array?e.join("\n"):String(e)}const s=n(39);class r{constructor(e={}){this.title=e.title,this.description=e.description,this.url=e.url,this.color=e.color,this.author=e.author,this.timestamp=e.timestamp,this.fields=e.fields||[],this.thumbnail=e.thumbnail,this.image=e.image,this.footer=e.footer,this.file=e.file}setTitle(e){if(e=i(e),e.length>256)throw new RangeError("RichEmbed titles may not exceed 256 characters.");return this.title=e,this}setDescription(e){if(e=i(e),e.length>2048)throw new RangeError("RichEmbed descriptions may not exceed 2048 characters.");return this.description=e,this}setURL(e){return this.url=e,this}setColor(e){return this.color=s.resolveColor(e),this}setAuthor(e,t,n){return this.author={name:i(e),icon_url:t,url:n},this}setTimestamp(e=new Date){return this.timestamp=e,this}addField(e,t,n=!1){if(this.fields.length>=25)throw new RangeError("RichEmbeds may not exceed 25 fields.");if(e=i(e),e.length>256)throw new RangeError("RichEmbed field names may not exceed 256 characters.");if(!/\S/.test(e))throw new RangeError("RichEmbed field names may not be empty.");if(t=i(t),t.length>1024)throw new RangeError("RichEmbed field values may not exceed 1024 characters.");if(!/\S/.test(t))throw new RangeError("RichEmbed field values may not be empty.");return this.fields.push({name:e,value:t,inline:n}),this}addBlankField(e=!1){return this.addField("​","​",e)}setThumbnail(e){return this.thumbnail={url:e},this}setImage(e){return this.image={url:e},this}setFooter(e,t){if(e=i(e),e.length>2048)throw new RangeError("RichEmbed footer text may not exceed 2048 characters.");return this.footer={text:e,icon_url:t},this}attachFile(e){if(this.file)throw new RangeError("You may not upload more than one file at once.");return this.file=e,this}}e.exports=r},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";function i(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function s(e){return 3*e.length/4-i(e)}function r(e){var t,n,s,r,o,a,c=e.length;o=i(e),a=new h(3*c/4-o),s=o>0?c-4:c;var u=0;for(t=0,n=0;t>16&255,a[u++]=r>>8&255,a[u++]=255&r;return 2===o?(r=l[e.charCodeAt(t)]<<2|l[e.charCodeAt(t+1)]>>4,a[u++]=255&r):1===o&&(r=l[e.charCodeAt(t)]<<10|l[e.charCodeAt(t+1)]<<4|l[e.charCodeAt(t+2)]>>2,a[u++]=r>>8&255,a[u++]=255&r),a}function o(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}function a(e,t,n){for(var i,s=[],r=t;rc?c:o+16383));return 1===i?(t=e[n-1],s+=u[t>>2],s+=u[t<<4&63],s+="=="):2===i&&(t=(e[n-2]<<8)+e[n-1],s+=u[t>>10],s+=u[t>>4&63],s+=u[t<<2&63],s+="="),r.push(s),r.join("")}t.byteLength=s,t.toByteArray=r,t.fromByteArray=c;for(var u=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,f=p.length;d>1,l=-7,h=n?s-1:0,p=n?-1:1,d=e[t+h];for(h+=p,r=d&(1<<-l)-1,d>>=-l,l+=a;l>0;r=256*r+e[t+h],h+=p,l-=8);for(o=r&(1<<-l)-1,r>>=-l,l+=i;l>0;o=256*o+e[t+h],h+=p,l-=8);if(0===r)r=1-u;else{if(r===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),r-=u}return(d?-1:1)*o*Math.pow(2,r-i)},t.write=function(e,t,n,i,s,r){var o,a,c,u=8*r-s-1,l=(1<>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:r-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),t+=o+h>=1?p/c:p*Math.pow(2,1-h),t*c>=2&&(o++,c/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(t*c-1)*Math.pow(2,s),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,s),o=0));s>=8;e[n+d]=255&a,d+=f,a/=256,s-=8);for(o=o<0;e[n+d]=255&o,d+=f,o/=256,u-=8);e[n+d-f]|=128*m}},function(e,t,n){(function(e,i){var s;!function(r){function o(e){throw new RangeError(I[e])}function a(e,t){for(var n=e.length,i=[];n--;)i[n]=t(e[n]);return i}function c(e,t){var n=e.split("@"),i="";return n.length>1&&(i=n[0]+"@",e=n[1]),e=e.replace(C,"."),i+a(e.split("."),t).join(".")}function u(e){for(var t,n,i=[],s=0,r=e.length;s=55296&&t<=56319&&s65535&&(e-=65536,t+=O(e>>>10&1023|55296),e=56320|1023&e),t+=O(e)}).join("")}function h(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:_}function p(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function d(e,t,n){var i=0;for(e=n?U(e/R):e>>1,e+=U(e/t);e>L*x>>1;i+=_)e=U(e/L);return U(i+(L+1)*e/(e+A))}function f(e){var t,n,i,s,r,a,c,u,p,f,m=[],g=e.length,v=0,E=k,b=T;for(n=e.lastIndexOf(D),n<0&&(n=0),i=0;i=128&&o("not-basic"),m.push(e.charCodeAt(i));for(s=n>0?n+1:0;s=g&&o("invalid-input"),u=h(e.charCodeAt(s++)),(u>=_||u>U((w-v)/a))&&o("overflow"),v+=u*a,p=c<=b?y:c>=b+x?x:c-b,!(uU(w/f)&&o("overflow"),a*=f;t=m.length+1,b=d(v-r,t,0==r),U(v/t)>w-E&&o("overflow"),E+=U(v/t),v%=t,m.splice(v++,0,E)}return l(m)}function m(e){var t,n,i,s,r,a,c,l,h,f,m,g,v,E,b,A=[];for(e=u(e),g=e.length,t=k,n=0,r=T,a=0;a=t&&mU((w-n)/v)&&o("overflow"),n+=(c-t)*v,t=c,a=0;aw&&o("overflow"),m==t){for(l=n,h=_;f=h<=r?y:h>=r+x?x:h-r,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=_-y,U=Math.floor,O=String.fromCharCode;b={version:"1.4.1",ucs2:{decode:u,encode:l},decode:f,encode:m,toASCII:v,toUnicode:g},void 0!==(s=function(){return b}.call(t,n,t,e))&&(e.exports=s)}()}).call(t,n(102)(e),n(9))},function(e,t,n){"use strict";function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,n,r){t=t||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;e=e.split(t);var a=1e3;r&&"number"==typeof r.maxKeys&&(a=r.maxKeys);var c=e.length;a>0&&c>a&&(c=a);for(var u=0;u=0?(l=f.substr(0,m),h=f.substr(m+1)):(l=f,h=""),p=decodeURIComponent(l),d=decodeURIComponent(h),i(o,p)?s(o[p])?o[p].push(d):o[p]=[o[p],d]:o[p]=d}return o};var s=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function i(e,t){if(e.map)return e.map(t);for(var n=[],i=0;i0?this.tail.next=t:this.head=t,this.tail=t,++this.length},i.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},i.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},i.prototype.clear=function(){this.head=this.tail=null,this.length=0},i.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},i.prototype.concat=function(e){if(0===this.length)return s.alloc(0);if(1===this.length)return this.head.data;for(var t=s.allocUnsafe(e>>>0),n=this.head,i=0;n;)n.data.copy(t,i),i+=n.data.length,n=n.next;return t}},function(e,t,n){e.exports=n(21).PassThrough},function(e,t,n){e.exports=n(21).Transform},function(e,t,n){e.exports=n(36)},function(e,t,n){(function(e,t){!function(e,n){"use strict";function i(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n=3.1.0 <4.0.0",type:"range"},"/home/travis/build/hydrabolt/discord.js"]],_from:"snekfetch@>=3.1.0 <4.0.0",_id:"snekfetch@3.1.7",_inCache:!0,_location:"/snekfetch",_nodeVersion:"8.0.0-rc.0",_npmOperationalInternal:{host:"packages-12-west.internal.npmjs.com",tmp:"tmp/snekfetch-3.1.7.tgz_1494815163487_0.09571001585572958"},_npmUser:{name:"snek",email:"me@gus.host"},_npmVersion:"4.5.0",_phantomChildren:{},_requested:{raw:"snekfetch@^3.1.0",scope:null,escapedName:"snekfetch",name:"snekfetch",rawSpec:"^3.1.0",spec:">=3.1.0 <4.0.0",type:"range"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/snekfetch/-/snekfetch-3.1.7.tgz",_shasum:"5eb980d29c3b455bf0b13359647909b0737315e9",_shrinkwrap:null,_spec:"snekfetch@^3.1.0",_where:"/home/travis/build/hydrabolt/discord.js",author:{name:"Gus Caplan",email:"me@gus.host"},bugs:{url:"https://github.com/devsnek/snekfetch/issues"},dependencies:{},description:"Just do http requests without all that weird nastiness from other libs",devDependencies:{},directories:{},dist:{shasum:"5eb980d29c3b455bf0b13359647909b0737315e9",tarball:"https://registry.npmjs.org/snekfetch/-/snekfetch-3.1.7.tgz"},gitHead:"f47ae6179addc843c76041a5b0a1013c67759729",homepage:"https://github.com/devsnek/snekfetch#readme",license:"MIT",main:"index.js",maintainers:[{name:"crawl",email:"icrawltogo@gmail.com"},{name:"hydrabolt",email:"amishshah.2k@gmail.com"},{name:"snek",email:"me@gus.host"}],name:"snekfetch",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/devsnek/snekfetch.git"},scripts:{},version:"3.1.7"}},function(e,t,n){(function(t){const i=n(27),s=n(93);class r{constructor(){this.boundary=`--snekfetch--${Math.random().toString().slice(2,7)}`,this.buffer=new t(0)}append(e,n,r){if(void 0!==n){let o=` +!function(n,o){s=[],i=o,void 0!==(r="function"==typeof i?i.apply(e,s):i)&&(t.exports=r)}(0,function(){"use strict";function t(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function e(t){return!0===(t&&t.__isLong__)}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=a[t])?i:(n=s(t,t<0?-1:0,!1),r&&(a[t]=n),n))}function i(t,e){if(isNaN(t)||!isFinite(t))return e?m:f;if(e){if(t<0)return m;if(t>=h)return w}else{if(t<=-p)return y;if(t+1>=p)return b}return t<0?i(-t,e).neg():s(t%u|0,t/u|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 f;if("number"==typeof e?(n=e,e=!1):e=!!e,(n=n||10)<2||360)throw Error("interior hyphen");if(0===s)return r(t.substring(1),e,n).neg();for(var o=i(l(n,8)),a=f,c=0;c>>0:this.low},_.toNumber=function(){return this.unsigned?(this.high>>>0)*u+(this.low>>>0):this.high*u+(this.low>>>0)},_.toString=function(t){if((t=t||10)<2||36>>0,h=u.toString(t);if(o=c,o.isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}},_.getHighBits=function(){return this.high},_.getHighBitsUnsigned=function(){return this.high>>>0},_.getLowBits=function(){return this.low},_.getLowBitsUnsigned=function(){return this.low>>>0},_.getNumBitsAbs=function(){if(this.isNegative())return this.eq(y)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<=0},_.isOdd=function(){return 1==(1&this.low)},_.isEven=function(){return 0==(1&this.low)},_.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)},_.eq=_.equals,_.notEquals=function(t){return!this.eq(t)},_.neq=_.notEquals,_.lessThan=function(t){return this.comp(t)<0},_.lt=_.lessThan,_.lessThanOrEqual=function(t){return this.comp(t)<=0},_.lte=_.lessThanOrEqual,_.greaterThan=function(t){return this.comp(t)>0},_.gt=_.greaterThan,_.greaterThanOrEqual=function(t){return this.comp(t)>=0},_.gte=_.greaterThanOrEqual,_.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},_.comp=_.compare,_.negate=function(){return!this.unsigned&&this.eq(y)?y:this.not().add(g)},_.neg=_.negate,_.add=function(t){e(t)||(t=o(t));var n=this.high>>>16,i=65535&this.high,r=this.low>>>16,a=65535&this.low,c=t.high>>>16,l=65535&t.high,u=t.low>>>16,h=65535&t.low,p=0,d=0,f=0,m=0;return m+=a+h,f+=m>>>16,m&=65535,f+=r+u,d+=f>>>16,f&=65535,d+=i+l,p+=d>>>16,d&=65535,p+=n+c,p&=65535,s(f<<16|m,p<<16|d,this.unsigned)},_.subtract=function(t){return e(t)||(t=o(t)),this.add(t.neg())},_.sub=_.subtract,_.multiply=function(t){if(this.isZero())return f;if(e(t)||(t=o(t)),t.isZero())return f;if(this.eq(y))return t.isOdd()?y:f;if(t.eq(y))return this.isOdd()?y:f;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,a=this.low>>>16,c=65535&this.low,l=t.high>>>16,u=65535&t.high,h=t.low>>>16,p=65535&t.low,m=0,g=0,v=0,E=0;return E+=c*p,v+=E>>>16,E&=65535,v+=a*p,g+=v>>>16,v&=65535,v+=c*h,g+=v>>>16,v&=65535,g+=r*p,m+=g>>>16,g&=65535,g+=a*h,m+=g>>>16,g&=65535,g+=c*u,m+=g>>>16,g&=65535,m+=n*p+r*h+a*u+c*l,m&=65535,s(v<<16|E,m<<16|g,this.unsigned)},_.mul=_.multiply,_.divide=function(t){if(e(t)||(t=o(t)),t.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?m:f;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 v;r=m}else{if(this.eq(y)){if(t.eq(g)||t.eq(E))return y;if(t.eq(y))return g;return n=this.shr(1).div(t).shl(1),n.eq(f)?t.isNegative()?g:E:(s=this.sub(t.mul(n)),r=n.add(s.div(t)))}if(t.eq(y))return this.unsigned?m:f;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=f}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:l(2,a-48),u=i(n),h=u.mul(t);h.isNegative()||h.gt(s);)n-=c,u=i(n,this.unsigned),h=u.mul(t);u.isZero()&&(u=g),r=r.add(u),s=s.sub(h)}return r},_.div=_.divide,_.modulo=function(t){return e(t)||(t=o(t)),this.sub(this.div(t).mul(t))},_.mod=_.modulo,_.not=function(){return s(~this.low,~this.high,this.unsigned)},_.and=function(t){return e(t)||(t=o(t)),s(this.low&t.low,this.high&t.high,this.unsigned)},_.or=function(t){return e(t)||(t=o(t)),s(this.low|t.low,this.high|t.high,this.unsigned)},_.xor=function(t){return e(t)||(t=o(t)),s(this.low^t.low,this.high^t.high,this.unsigned)},_.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)},_.shr=_.shiftRight,_.shiftRightUnsigned=function(t){if(e(t)&&(t=t.toInt()),0===(t&=63))return this;var n=this.high;if(t<32){return s(this.low>>>t|n<<32-t,n>>>t,this.unsigned)}return 32===t?s(n,0,this.unsigned):s(n>>>t-32,0,this.unsigned)},_.shru=_.shiftRightUnsigned,_.toSigned=function(){return this.unsigned?s(this.low,this.high,!1):this},_.toUnsigned=function(){return this.unsigned?this:s(this.low,this.high,!0)},_.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},_.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]},_.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){"use strict";(function(e){function n(t,n,i,s){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var r,o,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,i)});case 4:return e.nextTick(function(){t.call(null,n,i,s)});default:for(r=new Array(a-1),o=0;o-1?i:T;a.WritableState=o;var S=n(22);S.inherits=n(11);var k={deprecate:n(103)},D=n(60),M=n(5).Buffer,C=n(33);S.inherits(a,D),o.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(o.prototype,"buffer",{get:k.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(t){}}();var I;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(I=Function.prototype[Symbol.hasInstance],Object.defineProperty(a,Symbol.hasInstance,{value:function(t){return!!I.call(this,t)||t&&t._writableState instanceof o}})):I=function(t){return t instanceof this},a.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},a.prototype.write=function(t,e,n){var i=this._writableState,r=!1,o=M.isBuffer(t);return"function"==typeof e&&(n=e,e=null),o?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=s),i.ended?c(this,n):(o||l(this,i,t,n))&&(i.pendingcb++,r=h(this,i,o,t,e,n)),r},a.prototype.cork=function(){this._writableState.corked++},a.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||E(this,t))},a.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},a.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},a.prototype._writev=null,a.prototype.end=function(t,e,n){var i=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||_(this,i,n)}}).call(e,n(7),n(100).setImmediate)},function(t,e,n){const i=n(94);t.exports=i},function(t,e){},function(t,e,n){(function(e){const i=n(29),s=n(39),r=n(38),o=n(0),a=n(4).convertToBuffer,c=n(12),l=n(8),u=n(18),h=n(16),p=n(19),d=n(17),f=n(31);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 p?t.user:t instanceof l?t.author:t instanceof u?t.owner:null}resolveUserID(t){return t instanceof c||t instanceof p?t.id:"string"==typeof t?t||null:t instanceof l?t.author.id:t instanceof u?t.ownerID:null}resolveGuild(t){return t instanceof u?t:"string"==typeof t?this.client.guilds.get(t)||null:null}resolveGuildMember(t,e){return e instanceof p?e:(t=this.resolveGuild(t),e=this.resolveUser(e),t&&e?t.members.get(e.id)||null:null)}resolveChannel(t){return t instanceof h?t:"string"==typeof t?this.client.channels.get(t)||null:t instanceof l?t.channel:t instanceof u?t.channels.get(t.id)||null:null}resolveChannelID(t){return t instanceof h?t.id:"string"==typeof t?t:t instanceof l?t.channel.id:t instanceof u?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(a(t)):"string"==typeof t?new Promise((n,o)=>{if(/^https?:\/\//.test(t))r.get(t).end((t,i)=>{if(t)return o(t);if(!(i.body instanceof e))return o(new TypeError("The response body isn't a Buffer."));return n(i.body)});else{const e=i.resolve(t);s.stat(e,(t,i)=>{if(t)return o(t);if(!i||!i.isFile())return o(new Error(`The file could not be found: ${e}`));s.readFile(e,(t,e)=>{t?o(t):n(e)});return null})}}):Promise.reject(new TypeError("The resource must be a string or Buffer."))}resolveEmojiIdentifier(t){return t instanceof d||t instanceof f?t.identifier:"string"==typeof t?this.client.emojis.has(t)?this.client.emojis.get(t).identifier:t.includes("%")?t:encodeURIComponent(t):null}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(5).Buffer)},function(t,e){t.exports={name:"discord.js",version:"12.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:{long:"^3.2.0","prism-media":"^0.0.1",snekfetch:"^3.1.0",tweetnacl:"^0.14.0",ws:"^2.0.0"},peerDependencies:{bufferutil:"^3.0.0",erlpack:"hammerandchisel/erlpack","node-opus":"^0.2.5",opusscript:"^0.0.3",sodium:"^2.0.1","libsodium-wrappers":"^0.5.1",uws:"^0.14.1"},devDependencies:{"@types/node":"^7.0.0","discord.js-docgen":"hydrabolt/discord.js-docgen",eslint:"^3.19.0","parallel-webpack":"^1.6.0","uglify-js":"mishoo/UglifyJS2#harmony-v2.8.22","uglifyjs-webpack-plugin":"^0.4.3",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(12),s=n(3),r=n(43),o=n(0),a=n(4),c=n(18),l=n(8),u=n(30);class h 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.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,t.user_settings&&(this.settings=new r(this,t.user_settings))}edit(t,e){const n={};return n.username=t.username||this.username,n.avatar=this.client.resolver.resolveBase64(t.avatar)||this.avatar,this.bot||(n.email=t.email||this.email,n.password=e,t.new_password&&(n.new_password=t.newPassword)),this.client.api.users("@me").patch({data:t}).then(t=>this.client.actions.UserUpdate.handle(t).updated)}setUsername(t,e){return this.edit({username:t},e)}setEmail(t,e){return this.edit({email:t},e)}setPassword(t,e){return this.edit({password:t},e)}setAvatar(t){return"string"==typeof t&&t.startsWith("data:")?this.edit({avatar:t}):this.client.resolver.resolveBuffer(t).then(t=>this.edit({avatar:this.client.resolver.resolveBase64(t)||null}))}setPresence(t){return new Promise(e=>{let n=this.localPresence.status||this.presence.status;let i=this.localPresence.game;let s=this.localPresence.afk||this.presence.afk;!i&&this.presence.game&&(i={name:this.presence.game.name,type:this.presence.game.type,url:this.presence.game.url});if(t.status){if("string"!=typeof t.status)throw new TypeError("Status must be a string");this.bot?n=t.status:(this.settings.update(o.UserSettingsMap.status,t.status),n="invisible")}t.game?(i=t.game,i.url&&(i.type=1)):void 0!==t.game&&(i=null);void 0!==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 t?this.setPresence({game:{name:t,url:e}}):this.setPresence({game:null})}setAFK(t){return this.setPresence({afk:t})}fetchMentions(t={}){return t.guild instanceof c&&(t.guild=t.guild.id),a.mergeDefault({limit:25,roles:!0,everyone:!0,guild:null},t),this.client.api.users("@me").mentions.get({query:t}).then(t=>t.map(t=>new l(this.client.channels.get(t.channel_id),t,this.client)))}createGuild(t,{region:region,icon:icon=null}={}){return!icon||"string"==typeof icon&&icon.startsWith("data:")?this.client.api.guilds.post({data:{name:t,region:region,icon:icon}}).then(t=>this.client.dataManager.newGuild(t)):this.client.resolver.resolveBuffer(icon).then(e=>this.createGuild(t,region,this.client.resolver.resolveBase64(e)||null))}createGroupDM(t){const e=this.bot?{access_tokens:t.map(t=>t.accessToken),nicks:t.reduce((t,e)=>{e.nick&&(t[e.user?e.user.id:e.id]=e.nick);return t},{})}:{recipients:t.map(t=>this.client.resolver.resolveUserID(t))};return this.client.api.users("@me").channels.post({data:e}).then(t=>new u(this.client,t))}}t.exports=h},function(t,e,n){const i=n(0),s=n(4);class r{constructor(t,e){this.user=t,this.patch(e)}patch(t){for(const e of Object.keys(i.UserSettingsMap)){const n=i.UserSettingsMap[e];t.hasOwnProperty(e)&&("function"==typeof n?this[n.name]=n(t[e]):this[n]=t[e])}}update(t,e){return this.user.client.api.users("@me").settings.patch({data:{[t]:e}})}setGuildPosition(t,e,n){const i=Object.assign([],this.guildPositions);return s.moveElementInArray(i,t.id,e,n),this.update("guild_positions",i).then(()=>t)}addRestrictedGuild(t){const e=Object.assign([],this.restrictedGuilds);return e.includes(t.id)?Promise.reject(new Error("Guild is already restricted")):(e.push(t.id),this.update("restricted_guilds",e).then(()=>t))}removeRestrictedGuild(t){const e=Object.assign([],this.restrictedGuilds),n=e.indexOf(t.id);return n<0?Promise.reject(new Error("Guild is not restricted")):(e.splice(n,1),this.update("restricted_guilds",e).then(()=>t))}}t.exports=r},function(t,e,n){const i=n(16),s=n(24),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(){}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(3),s=n(6),r={GUILD:"GUILD",CHANNEL:"CHANNEL",USER:"USER",ROLE:"ROLE",INVITE:"INVITE",WEBHOOK:"WEBHOOK",EMOJI:"EMOJI",MESSAGE:"MESSAGE",UNKNOWN:"UNKNOWN"},o={GUILD_UPDATE:1,CHANNEL_CREATE:10,CHANNEL_UPDATE:11,CHANNEL_DELETE:12,CHANNEL_OVERWRITE_CREATE:13,CHANNEL_OVERWRITE_UPDATE:14,CHANNEL_OVERWRITE_DELETE:15,MEMBER_KICK:20,MEMBER_PRUNE:21,MEMBER_BAN_ADD:22,MEMBER_BAN_REMOVE:23,MEMBER_UPDATE:24,MEMBER_ROLE_UPDATE:25,ROLE_CREATE:30,ROLE_UPDATE:31,ROLE_DELETE:32,INVITE_CREATE:40,INVITE_UPDATE:41,INVITE_DELETE:42,WEBHOOK_CREATE:50,WEBHOOK_UPDATE:51,WEBHOOK_DELETE:52,EMOJI_CREATE:60,EMOJI_UPDATE:61,EMOJI_DELETE:62,MESSAGE_DELETE:72};class a{constructor(t,e){if(e.users)for(const n of e.users)t.client.dataManager.newUser(n);this.entries=new i;for(const n of e.audit_log_entries){const e=new c(t,n);this.entries.set(e.id,e)}}static build(...t){const e=new a(...t);return Promise.all(e.entries.map(t=>t.target)).then(()=>e)}static targetType(t){return t<10?r.GUILD:t<20?r.CHANNEL:t<30?r.USER:t<40?r.ROLE:t<50?r.INVITE:t<60?r.WEBHOOK:t<70?r.EMOJI:t<80?r.MESSAGE:r.UNKNOWN}static actionType(t){return[o.CHANNEL_CREATE,o.CHANNEL_OVERWRITE_CREATE,o.MEMBER_BAN_REMOVE,o.ROLE_CREATE,o.INVITE_CREATE,o.WEBHOOK_CREATE,o.EMOJI_CREATE].includes(t)?"CREATE":[o.CHANNEL_DELETE,o.CHANNEL_OVERWRITE_DELETE,o.MEMBER_KICK,o.MEMBER_PRUNE,o.MEMBER_BAN_ADD,o.ROLE_DELETE,o.INVITE_DELETE,o.WEBHOOK_DELETE,o.EMOJI_DELETE,o.MESSAGE_DELETE].includes(t)?"DELETE":[o.GUILD_UPDATE,o.CHANNEL_UPDATE,o.CHANNEL_OVERWRITE_UPDATE,o.MEMBER_UPDATE,o.ROLE_UPDATE,o.INVITE_UPDATE,o.WEBHOOK_UPDATE,o.EMOJI_UPDATE].includes(t)?"UPDATE":"ALL"}}class c{constructor(t,e){const n=a.targetType(e.action_type);if(this.targetType=n,this.actionType=a.actionType(e.action_type),this.action=Object.keys(o).find(t=>o[t]===e.action_type),this.reason=e.reason||null,this.executor=t.client.users.get(e.user_id),this.changes=e.changes?e.changes.map(t=>({key:t.key,old:t.old_value,new:t.new_value})):null,this.id=e.id,this.extra=null,e.options)if(e.action_type===o.MEMBER_PRUNE)this.extra={removed:e.options.members_removed,days:e.options.delete_member_days};else if(e.action_type===o.MESSAGE_DELETE)this.extra={count:e.options.count,channel:t.channels.get(e.options.channel_id)};else switch(e.options.type){case"member":this.extra=t.members.get(e.options.id),this.extra||(this.extra={id:e.options.id});break;case"role":this.extra=t.roles.get(e.options.id),this.extra||(this.extra={id:e.options.id,name:e.options.role_name})}if(n===r.UNKNOWN)this.target=e.target_id;else if([r.USER,r.GUILD].includes(n))this.target=t.client[`${n.toLowerCase()}s`].get(e.target_id);else if(n===r.WEBHOOK)this.target=t.fetchWebhooks().then(t=>{this.target=t.find(t=>t.id===e.target_id);return this.target});else if(n===r.INVITE){const e=this.changes.find(t=>"code"===t.key);this.target=t.fetchInvites().then(t=>{this.target=t.find(t=>t.code===(e.new_value||e.old_value));return this.target})}else this.target=n===r.MESSAGE?t.client.users.get(e.target_id):t[`${n.toLowerCase()}s`].get(e.target_id)}get createdTimestamp(){return s.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}}a.Actions=o,a.Targets=r,a.Entry=c,t.exports=a},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(32);class s extends i{constructor(t,e,n={}){super(t.client,e,n),this.channel=t,this.received=0,this.client.on("message",this.listener)}handle(t){return t.channel.id!==this.channel.id?null:(this.received++,{key:t.id,value:t})}postCheck(){return this.options.max&&this.collected.size>=this.options.max?"limit":this.options.maxProcessed&&this.received===this.options.maxProcessed?"processedLimit":null}cleanup(){this.client.removeListener("message",this.listener)}}t.exports=s},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 a(this,t.author):null,this.provider=t.provider?new o(this,t.provider):null,this.footer=t.footer?new l(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 a{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 l{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=a,n.Field=c,n.Footer=l,t.exports=n},function(t,e,n){const i=n(3);class s{constructor(t,e,n,s){if(this.everyone=Boolean(s),e)if(e instanceof i)this.users=new i(e);else{this.users=new i;for(const n of e){let e=t.client.users.get(n.id);e||(e=t.client.dataManager.newUser(n)),this.users.set(e.id,e)}}else this.users=new i;if(n)if(n instanceof i)this.roles=new i(n);else{this.roles=new i;for(const e of n){const n=t.channel.guild.roles.get(e);n&&this.roles.set(n.id,n)}}else this.roles=new i;this._content=t.content,this._client=t.client,this._guild=t.channel.guild,this._members=null,this._channels=null}get members(){return this._members?this._members:this._guild?(this._members=new i,this.users.forEach(t=>{const e=this._guild.member(t);e&&this._members.set(e.user.id,e)}),this._members):null}get channels(){if(this._channels)return this._channels;this._channels=new i;let t;for(;null!==(t=this.constructor.CHANNELS_PATTERN.exec(this._content));){const e=this._client.channels.get(t[1]);e&&this._channels.set(e.id,e)}return this._channels}}s.EVERYONE_PATTERN=/@(everyone|here)/g,s.USERS_PATTERN=/<@!?[0-9]+>/g,s.ROLES_PATTERN=/<@&[0-9]+>/g,s.CHANNELS_PATTERN=/<#([0-9]+)>/g,t.exports=s},function(t,e,n){const i=n(3),s=n(17),r=n(31);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.client.resolver.resolveUserID(t);return e?this.message.client.api.channels(this.message.channel.id).messages(this.message.id).reactions(this.emoji.identifier)[e===this.message.client.user.id?"@me":e].delete().then(()=>this.message.client.actions.MessageReactionRemove.handle({user_id:e,message_id:this.message.id,emoji:this.emoji,channel_id:this.message.channel.id}).reaction):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.api.channels(e.channel.id).messages(e.id).reactions(this.emoji.identifier).get({query:{limit:t}}).then(t=>{this.users=new i;for(const n of t){const t=e.client.dataManager.newUser(n);this.users.set(t.id,t)}this.count=this.users.size;return this.users})}}t.exports=o},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(t){return this.channel.client.api.channels(this.channel.id).permissions(this.id).delete({reason:t}).then(()=>this)}}t.exports=n},function(t,e,n){const i=n(32),s=n(3);class r extends i{constructor(t,e,n={}){super(t.client,e,n),this.message=t,this.users=new s,this.total=0,this.client.on("messageReactionAdd",this.listener)}handle(t){return t.message.id!==this.message.id?null:{key:t.emoji.id||t.emoji.name,value:t}}postCheck(t,e){return this.users.set(e.id,e),this.options.max&&++this.total>=this.options.max?"limit":this.options.maxEmojis&&this.collected.size>=this.options.maxEmojis?"emojiLimit":this.options.maxUsers&&this.users.size>=this.options.maxUsers?"userLimit":null}cleanup(){this.client.removeListener("messageReactionAdd",this.listener)}}t.exports=r},function(t,e,n){const i=n(26),s=n(21),r=n(24),o=n(3);class a extends i{constructor(t,e){super(t,e),this.type="text",this.messages=new o,this._typing=new Map}setup(t){super.setup(t),this.topic=t.topic,this.lastMessageID=t.last_message_id}get members(){const t=new o;for(const e of this.guild.members.values())this.permissionsFor(e).has("READ_MESSAGES")&&t.set(e.id,e);return t}get nsfw(){return/^nsfw(-|$)/.test(this.name)}fetchWebhooks(){return this.client.api.channels(this.id).webhooks.get().then(t=>{const e=new o;for(const n of t)e.set(n.id,new s(this.client,n));return e})}createWebhook(t,e){return"string"==typeof e&&e.startsWith("data:")?this.client.api.channels(this.id).webhooks.post({data:{name:t,avatar:e}}).then(t=>new s(this.client,t)):this.client.resolver.resolveBuffer(e).then(e=>this.createWebhook(t,this.client.resolver.resolveBase64(e)||null))}send(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}search(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}createMessageCollector(){}awaitMessages(){}bulkDelete(){}acknowledge(){}_cacheMessage(){}}r.applyToClass(a,!0),t.exports=a},function(t,e,n){const i=n(26),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).has("CONNECT")&&!(this.full&&!this.permissionsFor(this.client.user).has("MOVE_MEMBERS")))}get speakable(){return this.permissionsFor(this.client.user).has("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){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";(function(e){function i(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?M(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}function s(t,e){k=k||n(15),t=t||{},this.objectMode=!!t.objectMode,e instanceof k&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:s,this.highWaterMark=~~this.highWaterMark,this.buffer=new G,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(P||(P=n(65).StringDecoder),this.decoder=new P(t.encoding),this.encoding=t.encoding)}function r(t){if(k=k||n(15),!(this instanceof r))return new r(t);this._readableState=new s(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),I.call(this)}function o(t,e,n,i,s){var r=u(e,n);if(r)t.emit("error",r);else if(null===n)e.reading=!1,h(t,e);else if(e.objectMode||n&&n.length>0)if(e.ended&&!s){var o=new Error("stream.push() after EOF");t.emit("error",o)}else if(e.endEmitted&&s){var c=new Error("stream.unshift() after end event");t.emit("error",c)}else{var l;!e.decoder||s||i||(n=e.decoder.write(n),l=!e.objectMode&&0===n.length),s||(e.reading=!1),l||(e.flowing&&0===e.length&&!e.sync?(t.emit("data",n),t.read(0)):(e.length+=e.objectMode?1:n.length,s?e.buffer.unshift(n):e.buffer.push(n),e.needReadable&&p(t))),f(t,e)}else s||(e.reading=!1);return a(e)}function a(t){return!t.ended&&(t.needReadable||t.length=q?t=q:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function l(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!==t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=c(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function u(t,e){var n=null;return L.isBuffer(e)||"string"==typeof e||null===e||void 0===e||t.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function h(t,e){if(!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,p(t)}}function p(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(j("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?D(d,t):d(t))}function d(t){j("emit readable"),t.emit("readable"),w(t)}function f(t,e){e.readingMore||(e.readingMore=!0,D(m,t,e))}function m(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=_(t,e.buffer,e.decoder),n}function _(t,e,n){var i;return tr.length?r.length:t;if(o===r.length?s+=r:s+=r.slice(0,t),0===(t-=o)){o===r.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=r.slice(o));break}++i}return e.length-=i,s}function A(t,e){var n=O.allocUnsafe(t),i=e.head,s=1;for(i.data.copy(n),t-=i.data.length;i=i.next;){var r=i.data,o=t>r.length?r.length:t;if(r.copy(n,n.length-t,0,o),0===(t-=o)){o===r.length?(++s,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=r.slice(o));break}++s}return e.length-=s,n}function T(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,D(R,e,t))}function R(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function S(t,e){for(var n=0,i=t.length;n=e.highWaterMark||e.ended))return j("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?T(this):p(this),null;if(0===(t=l(t,e))&&e.ended)return 0===e.length&&T(this),null;var i=e.needReadable;j("need readable",i),(0===e.length||e.length-t0?y(t,e):null,null===s?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&T(this)),null!==s&&this.emit("data",s),s},r.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},r.prototype.pipe=function(t,n){function s(t){j("onunpipe"),t===p&&o()}function r(){j("onend"),t.end()}function o(){j("cleanup"),t.removeListener("close",l),t.removeListener("finish",u),t.removeListener("drain",v),t.removeListener("error",c),t.removeListener("unpipe",s),p.removeListener("end",r),p.removeListener("end",o),p.removeListener("data",a),E=!0,!d.awaitDrain||t._writableState&&!t._writableState.needDrain||v()}function a(e){j("ondata"),b=!1,!1!==t.write(e)||b||((1===d.pipesCount&&d.pipes===t||d.pipesCount>1&&-1!==S(d.pipes,t))&&!E&&(j("false write response, pause",p._readableState.awaitDrain),p._readableState.awaitDrain++,b=!0),p.pause())}function c(e){j("onerror",e),h(),t.removeListener("error",c),0===C(t,"error")&&t.emit("error",e)}function l(){t.removeListener("finish",u),h()}function u(){j("onfinish"),t.removeListener("close",l),h()}function h(){j("unpipe"),p.unpipe(t)}var p=this,d=this._readableState;switch(d.pipesCount){case 0:d.pipes=t;break;case 1:d.pipes=[d.pipes,t];break;default:d.pipes.push(t)}d.pipesCount+=1,j("pipe count=%d opts=%j",d.pipesCount,n);var f=(!n||!1!==n.end)&&t!==e.stdout&&t!==e.stderr,m=f?r:o;d.endEmitted?D(m):p.once("end",m),t.on("unpipe",s);var v=g(p);t.on("drain",v);var E=!1,b=!1;return p.on("data",a),i(t,"error",c),t.once("close",l),t.once("finish",u),t.emit("pipe",p),d.flowing||(j("pipe resume"),p.resume()),t},r.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s",'"',"`"," ","\r","\n","\t"],f=["{","}","|","\\","^","`"].concat(d),m=["'"].concat(f),g=["%","/","?",";","#"].concat(m),v=["/","?","#"],E={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},w={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=n(36);i.prototype.parse=function(t,e,n){if(!l.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),s=-1!==i&&i127?C+="x":C+=M[I];if(!C.match(/^[+a-z0-9A-Z_-]{0,63}$/)){var O=k.slice(0,x),N=k.slice(x+1),U=M.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);U&&(O.push(U[1]),N.unshift(U[2])),N.length&&(o="/"+N.join(".")+o),this.hostname=O.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),S||(this.hostname=c.toASCII(this.hostname));var j=this.port?":"+this.port:"",P=this.hostname||"";this.host=P+j,this.href+=this.host,S&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!E[d])for(var x=0,D=m.length;x0)&&n.host.split("@");T&&(n.auth=T.shift(),n.host=n.hostname=T.shift())}return n.search=t.search,n.query=t.query,l.isNull(n.pathname)&&l.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!x.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var R=x.slice(-1)[0],S=(n.host||t.host||x.length>1)&&("."===R||".."===R)||""===R,k=0,D=x.length;D>=0;D--)R=x[D],"."===R?x.splice(D,1):".."===R?(x.splice(D,1),k++):k&&(x.splice(D,1),k--);if(!y&&!_)for(;k--;k)x.unshift("..");!y||""===x[0]||x[0]&&"/"===x[0].charAt(0)||x.unshift(""),S&&"/"!==x.join("/").substr(-1)&&x.push("");var M=""===x[0]||x[0]&&"/"===x[0].charAt(0);if(A){n.hostname=n.host=M?"":x.length?x.shift():"";var T=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");T&&(n.auth=T.shift(),n.host=n.hostname=T.shift())}return y=y||n.host&&x.length,y&&!M&&x.unshift(""),x.length?n.pathname=x.join("/"):(n.pathname=null,n.path=null),l.isNull(n.pathname)&&l.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=t.auth||n.auth,n.slashes=n.slashes||t.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var t=this.host,e=h.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,n){function i(t){if(t&&!c(t))throw new Error("Unknown encoding: "+t)}function s(t){return t.toString(this.encoding)}function r(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function o(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}var a=n(5).Buffer,c=a.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},l=e.StringDecoder=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),i(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=r;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=o;break;default:return void(this.write=s)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};l.prototype.write=function(t){for(var e="";this.charLength;){var n=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var s=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,s),s-=this.charReceived),e+=t.toString(this.encoding,0,s);var s=e.length-1,i=e.charCodeAt(s);if(i>=55296&&i<=56319){var r=this.surrogateSize;return this.charLength+=r,this.charReceived+=r,this.charBuffer.copy(this.charBuffer,r,0,r),t.copy(this.charBuffer,0,0,r),e.substring(0,s)}return e},l.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(1==e&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},l.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,i=this.charBuffer,s=this.encoding;e+=i.slice(0,n).toString(s)}return e}},function(t,e){class n extends Error{constructor(t){super();const e=t.errors?` +${this.constructor.flattenErrors(t.errors).join("\n")}`:"";this.name="DiscordAPIError",this.message=`${t.message}${e}`,this.code=t.code}static flattenErrors(t,e=""){let n=[];for(const i of Object.keys(t)){const s=e?isNaN(i)?`${e}.${i}`:`${e}[${i}]`:i;t[i]._errors?n.push(`${s}: ${t[i]._errors.map(t=>t.message).join(" ")}`):t[i].code||t[i].message?n.push(`${t[i].code?`${t[i].code}: `:""}${t[i].message}`.trim()):n=n.concat(this.flattenErrors(t[i],s))}return n}}t.exports=n},function(t,e,n){const i=n(144),s=n(143),r=n(142),o=n(140),a=n(141),c=n(0);class l{constructor(t){this.client=t,this.handlers={},this.userAgentManager=new i(this),this.rateLimitedEndpoints={},this.globallyRateLimited=!1,this.api=a(this)}destroy(){for(const t in this.handlers)this.handlers[t].destroy()}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 s;case"burst":return r;default:throw new Error(c.Errors.INVALID_RATE_LIMIT_METHOD)}}request(t,e,n={}){const i=new o(this,t,e,n);if(!this.handlers[i.route]){const t=this.getRequestHandler();this.handlers[i.route]=new t(this,i.route)}return this.push(this.handlers[i.route],i)}}t.exports=l},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(){}destroy(){this.queue=[]}}t.exports=n},function(t,e,n){(function(e){const i="browser"===n(25).platform(),s=n(14),r=n(0),o=n(39),a=n(146),c=function(){try{const t=n(192);return t.pack?t:null}catch(t){return null}}(),l=function(){if(i)return window.WebSocket;try{return n(193)}catch(t){return n(194)}}();class u extends s{constructor(t,e){super(),this.manager=t,this.client=t.client,this.ws=null,this.sequence=-1,this.status=r.Status.IDLE,this.packetManager=new a(this),this.lastPingTimestamp=0,this.ratelimit={queue:[],remaining:120,resetTime:-1},this.connect(e),this.disabledEvents={},this.closeSequence=0,this.expectingClose=!1;for(const t of this.client.options.disabledEvents)this.disabledEvents[t]=!0}triggerReady(){if(this.status===r.Status.READY)return void this.debug("Tried to mark self as ready, but already ready");this.status=r.Status.READY,this.client.emit(r.Events.READY),this.packetManager.handleQueue()}checkIfReady(){if(this.status===r.Status.READY||this.status===r.Status.NEARLY)return!1;let t=0;for(const e of this.client.guilds.values())e.available||t++;if(0===t){if(this.status=r.Status.NEARLY,!this.client.options.fetchAllMembers)return this.triggerReady();const t=this.client.guilds.map(t=>t.fetchMembers());Promise.all(t).then(()=>this.triggerReady()).catch(t=>{this.debug(`Failed to fetch all members before ready! ${t}`);this.triggerReady()})}return!0}debug(t){return t instanceof Error&&(t=t.stack),this.manager.debug(`[connection] ${t}`)}unpack(t){return t instanceof ArrayBuffer&&(t=e.from(new Uint8Array(t))),c&&"string"!=typeof t?c.unpack(t):(t instanceof e&&(t=o.inflateSync(t).toString()),JSON.parse(t))}pack(t){return c?c.pack(t):JSON.stringify(t)}processQueue(){if(0!==this.ratelimit.remaining&&0!==this.ratelimit.queue.length)for(120===this.ratelimit.remaining&&(this.ratelimit.resetTimer=setTimeout(()=>{this.ratelimit.remaining=120;this.processQueue()},12e4));this.ratelimit.remaining>0;){const t=this.ratelimit.queue.shift();if(!t)return;this._send(t),this.ratelimit.remaining--}}_send(t){if(!this.ws||this.ws.readyState!==l.OPEN)return void this.debug(`Tried to send packet ${t} but no WebSocket is available!`);this.ws.send(this.pack(t))}send(t){if(!this.ws||this.ws.readyState!==l.OPEN)return void this.debug(`Tried to send packet ${t} but no WebSocket is available!`);this.ratelimit.queue.push(t),this.processQueue()}connect(t=this.gateway,e=0,n=!1){if(e)return this.client.setTimeout(()=>this.connect(t,0,n),e);if(this.ws&&!n)return this.debug("WebSocket connection already exists"),!1;if("string"!=typeof t)return this.debug(`Tried to connect to an invalid gateway: ${t}`),!1;this.expectingClose=!1,this.gateway=t,this.debug(`Connecting to ${t}`);const s=this.ws=new l(t);return i&&(s.binaryType="arraybuffer"),s.onmessage=this.onMessage.bind(this),s.onopen=this.onOpen.bind(this),s.onerror=this.onError.bind(this),s.onclose=this.onClose.bind(this),this.status=r.Status.CONNECTING,!0}destroy(){const t=this.ws;return t?(this.heartbeat(-1),this.expectingClose=!0,t.close(1e3),this.packetManager.handleQueue(),this.ws=null,this.status=r.Status.DISCONNECTED,!0):(this.debug("Attempted to destroy WebSocket but no connection exists!"),!1)}onMessage(t){let e;try{e=this.unpack(t.data)}catch(t){this.emit("debug",t)}return this.onPacket(e)}setSequence(t){this.sequence=t>this.sequence?t:this.sequence}onPacket(t){if(!t)return this.debug("Received null packet"),!1;switch(this.client.emit("raw",t),t.op){case r.OPCodes.HELLO:return this.heartbeat(t.d.heartbeat_interval);case r.OPCodes.RECONNECT:return this.reconnect();case r.OPCodes.INVALID_SESSION:return t.d||(this.sessionID=null),this.sequence=-1,this.debug("Session invalidated -- will identify with a new session"),this.identify(t.d?2500:0);case r.OPCodes.HEARTBEAT_ACK:return this.ackHeartbeat();case r.OPCodes.HEARTBEAT:return this.heartbeat();default:return this.packetManager.handle(t)}}onOpen(t){t&&t.target&&t.target.url&&(this.gateway=t.target.url),this.debug(`Connected to gateway ${this.gateway}`),this.identify()}reconnect(){this.debug("Attemping to reconnect in 5500ms..."),this.client.emit(r.Events.RECONNECTING),this.connect(this.gateway,5500,!0)}onError(t){this.client.emit(r.Events.ERROR,t),"uWs client connection error"===t.message&&this.reconnect()}onClose(t){if(this.debug(`${this.expectingClose?"Client":"Server"} closed the WebSocket connection: ${t.code}`),this.closeSequence=this.sequence,this.emit("close",t),this.heartbeat(-1),1e3===t.code?this.expectingClose:r.WSCodes[t.code])return this.expectingClose=!1,this.client.emit(r.Events.DISCONNECT,t),this.debug(r.WSCodes[t.code]),void this.destroy();this.expectingClose=!1,this.reconnect()}ackHeartbeat(){this.debug(`Heartbeat acknowledged, latency of ${Date.now()-this.lastPingTimestamp}ms`),this.client._pong(this.lastPingTimestamp)}heartbeat(t){if(!isNaN(t))return void(-1===t?(this.debug("Clearing heartbeat interval"),this.client.clearInterval(this.heartbeatInterval),this.heartbeatInterval=null):(this.debug(`Setting a heartbeat interval for ${t}ms`),this.heartbeatInterval=this.client.setInterval(()=>this.heartbeat(),t)));this.debug("Sending a heartbeat"),this.lastPingTimestamp=Date.now(),this.send({op:r.OPCodes.HEARTBEAT,d:this.sequence})}identify(t){return t?this.client.setTimeout(this.identify.apply(this),t):this.sessionID?this.identifyResume():this.identifyNew()}identifyNew(){if(!this.client.token)return void this.debug("No token available to identify a new session with");const t=Object.assign({token:this.client.token},this.client.options.ws),{shardId:shardId,shardCount:shardCount}=this.client.options;shardCount>0&&(t.shard=[Number(shardId),Number(shardCount)]),this.debug("Identifying as a new session"),this.send({op:r.OPCodes.IDENTIFY,d:t})}identifyResume(){if(!this.sessionID)return this.debug("Warning: wanted to resume but session ID not available; identifying as a new session instead"),this.identifyNew();this.debug(`Attempting to resume session ${this.sessionID}`);const t={token:this.client.token,session_id:this.sessionID,seq:this.sequence};return this.send({op:r.OPCodes.RESUME,d:t})}}u.ENCODING=c?"etf":"json",u.WebSocket=l,t.exports=u}).call(e,n(5).Buffer)},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,n){t.exports={search:n(186),sendMessage:n(187)}},function(module,exports,__webpack_require__){(function(process){const os=__webpack_require__(25),EventEmitter=__webpack_require__(14).EventEmitter,Constants=__webpack_require__(0),Permissions=__webpack_require__(10),Util=__webpack_require__(4),RESTManager=__webpack_require__(67),ClientDataManager=__webpack_require__(109),ClientManager=__webpack_require__(110),ClientDataResolver=__webpack_require__(40),ClientVoiceManager=__webpack_require__(190),WebSocketManager=__webpack_require__(145),ActionsManager=__webpack_require__(111),Collection=__webpack_require__(3),Presence=__webpack_require__(13).Presence,VoiceRegion=__webpack_require__(70),Webhook=__webpack_require__(21),User=__webpack_require__(12),Invite=__webpack_require__(27),OAuth2Application=__webpack_require__(28),ShardClientUtil=__webpack_require__(189),VoiceBroadcast=__webpack_require__(191);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.api=this.rest.api,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._timeouts=new Set,this._intervals=new Set,this.options.messageSweepInterval>0&&this.setInterval(this.sweepMessages.bind(this),1e3*this.options.messageSweepInterval)}get _pingTimestamp(){return this.ws.connection?this.ws.connection.lastPingTimestamp:0}get status(){return this.ws.connection.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 new Promise((e,n)=>{if("string"!=typeof t)throw new Error(Constants.Errors.INVALID_TOKEN);t=t.replace(/^Bot\s*/i,"");this.manager.connectToWebSocket(t,e,n)})}destroy(){for(const t of this._timeouts)clearTimeout(t);for(const t of this._intervals)clearInterval(t);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=!0){return this.users.has(t)?Promise.resolve(this.users.get(t)):this.api.users(t).get().then(t=>e?this.dataManager.newUser(t):new User(this,t))}fetchInvite(t){const e=this.resolver.resolveInviteCode(t);return this.api.invites(e).get({query:{with_counts:!0}}).then(t=>new Invite(this,t))}fetchWebhook(t,e){return this.api.webhooks(t,e).get().then(t=>new Webhook(this.client,t))}fetchVoiceRegions(){return this.rest.api.voice.regions.get().then(t=>{const e=new Collection;for(const n of t)e.set(n.id,new VoiceRegion(n));return e})}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 t of this.channels.values())if(t.messages){i++;for(const i of t.messages.values())n-(i.editedTimestamp||i.createdTimestamp)>e&&(t.messages.delete(i.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.api.oauth2.applications(t).get().then(t=>new OAuth2Application(this.client,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){if(this.presences.has(t))return void this.presences.get(t).update(e);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__(7))},function(t,e,n){const i=n(21),s=n(67),r=n(40),o=n(0),a=n(4);class c extends i{constructor(t,e,n){super(null,t,e),this.options=a.mergeDefault(o.DefaultOptions,n),this.rest=new s(this),this.api=this.rest.api,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 t of this._intervals)clearInterval(t);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(40);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=!1){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=!1){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,a,c=t.length;o=i(t),a=new h(3*c/4-o),s=o>0?c-4:c;var l=0;for(e=0,n=0;e>16&255,a[l++]=r>>8&255,a[l++]=255&r;return 2===o?(r=u[t.charCodeAt(e)]<<2|u[t.charCodeAt(e+1)]>>4,a[l++]=255&r):1===o&&(r=u[t.charCodeAt(e)]<<10|u[t.charCodeAt(e+1)]<<4|u[t.charCodeAt(e+2)]>>2,a[l++]=r>>8&255,a[l++]=255&r),a}function o(t){return l[t>>18&63]+l[t>>12&63]+l[t>>6&63]+l[63&t]}function a(t,e,n){for(var i,s=[],r=e;rc?c:o+16383));return 1===i?(e=t[n-1],s+=l[e>>2],s+=l[e<<4&63],s+="=="):2===i&&(e=(t[n-2]<<8)+t[n-1],s+=l[e>>10],s+=l[e>>4&63],s+=l[e<<2&63],s+="="),r.push(s),r.join("")}e.byteLength=s,e.toByteArray=r,e.fromByteArray=c;for(var l=[],u=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,f=p.length;d>1,u=-7,h=n?s-1:0,p=n?-1:1,d=t[e+h];for(h+=p,r=d&(1<<-u)-1,d>>=-u,u+=a;u>0;r=256*r+t[e+h],h+=p,u-=8);for(o=r&(1<<-u)-1,r>>=-u,u+=i;u>0;o=256*o+t[e+h],h+=p,u-=8);if(0===r)r=1-l;else{if(r===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),r-=l}return(d?-1:1)*o*Math.pow(2,r-i)},e.write=function(t,e,n,i,s,r){var o,a,c,l=8*r-s-1,u=(1<>1,p=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:r-1,f=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),e+=o+h>=1?p/c:p*Math.pow(2,1-h),e*c>=2&&(o++,c/=2),o+h>=u?(a=0,o=u):o+h>=1?(a=(e*c-1)*Math.pow(2,s),o+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,s),o=0));s>=8;t[n+d]=255&a,d+=f,a/=256,s-=8);for(o=o<0;t[n+d]=255&o,d+=f,o/=256,l-=8);t[n+d-f]|=128*m}},function(t,e,n){(function(t,i){var s;!function(r){function o(t){throw new RangeError(I[t])}function a(t,e){for(var n=t.length,i=[];n--;)i[n]=e(t[n]);return i}function c(t,e){var n=t.split("@"),i="";return n.length>1&&(i=n[0]+"@",t=n[1]),t=t.replace(C,"."),i+a(t.split("."),e).join(".")}function l(t){for(var e,n,i=[],s=0,r=t.length;s=55296&&e<=56319&&s65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function h(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:y}function p(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function d(t,e,n){var i=0;for(t=n?O(t/T):t>>1,t+=O(t/e);t>L*x>>1;i+=y)t=O(t/L);return O(i+(L+1)*t/(t+A))}function f(t){var e,n,i,s,r,a,c,l,p,f,m=[],g=t.length,v=0,E=S,b=R;for(n=t.lastIndexOf(k),n<0&&(n=0),i=0;i=128&&o("not-basic"),m.push(t.charCodeAt(i));for(s=n>0?n+1:0;s=g&&o("invalid-input"),l=h(t.charCodeAt(s++)),(l>=y||l>O((w-v)/a))&&o("overflow"),v+=l*a,p=c<=b?_:c>=b+x?x:c-b,!(lO(w/f)&&o("overflow"),a*=f;e=m.length+1,b=d(v-r,e,0==r),O(v/e)>w-E&&o("overflow"),E+=O(v/e),v%=e,m.splice(v++,0,E)}return u(m)}function m(t){var e,n,i,s,r,a,c,u,h,f,m,g,v,E,b,A=[];for(t=l(t),g=t.length,e=S,n=0,r=R,a=0;a=e&&mO((w-n)/v)&&o("overflow"),n+=(c-e)*v,e=c,a=0;aw&&o("overflow"),m==e){for(u=n,h=y;f=h<=r?_:h>=r+x?x:h-r,!(u= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=y-_,O=Math.floor,N=String.fromCharCode;b={version:"1.4.1",ucs2:{decode:l,encode:u},decode:f,encode:m,toASCII:v,toUnicode:g},void 0!==(s=function(){return b}.call(e,n,e,t))&&(t.exports=s)}()}).call(e,n(107)(t),n(9))},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;t=t.split(e);var a=1e3;r&&"number"==typeof r.maxKeys&&(a=r.maxKeys);var c=t.length;a>0&&c>a&&(c=a);for(var l=0;l=0?(u=f.substr(0,m),h=f.substr(m+1)):(u=f,h=""),p=decodeURIComponent(u),d=decodeURIComponent(h),i(o,p)?s(o[p])?o[p].push(d):o[p]=[o[p],d]:o[p]=d}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;i0?this.tail.next=e:this.head=e,this.tail=e,++this.length},i.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},i.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},i.prototype.clear=function(){this.head=this.tail=null,this.length=0},i.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},i.prototype.concat=function(t){if(0===this.length)return s.alloc(0);if(1===this.length)return this.head.data;for(var e=s.allocUnsafe(t>>>0),n=this.head,i=0;n;)n.data.copy(e,i),i+=n.data.length,n=n.next;return e}},function(t,e,n){t.exports=n(23).PassThrough},function(t,e,n){t.exports=n(23).Transform},function(t,e,n){t.exports=n(37)},function(t,e,n){(function(t,e){!function(t,n){"use strict";function i(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n=3.1.0 <4.0.0",type:"range"},"/home/travis/build/hydrabolt/discord.js"]],_from:"snekfetch@>=3.1.0 <4.0.0",_id:"snekfetch@3.1.7",_inCache:!0,_location:"/snekfetch",_nodeVersion:"8.0.0-rc.0",_npmOperationalInternal:{host:"packages-12-west.internal.npmjs.com",tmp:"tmp/snekfetch-3.1.7.tgz_1494815163487_0.09571001585572958"},_npmUser:{name:"snek",email:"me@gus.host"},_npmVersion:"4.5.0",_phantomChildren:{},_requested:{raw:"snekfetch@^3.1.0",scope:null,escapedName:"snekfetch",name:"snekfetch",rawSpec:"^3.1.0",spec:">=3.1.0 <4.0.0",type:"range"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/snekfetch/-/snekfetch-3.1.7.tgz",_shasum:"5eb980d29c3b455bf0b13359647909b0737315e9",_shrinkwrap:null,_spec:"snekfetch@^3.1.0",_where:"/home/travis/build/hydrabolt/discord.js",author:{name:"Gus Caplan",email:"me@gus.host"},bugs:{url:"https://github.com/devsnek/snekfetch/issues"},dependencies:{},description:"Just do http requests without all that weird nastiness from other libs",devDependencies:{},directories:{},dist:{shasum:"5eb980d29c3b455bf0b13359647909b0737315e9",tarball:"https://registry.npmjs.org/snekfetch/-/snekfetch-3.1.7.tgz"},gitHead:"f47ae6179addc843c76041a5b0a1013c67759729",homepage:"https://github.com/devsnek/snekfetch#readme",license:"MIT",main:"index.js",maintainers:[{name:"crawl",email:"icrawltogo@gmail.com"},{name:"hydrabolt",email:"amishshah.2k@gmail.com"},{name:"snek",email:"me@gus.host"}],name:"snekfetch",optionalDependencies:{},readme:"ERROR: No README data found!",repository:{type:"git",url:"git+https://github.com/devsnek/snekfetch.git"},scripts:{},version:"3.1.7"}},function(t,e,n){(function(e){const i=n(29),s=n(95);class r{constructor(){this.boundary=`--snekfetch--${Math.random().toString().slice(2,7)}`,this.buffer=new e(0)}append(t,n,r){if(void 0!==n){let o=` --${this.boundary} -Content-Disposition: form-data; name="${e}"`,a=null;if(r){o+=`; filename="${r}"`,a="application/octet-stream";const e=i.extname(r).slice(1);e&&(a=s.lookup(e))}n instanceof t?a=s.buffer(n):"object"==typeof n?(a="application/json",n=t.from(JSON.stringify(n))):n=t.from(String(n)),a&&(o+=` -Content-Type: ${a}`),this.buffer=t.concat([this.buffer,t.from(`${o} +Content-Disposition: form-data; name="${t}"`,a=null;if(r){o+=`; filename="${r}"`,a="application/octet-stream";const t=i.extname(r).slice(1);t&&(a=s.lookup(t))}n instanceof e?a=s.buffer(n):"object"==typeof n?(a="application/json",n=e.from(JSON.stringify(n))):n=e.from(String(n)),a&&(o+=` +Content-Type: ${a}`),this.buffer=e.concat([this.buffer,e.from(`${o} -`),n])}}end(){return this.buffer=t.concat([this.buffer,t.from(` ---${this.boundary}--`)]),this.buffer}}e.exports=r}).call(t,n(5).Buffer)},function(e,t,n){(function(t){function i(e){return c.format({protocol:e.connection.encrypted?"https:":"http:",hostname:e.getHeader("host"),pathname:e.path.split("?")[0],query:e.query})}n(61);const s=n(38),r=n(35),o=n(62),a=n(78),c=n(64),u=n(90),l=n(61),h=n(91);class p extends l.Readable{constructor(e,t,n={headers:{},data:null}){super();const i=c.parse(t);i.method=e.toUpperCase(),i.headers=n.headers,this.data=n.data,this.request=("https:"===i.protocol?a:o).request(i)}query(e,t){if(this.request.res)throw new Error("Cannot modify query after being sent!");return this.request.query||(this.request.query={}),null!==e&&"object"==typeof e?this.request.query=Object.assign(this.request.query,e):this.request.query[e]=t,this}set(e,t){if(this.request.res)throw new Error("Cannot modify headers after being sent!");if(null!==e&&"object"==typeof e)for(const t of Object.keys(e))this.set(t,e[t]);else this.request.setHeader(e,t);return this}attach(e,t,n){if(this.request.res)throw new Error("Cannot modify data after being sent!");const i=this._getFormData();return this.set("Content-Type",`multipart/form-data; boundary=${i.boundary}`),i.append(e,t,n),this.data=i,this}send(e){if(this.request.res)throw new Error("Cannot modify data after being sent!");if(null!==e&&"object"==typeof e){const t=this._getHeader("content-type");let n;t?t.includes("json")?n=JSON.stringify:t.includes("urlencoded")&&(n=r.stringify):(this.set("Content-Type","application/json"),n=JSON.stringify),this.data=n(e)}else this.data=e;return this}then(e,n){return new Promise((e,n)=>{const a=this.request;const u=e=>{e||(e=new Error("Unknown error occured"));e.request=a;n(e)};a.on("abort",u);a.on("aborted",u);a.on("error",u);a.on("response",u=>{const h=new l.PassThrough;this._shouldUnzip(u)?u.pipe(s.createUnzip({flush:s.Z_SYNC_FLUSH,finishFlush:s.Z_SYNC_FLUSH})).pipe(h):u.pipe(h);let d=[];h.on("data",e=>{this.push(e)||this.pause();d.push(e)});h.on("end",()=>{this.push(null);const s=t.concat(d);if(this._shouldRedirect(u)){let t=this.request.method;[301,302].includes(u.statusCode)?("HEAD"!==t&&(t="GET"),this.data=null):303===u.statusCode&&(t="GET");const n={};if(this.request._headerNames)for(const e of Object.keys(this.request._headerNames))"host"!==e.toLowerCase()&&(n[this.request._headerNames[e]]=this.request._headers[e]);else for(const e of Object.keys(this.request._headers))if("host"!==e.toLowerCase()){const t=this.request._headers[e];n[t.name]=t.value}const s=/^https?:\/\//i.test(u.headers.location)?u.headers.location:c.resolve(i(a),u.headers.location);return void e(new p(t,s,{data:this.data,headers:n}))}const l={request:this.request,body:s,text:s.toString(),ok:u.statusCode>=200&&u.statusCode<300,headers:u.headers,status:u.statusCode,statusText:u.statusText||o.STATUS_CODES[u.statusCode]};const h=u.headers["content-type"];if(h)if(h.includes("application/json"))try{l.body=JSON.parse(l.text)}catch(e){}else h.includes("application/x-www-form-urlencoded")&&(l.body=r.parse(l.text));if(l.ok)e(l);else{const e=new Error(`${l.status} ${l.statusText}`.trim());Object.assign(e,l),n(e)}})});this._addFinalHeaders();this.request.query&&(this.request.path=`${this.request.path}?${r.stringify(this.request.query)}`);a.end(this.data?this.data.end?this.data.end():this.data:null)}).then(e,n)}catch(e){return this.then(null,e)}end(e){return this.then(t=>e?e(null,t):t,t=>e?e(t,t.status?t:null):t)}_read(){this.resume(),this.response||this.catch(e=>this.emit("error",e))}_shouldUnzip(e){return 204!==e.statusCode&&304!==e.statusCode&&("0"!==e.headers["content-length"]&&/^\s*(?:deflate|gzip)\s*$/.test(e.headers["content-encoding"]))}_shouldRedirect(e){return[301,302,303,307,308].includes(e.statusCode)}_getFormData(){return this._formData||(this._formData=new h),this._formData}_addFinalHeaders(){this.request&&(this._getHeader("user-agent")||this.set("User-Agent",`snekfetch/${p.version} (${u.repository.url.replace(/\.?git/,"")})`),"HEAD"!==this.request.method&&this.set("Accept-Encoding","gzip, deflate"))}get response(){return this.request.res||this.request._response||null}_getHeader(e){try{return this.request.getHeader(e)}catch(e){return null}}}p.version=u.version,p.METHODS=o.METHODS.concat("BREW");for(const e of p.METHODS)p["M-SEARCH"===e?"msearch":e.toLowerCase()]=(t=>new p(e,t));e.exports=p}).call(t,n(5).Buffer)},function(e,t,n){function i(e){return r[e]||r.bin}function s(e){return o(e)||r.bin}const r=n(95),o=n(94);e.exports={buffer:s,lookup:i}},function(e,t){function n(e){const t=new Uint8Array(e);if(!(t&&t.length>1))return null;if(255===t[0]&&216===t[1]&&255===t[2])return{ext:"jpg",mime:"image/jpeg"};if(137===t[0]&&80===t[1]&&78===t[2]&&71===t[3])return{ext:"png",mime:"image/png"};if(71===t[0]&&73===t[1]&&70===t[2])return{ext:"gif",mime:"image/gif"};if(87===t[8]&&69===t[9]&&66===t[10]&&80===t[11])return{ext:"webp",mime:"image/webp"};if(70===t[0]&&76===t[1]&&73===t[2]&&70===t[3])return{ext:"flif",mime:"image/flif"};if((73===t[0]&&73===t[1]&&42===t[2]&&0===t[3]||77===t[0]&&77===t[1]&&0===t[2]&&42===t[3])&&67===t[8]&&82===t[9])return{ext:"cr2",mime:"image/x-canon-cr2"};if(73===t[0]&&73===t[1]&&42===t[2]&&0===t[3]||77===t[0]&&77===t[1]&&0===t[2]&&42===t[3])return{ext:"tif",mime:"image/tiff"};if(66===t[0]&&77===t[1])return{ext:"bmp",mime:"image/bmp"};if(73===t[0]&&73===t[1]&&188===t[2])return{ext:"jxr",mime:"image/vnd.ms-photo"};if(56===t[0]&&66===t[1]&&80===t[2]&&83===t[3])return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(80===t[0]&&75===t[1]&&3===t[2]&&4===t[3]&&109===t[30]&&105===t[31]&&109===t[32]&&101===t[33]&&116===t[34]&&121===t[35]&&112===t[36]&&101===t[37]&&97===t[38]&&112===t[39]&&112===t[40]&&108===t[41]&&105===t[42]&&99===t[43]&&97===t[44]&&116===t[45]&&105===t[46]&&111===t[47]&&110===t[48]&&47===t[49]&&101===t[50]&&112===t[51]&&117===t[52]&&98===t[53]&&43===t[54]&&122===t[55]&&105===t[56]&&112===t[57])return{ext:"epub",mime:"application/epub+zip"};if(80===t[0]&&75===t[1]&&3===t[2]&&4===t[3]&&77===t[30]&&69===t[31]&&84===t[32]&&65===t[33]&&45===t[34]&&73===t[35]&&78===t[36]&&70===t[37]&&47===t[38]&&109===t[39]&&111===t[40]&&122===t[41]&&105===t[42]&&108===t[43]&&108===t[44]&&97===t[45]&&46===t[46]&&114===t[47]&&115===t[48]&&97===t[49])return{ext:"xpi",mime:"application/x-xpinstall"};if(!(80!==t[0]||75!==t[1]||3!==t[2]&&5!==t[2]&&7!==t[2]||4!==t[3]&&6!==t[3]&&8!==t[3]))return{ext:"zip",mime:"application/zip"};if(117===t[257]&&115===t[258]&&116===t[259]&&97===t[260]&&114===t[261])return{ext:"tar",mime:"application/x-tar"};if(82===t[0]&&97===t[1]&&114===t[2]&&33===t[3]&&26===t[4]&&7===t[5]&&(0===t[6]||1===t[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(31===t[0]&&139===t[1]&&8===t[2])return{ext:"gz",mime:"application/gzip"};if(66===t[0]&&90===t[1]&&104===t[2])return{ext:"bz2",mime:"application/x-bzip2"};if(55===t[0]&&122===t[1]&&188===t[2]&&175===t[3]&&39===t[4]&&28===t[5])return{ext:"7z",mime:"application/x-7z-compressed"};if(120===t[0]&&1===t[1])return{ext:"dmg",mime:"application/x-apple-diskimage"};if(0===t[0]&&0===t[1]&&0===t[2]&&(24===t[3]||32===t[3])&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]||51===t[0]&&103===t[1]&&112===t[2]&&53===t[3]||0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&109===t[8]&&112===t[9]&&52===t[10]&&50===t[11]&&109===t[16]&&112===t[17]&&52===t[18]&&49===t[19]&&109===t[20]&&112===t[21]&&52===t[22]&&50===t[23]&&105===t[24]&&115===t[25]&&111===t[26]&&109===t[27]||0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&105===t[8]&&115===t[9]&&111===t[10]&&109===t[11]||0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&109===t[8]&&112===t[9]&&52===t[10]&&50===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&0===t[15])return{ext:"mp4",mime:"video/mp4"};if(0===t[0]&&0===t[1]&&0===t[2]&&28===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&77===t[8]&&52===t[9]&&86===t[10])return{ext:"m4v",mime:"video/x-m4v"};if(77===t[0]&&84===t[1]&&104===t[2]&&100===t[3])return{ext:"mid",mime:"audio/midi"};if(26===t[0]&&69===t[1]&&223===t[2]&&163===t[3]){const e=t.subarray(4,4100),n=e.findIndex((e,t,n)=>66===n[t]&&130===n[t+1]);if(n>=0){const t=n+3,i=n=>Array.from(n).every((n,i)=>e[t+i]===n.charCodeAt(0));if(i("matroska"))return{ext:"mkv",mime:"video/x-matroska"};if(i("webm"))return{ext:"webm",mime:"video/webm"}}}return 0===t[0]&&0===t[1]&&0===t[2]&&20===t[3]&&102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]?{ext:"mov",mime:"video/quicktime"}:82===t[0]&&73===t[1]&&70===t[2]&&70===t[3]&&65===t[8]&&86===t[9]&&73===t[10]?{ext:"avi",mime:"video/x-msvideo"}:48===t[0]&&38===t[1]&&178===t[2]&&117===t[3]&&142===t[4]&&102===t[5]&&207===t[6]&&17===t[7]&&166===t[8]&&217===t[9]?{ext:"wmv",mime:"video/x-ms-wmv"}:0===t[0]&&0===t[1]&&1===t[2]&&"b"===t[3].toString(16)[0]?{ext:"mpg",mime:"video/mpeg"}:73===t[0]&&68===t[1]&&51===t[2]||255===t[0]&&251===t[1]?{ext:"mp3",mime:"audio/mpeg"}:102===t[4]&&116===t[5]&&121===t[6]&&112===t[7]&&77===t[8]&&52===t[9]&&65===t[10]||77===t[0]&&52===t[1]&&65===t[2]&&32===t[3]?{ext:"m4a",mime:"audio/m4a"}:79===t[28]&&112===t[29]&&117===t[30]&&115===t[31]&&72===t[32]&&101===t[33]&&97===t[34]&&100===t[35]?{ext:"opus",mime:"audio/opus"}:79===t[0]&&103===t[1]&&103===t[2]&&83===t[3]?{ext:"ogg",mime:"audio/ogg"}:102===t[0]&&76===t[1]&&97===t[2]&&67===t[3]?{ext:"flac",mime:"audio/x-flac"}:82===t[0]&&73===t[1]&&70===t[2]&&70===t[3]&&87===t[8]&&65===t[9]&&86===t[10]&&69===t[11]?{ext:"wav",mime:"audio/x-wav"}:35===t[0]&&33===t[1]&&65===t[2]&&77===t[3]&&82===t[4]&&10===t[5]?{ext:"amr",mime:"audio/amr"}:37===t[0]&&80===t[1]&&68===t[2]&&70===t[3]?{ext:"pdf",mime:"application/pdf"}:77===t[0]&&90===t[1]?{ext:"exe",mime:"application/x-msdownload"}:67!==t[0]&&70!==t[0]||87!==t[1]||83!==t[2]?123===t[0]&&92===t[1]&&114===t[2]&&116===t[3]&&102===t[4]?{ext:"rtf",mime:"application/rtf"}:119===t[0]&&79===t[1]&&70===t[2]&&70===t[3]&&(0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]||79===t[4]&&84===t[5]&&84===t[6]&&79===t[7])?{ext:"woff",mime:"application/font-woff"}:119===t[0]&&79===t[1]&&70===t[2]&&50===t[3]&&(0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]||79===t[4]&&84===t[5]&&84===t[6]&&79===t[7])?{ext:"woff2",mime:"application/font-woff"}:76===t[34]&&80===t[35]&&(0===t[8]&&0===t[9]&&1===t[10]||1===t[8]&&0===t[9]&&2===t[10]||2===t[8]&&0===t[9]&&2===t[10])?{ext:"eot",mime:"application/octet-stream"}:0===t[0]&&1===t[1]&&0===t[2]&&0===t[3]&&0===t[4]?{ext:"ttf",mime:"application/font-sfnt"}:79===t[0]&&84===t[1]&&84===t[2]&&79===t[3]&&0===t[4]?{ext:"otf",mime:"application/font-sfnt"}:0===t[0]&&0===t[1]&&1===t[2]&&0===t[3]?{ext:"ico",mime:"image/x-icon"}:70===t[0]&&76===t[1]&&86===t[2]&&1===t[3]?{ext:"flv",mime:"video/x-flv"}:37===t[0]&&33===t[1]?{ext:"ps",mime:"application/postscript"}:253===t[0]&&55===t[1]&&122===t[2]&&88===t[3]&&90===t[4]&&0===t[5]?{ext:"xz",mime:"application/x-xz"}:83===t[0]&&81===t[1]&&76===t[2]&&105===t[3]?{ext:"sqlite",mime:"application/x-sqlite3"}:78===t[0]&&69===t[1]&&83===t[2]&&26===t[3]?{ext:"nes",mime:"application/x-nintendo-nes-rom"}:67===t[0]&&114===t[1]&&50===t[2]&&52===t[3]?{ext:"crx",mime:"application/x-google-chrome-extension"}:77===t[0]&&83===t[1]&&67===t[2]&&70===t[3]||73===t[0]&&83===t[1]&&99===t[2]&&40===t[3]?{ext:"cab",mime:"application/vnd.ms-cab-compressed"}:33===t[0]&&60===t[1]&&97===t[2]&&114===t[3]&&99===t[4]&&104===t[5]&&62===t[6]&&10===t[7]&&100===t[8]&&101===t[9]&&98===t[10]&&105===t[11]&&97===t[12]&&110===t[13]&&45===t[14]&&98===t[15]&&105===t[16]&&110===t[17]&&97===t[18]&&114===t[19]&&121===t[20]?{ext:"deb",mime:"application/x-deb"}:33===t[0]&&60===t[1]&&97===t[2]&&114===t[3]&&99===t[4]&&104===t[5]&&62===t[6]?{ext:"ar",mime:"application/x-unix-archive"}:237===t[0]&&171===t[1]&&238===t[2]&&219===t[3]?{ext:"rpm",mime:"application/x-rpm"}:31===t[0]&&160===t[1]||31===t[0]&&157===t[1]?{ext:"Z",mime:"application/x-compress"}:76===t[0]&&90===t[1]&&73===t[2]&&80===t[3]?{ext:"lz",mime:"application/x-lzip"}:208===t[0]&&207===t[1]&&17===t[2]&&224===t[3]&&161===t[4]&&177===t[5]&&26===t[6]&&225===t[7]?{ext:"msi",mime:"application/x-msi"}:6===t[0]&&14===t[1]&&43===t[2]&&52===t[3]&&2===t[4]&&5===t[5]&&1===t[6]&&1===t[7]&&13===t[8]&&1===t[9]&&2===t[10]&&1===t[11]&&1===t[12]&&2===t[13]?{ext:"mxf",mime:"application/mxf"}:null:{ext:"swf",mime:"application/x-shockwave-flash"}}e.exports=n},function(e,t){e.exports={123:"application/vnd.lotus-1-2-3",ez:"application/andrew-inset",aw:"application/applixware",atom:"application/atom+xml",atomcat:"application/atomcat+xml",atomsvc:"application/atomsvc+xml",bdoc:"application/x-bdoc",ccxml:"application/ccxml+xml",cdmia:"application/cdmi-capability",cdmic:"application/cdmi-container",cdmid:"application/cdmi-domain",cdmio:"application/cdmi-object",cdmiq:"application/cdmi-queue",cu:"application/cu-seeme",mpd:"application/dash+xml",davmount:"application/davmount+xml",dbk:"application/docbook+xml",dssc:"application/dssc+der",xdssc:"application/dssc+xml",ecma:"application/ecmascript",emma:"application/emma+xml",epub:"application/epub+zip",exi:"application/exi",pfr:"application/font-tdpfr",woff:"application/font-woff",woff2:"application/font-woff2",geojson:"application/geo+json",gml:"application/gml+xml",gpx:"application/gpx+xml",gxf:"application/gxf",stk:"application/hyperstudio",ink:"application/inkml+xml",inkml:"application/inkml+xml",ipfix:"application/ipfix",jar:"application/java-archive",war:"application/java-archive",ear:"application/java-archive",ser:"application/java-serialized-object",class:"application/java-vm",js:"application/javascript",json:"application/json",map:"application/json",json5:"application/json5",jsonml:"application/jsonml+json",jsonld:"application/ld+json",lostxml:"application/lost+xml",hqx:"application/mac-binhex40",cpt:"application/mac-compactpro",mads:"application/mads+xml",webmanifest:"application/manifest+json",mrc:"application/marc",mrcx:"application/marcxml+xml",ma:"application/mathematica",nb:"application/mathematica",mb:"application/mathematica",mathml:"application/mathml+xml",mbox:"application/mbox",mscml:"application/mediaservercontrol+xml",metalink:"application/metalink+xml",meta4:"application/metalink4+xml",mets:"application/mets+xml",mods:"application/mods+xml",m21:"application/mp21",mp21:"application/mp21",mp4s:"application/mp4",m4p:"application/mp4",doc:"application/msword",dot:"application/msword",mxf:"application/mxf",bin:"application/octet-stream",dms:"application/octet-stream",lrf:"application/octet-stream",mar:"application/octet-stream",so:"application/octet-stream",dist:"application/octet-stream",distz:"application/octet-stream",pkg:"application/octet-stream",bpk:"application/octet-stream",dump:"application/octet-stream",elc:"application/octet-stream",deploy:"application/octet-stream",exe:"application/x-msdownload",dll:"application/x-msdownload",deb:"application/x-debian-package",dmg:"application/x-apple-diskimage",iso:"application/x-iso9660-image",img:"application/octet-stream",msi:"application/x-msdownload",msp:"application/octet-stream",msm:"application/octet-stream",buffer:"application/octet-stream",oda:"application/oda",opf:"application/oebps-package+xml",ogx:"application/ogg",omdoc:"application/omdoc+xml",onetoc:"application/onenote",onetoc2:"application/onenote",onetmp:"application/onenote",onepkg:"application/onenote",oxps:"application/oxps",xer:"application/patch-ops-error+xml",pdf:"application/pdf",pgp:"application/pgp-encrypted",asc:"application/pgp-signature",sig:"application/pgp-signature",prf:"application/pics-rules",p10:"application/pkcs10",p7m:"application/pkcs7-mime",p7c:"application/pkcs7-mime",p7s:"application/pkcs7-signature",p8:"application/pkcs8",ac:"application/pkix-attr-cert",cer:"application/pkix-cert",crl:"application/pkix-crl",pkipath:"application/pkix-pkipath",pki:"application/pkixcmp",pls:"application/pls+xml",ai:"application/postscript",eps:"application/postscript",ps:"application/postscript",cww:"application/prs.cww",pskcxml:"application/pskc+xml",rdf:"application/rdf+xml",rif:"application/reginfo+xml",rnc:"application/relax-ng-compact-syntax",rl:"application/resource-lists+xml",rld:"application/resource-lists-diff+xml",rs:"application/rls-services+xml",gbr:"application/rpki-ghostbusters",mft:"application/rpki-manifest",roa:"application/rpki-roa",rsd:"application/rsd+xml",rss:"application/rss+xml",rtf:"text/rtf",sbml:"application/sbml+xml",scq:"application/scvp-cv-request",scs:"application/scvp-cv-response",spq:"application/scvp-vp-request",spp:"application/scvp-vp-response",sdp:"application/sdp",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",shf:"application/shf+xml",smi:"application/smil+xml",smil:"application/smil+xml",rq:"application/sparql-query",srx:"application/sparql-results+xml",gram:"application/srgs",grxml:"application/srgs+xml",sru:"application/sru+xml",ssdl:"application/ssdl+xml",ssml:"application/ssml+xml",tei:"application/tei+xml",teicorpus:"application/tei+xml",tfi:"application/thraud+xml",tsd:"application/timestamped-data",plb:"application/vnd.3gpp.pic-bw-large",psb:"application/vnd.3gpp.pic-bw-small",pvb:"application/vnd.3gpp.pic-bw-var",tcap:"application/vnd.3gpp2.tcap",pwn:"application/vnd.3m.post-it-notes",aso:"application/vnd.accpac.simply.aso",imp:"application/vnd.accpac.simply.imp",acu:"application/vnd.acucobol",atc:"application/vnd.acucorp",acutc:"application/vnd.acucorp",air:"application/vnd.adobe.air-application-installer-package+zip",fcdt:"application/vnd.adobe.formscentral.fcdt",fxp:"application/vnd.adobe.fxp",fxpl:"application/vnd.adobe.fxp",xdp:"application/vnd.adobe.xdp+xml",xfdf:"application/vnd.adobe.xfdf",ahead:"application/vnd.ahead.space",azf:"application/vnd.airzip.filesecure.azf",azs:"application/vnd.airzip.filesecure.azs",azw:"application/vnd.amazon.ebook",acc:"application/vnd.americandynamics.acc",ami:"application/vnd.amiga.ami",apk:"application/vnd.android.package-archive",cii:"application/vnd.anser-web-certificate-issue-initiation",fti:"application/vnd.anser-web-funds-transfer-initiation",atx:"application/vnd.antix.game-component",mpkg:"application/vnd.apple.installer+xml",m3u8:"application/vnd.apple.mpegurl",pkpass:"application/vnd.apple.pkpass",swi:"application/vnd.aristanetworks.swi",iota:"application/vnd.astraea-software.iota",aep:"application/vnd.audiograph",mpm:"application/vnd.blueice.multipass",bmi:"application/vnd.bmi",rep:"application/vnd.businessobjects",cdxml:"application/vnd.chemdraw+xml",mmd:"application/vnd.chipnuts.karaoke-mmd",cdy:"application/vnd.cinderella",cla:"application/vnd.claymore",rp9:"application/vnd.cloanto.rp9",c4g:"application/vnd.clonk.c4group",c4d:"application/vnd.clonk.c4group",c4f:"application/vnd.clonk.c4group",c4p:"application/vnd.clonk.c4group",c4u:"application/vnd.clonk.c4group",c11amc:"application/vnd.cluetrust.cartomobile-config",c11amz:"application/vnd.cluetrust.cartomobile-config-pkg",csp:"application/vnd.commonspace",cdbcmsg:"application/vnd.contact.cmsg",cmc:"application/vnd.cosmocaller",clkx:"application/vnd.crick.clicker",clkk:"application/vnd.crick.clicker.keyboard",clkp:"application/vnd.crick.clicker.palette",clkt:"application/vnd.crick.clicker.template",clkw:"application/vnd.crick.clicker.wordbank",wbs:"application/vnd.criticaltools.wbs+xml",pml:"application/vnd.ctc-posml",ppd:"application/vnd.cups-ppd",car:"application/vnd.curl.car",pcurl:"application/vnd.curl.pcurl",dart:"application/vnd.dart",rdz:"application/vnd.data-vision.rdz",uvf:"application/vnd.dece.data",uvvf:"application/vnd.dece.data",uvd:"application/vnd.dece.data",uvvd:"application/vnd.dece.data",uvt:"application/vnd.dece.ttml+xml",uvvt:"application/vnd.dece.ttml+xml",uvx:"application/vnd.dece.unspecified",uvvx:"application/vnd.dece.unspecified",uvz:"application/vnd.dece.zip",uvvz:"application/vnd.dece.zip",fe_launch:"application/vnd.denovo.fcselayout-link",dna:"application/vnd.dna",mlp:"application/vnd.dolby.mlp",dpg:"application/vnd.dpgraph",dfac:"application/vnd.dreamfactory",kpxx:"application/vnd.ds-keypoint",ait:"application/vnd.dvb.ait",svc:"application/vnd.dvb.service",geo:"application/vnd.dynageo",mag:"application/vnd.ecowin.chart",nml:"application/vnd.enliven",esf:"application/vnd.epson.esf",msf:"application/vnd.epson.msf",qam:"application/vnd.epson.quickanime",slt:"application/vnd.epson.salt",ssf:"application/vnd.epson.ssf",es3:"application/vnd.eszigno3+xml",et3:"application/vnd.eszigno3+xml",ez2:"application/vnd.ezpix-album",ez3:"application/vnd.ezpix-package",fdf:"application/vnd.fdf",mseed:"application/vnd.fdsn.mseed",seed:"application/vnd.fdsn.seed",dataless:"application/vnd.fdsn.seed",gph:"application/vnd.flographit",ftc:"application/vnd.fluxtime.clip",fm:"application/vnd.framemaker",frame:"application/vnd.framemaker",maker:"application/vnd.framemaker",book:"application/vnd.framemaker",fnc:"application/vnd.frogans.fnc",ltf:"application/vnd.frogans.ltf",fsc:"application/vnd.fsc.weblaunch",oas:"application/vnd.fujitsu.oasys",oa2:"application/vnd.fujitsu.oasys2",oa3:"application/vnd.fujitsu.oasys3",fg5:"application/vnd.fujitsu.oasysgp",bh2:"application/vnd.fujitsu.oasysprs",ddd:"application/vnd.fujixerox.ddd",xdw:"application/vnd.fujixerox.docuworks",xbd:"application/vnd.fujixerox.docuworks.binder",fzs:"application/vnd.fuzzysheet",txd:"application/vnd.genomatix.tuxedo",ggb:"application/vnd.geogebra.file",ggt:"application/vnd.geogebra.tool",gex:"application/vnd.geometry-explorer",gre:"application/vnd.geometry-explorer",gxt:"application/vnd.geonext",g2w:"application/vnd.geoplan",g3w:"application/vnd.geospace",gmx:"application/vnd.gmx",gdoc:"application/vnd.google-apps.document",gslides:"application/vnd.google-apps.presentation",gsheet:"application/vnd.google-apps.spreadsheet",kml:"application/vnd.google-earth.kml+xml",kmz:"application/vnd.google-earth.kmz",gqf:"application/vnd.grafeq",gqs:"application/vnd.grafeq",gac:"application/vnd.groove-account",ghf:"application/vnd.groove-help",gim:"application/vnd.groove-identity-message",grv:"application/vnd.groove-injector",gtm:"application/vnd.groove-tool-message",tpl:"application/vnd.groove-tool-template",vcg:"application/vnd.groove-vcard",hal:"application/vnd.hal+xml",zmm:"application/vnd.handheld-entertainment+xml",hbci:"application/vnd.hbci",les:"application/vnd.hhe.lesson-player",hpgl:"application/vnd.hp-hpgl",hpid:"application/vnd.hp-hpid",hps:"application/vnd.hp-hps",jlt:"application/vnd.hp-jlyt",pcl:"application/vnd.hp-pcl",pclxl:"application/vnd.hp-pclxl","sfd-hdstx":"application/vnd.hydrostatix.sof-data",mpy:"application/vnd.ibm.minipay",afp:"application/vnd.ibm.modcap",listafp:"application/vnd.ibm.modcap",list3820:"application/vnd.ibm.modcap",irm:"application/vnd.ibm.rights-management",sc:"application/vnd.ibm.secure-container",icc:"application/vnd.iccprofile",icm:"application/vnd.iccprofile",igl:"application/vnd.igloader",ivp:"application/vnd.immervision-ivp",ivu:"application/vnd.immervision-ivu",igm:"application/vnd.insors.igm",xpw:"application/vnd.intercon.formnet",xpx:"application/vnd.intercon.formnet",i2g:"application/vnd.intergeo",qbo:"application/vnd.intu.qbo",qfx:"application/vnd.intu.qfx",rcprofile:"application/vnd.ipunplugged.rcprofile",irp:"application/vnd.irepository.package+xml",xpr:"application/vnd.is-xpr",fcs:"application/vnd.isac.fcs",jam:"application/vnd.jam",rms:"application/vnd.jcp.javame.midlet-rms",jisp:"application/vnd.jisp",joda:"application/vnd.joost.joda-archive",ktz:"application/vnd.kahootz",ktr:"application/vnd.kahootz",karbon:"application/vnd.kde.karbon",chrt:"application/vnd.kde.kchart",kfo:"application/vnd.kde.kformula",flw:"application/vnd.kde.kivio",kon:"application/vnd.kde.kontour",kpr:"application/vnd.kde.kpresenter",kpt:"application/vnd.kde.kpresenter",ksp:"application/vnd.kde.kspread",kwd:"application/vnd.kde.kword",kwt:"application/vnd.kde.kword",htke:"application/vnd.kenameaapp",kia:"application/vnd.kidspiration",kne:"application/vnd.kinar",knp:"application/vnd.kinar",skp:"application/vnd.koan",skd:"application/vnd.koan",skt:"application/vnd.koan",skm:"application/vnd.koan",sse:"application/vnd.kodak-descriptor",lasxml:"application/vnd.las.las+xml",lbd:"application/vnd.llamagraphics.life-balance.desktop",lbe:"application/vnd.llamagraphics.life-balance.exchange+xml",apr:"application/vnd.lotus-approach",pre:"application/vnd.lotus-freelance",nsf:"application/vnd.lotus-notes",org:"application/vnd.lotus-organizer",scm:"application/vnd.lotus-screencam",lwp:"application/vnd.lotus-wordpro",portpkg:"application/vnd.macports.portpkg",mcd:"application/vnd.mcd",mc1:"application/vnd.medcalcdata",cdkey:"application/vnd.mediastation.cdkey",mwf:"application/vnd.mfer",mfm:"application/vnd.mfmp",flo:"application/vnd.micrografx.flo",igx:"application/vnd.micrografx.igx",mif:"application/vnd.mif",daf:"application/vnd.mobius.daf",dis:"application/vnd.mobius.dis",mbk:"application/vnd.mobius.mbk",mqy:"application/vnd.mobius.mqy",msl:"application/vnd.mobius.msl",plc:"application/vnd.mobius.plc",txf:"application/vnd.mobius.txf",mpn:"application/vnd.mophun.application",mpc:"application/vnd.mophun.certificate",xul:"application/vnd.mozilla.xul+xml",cil:"application/vnd.ms-artgalry",cab:"application/vnd.ms-cab-compressed",xls:"application/vnd.ms-excel",xlm:"application/vnd.ms-excel",xla:"application/vnd.ms-excel",xlc:"application/vnd.ms-excel",xlt:"application/vnd.ms-excel",xlw:"application/vnd.ms-excel",xlam:"application/vnd.ms-excel.addin.macroenabled.12",xlsb:"application/vnd.ms-excel.sheet.binary.macroenabled.12",xlsm:"application/vnd.ms-excel.sheet.macroenabled.12",xltm:"application/vnd.ms-excel.template.macroenabled.12",eot:"application/vnd.ms-fontobject",chm:"application/vnd.ms-htmlhelp",ims:"application/vnd.ms-ims",lrm:"application/vnd.ms-lrm",thmx:"application/vnd.ms-officetheme",cat:"application/vnd.ms-pki.seccat",stl:"application/vnd.ms-pki.stl",ppt:"application/vnd.ms-powerpoint",pps:"application/vnd.ms-powerpoint",pot:"application/vnd.ms-powerpoint",ppam:"application/vnd.ms-powerpoint.addin.macroenabled.12",pptm:"application/vnd.ms-powerpoint.presentation.macroenabled.12",sldm:"application/vnd.ms-powerpoint.slide.macroenabled.12",ppsm:"application/vnd.ms-powerpoint.slideshow.macroenabled.12",potm:"application/vnd.ms-powerpoint.template.macroenabled.12",mpp:"application/vnd.ms-project",mpt:"application/vnd.ms-project",docm:"application/vnd.ms-word.document.macroenabled.12",dotm:"application/vnd.ms-word.template.macroenabled.12",wps:"application/vnd.ms-works",wks:"application/vnd.ms-works",wcm:"application/vnd.ms-works",wdb:"application/vnd.ms-works",wpl:"application/vnd.ms-wpl",xps:"application/vnd.ms-xpsdocument",mseq:"application/vnd.mseq",mus:"application/vnd.musician",msty:"application/vnd.muvee.style",taglet:"application/vnd.mynfc",nlu:"application/vnd.neurolanguage.nlu",ntf:"application/vnd.nitf",nitf:"application/vnd.nitf",nnd:"application/vnd.noblenet-directory",nns:"application/vnd.noblenet-sealer",nnw:"application/vnd.noblenet-web",ngdat:"application/vnd.nokia.n-gage.data","n-gage":"application/vnd.nokia.n-gage.symbian.install",rpst:"application/vnd.nokia.radio-preset",rpss:"application/vnd.nokia.radio-presets",edm:"application/vnd.novadigm.edm",edx:"application/vnd.novadigm.edx",ext:"application/vnd.novadigm.ext",odc:"application/vnd.oasis.opendocument.chart",otc:"application/vnd.oasis.opendocument.chart-template",odb:"application/vnd.oasis.opendocument.database",odf:"application/vnd.oasis.opendocument.formula",odft:"application/vnd.oasis.opendocument.formula-template",odg:"application/vnd.oasis.opendocument.graphics",otg:"application/vnd.oasis.opendocument.graphics-template",odi:"application/vnd.oasis.opendocument.image",oti:"application/vnd.oasis.opendocument.image-template",odp:"application/vnd.oasis.opendocument.presentation",otp:"application/vnd.oasis.opendocument.presentation-template",ods:"application/vnd.oasis.opendocument.spreadsheet",ots:"application/vnd.oasis.opendocument.spreadsheet-template",odt:"application/vnd.oasis.opendocument.text",odm:"application/vnd.oasis.opendocument.text-master",ott:"application/vnd.oasis.opendocument.text-template",oth:"application/vnd.oasis.opendocument.text-web",xo:"application/vnd.olpc-sugar",dd2:"application/vnd.oma.dd2+xml",oxt:"application/vnd.openofficeorg.extension",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",sldx:"application/vnd.openxmlformats-officedocument.presentationml.slide",ppsx:"application/vnd.openxmlformats-officedocument.presentationml.slideshow",potx:"application/vnd.openxmlformats-officedocument.presentationml.template",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xltx:"application/vnd.openxmlformats-officedocument.spreadsheetml.template",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",dotx:"application/vnd.openxmlformats-officedocument.wordprocessingml.template",mgp:"application/vnd.osgeo.mapguide.package",dp:"application/vnd.osgi.dp",esa:"application/vnd.osgi.subsystem",pdb:"application/x-pilot",pqa:"application/vnd.palm",oprc:"application/vnd.palm",paw:"application/vnd.pawaafile",str:"application/vnd.pg.format",ei6:"application/vnd.pg.osasli",efif:"application/vnd.picsel",wg:"application/vnd.pmi.widget",plf:"application/vnd.pocketlearn",pbd:"application/vnd.powerbuilder6",box:"application/vnd.previewsystems.box",mgz:"application/vnd.proteus.magazine",qps:"application/vnd.publishare-delta-tree",ptid:"application/vnd.pvi.ptid1",qxd:"application/vnd.quark.quarkxpress",qxt:"application/vnd.quark.quarkxpress",qwd:"application/vnd.quark.quarkxpress",qwt:"application/vnd.quark.quarkxpress",qxl:"application/vnd.quark.quarkxpress",qxb:"application/vnd.quark.quarkxpress",bed:"application/vnd.realvnc.bed",mxl:"application/vnd.recordare.musicxml",musicxml:"application/vnd.recordare.musicxml+xml",cryptonote:"application/vnd.rig.cryptonote",cod:"application/vnd.rim.cod",rm:"application/vnd.rn-realmedia",rmvb:"application/vnd.rn-realmedia-vbr",link66:"application/vnd.route66.link66+xml",st:"application/vnd.sailingtracker.track",see:"application/vnd.seemail",sema:"application/vnd.sema",semd:"application/vnd.semd",semf:"application/vnd.semf",ifm:"application/vnd.shana.informed.formdata",itp:"application/vnd.shana.informed.formtemplate",iif:"application/vnd.shana.informed.interchange",ipk:"application/vnd.shana.informed.package",twd:"application/vnd.simtech-mindmapper",twds:"application/vnd.simtech-mindmapper",mmf:"application/vnd.smaf",teacher:"application/vnd.smart.teacher",sdkm:"application/vnd.solent.sdkm+xml",sdkd:"application/vnd.solent.sdkm+xml",dxp:"application/vnd.spotfire.dxp",sfs:"application/vnd.spotfire.sfs",sdc:"application/vnd.stardivision.calc",sda:"application/vnd.stardivision.draw",sdd:"application/vnd.stardivision.impress",smf:"application/vnd.stardivision.math",sdw:"application/vnd.stardivision.writer",vor:"application/vnd.stardivision.writer",sgl:"application/vnd.stardivision.writer-global",smzip:"application/vnd.stepmania.package",sm:"application/vnd.stepmania.stepchart",sxc:"application/vnd.sun.xml.calc",stc:"application/vnd.sun.xml.calc.template",sxd:"application/vnd.sun.xml.draw",std:"application/vnd.sun.xml.draw.template",sxi:"application/vnd.sun.xml.impress",sti:"application/vnd.sun.xml.impress.template",sxm:"application/vnd.sun.xml.math",sxw:"application/vnd.sun.xml.writer",sxg:"application/vnd.sun.xml.writer.global",stw:"application/vnd.sun.xml.writer.template",sus:"application/vnd.sus-calendar",susp:"application/vnd.sus-calendar",svd:"application/vnd.svd",sis:"application/vnd.symbian.install",sisx:"application/vnd.symbian.install",xsm:"application/vnd.syncml+xml",bdm:"application/vnd.syncml.dm+wbxml",xdm:"application/vnd.syncml.dm+xml",tao:"application/vnd.tao.intent-module-archive",pcap:"application/vnd.tcpdump.pcap",cap:"application/vnd.tcpdump.pcap",dmp:"application/vnd.tcpdump.pcap",tmo:"application/vnd.tmobile-livetv",tpt:"application/vnd.trid.tpt",mxs:"application/vnd.triscape.mxs",tra:"application/vnd.trueapp",ufd:"application/vnd.ufdl",ufdl:"application/vnd.ufdl",utz:"application/vnd.uiq.theme",umj:"application/vnd.umajin",unityweb:"application/vnd.unity",uoml:"application/vnd.uoml+xml",vcx:"application/vnd.vcx",vsd:"application/vnd.visio",vst:"application/vnd.visio",vss:"application/vnd.visio",vsw:"application/vnd.visio",vis:"application/vnd.visionary",vsf:"application/vnd.vsf",wbxml:"application/vnd.wap.wbxml",wmlc:"application/vnd.wap.wmlc",wmlsc:"application/vnd.wap.wmlscriptc",wtb:"application/vnd.webturbo",nbp:"application/vnd.wolfram.player",wpd:"application/vnd.wordperfect",wqd:"application/vnd.wqd",stf:"application/vnd.wt.stf",xar:"application/vnd.xara",xfdl:"application/vnd.xfdl",hvd:"application/vnd.yamaha.hv-dic",hvs:"application/vnd.yamaha.hv-script",hvp:"application/vnd.yamaha.hv-voice",osf:"application/vnd.yamaha.openscoreformat",osfpvg:"application/vnd.yamaha.openscoreformat.osfpvg+xml",saf:"application/vnd.yamaha.smaf-audio",spf:"application/vnd.yamaha.smaf-phrase",cmp:"application/vnd.yellowriver-custom-menu",zir:"application/vnd.zul",zirz:"application/vnd.zul",zaz:"application/vnd.zzazz.deck+xml",vxml:"application/voicexml+xml",wgt:"application/widget",hlp:"application/winhlp",wsdl:"application/wsdl+xml",wspolicy:"application/wspolicy+xml","7z":"application/x-7z-compressed",abw:"application/x-abiword",ace:"application/x-ace-compressed",aab:"application/x-authorware-bin",x32:"application/x-authorware-bin",u32:"application/x-authorware-bin",vox:"application/x-authorware-bin",aam:"application/x-authorware-map",aas:"application/x-authorware-seg",bcpio:"application/x-bcpio",torrent:"application/x-bittorrent",blb:"application/x-blorb",blorb:"application/x-blorb",bz:"application/x-bzip",bz2:"application/x-bzip2",boz:"application/x-bzip2",cbr:"application/x-cbr",cba:"application/x-cbr",cbt:"application/x-cbr",cbz:"application/x-cbr",cb7:"application/x-cbr",vcd:"application/x-cdlink",cfs:"application/x-cfs-compressed",chat:"application/x-chat",pgn:"application/x-chess-pgn",crx:"application/x-chrome-extension",cco:"application/x-cocoa",nsc:"application/x-conference",cpio:"application/x-cpio",csh:"application/x-csh",udeb:"application/x-debian-package",dgc:"application/x-dgc-compressed",dir:"application/x-director",dcr:"application/x-director",dxr:"application/x-director",cst:"application/x-director",cct:"application/x-director",cxt:"application/x-director",w3d:"application/x-director",fgd:"application/x-director",swa:"application/x-director",wad:"application/x-doom",ncx:"application/x-dtbncx+xml",dtb:"application/x-dtbook+xml",res:"application/x-dtbresource+xml",dvi:"application/x-dvi",evy:"application/x-envoy",eva:"application/x-eva",bdf:"application/x-font-bdf",gsf:"application/x-font-ghostscript",psf:"application/x-font-linux-psf",otf:"font/opentype",pcf:"application/x-font-pcf",snf:"application/x-font-snf",ttf:"application/x-font-ttf",ttc:"application/x-font-ttf",pfa:"application/x-font-type1",pfb:"application/x-font-type1",pfm:"application/x-font-type1",afm:"application/x-font-type1",arc:"application/x-freearc",spl:"application/x-futuresplash",gca:"application/x-gca-compressed",ulx:"application/x-glulx",gnumeric:"application/x-gnumeric",gramps:"application/x-gramps-xml",gtar:"application/x-gtar",hdf:"application/x-hdf",php:"application/x-httpd-php",install:"application/x-install-instructions",jardiff:"application/x-java-archive-diff",jnlp:"application/x-java-jnlp-file",latex:"application/x-latex",luac:"application/x-lua-bytecode",lzh:"application/x-lzh-compressed",lha:"application/x-lzh-compressed",run:"application/x-makeself",mie:"application/x-mie",prc:"application/x-pilot",mobi:"application/x-mobipocket-ebook",application:"application/x-ms-application",lnk:"application/x-ms-shortcut",wmd:"application/x-ms-wmd",wmz:"application/x-msmetafile",xbap:"application/x-ms-xbap",mdb:"application/x-msaccess",obd:"application/x-msbinder",crd:"application/x-mscardfile",clp:"application/x-msclip",com:"application/x-msdownload",bat:"application/x-msdownload",mvb:"application/x-msmediaview",m13:"application/x-msmediaview",m14:"application/x-msmediaview",wmf:"application/x-msmetafile",emf:"application/x-msmetafile",emz:"application/x-msmetafile",mny:"application/x-msmoney",pub:"application/x-mspublisher",scd:"application/x-msschedule",trm:"application/x-msterminal",wri:"application/x-mswrite",nc:"application/x-netcdf",cdf:"application/x-netcdf",pac:"application/x-ns-proxy-autoconfig",nzb:"application/x-nzb",pl:"application/x-perl",pm:"application/x-perl",p12:"application/x-pkcs12",pfx:"application/x-pkcs12",p7b:"application/x-pkcs7-certificates",spc:"application/x-pkcs7-certificates",p7r:"application/x-pkcs7-certreqresp",rar:"application/x-rar-compressed",rpm:"application/x-redhat-package-manager",ris:"application/x-research-info-systems",sea:"application/x-sea",sh:"application/x-sh",shar:"application/x-shar",swf:"application/x-shockwave-flash",xap:"application/x-silverlight-app",sql:"application/x-sql",sit:"application/x-stuffit",sitx:"application/x-stuffitx",srt:"application/x-subrip",sv4cpio:"application/x-sv4cpio",sv4crc:"application/x-sv4crc",t3:"application/x-t3vm-image",gam:"application/x-tads",tar:"application/x-tar",tcl:"application/x-tcl",tk:"application/x-tcl",tex:"application/x-tex",tfm:"application/x-tex-tfm",texinfo:"application/x-texinfo",texi:"application/x-texinfo",obj:"application/x-tgif",ustar:"application/x-ustar",src:"application/x-wais-source",webapp:"application/x-web-app-manifest+json",der:"application/x-x509-ca-cert",crt:"application/x-x509-ca-cert",pem:"application/x-x509-ca-cert",fig:"application/x-xfig",xlf:"application/x-xliff+xml",xpi:"application/x-xpinstall",xz:"application/x-xz",z1:"application/x-zmachine",z2:"application/x-zmachine",z3:"application/x-zmachine",z4:"application/x-zmachine",z5:"application/x-zmachine",z6:"application/x-zmachine",z7:"application/x-zmachine",z8:"application/x-zmachine",xaml:"application/xaml+xml",xdf:"application/xcap-diff+xml",xenc:"application/xenc+xml",xhtml:"application/xhtml+xml",xht:"application/xhtml+xml",xml:"text/xml",xsl:"application/xml",xsd:"application/xml",rng:"application/xml",dtd:"application/xml-dtd",xop:"application/xop+xml",xpl:"application/xproc+xml",xslt:"application/xslt+xml",xspf:"application/xspf+xml",mxml:"application/xv+xml",xhvml:"application/xv+xml",xvml:"application/xv+xml",xvm:"application/xv+xml",yang:"application/yang",yin:"application/yin+xml",zip:"application/zip","3gpp":"video/3gpp",adp:"audio/adpcm",au:"audio/basic",snd:"audio/basic",mid:"audio/midi",midi:"audio/midi",kar:"audio/midi",rmi:"audio/midi",mp3:"audio/mpeg",m4a:"audio/x-m4a",mp4a:"audio/mp4",mpga:"audio/mpeg",mp2:"audio/mpeg",mp2a:"audio/mpeg",m2a:"audio/mpeg",m3a:"audio/mpeg",oga:"audio/ogg",ogg:"audio/ogg",spx:"audio/ogg",s3m:"audio/s3m",sil:"audio/silk",uva:"audio/vnd.dece.audio",uvva:"audio/vnd.dece.audio",eol:"audio/vnd.digital-winds",dra:"audio/vnd.dra",dts:"audio/vnd.dts",dtshd:"audio/vnd.dts.hd",lvp:"audio/vnd.lucent.voice",pya:"audio/vnd.ms-playready.media.pya",ecelp4800:"audio/vnd.nuera.ecelp4800",ecelp7470:"audio/vnd.nuera.ecelp7470",ecelp9600:"audio/vnd.nuera.ecelp9600",rip:"audio/vnd.rip",wav:"audio/x-wav",weba:"audio/webm",aac:"audio/x-aac",aif:"audio/x-aiff",aiff:"audio/x-aiff",aifc:"audio/x-aiff",caf:"audio/x-caf",flac:"audio/x-flac",mka:"audio/x-matroska",m3u:"audio/x-mpegurl",wax:"audio/x-ms-wax",wma:"audio/x-ms-wma",ram:"audio/x-pn-realaudio",ra:"audio/x-realaudio",rmp:"audio/x-pn-realaudio-plugin",xm:"audio/xm",cdx:"chemical/x-cdx",cif:"chemical/x-cif",cmdf:"chemical/x-cmdf",cml:"chemical/x-cml",csml:"chemical/x-csml",xyz:"chemical/x-xyz",bmp:"image/x-ms-bmp",cgm:"image/cgm",g3:"image/g3fax",gif:"image/gif",ief:"image/ief",jpeg:"image/jpeg",jpg:"image/jpeg",jpe:"image/jpeg",ktx:"image/ktx",png:"image/png",btif:"image/prs.btif",sgi:"image/sgi",svg:"image/svg+xml",svgz:"image/svg+xml",tiff:"image/tiff",tif:"image/tiff",psd:"image/vnd.adobe.photoshop",uvi:"image/vnd.dece.graphic",uvvi:"image/vnd.dece.graphic",uvg:"image/vnd.dece.graphic",uvvg:"image/vnd.dece.graphic",djvu:"image/vnd.djvu",djv:"image/vnd.djvu",sub:"text/vnd.dvb.subtitle",dwg:"image/vnd.dwg",dxf:"image/vnd.dxf",fbs:"image/vnd.fastbidsheet",fpx:"image/vnd.fpx",fst:"image/vnd.fst",mmr:"image/vnd.fujixerox.edmics-mmr",rlc:"image/vnd.fujixerox.edmics-rlc",mdi:"image/vnd.ms-modi",wdp:"image/vnd.ms-photo",npx:"image/vnd.net-fpx",wbmp:"image/vnd.wap.wbmp",xif:"image/vnd.xiff",webp:"image/webp","3ds":"image/x-3ds",ras:"image/x-cmu-raster",cmx:"image/x-cmx",fh:"image/x-freehand",fhc:"image/x-freehand",fh4:"image/x-freehand",fh5:"image/x-freehand",fh7:"image/x-freehand",ico:"image/x-icon",jng:"image/x-jng",sid:"image/x-mrsid-image",pcx:"image/x-pcx",pic:"image/x-pict",pct:"image/x-pict",pnm:"image/x-portable-anymap",pbm:"image/x-portable-bitmap",pgm:"image/x-portable-graymap",ppm:"image/x-portable-pixmap",rgb:"image/x-rgb",tga:"image/x-tga",xbm:"image/x-xbitmap",xpm:"image/x-xpixmap",xwd:"image/x-xwindowdump",eml:"message/rfc822",mime:"message/rfc822",igs:"model/iges",iges:"model/iges",msh:"model/mesh",mesh:"model/mesh",silo:"model/mesh",dae:"model/vnd.collada+xml",dwf:"model/vnd.dwf",gdl:"model/vnd.gdl",gtw:"model/vnd.gtw",mts:"model/vnd.mts",vtu:"model/vnd.vtu",wrl:"model/vrml",vrml:"model/vrml",x3db:"model/x3d+binary",x3dbz:"model/x3d+binary",x3dv:"model/x3d+vrml",x3dvz:"model/x3d+vrml",x3d:"model/x3d+xml",x3dz:"model/x3d+xml",appcache:"text/cache-manifest",manifest:"text/cache-manifest",ics:"text/calendar",ifb:"text/calendar",coffee:"text/coffeescript",litcoffee:"text/coffeescript",css:"text/css",csv:"text/csv",hjson:"text/hjson",html:"text/html",htm:"text/html",shtml:"text/html",jade:"text/jade",jsx:"text/jsx",less:"text/less",mml:"text/mathml",n3:"text/n3",txt:"text/plain",text:"text/plain",conf:"text/plain",def:"text/plain",list:"text/plain",log:"text/plain",in:"text/plain",ini:"text/plain",dsc:"text/prs.lines.tag",rtx:"text/richtext",sgml:"text/sgml",sgm:"text/sgml",slim:"text/slim",slm:"text/slim",stylus:"text/stylus",styl:"text/stylus",tsv:"text/tab-separated-values",t:"text/troff",tr:"text/troff",roff:"text/troff",man:"text/troff",me:"text/troff",ms:"text/troff",ttl:"text/turtle",uri:"text/uri-list",uris:"text/uri-list",urls:"text/uri-list",vcard:"text/vcard",curl:"text/vnd.curl",dcurl:"text/vnd.curl.dcurl",mcurl:"text/vnd.curl.mcurl",scurl:"text/vnd.curl.scurl",fly:"text/vnd.fly",flx:"text/vnd.fmi.flexstor",gv:"text/vnd.graphviz","3dml":"text/vnd.in3d.3dml",spot:"text/vnd.in3d.spot",jad:"text/vnd.sun.j2me.app-descriptor",wml:"text/vnd.wap.wml",wmls:"text/vnd.wap.wmlscript",vtt:"text/vtt",s:"text/x-asm",asm:"text/x-asm",c:"text/x-c",cc:"text/x-c",cxx:"text/x-c",cpp:"text/x-c",h:"text/x-c",hh:"text/x-c",dic:"text/x-c",htc:"text/x-component",f:"text/x-fortran",for:"text/x-fortran",f77:"text/x-fortran",f90:"text/x-fortran",hbs:"text/x-handlebars-template",java:"text/x-java-source",lua:"text/x-lua",markdown:"text/x-markdown",md:"text/x-markdown",mkd:"text/x-markdown",nfo:"text/x-nfo",opml:"text/x-opml",p:"text/x-pascal",pas:"text/x-pascal",pde:"text/x-processing",sass:"text/x-sass",scss:"text/x-scss",etx:"text/x-setext",sfv:"text/x-sfv",ymp:"text/x-suse-ymp",uu:"text/x-uuencode",vcs:"text/x-vcalendar",vcf:"text/x-vcard",yaml:"text/yaml",yml:"text/yaml","3gp":"video/3gpp","3g2":"video/3gpp2",h261:"video/h261",h263:"video/h263",h264:"video/h264",jpgv:"video/jpeg",jpm:"video/jpm",jpgm:"video/jpm",mj2:"video/mj2",mjp2:"video/mj2",ts:"video/mp2t",mp4:"video/mp4",mp4v:"video/mp4",mpg4:"video/mp4",mpeg:"video/mpeg",mpg:"video/mpeg",mpe:"video/mpeg",m1v:"video/mpeg",m2v:"video/mpeg",ogv:"video/ogg",qt:"video/quicktime",mov:"video/quicktime",uvh:"video/vnd.dece.hd",uvvh:"video/vnd.dece.hd",uvm:"video/vnd.dece.mobile",uvvm:"video/vnd.dece.mobile",uvp:"video/vnd.dece.pd",uvvp:"video/vnd.dece.pd",uvs:"video/vnd.dece.sd",uvvs:"video/vnd.dece.sd",uvv:"video/vnd.dece.video",uvvv:"video/vnd.dece.video",dvb:"video/vnd.dvb.file",fvt:"video/vnd.fvt",mxu:"video/vnd.mpegurl",m4u:"video/vnd.mpegurl",pyv:"video/vnd.ms-playready.media.pyv",uvu:"video/vnd.uvvu.mp4",uvvu:"video/vnd.uvvu.mp4",viv:"video/vnd.vivo",webm:"video/webm",f4v:"video/x-f4v",fli:"video/x-fli",flv:"video/x-flv",m4v:"video/x-m4v",mkv:"video/x-matroska",mk3d:"video/x-matroska",mks:"video/x-matroska",mng:"video/x-mng",asf:"video/x-ms-asf",asx:"video/x-ms-asf",vob:"video/x-ms-vob",wm:"video/x-ms-wm",wmv:"video/x-ms-wmv",wmx:"video/x-ms-wmx",wvx:"video/x-ms-wvx",avi:"video/x-msvideo",movie:"video/x-sgi-movie",smv:"video/x-smv",ice:"x-conference/x-cooltalk"}},function(e,t,n){(function(t,i,s){function r(e,t){return a.fetch&&t?"fetch":a.mozchunkedarraybuffer?"moz-chunked-arraybuffer":a.msstream?"ms-stream":a.arraybuffer&&e?"arraybuffer":a.vbArray&&e?"text:vbarray":"text"}function o(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}}var a=n(63),c=n(10),u=n(97),l=n(21),h=n(99),p=u.IncomingMessage,d=u.readyStates,f=e.exports=function(e){var n=this;l.Writable.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+new t(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){n.setHeader(t,e.headers[t])});var i,s=!0;if("disable-fetch"===e.mode||"timeout"in e)s=!1,i=!0;else if("prefer-streaming"===e.mode)i=!1;else if("allow-wrong-content-type"===e.mode)i=!a.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");i=!0}n._mode=r(i,s),n.on("finish",function(){n._onFinish()})};c(f,l.Writable),f.prototype.setHeader=function(e,t){var n=this,i=e.toLowerCase();-1===m.indexOf(i)&&(n._headers[i]={name:e,value:t})},f.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},f.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},f.prototype._onFinish=function(){var e=this;if(!e._destroyed){var n=e._opts,r=e._headers,o=null;"GET"!==n.method&&"HEAD"!==n.method&&(o=a.blobConstructor?new i.Blob(e._body.map(function(e){return h(e)}),{type:(r["content-type"]||{}).value||""}):t.concat(e._body).toString());var c=[];if(Object.keys(r).forEach(function(e){var t=r[e].name,n=r[e].value;Array.isArray(n)?n.forEach(function(e){c.push([t,e])}):c.push([t,n])}),"fetch"===e._mode)i.fetch(e._opts.url,{method:e._opts.method,headers:c,body:o||void 0,mode:"cors",credentials:n.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)});else{var u=e._xhr=new i.XMLHttpRequest;try{u.open(e._opts.method,e._opts.url,!0)}catch(t){return void s.nextTick(function(){e.emit("error",t)})}"responseType"in u&&(u.responseType=e._mode.split(":")[0]),"withCredentials"in u&&(u.withCredentials=!!n.withCredentials),"text"===e._mode&&"overrideMimeType"in u&&u.overrideMimeType("text/plain; charset=x-user-defined"),"timeout"in n&&(u.timeout=n.timeout,u.ontimeout=function(){e.emit("timeout")}),c.forEach(function(e){u.setRequestHeader(e[0],e[1])}),e._response=null,u.onreadystatechange=function(){switch(u.readyState){case d.LOADING:case d.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(u.onprogress=function(){e._onXHRProgress()}),u.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{u.send(o)}catch(t){return void s.nextTick(function(){e.emit("error",t)})}}}},f.prototype._onXHRProgress=function(){var e=this;o(e._xhr)&&!e._destroyed&&(e._response||e._connect(),e._response._onXHRProgress())},f.prototype._connect=function(){var e=this;e._destroyed||(e._response=new p(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},f.prototype._write=function(e,t,n){this._body.push(e),n()},f.prototype.abort=f.prototype.destroy=function(){var e=this;e._destroyed=!0,e._response&&(e._response._destroyed=!0),e._xhr&&e._xhr.abort()},f.prototype.end=function(e,t,n){var i=this;"function"==typeof e&&(n=e,e=void 0),l.Writable.prototype.end.call(i,e,t,n)},f.prototype.flushHeaders=function(){},f.prototype.setTimeout=function(){},f.prototype.setNoDelay=function(){},f.prototype.setSocketKeepAlive=function(){};var m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(t,n(5).Buffer,n(9),n(7))},function(e,t,n){(function(e,i,s){var r=n(63),o=n(10),a=n(21),c=t.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},u=t.IncomingMessage=function(t,n,s){function o(){u.read().then(function(e){if(!c._destroyed){if(e.done)return void c.push(null);c.push(new i(e.value)),o()}}).catch(function(e){c.emit("error",e)})}var c=this;if(a.Readable.call(c),c._mode=s,c.headers={},c.rawHeaders=[],c.trailers={},c.rawTrailers=[],c.on("end",function(){e.nextTick(function(){c.emit("close")})}),"fetch"===s){c._fetchResponse=n,c.url=n.url,c.statusCode=n.status,c.statusMessage=n.statusText,n.headers.forEach(function(e,t){c.headers[t.toLowerCase()]=e,c.rawHeaders.push(t,e)});var u=n.body.getReader();o()}else{c._xhr=t,c._pos=0,c.url=t.responseURL,c.statusCode=t.status,c.statusMessage=t.statusText;if(t.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var n=t[1].toLowerCase();"set-cookie"===n?(void 0===c.headers[n]&&(c.headers[n]=[]),c.headers[n].push(t[2])):void 0!==c.headers[n]?c.headers[n]+=", "+t[2]:c.headers[n]=t[2],c.rawHeaders.push(t[1],t[2])}}),c._charset="x-user-defined",!r.overrideMimeType){var l=c.rawHeaders["mime-type"];if(l){var h=l.match(/;\s*charset=([^;])(;|$)/);h&&(c._charset=h[1].toLowerCase())}c._charset||(c._charset="utf-8")}}};o(u,a.Readable),u.prototype._read=function(){},u.prototype._onXHRProgress=function(){var e=this,t=e._xhr,n=null;switch(e._mode){case"text:vbarray":if(t.readyState!==c.DONE)break;try{n=new s.VBArray(t.responseBody).toArray()}catch(e){}if(null!==n){e.push(new i(n));break}case"text":try{n=t.responseText}catch(t){e._mode="text:vbarray";break}if(n.length>e._pos){var r=n.substr(e._pos);if("x-user-defined"===e._charset){for(var o=new i(r.length),a=0;ae._pos&&(e.push(new i(new Uint8Array(u.result.slice(e._pos)))),e._pos=u.result.byteLength)},u.onload=function(){e.push(null)},u.readAsArrayBuffer(n)}e._xhr.readyState===c.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(t,n(7),n(5).Buffer,n(9))},function(e,t,n){function i(e,t){this._id=e,this._clearFn=t}var s=Function.prototype.apply;t.setTimeout=function(){return new i(s.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new i(s.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(89),t.setImmediate=setImmediate,t.clearImmediate=clearImmediate},function(e,t,n){var i=n(5).Buffer;e.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(i.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,s=0;s{this.client.emit(i.Events.GUILD_CREATE,n)}):this.client.emit(i.Events.GUILD_CREATE,n)),n}newUser(e){if(this.client.users.has(e.id))return this.client.users.get(e.id);const t=new o(this.client,e);return this.client.users.set(t.id,t),t}newChannel(e,t){const n=this.client.channels.has(e.id);let s;return e.type===i.ChannelTypes.DM?s=new a(this.client,e):e.type===i.ChannelTypes.GROUP_DM?s=new p(this.client,e):(t=t||this.client.guilds.get(e.guild_id))&&(e.type===i.ChannelTypes.TEXT?(s=new u(t,e),t.channels.set(s.id,s)):e.type===i.ChannelTypes.VOICE&&(s=new l(t,e),t.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(e,t){const n=t.emojis.has(e.id);if(e&&!n){let n=new c(t,e);return this.client.emit(i.Events.GUILD_EMOJI_CREATE,n),t.emojis.set(n.id,n),n}return n?t.emojis.get(e.id):null}killEmoji(e){e instanceof c&&e.guild&&(this.client.emit(i.Events.GUILD_EMOJI_DELETE,e),e.guild.emojis.delete(e.id))}killGuild(e){const t=this.client.guilds.has(e.id);this.client.guilds.delete(e.id),t&&this.pastReady&&this.client.emit(i.Events.GUILD_DELETE,e)}killUser(e){this.client.users.delete(e.id)}killChannel(e){this.client.channels.delete(e.id),e instanceof h&&e.guild.channels.delete(e.id)}updateGuild(e,t){const n=s.cloneObject(e);e.setup(t),this.pastReady&&this.client.emit(i.Events.GUILD_UPDATE,n,e)}updateChannel(e,t){e.setup(t)}updateEmoji(e,t){const n=s.cloneObject(e);return e.setup(t),this.client.emit(i.Events.GUILD_EMOJI_UPDATE,n,e),e}}e.exports=d},function(e,t,n){const i=n(0),s=n(69);class r{constructor(e){this.client=e,this.heartbeatInterval=null}get status(){return this.connection?this.connection.status:i.Status.IDLE}connectToWebSocket(e,t,n){this.client.emit(i.Events.DEBUG,`Authenticated using token ${e}`),this.client.token=e;const r=this.client.setTimeout(()=>n(new Error(i.Errors.TOOK_TOO_LONG)),3e5);this.client.rest.methods.getGateway().then(o=>{const a=i.DefaultOptions.ws.version;const c=`${o.url}/?v=${a}&encoding=${s.ENCODING}`;this.client.emit(i.Events.DEBUG,`Using gateway ${c}`);this.client.ws.connect(c);this.client.ws.connection.once("close",e=>{4004===e.code&&n(new Error(i.Errors.BAD_LOGIN));4010===e.code&&n(new Error(i.Errors.INVALID_SHARD));4011===e.code&&n(new Error(i.Errors.SHARDING_REQUIRED))});this.client.once(i.Events.READY,()=>{t(e);this.client.clearTimeout(r)})},n)}destroy(){return this.client.ws.destroy(),this.client.rest.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()}}e.exports=r},function(e,t,n){class i{constructor(e){this.client=e,this.register(n(125)),this.register(n(126)),this.register(n(127)),this.register(n(131)),this.register(n(128)),this.register(n(129)),this.register(n(130)),this.register(n(107)),this.register(n(108)),this.register(n(109)),this.register(n(112)),this.register(n(124)),this.register(n(117)),this.register(n(118)),this.register(n(110)),this.register(n(119)),this.register(n(120)),this.register(n(121)),this.register(n(132)),this.register(n(134)),this.register(n(133)),this.register(n(123)),this.register(n(113)),this.register(n(114)),this.register(n(115)),this.register(n(116)),this.register(n(122)),this.register(n(111))}register(e){this[e.name.replace(/Action$/,"")]=new e(this.client)}}e.exports=i},function(e,t,n){const i=n(2);class s extends i{handle(e){return{channel:this.client.dataManager.newChannel(e)}}}e.exports=s},function(e,t,n){const i=n(2);class s extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client;let n=t.channels.get(e.id);return n?(t.dataManager.killChannel(n),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)):n=this.deleted.get(e.id)||null,{channel:n}}scheduleForDeletion(e){this.client.setTimeout(()=>this.deleted.delete(e),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.id);if(n){const i=r.cloneObject(n);return n.setup(e),t.emit(s.Events.CHANNEL_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(2),s=n(0);class r extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id),i=t.dataManager.newUser(e.user);n&&i&&t.emit(s.Events.GUILD_BAN_REMOVE,n,i)}}e.exports=r},function(e,t,n){const i=n(2);class s extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n)for(const t of e.channels){const e=n.channels.get(t.id);e&&(e.position=t.position)}return{guild:n}}}e.exports=s},function(e,t,n){const i=n(2),s=n(0);class r extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client;let n=t.guilds.get(e.id);if(n){for(const e of n.channels.values())"text"===e.type&&e.stopTyping(!0);if(n.available&&e.unavailable)return n.available=!1,t.emit(s.Events.GUILD_UNAVAILABLE,n),{guild:null};t.guilds.delete(n.id),this.deleted.set(n.id,n),this.scheduleForDeletion(n.id)}else n=this.deleted.get(e.id)||null;return{guild:n}}scheduleForDeletion(e){this.client.setTimeout(()=>this.deleted.delete(e),this.client.options.restWsBridgeTimeout)}}e.exports=r},function(e,t,n){const i=n(2);class s extends i{handle(e,t){return{emoji:this.client.dataManager.newEmoji(t,e)}}}e.exports=s},function(e,t,n){const i=n(2);class s extends i{handle(e){return this.client.dataManager.killEmoji(e),{emoji:e}}}e.exports=s},function(e,t,n){const i=n(2);class s extends i{handle(e,t){return{emoji:this.client.dataManager.updateEmoji(e,t)}}}e.exports=s},function(e,t,n){function i(e){const t=new Map;for(const n of e)t.set(...n);return t}const s=n(2);class r extends s{handle(e){const t=this.client.guilds.get(e.guild_id);if(t&&t.emojis){const n=i(t.emojis.entries());for(const i of e.emojis){const e=t.emojis.get(i.id);e?(n.delete(i.id),e.equals(i,!0)||this.client.actions.GuildEmojiUpdate.handle(e,i)):this.client.actions.GuildEmojiCreate.handle(t,i)}for(const e of n.values())this.client.actions.GuildEmojiDelete.handle(e)}}}e.exports=r},function(e,t,n){const i=n(2);class s extends i{handle(e,t){return{member:e._addMember(t,!1)}}}e.exports=s},function(e,t,n){const i=n(2),s=n(0);class r extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client,n=t.guilds.get(e.guild_id);let i=null;return n&&(i=n.members.get(e.user.id),i?(n.memberCount--,n._removeMember(i),this.deleted.set(n.id+e.user.id,i),t.status===s.Status.READY&&t.emit(s.Events.GUILD_MEMBER_REMOVE,i),this.scheduleForDeletion(n.id,e.user.id)):i=this.deleted.get(n.id+e.user.id)||null),{guild:n,member:i}}scheduleForDeletion(e,t){this.client.setTimeout(()=>this.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=r},function(e,t,n){const i=n(2),s=n(0),r=n(15);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);let i;if(n){const o=n.roles.has(e.role.id);i=new r(n,e.role),n.roles.set(i.id,i),o||t.emit(s.Events.GUILD_ROLE_CREATE,i)}return{role:i}}}e.exports=o},function(e,t,n){const i=n(2),s=n(0);class r extends i{constructor(e){super(e),this.deleted=new Map}handle(e){const t=this.client,n=t.guilds.get(e.guild_id);let i;return n&&(i=n.roles.get(e.role_id),i?(n.roles.delete(e.role_id),this.deleted.set(n.id+e.role_id,i),this.scheduleForDeletion(n.id,e.role_id),t.emit(s.Events.GUILD_ROLE_DELETE,i)):i=this.deleted.get(n.id+e.role_id)||null),{role:i}}scheduleForDeletion(e,t){this.client.setTimeout(()=>this.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=r},function(e,t,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n){const i=e.role;let o=null;const a=n.roles.get(i.id);return a&&(o=r.cloneObject(a),a.setup(e.role),t.emit(s.Events.GUILD_ROLE_UPDATE,o,a)),{old:o,updated:a}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(2);class s extends i{handle(e){const t=this.client,n=t.guilds.get(e.guild_id);if(n)for(const t of e.roles){const e=n.roles.get(t.id);e&&(e.position=t.position)}return{guild:n}}}e.exports=s},function(e,t,n){const i=n(2);class s extends i{handle(e){const t=this.client,n=t.guilds.get(e.id);if(n){if(e.presences)for(const t of e.presences)n._setPresence(t.user.id,t);if(e.members)for(const t of e.members){const e=n.members.get(t.user.id);e?n._updateMember(e,t):n._addMember(t,!1)}"large"in e&&(n.large=e.large)}}}e.exports=s},function(e,t,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(e){const t=this.client,n=t.guilds.get(e.id);if(n){const i=r.cloneObject(n);return n.setup(e),t.emit(s.Events.GUILD_UPDATE,i,n),{old:i,updated:n}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(2),s=n(19);class r extends i{handle(e){const t=this.client,n=t.channels.get((e instanceof Array?e[0]:e).channel_id),i=t.users.get((e instanceof Array?e[0]:e).author.id);if(n){const r=n.guild?n.guild.member(i):null;if(e instanceof Array){const o=new Array(e.length);for(let i=0;ithis.deleted.delete(e+t),this.client.options.restWsBridgeTimeout)}}e.exports=s},function(e,t,n){const i=n(2),s=n(3),r=n(0);class o extends i{handle(e){const t=this.client,n=t.channels.get(e.channel_id),i=e.ids,o=new s;for(const e of i){const t=n.messages.get(e);t&&o.set(t.id,t)}return o.size>0&&t.emit(r.Events.MESSAGE_BULK_DELETE,o),{messages:o}}}e.exports=o},function(e,t,n){const i=n(2),s=n(0);class r extends i{handle(e){const t=this.client.users.get(e.user_id);if(!t)return!1;const n=this.client.channels.get(e.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(e.message_id);if(!i)return!1;if(!e.emoji)return!1;const r=i._addReaction(e.emoji,t);return r&&this.client.emit(s.Events.MESSAGE_REACTION_ADD,r,t),{message:i,reaction:r,user:t}}}e.exports=r},function(e,t,n){const i=n(2),s=n(0);class r extends i{handle(e){const t=this.client.users.get(e.user_id);if(!t)return!1;const n=this.client.channels.get(e.channel_id);if(!n||"voice"===n.type)return!1;const i=n.messages.get(e.message_id);if(!i)return!1;if(!e.emoji)return!1;const r=i._removeReaction(e.emoji,t);return r&&this.client.emit(s.Events.MESSAGE_REACTION_REMOVE,r,t),{message:i,reaction:r,user:t}}}e.exports=r},function(e,t,n){const i=n(2),s=n(0);class r extends i{handle(e){const t=this.client.channels.get(e.channel_id);if(!t||"voice"===t.type)return!1;const n=t.messages.get(e.message_id);return!!n&&(n._clearReactions(),this.client.emit(s.Events.MESSAGE_REACTION_REMOVE_ALL,n),{message:n})}}e.exports=r},function(e,t,n){const i=n(2),s=n(0);class r extends i{handle(e){const t=this.client,n=t.channels.get(e.channel_id);if(n){const i=n.messages.get(e.id);return i?(i.patch(e),t.emit(s.Events.MESSAGE_UPDATE,i._edits[0],i),{old:i._edits[0],updated:i}):{old:i,updated:i}}return{old:null,updated:null}}}e.exports=r},function(e,t,n){const i=n(2);class s extends i{handle(e){return{user:this.client.dataManager.newUser(e)}}}e.exports=s},function(e,t,n){const i=n(2),s=n(0);class r extends i{handle(e){const t=this.client,n=t.user.notes.get(e.id),i=e.note.length?e.note:null;return t.user.notes.set(e.id,i),t.emit(s.Events.USER_NOTE_UPDATE,e.id,n,i),{old:n,updated:i}}}e.exports=r},function(e,t,n){const i=n(2),s=n(0),r=n(4);class o extends i{handle(e){const t=this.client;if(t.user){if(t.user.equals(e))return{old:t.user,updated:t.user};const n=r.cloneObject(t.user);return t.user.patch(e),t.emit(s.Events.USER_UPDATE,n,t.user),{old:n,updated:t.user}}return{old:null,updated:null}}}e.exports=o},function(e,t,n){const i=n(37),s=n(0);class r{constructor(e,t,n,i,s,r){this.rest=e,this.client=e.client,this.method=t,this.path=n.toString(),this.auth=i,this.data=s,this.files=r,this.route=this.getRoute(this.path)}getRoute(e){let t=e.split("?")[0];if(t.includes("/channels/")||t.includes("/guilds/")){const e=t.includes("/channels/")?t.indexOf("/channels/"):t.indexOf("/guilds/"),n=t.substring(e).split("/")[2];t=t.replace(/(\d{8,})/g,":id").replace(":id",n)}return t}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 e=`${this.client.options.http.host}/api/v${this.client.options.http.version}`,t=i[this.method](`${e}${this.path}`);if(this.auth&&t.set("Authorization",this.getAuth()),this.rest.client.browser||t.set("User-Agent",this.rest.userAgentManager.userAgent),this.files){for(const e of this.files)e&&e.file&&t.attach(e.name,e.file,e.name);void 0!==this.data&&t.attach("payload_json",JSON.stringify(this.data))}else this.data&&t.send(this.data);return t}}e.exports=r},function(e,t,n){const i=n(35),s=n(33),r=n(8),o=n(0),a=o.Endpoints,c=n(3),u=n(6),l=n(4),h=n(16),p=n(18),d=n(19),f=n(15),m=n(45),g=n(30),v=n(180),E=n(26),b=n(14),w=n(28),_=n(24),y=n(181),x=n(44);class A{constructor(e){this.rest=e,this.client=e.client,this._ackToken=null}login(e=this.client.token){return new Promise((t,n)=>{if("string"!=typeof e)throw new Error(o.Errors.INVALID_TOKEN);e=e.replace(/^Bot\s*/i,"");this.client.manager.connectToWebSocket(e,t,n)})}logout(){return this.rest.makeRequest("post",a.logout,!0,{})}getGateway(e=!1){return this.rest.makeRequest("get",e?a.gateway.bot:a.gateway,!0)}fetchVoiceRegions(e){let t;return t=e?a.Guild(e).voiceRegions:a.voiceRegions,this.rest.makeRequest("get",t,!0).then(e=>{const t=new c;for(const n of e)t.set(n.id,new y(n));return t})}sendMessage(e,t,{tts:tts,nonce:nonce,embed:embed,disableEveryone:disableEveryone,split:split,code:code,reply:reply}={},n=null){return new Promise((i,s)=>{void 0!==t&&(t=this.client.resolver.resolveString(t));if(void 0!==nonce&&(nonce=parseInt(nonce),isNaN(nonce)||nonce<0))throw new RangeError("Message nonce must fit in an unsigned 64-bit integer.");if(t){if(split&&"object"!=typeof split&&(split={}),void 0===code||"boolean"==typeof code&&!0!==code||(t=l.escapeMarkdown(this.client.resolver.resolveString(t),!0),t=`\`\`\`${"boolean"!=typeof code?code||"":""} -${t} +`),n])}}end(){return this.buffer=e.concat([this.buffer,e.from(` +--${this.boundary}--`)]),this.buffer}}t.exports=r}).call(e,n(5).Buffer)},function(t,e,n){(function(e){function i(t){return c.format({protocol:t.connection.encrypted?"https:":"http:",hostname:t.getHeader("host"),pathname:t.path.split("?")[0],query:t.query})}n(61);const s=n(39),r=n(36),o=n(62),a=n(80),c=n(64),l=n(92),u=n(61),h=n(93);class p extends u.Readable{constructor(t,e,n={headers:{},data:null}){super();const i=c.parse(e);i.method=t.toUpperCase(),i.headers=n.headers,this.data=n.data,this.request=("https:"===i.protocol?a:o).request(i)}query(t,e){if(this.request.res)throw new Error("Cannot modify query after being sent!");return this.request.query||(this.request.query={}),null!==t&&"object"==typeof t?this.request.query=Object.assign(this.request.query,t):this.request.query[t]=e,this}set(t,e){if(this.request.res)throw new Error("Cannot modify headers after being sent!");if(null!==t&&"object"==typeof t)for(const e of Object.keys(t))this.set(e,t[e]);else this.request.setHeader(t,e);return this}attach(t,e,n){if(this.request.res)throw new Error("Cannot modify data after being sent!");const i=this._getFormData();return this.set("Content-Type",`multipart/form-data; boundary=${i.boundary}`),i.append(t,e,n),this.data=i,this}send(t){if(this.request.res)throw new Error("Cannot modify data after being sent!");if(null!==t&&"object"==typeof t){const e=this._getHeader("content-type");let n;e?e.includes("json")?n=JSON.stringify:e.includes("urlencoded")&&(n=r.stringify):(this.set("Content-Type","application/json"),n=JSON.stringify),this.data=n(t)}else this.data=t;return this}then(t,n){return new Promise((t,n)=>{const a=this.request;const l=t=>{t||(t=new Error("Unknown error occured"));t.request=a;n(t)};a.on("abort",l);a.on("aborted",l);a.on("error",l);a.on("response",l=>{const h=new u.PassThrough;this._shouldUnzip(l)?l.pipe(s.createUnzip({flush:s.Z_SYNC_FLUSH,finishFlush:s.Z_SYNC_FLUSH})).pipe(h):l.pipe(h);let d=[];h.on("data",t=>{this.push(t)||this.pause();d.push(t)});h.on("end",()=>{this.push(null);const s=e.concat(d);if(this._shouldRedirect(l)){let e=this.request.method;[301,302].includes(l.statusCode)?("HEAD"!==e&&(e="GET"),this.data=null):303===l.statusCode&&(e="GET");const n={};if(this.request._headerNames)for(const t of Object.keys(this.request._headerNames))"host"!==t.toLowerCase()&&(n[this.request._headerNames[t]]=this.request._headers[t]);else for(const t of Object.keys(this.request._headers))if("host"!==t.toLowerCase()){const e=this.request._headers[t];n[e.name]=e.value}const s=/^https?:\/\//i.test(l.headers.location)?l.headers.location:c.resolve(i(a),l.headers.location);return void t(new p(e,s,{data:this.data,headers:n}))}const u={request:this.request,body:s,text:s.toString(),ok:l.statusCode>=200&&l.statusCode<300,headers:l.headers,status:l.statusCode,statusText:l.statusText||o.STATUS_CODES[l.statusCode]};const h=l.headers["content-type"];if(h)if(h.includes("application/json"))try{u.body=JSON.parse(u.text)}catch(t){}else h.includes("application/x-www-form-urlencoded")&&(u.body=r.parse(u.text));if(u.ok)t(u);else{const t=new Error(`${u.status} ${u.statusText}`.trim());Object.assign(t,u),n(t)}})});this._addFinalHeaders();this.request.query&&(this.request.path=`${this.request.path}?${r.stringify(this.request.query)}`);a.end(this.data?this.data.end?this.data.end():this.data:null)}).then(t,n)}catch(t){return this.then(null,t)}end(t){return this.then(e=>t?t(null,e):e,e=>t?t(e,e.status?e:null):e)}_read(){this.resume(),this.response||this.catch(t=>this.emit("error",t))}_shouldUnzip(t){return 204!==t.statusCode&&304!==t.statusCode&&("0"!==t.headers["content-length"]&&/^\s*(?:deflate|gzip)\s*$/.test(t.headers["content-encoding"]))}_shouldRedirect(t){return[301,302,303,307,308].includes(t.statusCode)}_getFormData(){return this._formData||(this._formData=new h),this._formData}_addFinalHeaders(){this.request&&(this._getHeader("user-agent")||this.set("User-Agent",`snekfetch/${p.version} (${l.repository.url.replace(/\.?git/,"")})`),"HEAD"!==this.request.method&&this.set("Accept-Encoding","gzip, deflate"))}get response(){return this.request.res||this.request._response||null}_getHeader(t){try{return this.request.getHeader(t)}catch(t){return null}}}p.version=l.version,p.METHODS=o.METHODS.concat("BREW");for(const t of p.METHODS)p["M-SEARCH"===t?"msearch":t.toLowerCase()]=(e=>new p(t,e));t.exports=p}).call(e,n(5).Buffer)},function(t,e,n){function i(t){return r[t]||r.bin}function s(t){return o(t)||r.bin}const r=n(97),o=n(96);t.exports={buffer:s,lookup:i}},function(t,e){function n(t){const e=new Uint8Array(t);if(!(e&&e.length>1))return null;if(255===e[0]&&216===e[1]&&255===e[2])return{ext:"jpg",mime:"image/jpeg"};if(137===e[0]&&80===e[1]&&78===e[2]&&71===e[3])return{ext:"png",mime:"image/png"};if(71===e[0]&&73===e[1]&&70===e[2])return{ext:"gif",mime:"image/gif"};if(87===e[8]&&69===e[9]&&66===e[10]&&80===e[11])return{ext:"webp",mime:"image/webp"};if(70===e[0]&&76===e[1]&&73===e[2]&&70===e[3])return{ext:"flif",mime:"image/flif"};if((73===e[0]&&73===e[1]&&42===e[2]&&0===e[3]||77===e[0]&&77===e[1]&&0===e[2]&&42===e[3])&&67===e[8]&&82===e[9])return{ext:"cr2",mime:"image/x-canon-cr2"};if(73===e[0]&&73===e[1]&&42===e[2]&&0===e[3]||77===e[0]&&77===e[1]&&0===e[2]&&42===e[3])return{ext:"tif",mime:"image/tiff"};if(66===e[0]&&77===e[1])return{ext:"bmp",mime:"image/bmp"};if(73===e[0]&&73===e[1]&&188===e[2])return{ext:"jxr",mime:"image/vnd.ms-photo"};if(56===e[0]&&66===e[1]&&80===e[2]&&83===e[3])return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(80===e[0]&&75===e[1]&&3===e[2]&&4===e[3]&&109===e[30]&&105===e[31]&&109===e[32]&&101===e[33]&&116===e[34]&&121===e[35]&&112===e[36]&&101===e[37]&&97===e[38]&&112===e[39]&&112===e[40]&&108===e[41]&&105===e[42]&&99===e[43]&&97===e[44]&&116===e[45]&&105===e[46]&&111===e[47]&&110===e[48]&&47===e[49]&&101===e[50]&&112===e[51]&&117===e[52]&&98===e[53]&&43===e[54]&&122===e[55]&&105===e[56]&&112===e[57])return{ext:"epub",mime:"application/epub+zip"};if(80===e[0]&&75===e[1]&&3===e[2]&&4===e[3]&&77===e[30]&&69===e[31]&&84===e[32]&&65===e[33]&&45===e[34]&&73===e[35]&&78===e[36]&&70===e[37]&&47===e[38]&&109===e[39]&&111===e[40]&&122===e[41]&&105===e[42]&&108===e[43]&&108===e[44]&&97===e[45]&&46===e[46]&&114===e[47]&&115===e[48]&&97===e[49])return{ext:"xpi",mime:"application/x-xpinstall"};if(!(80!==e[0]||75!==e[1]||3!==e[2]&&5!==e[2]&&7!==e[2]||4!==e[3]&&6!==e[3]&&8!==e[3]))return{ext:"zip",mime:"application/zip"};if(117===e[257]&&115===e[258]&&116===e[259]&&97===e[260]&&114===e[261])return{ext:"tar",mime:"application/x-tar"};if(82===e[0]&&97===e[1]&&114===e[2]&&33===e[3]&&26===e[4]&&7===e[5]&&(0===e[6]||1===e[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(31===e[0]&&139===e[1]&&8===e[2])return{ext:"gz",mime:"application/gzip"};if(66===e[0]&&90===e[1]&&104===e[2])return{ext:"bz2",mime:"application/x-bzip2"};if(55===e[0]&&122===e[1]&&188===e[2]&&175===e[3]&&39===e[4]&&28===e[5])return{ext:"7z",mime:"application/x-7z-compressed"};if(120===e[0]&&1===e[1])return{ext:"dmg",mime:"application/x-apple-diskimage"};if(0===e[0]&&0===e[1]&&0===e[2]&&(24===e[3]||32===e[3])&&102===e[4]&&116===e[5]&&121===e[6]&&112===e[7]||51===e[0]&&103===e[1]&&112===e[2]&&53===e[3]||0===e[0]&&0===e[1]&&0===e[2]&&28===e[3]&&102===e[4]&&116===e[5]&&121===e[6]&&112===e[7]&&109===e[8]&&112===e[9]&&52===e[10]&&50===e[11]&&109===e[16]&&112===e[17]&&52===e[18]&&49===e[19]&&109===e[20]&&112===e[21]&&52===e[22]&&50===e[23]&&105===e[24]&&115===e[25]&&111===e[26]&&109===e[27]||0===e[0]&&0===e[1]&&0===e[2]&&28===e[3]&&102===e[4]&&116===e[5]&&121===e[6]&&112===e[7]&&105===e[8]&&115===e[9]&&111===e[10]&&109===e[11]||0===e[0]&&0===e[1]&&0===e[2]&&28===e[3]&&102===e[4]&&116===e[5]&&121===e[6]&&112===e[7]&&109===e[8]&&112===e[9]&&52===e[10]&&50===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&0===e[15])return{ext:"mp4",mime:"video/mp4"};if(0===e[0]&&0===e[1]&&0===e[2]&&28===e[3]&&102===e[4]&&116===e[5]&&121===e[6]&&112===e[7]&&77===e[8]&&52===e[9]&&86===e[10])return{ext:"m4v",mime:"video/x-m4v"};if(77===e[0]&&84===e[1]&&104===e[2]&&100===e[3])return{ext:"mid",mime:"audio/midi"};if(26===e[0]&&69===e[1]&&223===e[2]&&163===e[3]){const t=e.subarray(4,4100),n=t.findIndex((t,e,n)=>66===n[e]&&130===n[e+1]);if(n>=0){const e=n+3,i=n=>Array.from(n).every((n,i)=>t[e+i]===n.charCodeAt(0));if(i("matroska"))return{ext:"mkv",mime:"video/x-matroska"};if(i("webm"))return{ext:"webm",mime:"video/webm"}}}return 0===e[0]&&0===e[1]&&0===e[2]&&20===e[3]&&102===e[4]&&116===e[5]&&121===e[6]&&112===e[7]?{ext:"mov",mime:"video/quicktime"}:82===e[0]&&73===e[1]&&70===e[2]&&70===e[3]&&65===e[8]&&86===e[9]&&73===e[10]?{ext:"avi",mime:"video/x-msvideo"}:48===e[0]&&38===e[1]&&178===e[2]&&117===e[3]&&142===e[4]&&102===e[5]&&207===e[6]&&17===e[7]&&166===e[8]&&217===e[9]?{ext:"wmv",mime:"video/x-ms-wmv"}:0===e[0]&&0===e[1]&&1===e[2]&&"b"===e[3].toString(16)[0]?{ext:"mpg",mime:"video/mpeg"}:73===e[0]&&68===e[1]&&51===e[2]||255===e[0]&&251===e[1]?{ext:"mp3",mime:"audio/mpeg"}:102===e[4]&&116===e[5]&&121===e[6]&&112===e[7]&&77===e[8]&&52===e[9]&&65===e[10]||77===e[0]&&52===e[1]&&65===e[2]&&32===e[3]?{ext:"m4a",mime:"audio/m4a"}:79===e[28]&&112===e[29]&&117===e[30]&&115===e[31]&&72===e[32]&&101===e[33]&&97===e[34]&&100===e[35]?{ext:"opus",mime:"audio/opus"}:79===e[0]&&103===e[1]&&103===e[2]&&83===e[3]?{ext:"ogg",mime:"audio/ogg"}:102===e[0]&&76===e[1]&&97===e[2]&&67===e[3]?{ext:"flac",mime:"audio/x-flac"}:82===e[0]&&73===e[1]&&70===e[2]&&70===e[3]&&87===e[8]&&65===e[9]&&86===e[10]&&69===e[11]?{ext:"wav",mime:"audio/x-wav"}:35===e[0]&&33===e[1]&&65===e[2]&&77===e[3]&&82===e[4]&&10===e[5]?{ext:"amr",mime:"audio/amr"}:37===e[0]&&80===e[1]&&68===e[2]&&70===e[3]?{ext:"pdf",mime:"application/pdf"}:77===e[0]&&90===e[1]?{ext:"exe",mime:"application/x-msdownload"}:67!==e[0]&&70!==e[0]||87!==e[1]||83!==e[2]?123===e[0]&&92===e[1]&&114===e[2]&&116===e[3]&&102===e[4]?{ext:"rtf",mime:"application/rtf"}:119===e[0]&&79===e[1]&&70===e[2]&&70===e[3]&&(0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]||79===e[4]&&84===e[5]&&84===e[6]&&79===e[7])?{ext:"woff",mime:"application/font-woff"}:119===e[0]&&79===e[1]&&70===e[2]&&50===e[3]&&(0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]||79===e[4]&&84===e[5]&&84===e[6]&&79===e[7])?{ext:"woff2",mime:"application/font-woff"}:76===e[34]&&80===e[35]&&(0===e[8]&&0===e[9]&&1===e[10]||1===e[8]&&0===e[9]&&2===e[10]||2===e[8]&&0===e[9]&&2===e[10])?{ext:"eot",mime:"application/octet-stream"}:0===e[0]&&1===e[1]&&0===e[2]&&0===e[3]&&0===e[4]?{ext:"ttf",mime:"application/font-sfnt"}:79===e[0]&&84===e[1]&&84===e[2]&&79===e[3]&&0===e[4]?{ext:"otf",mime:"application/font-sfnt"}:0===e[0]&&0===e[1]&&1===e[2]&&0===e[3]?{ext:"ico",mime:"image/x-icon"}:70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]?{ext:"flv",mime:"video/x-flv"}:37===e[0]&&33===e[1]?{ext:"ps",mime:"application/postscript"}:253===e[0]&&55===e[1]&&122===e[2]&&88===e[3]&&90===e[4]&&0===e[5]?{ext:"xz",mime:"application/x-xz"}:83===e[0]&&81===e[1]&&76===e[2]&&105===e[3]?{ext:"sqlite",mime:"application/x-sqlite3"}:78===e[0]&&69===e[1]&&83===e[2]&&26===e[3]?{ext:"nes",mime:"application/x-nintendo-nes-rom"}:67===e[0]&&114===e[1]&&50===e[2]&&52===e[3]?{ext:"crx",mime:"application/x-google-chrome-extension"}:77===e[0]&&83===e[1]&&67===e[2]&&70===e[3]||73===e[0]&&83===e[1]&&99===e[2]&&40===e[3]?{ext:"cab",mime:"application/vnd.ms-cab-compressed"}:33===e[0]&&60===e[1]&&97===e[2]&&114===e[3]&&99===e[4]&&104===e[5]&&62===e[6]&&10===e[7]&&100===e[8]&&101===e[9]&&98===e[10]&&105===e[11]&&97===e[12]&&110===e[13]&&45===e[14]&&98===e[15]&&105===e[16]&&110===e[17]&&97===e[18]&&114===e[19]&&121===e[20]?{ext:"deb",mime:"application/x-deb"}:33===e[0]&&60===e[1]&&97===e[2]&&114===e[3]&&99===e[4]&&104===e[5]&&62===e[6]?{ext:"ar",mime:"application/x-unix-archive"}:237===e[0]&&171===e[1]&&238===e[2]&&219===e[3]?{ext:"rpm",mime:"application/x-rpm"}:31===e[0]&&160===e[1]||31===e[0]&&157===e[1]?{ext:"Z",mime:"application/x-compress"}:76===e[0]&&90===e[1]&&73===e[2]&&80===e[3]?{ext:"lz",mime:"application/x-lzip"}:208===e[0]&&207===e[1]&&17===e[2]&&224===e[3]&&161===e[4]&&177===e[5]&&26===e[6]&&225===e[7]?{ext:"msi",mime:"application/x-msi"}:6===e[0]&&14===e[1]&&43===e[2]&&52===e[3]&&2===e[4]&&5===e[5]&&1===e[6]&&1===e[7]&&13===e[8]&&1===e[9]&&2===e[10]&&1===e[11]&&1===e[12]&&2===e[13]?{ext:"mxf",mime:"application/mxf"}:null:{ext:"swf",mime:"application/x-shockwave-flash"}}t.exports=n},function(t,e){t.exports={123:"application/vnd.lotus-1-2-3",ez:"application/andrew-inset",aw:"application/applixware",atom:"application/atom+xml",atomcat:"application/atomcat+xml",atomsvc:"application/atomsvc+xml",bdoc:"application/x-bdoc",ccxml:"application/ccxml+xml",cdmia:"application/cdmi-capability",cdmic:"application/cdmi-container",cdmid:"application/cdmi-domain",cdmio:"application/cdmi-object",cdmiq:"application/cdmi-queue",cu:"application/cu-seeme",mpd:"application/dash+xml",davmount:"application/davmount+xml",dbk:"application/docbook+xml",dssc:"application/dssc+der",xdssc:"application/dssc+xml",ecma:"application/ecmascript",emma:"application/emma+xml",epub:"application/epub+zip",exi:"application/exi",pfr:"application/font-tdpfr",woff:"application/font-woff",woff2:"application/font-woff2",geojson:"application/geo+json",gml:"application/gml+xml",gpx:"application/gpx+xml",gxf:"application/gxf",stk:"application/hyperstudio",ink:"application/inkml+xml",inkml:"application/inkml+xml",ipfix:"application/ipfix",jar:"application/java-archive",war:"application/java-archive",ear:"application/java-archive",ser:"application/java-serialized-object",class:"application/java-vm",js:"application/javascript",json:"application/json",map:"application/json",json5:"application/json5",jsonml:"application/jsonml+json",jsonld:"application/ld+json",lostxml:"application/lost+xml",hqx:"application/mac-binhex40",cpt:"application/mac-compactpro",mads:"application/mads+xml",webmanifest:"application/manifest+json",mrc:"application/marc",mrcx:"application/marcxml+xml",ma:"application/mathematica",nb:"application/mathematica",mb:"application/mathematica",mathml:"application/mathml+xml",mbox:"application/mbox",mscml:"application/mediaservercontrol+xml",metalink:"application/metalink+xml",meta4:"application/metalink4+xml",mets:"application/mets+xml",mods:"application/mods+xml",m21:"application/mp21",mp21:"application/mp21",mp4s:"application/mp4",m4p:"application/mp4",doc:"application/msword",dot:"application/msword",mxf:"application/mxf",bin:"application/octet-stream",dms:"application/octet-stream",lrf:"application/octet-stream",mar:"application/octet-stream",so:"application/octet-stream",dist:"application/octet-stream",distz:"application/octet-stream",pkg:"application/octet-stream",bpk:"application/octet-stream",dump:"application/octet-stream",elc:"application/octet-stream",deploy:"application/octet-stream",exe:"application/x-msdownload",dll:"application/x-msdownload",deb:"application/x-debian-package",dmg:"application/x-apple-diskimage",iso:"application/x-iso9660-image",img:"application/octet-stream",msi:"application/x-msdownload",msp:"application/octet-stream",msm:"application/octet-stream",buffer:"application/octet-stream",oda:"application/oda",opf:"application/oebps-package+xml",ogx:"application/ogg",omdoc:"application/omdoc+xml",onetoc:"application/onenote",onetoc2:"application/onenote",onetmp:"application/onenote",onepkg:"application/onenote",oxps:"application/oxps",xer:"application/patch-ops-error+xml",pdf:"application/pdf",pgp:"application/pgp-encrypted",asc:"application/pgp-signature",sig:"application/pgp-signature",prf:"application/pics-rules",p10:"application/pkcs10",p7m:"application/pkcs7-mime",p7c:"application/pkcs7-mime",p7s:"application/pkcs7-signature",p8:"application/pkcs8",ac:"application/pkix-attr-cert",cer:"application/pkix-cert",crl:"application/pkix-crl",pkipath:"application/pkix-pkipath",pki:"application/pkixcmp",pls:"application/pls+xml",ai:"application/postscript",eps:"application/postscript",ps:"application/postscript",cww:"application/prs.cww",pskcxml:"application/pskc+xml",rdf:"application/rdf+xml",rif:"application/reginfo+xml",rnc:"application/relax-ng-compact-syntax",rl:"application/resource-lists+xml",rld:"application/resource-lists-diff+xml",rs:"application/rls-services+xml",gbr:"application/rpki-ghostbusters",mft:"application/rpki-manifest",roa:"application/rpki-roa",rsd:"application/rsd+xml",rss:"application/rss+xml",rtf:"text/rtf",sbml:"application/sbml+xml",scq:"application/scvp-cv-request",scs:"application/scvp-cv-response",spq:"application/scvp-vp-request",spp:"application/scvp-vp-response",sdp:"application/sdp",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",shf:"application/shf+xml",smi:"application/smil+xml",smil:"application/smil+xml",rq:"application/sparql-query",srx:"application/sparql-results+xml",gram:"application/srgs",grxml:"application/srgs+xml",sru:"application/sru+xml",ssdl:"application/ssdl+xml",ssml:"application/ssml+xml",tei:"application/tei+xml",teicorpus:"application/tei+xml",tfi:"application/thraud+xml",tsd:"application/timestamped-data",plb:"application/vnd.3gpp.pic-bw-large",psb:"application/vnd.3gpp.pic-bw-small",pvb:"application/vnd.3gpp.pic-bw-var",tcap:"application/vnd.3gpp2.tcap",pwn:"application/vnd.3m.post-it-notes",aso:"application/vnd.accpac.simply.aso",imp:"application/vnd.accpac.simply.imp",acu:"application/vnd.acucobol",atc:"application/vnd.acucorp",acutc:"application/vnd.acucorp",air:"application/vnd.adobe.air-application-installer-package+zip",fcdt:"application/vnd.adobe.formscentral.fcdt",fxp:"application/vnd.adobe.fxp",fxpl:"application/vnd.adobe.fxp",xdp:"application/vnd.adobe.xdp+xml",xfdf:"application/vnd.adobe.xfdf",ahead:"application/vnd.ahead.space",azf:"application/vnd.airzip.filesecure.azf",azs:"application/vnd.airzip.filesecure.azs",azw:"application/vnd.amazon.ebook",acc:"application/vnd.americandynamics.acc",ami:"application/vnd.amiga.ami",apk:"application/vnd.android.package-archive",cii:"application/vnd.anser-web-certificate-issue-initiation",fti:"application/vnd.anser-web-funds-transfer-initiation",atx:"application/vnd.antix.game-component",mpkg:"application/vnd.apple.installer+xml",m3u8:"application/vnd.apple.mpegurl",pkpass:"application/vnd.apple.pkpass",swi:"application/vnd.aristanetworks.swi",iota:"application/vnd.astraea-software.iota",aep:"application/vnd.audiograph",mpm:"application/vnd.blueice.multipass",bmi:"application/vnd.bmi",rep:"application/vnd.businessobjects",cdxml:"application/vnd.chemdraw+xml",mmd:"application/vnd.chipnuts.karaoke-mmd",cdy:"application/vnd.cinderella",cla:"application/vnd.claymore",rp9:"application/vnd.cloanto.rp9",c4g:"application/vnd.clonk.c4group",c4d:"application/vnd.clonk.c4group",c4f:"application/vnd.clonk.c4group",c4p:"application/vnd.clonk.c4group",c4u:"application/vnd.clonk.c4group",c11amc:"application/vnd.cluetrust.cartomobile-config",c11amz:"application/vnd.cluetrust.cartomobile-config-pkg",csp:"application/vnd.commonspace",cdbcmsg:"application/vnd.contact.cmsg",cmc:"application/vnd.cosmocaller",clkx:"application/vnd.crick.clicker",clkk:"application/vnd.crick.clicker.keyboard",clkp:"application/vnd.crick.clicker.palette",clkt:"application/vnd.crick.clicker.template",clkw:"application/vnd.crick.clicker.wordbank",wbs:"application/vnd.criticaltools.wbs+xml",pml:"application/vnd.ctc-posml",ppd:"application/vnd.cups-ppd",car:"application/vnd.curl.car",pcurl:"application/vnd.curl.pcurl",dart:"application/vnd.dart",rdz:"application/vnd.data-vision.rdz",uvf:"application/vnd.dece.data",uvvf:"application/vnd.dece.data",uvd:"application/vnd.dece.data",uvvd:"application/vnd.dece.data",uvt:"application/vnd.dece.ttml+xml",uvvt:"application/vnd.dece.ttml+xml",uvx:"application/vnd.dece.unspecified",uvvx:"application/vnd.dece.unspecified",uvz:"application/vnd.dece.zip",uvvz:"application/vnd.dece.zip",fe_launch:"application/vnd.denovo.fcselayout-link",dna:"application/vnd.dna",mlp:"application/vnd.dolby.mlp",dpg:"application/vnd.dpgraph",dfac:"application/vnd.dreamfactory",kpxx:"application/vnd.ds-keypoint",ait:"application/vnd.dvb.ait",svc:"application/vnd.dvb.service",geo:"application/vnd.dynageo",mag:"application/vnd.ecowin.chart",nml:"application/vnd.enliven",esf:"application/vnd.epson.esf",msf:"application/vnd.epson.msf",qam:"application/vnd.epson.quickanime",slt:"application/vnd.epson.salt",ssf:"application/vnd.epson.ssf",es3:"application/vnd.eszigno3+xml",et3:"application/vnd.eszigno3+xml",ez2:"application/vnd.ezpix-album",ez3:"application/vnd.ezpix-package",fdf:"application/vnd.fdf",mseed:"application/vnd.fdsn.mseed",seed:"application/vnd.fdsn.seed",dataless:"application/vnd.fdsn.seed",gph:"application/vnd.flographit",ftc:"application/vnd.fluxtime.clip",fm:"application/vnd.framemaker",frame:"application/vnd.framemaker",maker:"application/vnd.framemaker",book:"application/vnd.framemaker",fnc:"application/vnd.frogans.fnc",ltf:"application/vnd.frogans.ltf",fsc:"application/vnd.fsc.weblaunch",oas:"application/vnd.fujitsu.oasys",oa2:"application/vnd.fujitsu.oasys2",oa3:"application/vnd.fujitsu.oasys3",fg5:"application/vnd.fujitsu.oasysgp",bh2:"application/vnd.fujitsu.oasysprs",ddd:"application/vnd.fujixerox.ddd",xdw:"application/vnd.fujixerox.docuworks",xbd:"application/vnd.fujixerox.docuworks.binder",fzs:"application/vnd.fuzzysheet",txd:"application/vnd.genomatix.tuxedo",ggb:"application/vnd.geogebra.file",ggt:"application/vnd.geogebra.tool",gex:"application/vnd.geometry-explorer",gre:"application/vnd.geometry-explorer",gxt:"application/vnd.geonext",g2w:"application/vnd.geoplan",g3w:"application/vnd.geospace",gmx:"application/vnd.gmx",gdoc:"application/vnd.google-apps.document",gslides:"application/vnd.google-apps.presentation",gsheet:"application/vnd.google-apps.spreadsheet",kml:"application/vnd.google-earth.kml+xml",kmz:"application/vnd.google-earth.kmz",gqf:"application/vnd.grafeq",gqs:"application/vnd.grafeq",gac:"application/vnd.groove-account",ghf:"application/vnd.groove-help",gim:"application/vnd.groove-identity-message",grv:"application/vnd.groove-injector",gtm:"application/vnd.groove-tool-message",tpl:"application/vnd.groove-tool-template",vcg:"application/vnd.groove-vcard",hal:"application/vnd.hal+xml",zmm:"application/vnd.handheld-entertainment+xml",hbci:"application/vnd.hbci",les:"application/vnd.hhe.lesson-player",hpgl:"application/vnd.hp-hpgl",hpid:"application/vnd.hp-hpid",hps:"application/vnd.hp-hps",jlt:"application/vnd.hp-jlyt",pcl:"application/vnd.hp-pcl",pclxl:"application/vnd.hp-pclxl","sfd-hdstx":"application/vnd.hydrostatix.sof-data",mpy:"application/vnd.ibm.minipay",afp:"application/vnd.ibm.modcap",listafp:"application/vnd.ibm.modcap",list3820:"application/vnd.ibm.modcap",irm:"application/vnd.ibm.rights-management",sc:"application/vnd.ibm.secure-container",icc:"application/vnd.iccprofile",icm:"application/vnd.iccprofile",igl:"application/vnd.igloader",ivp:"application/vnd.immervision-ivp",ivu:"application/vnd.immervision-ivu",igm:"application/vnd.insors.igm",xpw:"application/vnd.intercon.formnet",xpx:"application/vnd.intercon.formnet",i2g:"application/vnd.intergeo",qbo:"application/vnd.intu.qbo",qfx:"application/vnd.intu.qfx",rcprofile:"application/vnd.ipunplugged.rcprofile",irp:"application/vnd.irepository.package+xml",xpr:"application/vnd.is-xpr",fcs:"application/vnd.isac.fcs",jam:"application/vnd.jam",rms:"application/vnd.jcp.javame.midlet-rms",jisp:"application/vnd.jisp",joda:"application/vnd.joost.joda-archive",ktz:"application/vnd.kahootz",ktr:"application/vnd.kahootz",karbon:"application/vnd.kde.karbon",chrt:"application/vnd.kde.kchart",kfo:"application/vnd.kde.kformula",flw:"application/vnd.kde.kivio",kon:"application/vnd.kde.kontour",kpr:"application/vnd.kde.kpresenter",kpt:"application/vnd.kde.kpresenter",ksp:"application/vnd.kde.kspread",kwd:"application/vnd.kde.kword",kwt:"application/vnd.kde.kword",htke:"application/vnd.kenameaapp",kia:"application/vnd.kidspiration",kne:"application/vnd.kinar",knp:"application/vnd.kinar",skp:"application/vnd.koan",skd:"application/vnd.koan",skt:"application/vnd.koan",skm:"application/vnd.koan",sse:"application/vnd.kodak-descriptor",lasxml:"application/vnd.las.las+xml",lbd:"application/vnd.llamagraphics.life-balance.desktop",lbe:"application/vnd.llamagraphics.life-balance.exchange+xml",apr:"application/vnd.lotus-approach",pre:"application/vnd.lotus-freelance",nsf:"application/vnd.lotus-notes",org:"application/vnd.lotus-organizer",scm:"application/vnd.lotus-screencam",lwp:"application/vnd.lotus-wordpro",portpkg:"application/vnd.macports.portpkg",mcd:"application/vnd.mcd",mc1:"application/vnd.medcalcdata",cdkey:"application/vnd.mediastation.cdkey",mwf:"application/vnd.mfer",mfm:"application/vnd.mfmp",flo:"application/vnd.micrografx.flo",igx:"application/vnd.micrografx.igx",mif:"application/vnd.mif",daf:"application/vnd.mobius.daf",dis:"application/vnd.mobius.dis",mbk:"application/vnd.mobius.mbk",mqy:"application/vnd.mobius.mqy",msl:"application/vnd.mobius.msl",plc:"application/vnd.mobius.plc",txf:"application/vnd.mobius.txf",mpn:"application/vnd.mophun.application",mpc:"application/vnd.mophun.certificate",xul:"application/vnd.mozilla.xul+xml",cil:"application/vnd.ms-artgalry",cab:"application/vnd.ms-cab-compressed",xls:"application/vnd.ms-excel",xlm:"application/vnd.ms-excel",xla:"application/vnd.ms-excel",xlc:"application/vnd.ms-excel",xlt:"application/vnd.ms-excel",xlw:"application/vnd.ms-excel",xlam:"application/vnd.ms-excel.addin.macroenabled.12",xlsb:"application/vnd.ms-excel.sheet.binary.macroenabled.12",xlsm:"application/vnd.ms-excel.sheet.macroenabled.12",xltm:"application/vnd.ms-excel.template.macroenabled.12",eot:"application/vnd.ms-fontobject",chm:"application/vnd.ms-htmlhelp",ims:"application/vnd.ms-ims",lrm:"application/vnd.ms-lrm",thmx:"application/vnd.ms-officetheme",cat:"application/vnd.ms-pki.seccat",stl:"application/vnd.ms-pki.stl",ppt:"application/vnd.ms-powerpoint",pps:"application/vnd.ms-powerpoint",pot:"application/vnd.ms-powerpoint",ppam:"application/vnd.ms-powerpoint.addin.macroenabled.12",pptm:"application/vnd.ms-powerpoint.presentation.macroenabled.12",sldm:"application/vnd.ms-powerpoint.slide.macroenabled.12",ppsm:"application/vnd.ms-powerpoint.slideshow.macroenabled.12",potm:"application/vnd.ms-powerpoint.template.macroenabled.12",mpp:"application/vnd.ms-project",mpt:"application/vnd.ms-project",docm:"application/vnd.ms-word.document.macroenabled.12",dotm:"application/vnd.ms-word.template.macroenabled.12",wps:"application/vnd.ms-works",wks:"application/vnd.ms-works",wcm:"application/vnd.ms-works",wdb:"application/vnd.ms-works",wpl:"application/vnd.ms-wpl",xps:"application/vnd.ms-xpsdocument",mseq:"application/vnd.mseq",mus:"application/vnd.musician",msty:"application/vnd.muvee.style",taglet:"application/vnd.mynfc",nlu:"application/vnd.neurolanguage.nlu",ntf:"application/vnd.nitf",nitf:"application/vnd.nitf",nnd:"application/vnd.noblenet-directory",nns:"application/vnd.noblenet-sealer",nnw:"application/vnd.noblenet-web",ngdat:"application/vnd.nokia.n-gage.data","n-gage":"application/vnd.nokia.n-gage.symbian.install",rpst:"application/vnd.nokia.radio-preset",rpss:"application/vnd.nokia.radio-presets",edm:"application/vnd.novadigm.edm",edx:"application/vnd.novadigm.edx",ext:"application/vnd.novadigm.ext",odc:"application/vnd.oasis.opendocument.chart",otc:"application/vnd.oasis.opendocument.chart-template",odb:"application/vnd.oasis.opendocument.database",odf:"application/vnd.oasis.opendocument.formula",odft:"application/vnd.oasis.opendocument.formula-template",odg:"application/vnd.oasis.opendocument.graphics",otg:"application/vnd.oasis.opendocument.graphics-template",odi:"application/vnd.oasis.opendocument.image",oti:"application/vnd.oasis.opendocument.image-template",odp:"application/vnd.oasis.opendocument.presentation",otp:"application/vnd.oasis.opendocument.presentation-template",ods:"application/vnd.oasis.opendocument.spreadsheet",ots:"application/vnd.oasis.opendocument.spreadsheet-template",odt:"application/vnd.oasis.opendocument.text",odm:"application/vnd.oasis.opendocument.text-master",ott:"application/vnd.oasis.opendocument.text-template",oth:"application/vnd.oasis.opendocument.text-web",xo:"application/vnd.olpc-sugar",dd2:"application/vnd.oma.dd2+xml",oxt:"application/vnd.openofficeorg.extension",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",sldx:"application/vnd.openxmlformats-officedocument.presentationml.slide",ppsx:"application/vnd.openxmlformats-officedocument.presentationml.slideshow",potx:"application/vnd.openxmlformats-officedocument.presentationml.template",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xltx:"application/vnd.openxmlformats-officedocument.spreadsheetml.template",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",dotx:"application/vnd.openxmlformats-officedocument.wordprocessingml.template",mgp:"application/vnd.osgeo.mapguide.package",dp:"application/vnd.osgi.dp",esa:"application/vnd.osgi.subsystem",pdb:"application/x-pilot",pqa:"application/vnd.palm",oprc:"application/vnd.palm",paw:"application/vnd.pawaafile",str:"application/vnd.pg.format",ei6:"application/vnd.pg.osasli",efif:"application/vnd.picsel",wg:"application/vnd.pmi.widget",plf:"application/vnd.pocketlearn",pbd:"application/vnd.powerbuilder6",box:"application/vnd.previewsystems.box",mgz:"application/vnd.proteus.magazine",qps:"application/vnd.publishare-delta-tree",ptid:"application/vnd.pvi.ptid1",qxd:"application/vnd.quark.quarkxpress",qxt:"application/vnd.quark.quarkxpress",qwd:"application/vnd.quark.quarkxpress",qwt:"application/vnd.quark.quarkxpress",qxl:"application/vnd.quark.quarkxpress",qxb:"application/vnd.quark.quarkxpress",bed:"application/vnd.realvnc.bed",mxl:"application/vnd.recordare.musicxml",musicxml:"application/vnd.recordare.musicxml+xml",cryptonote:"application/vnd.rig.cryptonote",cod:"application/vnd.rim.cod",rm:"application/vnd.rn-realmedia",rmvb:"application/vnd.rn-realmedia-vbr",link66:"application/vnd.route66.link66+xml",st:"application/vnd.sailingtracker.track",see:"application/vnd.seemail",sema:"application/vnd.sema",semd:"application/vnd.semd",semf:"application/vnd.semf",ifm:"application/vnd.shana.informed.formdata",itp:"application/vnd.shana.informed.formtemplate",iif:"application/vnd.shana.informed.interchange",ipk:"application/vnd.shana.informed.package",twd:"application/vnd.simtech-mindmapper",twds:"application/vnd.simtech-mindmapper",mmf:"application/vnd.smaf",teacher:"application/vnd.smart.teacher",sdkm:"application/vnd.solent.sdkm+xml",sdkd:"application/vnd.solent.sdkm+xml",dxp:"application/vnd.spotfire.dxp",sfs:"application/vnd.spotfire.sfs",sdc:"application/vnd.stardivision.calc",sda:"application/vnd.stardivision.draw",sdd:"application/vnd.stardivision.impress",smf:"application/vnd.stardivision.math",sdw:"application/vnd.stardivision.writer",vor:"application/vnd.stardivision.writer",sgl:"application/vnd.stardivision.writer-global",smzip:"application/vnd.stepmania.package",sm:"application/vnd.stepmania.stepchart",sxc:"application/vnd.sun.xml.calc",stc:"application/vnd.sun.xml.calc.template",sxd:"application/vnd.sun.xml.draw",std:"application/vnd.sun.xml.draw.template",sxi:"application/vnd.sun.xml.impress",sti:"application/vnd.sun.xml.impress.template",sxm:"application/vnd.sun.xml.math",sxw:"application/vnd.sun.xml.writer",sxg:"application/vnd.sun.xml.writer.global",stw:"application/vnd.sun.xml.writer.template",sus:"application/vnd.sus-calendar",susp:"application/vnd.sus-calendar",svd:"application/vnd.svd",sis:"application/vnd.symbian.install",sisx:"application/vnd.symbian.install",xsm:"application/vnd.syncml+xml",bdm:"application/vnd.syncml.dm+wbxml",xdm:"application/vnd.syncml.dm+xml",tao:"application/vnd.tao.intent-module-archive",pcap:"application/vnd.tcpdump.pcap",cap:"application/vnd.tcpdump.pcap",dmp:"application/vnd.tcpdump.pcap",tmo:"application/vnd.tmobile-livetv",tpt:"application/vnd.trid.tpt",mxs:"application/vnd.triscape.mxs",tra:"application/vnd.trueapp",ufd:"application/vnd.ufdl",ufdl:"application/vnd.ufdl",utz:"application/vnd.uiq.theme",umj:"application/vnd.umajin",unityweb:"application/vnd.unity",uoml:"application/vnd.uoml+xml",vcx:"application/vnd.vcx",vsd:"application/vnd.visio",vst:"application/vnd.visio",vss:"application/vnd.visio",vsw:"application/vnd.visio",vis:"application/vnd.visionary",vsf:"application/vnd.vsf",wbxml:"application/vnd.wap.wbxml",wmlc:"application/vnd.wap.wmlc",wmlsc:"application/vnd.wap.wmlscriptc",wtb:"application/vnd.webturbo",nbp:"application/vnd.wolfram.player",wpd:"application/vnd.wordperfect",wqd:"application/vnd.wqd",stf:"application/vnd.wt.stf",xar:"application/vnd.xara",xfdl:"application/vnd.xfdl",hvd:"application/vnd.yamaha.hv-dic",hvs:"application/vnd.yamaha.hv-script",hvp:"application/vnd.yamaha.hv-voice",osf:"application/vnd.yamaha.openscoreformat",osfpvg:"application/vnd.yamaha.openscoreformat.osfpvg+xml",saf:"application/vnd.yamaha.smaf-audio",spf:"application/vnd.yamaha.smaf-phrase",cmp:"application/vnd.yellowriver-custom-menu",zir:"application/vnd.zul",zirz:"application/vnd.zul",zaz:"application/vnd.zzazz.deck+xml",vxml:"application/voicexml+xml",wgt:"application/widget",hlp:"application/winhlp",wsdl:"application/wsdl+xml",wspolicy:"application/wspolicy+xml","7z":"application/x-7z-compressed",abw:"application/x-abiword",ace:"application/x-ace-compressed",aab:"application/x-authorware-bin",x32:"application/x-authorware-bin",u32:"application/x-authorware-bin",vox:"application/x-authorware-bin",aam:"application/x-authorware-map",aas:"application/x-authorware-seg",bcpio:"application/x-bcpio",torrent:"application/x-bittorrent",blb:"application/x-blorb",blorb:"application/x-blorb",bz:"application/x-bzip",bz2:"application/x-bzip2",boz:"application/x-bzip2",cbr:"application/x-cbr",cba:"application/x-cbr",cbt:"application/x-cbr",cbz:"application/x-cbr",cb7:"application/x-cbr",vcd:"application/x-cdlink",cfs:"application/x-cfs-compressed",chat:"application/x-chat",pgn:"application/x-chess-pgn",crx:"application/x-chrome-extension",cco:"application/x-cocoa",nsc:"application/x-conference",cpio:"application/x-cpio",csh:"application/x-csh",udeb:"application/x-debian-package",dgc:"application/x-dgc-compressed",dir:"application/x-director",dcr:"application/x-director",dxr:"application/x-director",cst:"application/x-director",cct:"application/x-director",cxt:"application/x-director",w3d:"application/x-director",fgd:"application/x-director",swa:"application/x-director",wad:"application/x-doom",ncx:"application/x-dtbncx+xml",dtb:"application/x-dtbook+xml",res:"application/x-dtbresource+xml",dvi:"application/x-dvi",evy:"application/x-envoy",eva:"application/x-eva",bdf:"application/x-font-bdf",gsf:"application/x-font-ghostscript",psf:"application/x-font-linux-psf",otf:"font/opentype",pcf:"application/x-font-pcf",snf:"application/x-font-snf",ttf:"application/x-font-ttf",ttc:"application/x-font-ttf",pfa:"application/x-font-type1",pfb:"application/x-font-type1",pfm:"application/x-font-type1",afm:"application/x-font-type1",arc:"application/x-freearc",spl:"application/x-futuresplash",gca:"application/x-gca-compressed",ulx:"application/x-glulx",gnumeric:"application/x-gnumeric",gramps:"application/x-gramps-xml",gtar:"application/x-gtar",hdf:"application/x-hdf",php:"application/x-httpd-php",install:"application/x-install-instructions",jardiff:"application/x-java-archive-diff",jnlp:"application/x-java-jnlp-file",latex:"application/x-latex",luac:"application/x-lua-bytecode",lzh:"application/x-lzh-compressed",lha:"application/x-lzh-compressed",run:"application/x-makeself",mie:"application/x-mie",prc:"application/x-pilot",mobi:"application/x-mobipocket-ebook",application:"application/x-ms-application",lnk:"application/x-ms-shortcut",wmd:"application/x-ms-wmd",wmz:"application/x-msmetafile",xbap:"application/x-ms-xbap",mdb:"application/x-msaccess",obd:"application/x-msbinder",crd:"application/x-mscardfile",clp:"application/x-msclip",com:"application/x-msdownload",bat:"application/x-msdownload",mvb:"application/x-msmediaview",m13:"application/x-msmediaview",m14:"application/x-msmediaview",wmf:"application/x-msmetafile",emf:"application/x-msmetafile",emz:"application/x-msmetafile",mny:"application/x-msmoney",pub:"application/x-mspublisher",scd:"application/x-msschedule",trm:"application/x-msterminal",wri:"application/x-mswrite",nc:"application/x-netcdf",cdf:"application/x-netcdf",pac:"application/x-ns-proxy-autoconfig",nzb:"application/x-nzb",pl:"application/x-perl",pm:"application/x-perl",p12:"application/x-pkcs12",pfx:"application/x-pkcs12",p7b:"application/x-pkcs7-certificates",spc:"application/x-pkcs7-certificates",p7r:"application/x-pkcs7-certreqresp",rar:"application/x-rar-compressed",rpm:"application/x-redhat-package-manager",ris:"application/x-research-info-systems",sea:"application/x-sea",sh:"application/x-sh",shar:"application/x-shar",swf:"application/x-shockwave-flash",xap:"application/x-silverlight-app",sql:"application/x-sql",sit:"application/x-stuffit",sitx:"application/x-stuffitx",srt:"application/x-subrip",sv4cpio:"application/x-sv4cpio",sv4crc:"application/x-sv4crc",t3:"application/x-t3vm-image",gam:"application/x-tads",tar:"application/x-tar",tcl:"application/x-tcl",tk:"application/x-tcl",tex:"application/x-tex",tfm:"application/x-tex-tfm",texinfo:"application/x-texinfo",texi:"application/x-texinfo",obj:"application/x-tgif",ustar:"application/x-ustar",src:"application/x-wais-source",webapp:"application/x-web-app-manifest+json",der:"application/x-x509-ca-cert",crt:"application/x-x509-ca-cert",pem:"application/x-x509-ca-cert",fig:"application/x-xfig",xlf:"application/x-xliff+xml",xpi:"application/x-xpinstall",xz:"application/x-xz",z1:"application/x-zmachine",z2:"application/x-zmachine",z3:"application/x-zmachine",z4:"application/x-zmachine",z5:"application/x-zmachine",z6:"application/x-zmachine",z7:"application/x-zmachine",z8:"application/x-zmachine",xaml:"application/xaml+xml",xdf:"application/xcap-diff+xml",xenc:"application/xenc+xml",xhtml:"application/xhtml+xml",xht:"application/xhtml+xml",xml:"text/xml",xsl:"application/xml",xsd:"application/xml",rng:"application/xml",dtd:"application/xml-dtd",xop:"application/xop+xml",xpl:"application/xproc+xml",xslt:"application/xslt+xml",xspf:"application/xspf+xml",mxml:"application/xv+xml",xhvml:"application/xv+xml",xvml:"application/xv+xml",xvm:"application/xv+xml",yang:"application/yang",yin:"application/yin+xml",zip:"application/zip","3gpp":"video/3gpp",adp:"audio/adpcm",au:"audio/basic",snd:"audio/basic",mid:"audio/midi",midi:"audio/midi",kar:"audio/midi",rmi:"audio/midi",mp3:"audio/mpeg",m4a:"audio/x-m4a",mp4a:"audio/mp4",mpga:"audio/mpeg",mp2:"audio/mpeg",mp2a:"audio/mpeg",m2a:"audio/mpeg",m3a:"audio/mpeg",oga:"audio/ogg",ogg:"audio/ogg",spx:"audio/ogg",s3m:"audio/s3m",sil:"audio/silk",uva:"audio/vnd.dece.audio",uvva:"audio/vnd.dece.audio",eol:"audio/vnd.digital-winds",dra:"audio/vnd.dra",dts:"audio/vnd.dts",dtshd:"audio/vnd.dts.hd",lvp:"audio/vnd.lucent.voice",pya:"audio/vnd.ms-playready.media.pya",ecelp4800:"audio/vnd.nuera.ecelp4800",ecelp7470:"audio/vnd.nuera.ecelp7470",ecelp9600:"audio/vnd.nuera.ecelp9600",rip:"audio/vnd.rip",wav:"audio/x-wav",weba:"audio/webm",aac:"audio/x-aac",aif:"audio/x-aiff",aiff:"audio/x-aiff",aifc:"audio/x-aiff",caf:"audio/x-caf",flac:"audio/x-flac",mka:"audio/x-matroska",m3u:"audio/x-mpegurl",wax:"audio/x-ms-wax",wma:"audio/x-ms-wma",ram:"audio/x-pn-realaudio",ra:"audio/x-realaudio",rmp:"audio/x-pn-realaudio-plugin",xm:"audio/xm",cdx:"chemical/x-cdx",cif:"chemical/x-cif",cmdf:"chemical/x-cmdf",cml:"chemical/x-cml",csml:"chemical/x-csml",xyz:"chemical/x-xyz",bmp:"image/x-ms-bmp",cgm:"image/cgm",g3:"image/g3fax",gif:"image/gif",ief:"image/ief",jpeg:"image/jpeg",jpg:"image/jpeg",jpe:"image/jpeg",ktx:"image/ktx",png:"image/png",btif:"image/prs.btif",sgi:"image/sgi",svg:"image/svg+xml",svgz:"image/svg+xml",tiff:"image/tiff",tif:"image/tiff",psd:"image/vnd.adobe.photoshop",uvi:"image/vnd.dece.graphic",uvvi:"image/vnd.dece.graphic",uvg:"image/vnd.dece.graphic",uvvg:"image/vnd.dece.graphic",djvu:"image/vnd.djvu",djv:"image/vnd.djvu",sub:"text/vnd.dvb.subtitle",dwg:"image/vnd.dwg",dxf:"image/vnd.dxf",fbs:"image/vnd.fastbidsheet",fpx:"image/vnd.fpx",fst:"image/vnd.fst",mmr:"image/vnd.fujixerox.edmics-mmr",rlc:"image/vnd.fujixerox.edmics-rlc",mdi:"image/vnd.ms-modi",wdp:"image/vnd.ms-photo",npx:"image/vnd.net-fpx",wbmp:"image/vnd.wap.wbmp",xif:"image/vnd.xiff",webp:"image/webp","3ds":"image/x-3ds",ras:"image/x-cmu-raster",cmx:"image/x-cmx",fh:"image/x-freehand",fhc:"image/x-freehand",fh4:"image/x-freehand",fh5:"image/x-freehand",fh7:"image/x-freehand",ico:"image/x-icon",jng:"image/x-jng",sid:"image/x-mrsid-image",pcx:"image/x-pcx",pic:"image/x-pict",pct:"image/x-pict",pnm:"image/x-portable-anymap",pbm:"image/x-portable-bitmap",pgm:"image/x-portable-graymap",ppm:"image/x-portable-pixmap",rgb:"image/x-rgb",tga:"image/x-tga",xbm:"image/x-xbitmap",xpm:"image/x-xpixmap",xwd:"image/x-xwindowdump",eml:"message/rfc822",mime:"message/rfc822",igs:"model/iges",iges:"model/iges",msh:"model/mesh",mesh:"model/mesh",silo:"model/mesh",dae:"model/vnd.collada+xml",dwf:"model/vnd.dwf",gdl:"model/vnd.gdl",gtw:"model/vnd.gtw",mts:"model/vnd.mts",vtu:"model/vnd.vtu",wrl:"model/vrml",vrml:"model/vrml",x3db:"model/x3d+binary",x3dbz:"model/x3d+binary",x3dv:"model/x3d+vrml",x3dvz:"model/x3d+vrml",x3d:"model/x3d+xml",x3dz:"model/x3d+xml",appcache:"text/cache-manifest",manifest:"text/cache-manifest",ics:"text/calendar",ifb:"text/calendar",coffee:"text/coffeescript",litcoffee:"text/coffeescript",css:"text/css",csv:"text/csv",hjson:"text/hjson",html:"text/html",htm:"text/html",shtml:"text/html",jade:"text/jade",jsx:"text/jsx",less:"text/less",mml:"text/mathml",n3:"text/n3",txt:"text/plain",text:"text/plain",conf:"text/plain",def:"text/plain",list:"text/plain",log:"text/plain",in:"text/plain",ini:"text/plain",dsc:"text/prs.lines.tag",rtx:"text/richtext",sgml:"text/sgml",sgm:"text/sgml",slim:"text/slim",slm:"text/slim",stylus:"text/stylus",styl:"text/stylus",tsv:"text/tab-separated-values",t:"text/troff",tr:"text/troff",roff:"text/troff",man:"text/troff",me:"text/troff",ms:"text/troff",ttl:"text/turtle",uri:"text/uri-list",uris:"text/uri-list",urls:"text/uri-list",vcard:"text/vcard",curl:"text/vnd.curl",dcurl:"text/vnd.curl.dcurl",mcurl:"text/vnd.curl.mcurl",scurl:"text/vnd.curl.scurl",fly:"text/vnd.fly",flx:"text/vnd.fmi.flexstor",gv:"text/vnd.graphviz","3dml":"text/vnd.in3d.3dml",spot:"text/vnd.in3d.spot",jad:"text/vnd.sun.j2me.app-descriptor",wml:"text/vnd.wap.wml",wmls:"text/vnd.wap.wmlscript",vtt:"text/vtt",s:"text/x-asm",asm:"text/x-asm",c:"text/x-c",cc:"text/x-c",cxx:"text/x-c",cpp:"text/x-c",h:"text/x-c",hh:"text/x-c",dic:"text/x-c",htc:"text/x-component",f:"text/x-fortran",for:"text/x-fortran",f77:"text/x-fortran",f90:"text/x-fortran",hbs:"text/x-handlebars-template",java:"text/x-java-source",lua:"text/x-lua",markdown:"text/x-markdown",md:"text/x-markdown",mkd:"text/x-markdown",nfo:"text/x-nfo",opml:"text/x-opml",p:"text/x-pascal",pas:"text/x-pascal",pde:"text/x-processing",sass:"text/x-sass",scss:"text/x-scss",etx:"text/x-setext",sfv:"text/x-sfv",ymp:"text/x-suse-ymp",uu:"text/x-uuencode",vcs:"text/x-vcalendar",vcf:"text/x-vcard",yaml:"text/yaml",yml:"text/yaml","3gp":"video/3gpp","3g2":"video/3gpp2",h261:"video/h261",h263:"video/h263",h264:"video/h264",jpgv:"video/jpeg",jpm:"video/jpm",jpgm:"video/jpm",mj2:"video/mj2",mjp2:"video/mj2",ts:"video/mp2t",mp4:"video/mp4",mp4v:"video/mp4",mpg4:"video/mp4",mpeg:"video/mpeg",mpg:"video/mpeg",mpe:"video/mpeg",m1v:"video/mpeg",m2v:"video/mpeg",ogv:"video/ogg",qt:"video/quicktime",mov:"video/quicktime",uvh:"video/vnd.dece.hd",uvvh:"video/vnd.dece.hd",uvm:"video/vnd.dece.mobile",uvvm:"video/vnd.dece.mobile",uvp:"video/vnd.dece.pd",uvvp:"video/vnd.dece.pd",uvs:"video/vnd.dece.sd",uvvs:"video/vnd.dece.sd",uvv:"video/vnd.dece.video",uvvv:"video/vnd.dece.video",dvb:"video/vnd.dvb.file",fvt:"video/vnd.fvt",mxu:"video/vnd.mpegurl",m4u:"video/vnd.mpegurl",pyv:"video/vnd.ms-playready.media.pyv",uvu:"video/vnd.uvvu.mp4",uvvu:"video/vnd.uvvu.mp4",viv:"video/vnd.vivo",webm:"video/webm",f4v:"video/x-f4v",fli:"video/x-fli",flv:"video/x-flv",m4v:"video/x-m4v",mkv:"video/x-matroska",mk3d:"video/x-matroska",mks:"video/x-matroska",mng:"video/x-mng",asf:"video/x-ms-asf",asx:"video/x-ms-asf",vob:"video/x-ms-vob",wm:"video/x-ms-wm",wmv:"video/x-ms-wmv",wmx:"video/x-ms-wmx",wvx:"video/x-ms-wvx",avi:"video/x-msvideo",movie:"video/x-sgi-movie",smv:"video/x-smv",ice:"x-conference/x-cooltalk"}},function(t,e,n){(function(e,i,s){function r(t,e){return a.fetch&&e?"fetch":a.mozchunkedarraybuffer?"moz-chunked-arraybuffer":a.msstream?"ms-stream":a.arraybuffer&&t?"arraybuffer":a.vbArray&&t?"text:vbarray":"text"}function o(t){try{var e=t.status;return null!==e&&0!==e}catch(t){return!1}}var a=n(63),c=n(11),l=n(99),u=n(23),h=n(101),p=l.IncomingMessage,d=l.readyStates,f=t.exports=function(t){var n=this;u.Writable.call(n),n._opts=t,n._body=[],n._headers={},t.auth&&n.setHeader("Authorization","Basic "+new e(t.auth).toString("base64")),Object.keys(t.headers).forEach(function(e){n.setHeader(e,t.headers[e])});var i,s=!0;if("disable-fetch"===t.mode||"timeout"in t)s=!1,i=!0;else if("prefer-streaming"===t.mode)i=!1;else if("allow-wrong-content-type"===t.mode)i=!a.overrideMimeType;else{if(t.mode&&"default"!==t.mode&&"prefer-fast"!==t.mode)throw new Error("Invalid value for opts.mode");i=!0}n._mode=r(i,s),n.on("finish",function(){n._onFinish()})};c(f,u.Writable),f.prototype.setHeader=function(t,e){var n=this,i=t.toLowerCase();-1===m.indexOf(i)&&(n._headers[i]={name:t,value:e})},f.prototype.getHeader=function(t){var e=this._headers[t.toLowerCase()];return e?e.value:null},f.prototype.removeHeader=function(t){delete this._headers[t.toLowerCase()]},f.prototype._onFinish=function(){var t=this;if(!t._destroyed){var n=t._opts,r=t._headers,o=null;"GET"!==n.method&&"HEAD"!==n.method&&(o=a.blobConstructor?new i.Blob(t._body.map(function(t){return h(t)}),{type:(r["content-type"]||{}).value||""}):e.concat(t._body).toString());var c=[];if(Object.keys(r).forEach(function(t){var e=r[t].name,n=r[t].value;Array.isArray(n)?n.forEach(function(t){c.push([e,t])}):c.push([e,n])}),"fetch"===t._mode)i.fetch(t._opts.url,{method:t._opts.method,headers:c,body:o||void 0,mode:"cors",credentials:n.withCredentials?"include":"same-origin"}).then(function(e){t._fetchResponse=e,t._connect()},function(e){t.emit("error",e)});else{var l=t._xhr=new i.XMLHttpRequest;try{l.open(t._opts.method,t._opts.url,!0)}catch(e){return void s.nextTick(function(){t.emit("error",e)})}"responseType"in l&&(l.responseType=t._mode.split(":")[0]),"withCredentials"in l&&(l.withCredentials=!!n.withCredentials),"text"===t._mode&&"overrideMimeType"in l&&l.overrideMimeType("text/plain; charset=x-user-defined"),"timeout"in n&&(l.timeout=n.timeout,l.ontimeout=function(){t.emit("timeout")}),c.forEach(function(t){l.setRequestHeader(t[0],t[1])}),t._response=null,l.onreadystatechange=function(){switch(l.readyState){case d.LOADING:case d.DONE:t._onXHRProgress()}},"moz-chunked-arraybuffer"===t._mode&&(l.onprogress=function(){t._onXHRProgress()}),l.onerror=function(){t._destroyed||t.emit("error",new Error("XHR error"))};try{l.send(o)}catch(e){return void s.nextTick(function(){t.emit("error",e)})}}}},f.prototype._onXHRProgress=function(){var t=this;o(t._xhr)&&!t._destroyed&&(t._response||t._connect(),t._response._onXHRProgress())},f.prototype._connect=function(){var t=this;t._destroyed||(t._response=new p(t._xhr,t._fetchResponse,t._mode),t._response.on("error",function(e){t.emit("error",e)}),t.emit("response",t._response))},f.prototype._write=function(t,e,n){this._body.push(t),n()},f.prototype.abort=f.prototype.destroy=function(){var t=this;t._destroyed=!0,t._response&&(t._response._destroyed=!0),t._xhr&&t._xhr.abort()},f.prototype.end=function(t,e,n){var i=this;"function"==typeof t&&(n=t,t=void 0),u.Writable.prototype.end.call(i,t,e,n)},f.prototype.flushHeaders=function(){},f.prototype.setTimeout=function(){},f.prototype.setNoDelay=function(){},f.prototype.setSocketKeepAlive=function(){};var m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(e,n(5).Buffer,n(9),n(7))},function(t,e,n){(function(t,i,s){var r=n(63),o=n(11),a=n(23),c=e.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},l=e.IncomingMessage=function(e,n,s){function o(){l.read().then(function(t){if(!c._destroyed){if(t.done)return void c.push(null);c.push(new i(t.value)),o()}}).catch(function(t){c.emit("error",t)})}var c=this;if(a.Readable.call(c),c._mode=s,c.headers={},c.rawHeaders=[],c.trailers={},c.rawTrailers=[],c.on("end",function(){t.nextTick(function(){c.emit("close")})}),"fetch"===s){c._fetchResponse=n,c.url=n.url,c.statusCode=n.status,c.statusMessage=n.statusText,n.headers.forEach(function(t,e){c.headers[e.toLowerCase()]=t,c.rawHeaders.push(e,t)});var l=n.body.getReader();o()}else{c._xhr=e,c._pos=0,c.url=e.responseURL,c.statusCode=e.status,c.statusMessage=e.statusText;if(e.getAllResponseHeaders().split(/\r?\n/).forEach(function(t){var e=t.match(/^([^:]+):\s*(.*)/);if(e){var n=e[1].toLowerCase();"set-cookie"===n?(void 0===c.headers[n]&&(c.headers[n]=[]),c.headers[n].push(e[2])):void 0!==c.headers[n]?c.headers[n]+=", "+e[2]:c.headers[n]=e[2],c.rawHeaders.push(e[1],e[2])}}),c._charset="x-user-defined",!r.overrideMimeType){var u=c.rawHeaders["mime-type"];if(u){var h=u.match(/;\s*charset=([^;])(;|$)/);h&&(c._charset=h[1].toLowerCase())}c._charset||(c._charset="utf-8")}}};o(l,a.Readable),l.prototype._read=function(){},l.prototype._onXHRProgress=function(){var t=this,e=t._xhr,n=null;switch(t._mode){case"text:vbarray":if(e.readyState!==c.DONE)break;try{n=new s.VBArray(e.responseBody).toArray()}catch(t){}if(null!==n){t.push(new i(n));break}case"text":try{n=e.responseText}catch(e){t._mode="text:vbarray";break}if(n.length>t._pos){var r=n.substr(t._pos);if("x-user-defined"===t._charset){for(var o=new i(r.length),a=0;at._pos&&(t.push(new i(new Uint8Array(l.result.slice(t._pos)))),t._pos=l.result.byteLength)},l.onload=function(){t.push(null)},l.readAsArrayBuffer(n)}t._xhr.readyState===c.DONE&&"ms-stream"!==t._mode&&t.push(null)}}).call(e,n(7),n(5).Buffer,n(9))},function(t,e,n){function i(t,e){this._id=t,this._clearFn=e}var s=Function.prototype.apply;e.setTimeout=function(){return new i(s.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new i(s.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(91),e.setImmediate=setImmediate,e.clearImmediate=clearImmediate},function(t,e,n){var i=n(5).Buffer;t.exports=function(t){if(t instanceof Uint8Array){if(0===t.byteOffset&&t.byteLength===t.buffer.byteLength)return t.buffer;if("function"==typeof t.buffer.slice)return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(i.isBuffer(t)){for(var e=new Uint8Array(t.length),n=t.length,s=0;s=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),m(n)?i.showHidden=n:n&&e._extend(i,n),y(i.showHidden)&&(i.showHidden=!1),y(i.depth)&&(i.depth=2),y(i.colors)&&(i.colors=!1),y(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=r),c(i,t,i.depth)}function r(t,e){var n=s.styles[e];return n?"["+s.colors[n][0]+"m"+t+"["+s.colors[n][1]+"m":t}function o(t,e){return t}function a(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}function c(t,n,i){if(t.customInspect&&n&&R(n.inspect)&&n.inspect!==e.inspect&&(!n.constructor||n.constructor.prototype!==n)){var s=n.inspect(i,t);return b(s)||(s=c(t,s,i)),s}var r=l(t,n);if(r)return r;var o=Object.keys(n),m=a(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(n)),T(n)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return u(n);if(0===o.length){if(R(n)){var g=n.name?": "+n.name:"";return t.stylize("[Function"+g+"]","special")}if(_(n))return t.stylize(RegExp.prototype.toString.call(n),"regexp");if(A(n))return t.stylize(Date.prototype.toString.call(n),"date");if(T(n))return u(n)}var v="",E=!1,w=["{","}"];if(f(n)&&(E=!0,w=["[","]"]),R(n)){v=" [Function"+(n.name?": "+n.name:"")+"]"}if(_(n)&&(v=" "+RegExp.prototype.toString.call(n)),A(n)&&(v=" "+Date.prototype.toUTCString.call(n)),T(n)&&(v=" "+u(n)),0===o.length&&(!E||0==n.length))return w[0]+v+w[1];if(i<0)return _(n)?t.stylize(RegExp.prototype.toString.call(n),"regexp"):t.stylize("[Object]","special");t.seen.push(n);var y;return y=E?h(t,n,i,m,o):o.map(function(e){return p(t,n,i,m,e,E)}),t.seen.pop(),d(y,v,w)}function l(t,e){if(y(e))return t.stylize("undefined","undefined");if(b(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return E(e)?t.stylize(""+e,"number"):m(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}function u(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,n,i,s){for(var r=[],o=0,a=e.length;o-1&&(a=r?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),y(o)){if(r&&s.match(/^\d+$/))return a;o=JSON.stringify(""+s),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function d(t,e,n){var i=0;return t.reduce(function(t,e){return i++,e.indexOf("\n")>=0&&i++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function f(t){return Array.isArray(t)}function m(t){return"boolean"==typeof t}function g(t){return null===t}function v(t){return null==t}function E(t){return"number"==typeof t}function b(t){return"string"==typeof t}function w(t){return"symbol"==typeof t}function y(t){return void 0===t}function _(t){return x(t)&&"[object RegExp]"===k(t)}function x(t){return"object"==typeof t&&null!==t}function A(t){return x(t)&&"[object Date]"===k(t)}function T(t){return x(t)&&("[object Error]"===k(t)||t instanceof Error)}function R(t){return"function"==typeof t}function S(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function k(t){return Object.prototype.toString.call(t)}function D(t){return t<10?"0"+t.toString(10):t.toString(10)}function M(){var t=new Date,e=[D(t.getHours()),D(t.getMinutes()),D(t.getSeconds())].join(":");return[t.getDate(),O[t.getMonth()],e].join(" ")}function C(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.format=function(t){if(!b(t)){for(var e=[],n=0;n=r)return t;switch(t){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(t){return"[Circular]"}default:return t}}),a=i[n];n{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 a(this.client,t):t.type===i.ChannelTypes.GROUP_DM?s=new p(this.client,t):(e=e||this.client.guilds.get(t.guild_id))&&(t.type===i.ChannelTypes.TEXT?(s=new l(e,t),e.channels.set(s.id,s)):t.type===i.ChannelTypes.VOICE&&(s=new u(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 h&&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),s=n(69);class r{constructor(t){this.client=t,this.heartbeatInterval=null}get status(){return this.connection?this.connection.status:i.Status.IDLE}connectToWebSocket(t,e,n){this.client.emit(i.Events.DEBUG,`Authenticated using token ${t}`),this.client.token=t;const r=this.client.setTimeout(()=>n(new Error(i.Errors.TOOK_TOO_LONG)),3e5);this.client.api.gateway.get().then(o=>{const a=i.DefaultOptions.ws.version;const c=`${o.url}/?v=${a}&encoding=${s.ENCODING}`;this.client.emit(i.Events.DEBUG,`Using gateway ${c}`);this.client.ws.connect(c);this.client.ws.connection.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(r)})},n)}destroy(){return this.client.ws.destroy(),this.client.rest.destroy(),this.client.user?this.client.user.bot?(this.client.token=null,Promise.resolve()):this.client.api.logout.post().then(()=>{this.client.token=null}):Promise.resolve()}}t.exports=r},function(t,e,n){class i{constructor(t){this.client=t,this.register(n(130)),this.register(n(131)),this.register(n(132)),this.register(n(136)),this.register(n(133)),this.register(n(134)),this.register(n(135)),this.register(n(112)),this.register(n(113)),this.register(n(114)),this.register(n(117)),this.register(n(129)),this.register(n(122)),this.register(n(123)),this.register(n(115)),this.register(n(124)),this.register(n(125)),this.register(n(126)),this.register(n(137)),this.register(n(139)),this.register(n(138)),this.register(n(128)),this.register(n(118)),this.register(n(119)),this.register(n(120)),this.register(n(121)),this.register(n(127)),this.register(n(116))}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){return{channel:this.client.dataManager.newChannel(t)}}}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 e of t.channels){const t=n.channels.get(e.id);t&&(t.position=e.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 t of n.channels.values())"text"===t.type&&t.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){return{emoji:this.client.dataManager.newEmoji(e,t)}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t){return this.client.dataManager.killEmoji(t),{emoji:t}}}t.exports=s},function(t,e,n){const i=n(2);class s extends i{handle(t,e){return{emoji:this.client.dataManager.updateEmoji(t,e)}}}t.exports=s},function(t,e,n){function i(t){const e=new Map;for(const n of t)e.set(...n);return e}const s=n(2);class r extends s{handle(t){const e=this.client.guilds.get(t.guild_id);if(e&&e.emojis){const n=i(e.emojis.entries());for(const i of t.emojis){const t=e.emojis.get(i.id);t?(n.delete(i.id),t.equals(i,!0)||this.client.actions.GuildEmojiUpdate.handle(t,i)):this.client.actions.GuildEmojiCreate.handle(e,i)}for(const t of n.values())this.client.actions.GuildEmojiDelete.handle(t)}}}t.exports=r},function(t,e,n){const i=n(2);class s extends i{handle(t,e){return{member:t._addMember(e,!1)}}}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);let i=null;return n&&(i=n.members.get(t.user.id),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}}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(20);class o extends i{handle(t){const e=this.client,n=e.guilds.get(t.guild_id);let i;if(n){const o=n.roles.has(t.role.id);i=new r(n,t.role),n.roles.set(i.id,i),o||e.emit(s.Events.GUILD_ROLE_CREATE,i)}return{role:i}}}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);let i;return n&&(i=n.roles.get(t.role_id),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}}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 a=n.roles.get(i.id);return a&&(o=r.cloneObject(a),a.setup(t.role),e.emit(s.Events.GUILD_ROLE_UPDATE,o,a)),{old:o,updated:a}}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 e of t.roles){const t=n.roles.get(e.id);t&&(t.position=e.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 e of t.members){const t=n.members.get(e.user.id);t?n._updateMember(t,e):n._addMember(e,!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(8);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 i=0;ithis.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 t of i){const e=n.messages.get(t);e&&o.set(e.id,e)}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);class r extends i{handle(t){const e=this.client,n=e.channels.get(t.channel_id);if(n){const i=n.messages.get(t.id);return i?(i.patch(t),e.emit(s.Events.MESSAGE_UPDATE,i._edits[0],i),{old:i._edits[0],updated:i}):{old:i,updated:i}}return{old:null,updated:null}}}t.exports=r},function(t,e,n){const i=n(2);class s extends i{handle(t){return{user:this.client.dataManager.newUser(t)}}}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(36),s=n(38),r=n(0);class o{constructor(t,e,n,i){this.rest=t,this.client=t.client,this.method=e,this.path=n.toString(),this.route=this.getRoute(this.path),this.options=i}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(r.Errors.NO_TOKEN)}gen(){const t=`${this.client.options.http.host}/api/v${this.client.options.http.version}`;if(this.options.query){const t=(i.stringify(this.options.query).match(/[^=&?]+=[^=&?]+/g)||[]).join("&");this.path+=`?${t}`}const e=s[this.method](`${t}${this.path}`);if(!1!==this.options.auth&&e.set("Authorization",this.getAuth()),this.options.reason&&e.set("X-Audit-Log-Reason",this.options.reason),this.rest.client.browser||e.set("User-Agent",this.rest.userAgentManager.userAgent),this.options.files){for(const t of this.options.files)t&&t.file&&e.attach(t.name,t.file,t.name);void 0!==this.options.data&&e.attach("payload_json",JSON.stringify(this.options.data))}else void 0!==this.options.data&&e.send(this.options.data);return e}}t.exports=o},function(t,e,n){const i=n(106),s=["get","post","delete","patch","put"],r=["channels","users","guilds","members","bans","emojis","pins","permissions","reactions","webhooks","messages","notes","roles","applications","invites"],o=["toString","valueOf","inspect",Symbol.toPrimitive,i.inspect.custom];t.exports=(t=>{const e={get(n,i){function a(...t){n=n.concat(i);for(const e of t)null!==e&&void 0!==e&&(n=n.concat(e));return new Proxy(n,e)}if(o.includes(i))return()=>n.join("/");if(r.includes(i)){const e=()=>`${n.join("/")}/${i}`;for(const t of o)a[t]=e;for(const e of s)a[e]=(s=>t.request(e,`${n.join("/")}/${i}`,s));return a}return s.includes(i)?e=>t.request(i,n.join("/"),e):new Proxy(n.concat(i),e)}};return new Proxy([""],e)})},function(t,e,n){const i=n(68),s=n(66);class r 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)=>{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());if(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(400===e.status?new s(n.body):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=r},function(t,e,n){const i=n(68),s=n(66);class r extends i{constructor(t,e){super(t,e),this.endpoint=e,this.timeDifference=0,this.busy=!1}push(t){super.push(t),this.handle()}execute(t){return this.busy=!0,new Promise(e=>{t.request.gen().end((n,i)=>{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());if(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.status>=400&&n.status<500?new s(i.body):n),e(n));else{this.globalLimit=!1;const n=i&&i.body?i.body:{};t.resolve(n),0===this.requestRemaining?this.restManager.client.setTimeout(()=>e(n),this.requestResetTime-Date.now()+this.timeDifference+this.restManager.client.options.restTimeOffset):e(n)}})})}handle(){super.handle(),this.busy||0===this.remaining||0===this.queue.length||this.globalLimit||this.execute(this.queue.shift()).then(()=>{this.busy=!1;this.handle()})}}t.exports=r},function(t,e,n){(function(e){const i=n(0);class s{constructor(){this.build(this.constructor.DEFAULT)}set({url:url,version: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(7))},function(t,e,n){const i=n(14).EventEmitter,s=n(0),r=n(69);class o extends i{constructor(t){super(),this.client=t,this.connection=null}heartbeat(){return this.connection?this.connection.heartbeat():this.debug("No connection to heartbeat")}debug(t){return this.client.emit("debug",`[ws] ${t}`)}destroy(){return this.connection?this.connection.destroy():(this.debug("Attempted to destroy WebSocket but no connection exists!"),!1)}send(t){if(!this.connection)return void this.debug("No connection to websocket");this.connection.send(t)}connect(t){if(!this.connection)return this.connection=new r(this,t),!0;switch(this.connection.status){case s.Status.IDLE:case s.Status.DISCONNECTED:return this.connection.connect(t,5500),!0;default:return this.debug(`Couldn't connect to ${t} as the websocket is at state ${this.connection.status}`),!1}}}t.exports=o},function(t,e,n){const i=n(0),s=[i.WSEvents.READY,i.WSEvents.RESUMED,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(173)),this.register(i.WSEvents.RESUMED,n(176)),this.register(i.WSEvents.GUILD_CREATE,n(153)),this.register(i.WSEvents.GUILD_DELETE,n(154)),this.register(i.WSEvents.GUILD_UPDATE,n(164)),this.register(i.WSEvents.GUILD_BAN_ADD,n(151)),this.register(i.WSEvents.GUILD_BAN_REMOVE,n(152)),this.register(i.WSEvents.GUILD_MEMBER_ADD,n(156)),this.register(i.WSEvents.GUILD_MEMBER_REMOVE,n(157)),this.register(i.WSEvents.GUILD_MEMBER_UPDATE,n(158)),this.register(i.WSEvents.GUILD_ROLE_CREATE,n(160)),this.register(i.WSEvents.GUILD_ROLE_DELETE,n(161)),this.register(i.WSEvents.GUILD_ROLE_UPDATE,n(162)),this.register(i.WSEvents.GUILD_EMOJIS_UPDATE,n(155)),this.register(i.WSEvents.GUILD_MEMBERS_CHUNK,n(159)),this.register(i.WSEvents.CHANNEL_CREATE,n(147)),this.register(i.WSEvents.CHANNEL_DELETE,n(148)),this.register(i.WSEvents.CHANNEL_UPDATE,n(150)),this.register(i.WSEvents.CHANNEL_PINS_UPDATE,n(149)),this.register(i.WSEvents.PRESENCE_UPDATE,n(172)),this.register(i.WSEvents.USER_UPDATE,n(180)),this.register(i.WSEvents.USER_NOTE_UPDATE,n(178)),this.register(i.WSEvents.USER_SETTINGS_UPDATE,n(179)),this.register(i.WSEvents.VOICE_STATE_UPDATE,n(182)),this.register(i.WSEvents.TYPING_START,n(177)),this.register(i.WSEvents.MESSAGE_CREATE,n(165)),this.register(i.WSEvents.MESSAGE_DELETE,n(166)),this.register(i.WSEvents.MESSAGE_UPDATE,n(171)),this.register(i.WSEvents.MESSAGE_DELETE_BULK,n(167)),this.register(i.WSEvents.VOICE_SERVER_UPDATE,n(181)),this.register(i.WSEvents.GUILD_SYNC,n(163)),this.register(i.WSEvents.RELATIONSHIP_ADD,n(174)),this.register(i.WSEvents.RELATIONSHIP_REMOVE,n(175)),this.register(i.WSEvents.MESSAGE_REACTION_ADD,n(168)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE,n(169)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE_ALL,n(170))}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],!0);this.queue.splice(e,1)})}handle(t,e=!1){return 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.ws.setSequence(t.s),void 0===this.ws.disabledEvents[t.t]&&(this.ws.status!==i.Status.READY&&-1===s.indexOf(t.t)?(this.queue.push(t),!1):(!e&&this.queue.length>0&&this.handleQueue(),!!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){const i=n(1);class s extends i{handle(t){const e=this.packetManager.client,n=t.d;e.actions.GuildEmojisUpdate.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);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 a=r.cloneObject(i);if(i.patch(n.user),i.equals(a)||e.emit(s.Events.USER_UPDATE,a,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 a=r.cloneObject(t);t.presence&&(a.frozenPresence=r.cloneObject(t.presence)),o._setPresence(i.id,n),e.emit(s.Events.PRESENCE_UPDATE,a,t)}else o._setPresence(i.id,n)}}}t.exports=o},function(t,e,n){const i=n(1),s=n(42);class r extends i{handle(t){const e=this.packetManager.client,n=t.d;e.ws.heartbeat(),n.user.user_settings=n.user_settings;const i=new s(e,n.user);e.user=i,e.readyAt=new Date,e.users.set(i.id,i);for(const t of n.guilds)e.dataManager.newGuild(t);for(const t of n.private_channels)e.dataManager.newChannel(t);for(const t of n.relationships){const n=e.dataManager.newUser(t.user);1===t.type?e.user.friends.set(n.id,n):2===t.type&&e.user.blocked.set(n.id,n)}n.presences=n.presences||[];for(const t of n.presences)e.dataManager.newUser(t.user),e._setPresence(t.user.id,t);if(n.notes)for(const t in n.notes){let i=n.notes[t];i.length||(i=null),e.user.notes.set(t,i)}!e.user.bot&&e.options.sync&&e.setInterval(e.syncGuilds.bind(e),3e4),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});const r=e.setTimeout(()=>{e.ws.connection.triggerReady()},1200*n.guilds.length);e.setMaxListeners(n.guilds.length+10),e.once("ready",()=>{e.syncGuilds();e.setMaxListeners(10);e.clearTimeout(r)});const o=this.packetManager.ws;o.sessionID=n.session_id,o._trace=n._trace,e.emit("debug",`READY ${o._trace.join(" -> ")} ${o.sessionID}`),o.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){const i=n(1),s=n(0);class r extends i{handle(t){const e=this.packetManager.client,n=e.ws.connection;n._trace=t.d._trace,n.status=s.Status.READY,this.packetManager.handleQueue();const i=n.sequence-n.closeSequence;n.debug(`RESUMED ${n._trace.join(" -> ")} | replayed ${i} events.`),e.emit("resume",i),n.heartbeat()}}t.exports=r},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 a(e,c,c,i(s,o))),e.emit(r.Events.TYPING_START,s,o)}}}class a{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),s=n(0);class r extends i{handle(t){const e=this.packetManager.client;e.user.settings.patch(t.d),e.emit(s.Events.USER_SETTINGS_UPDATE,e.user.settings)}}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.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,n){const i=n(4);t.exports={Client:n(72),Shard:n(75),ShardClientUtil:n(76),ShardingManager:n(77),WebhookClient:n(73),Collection:n(3),Constants:n(0),EvaluatedPermissions:n(10),Permissions:n(10),Snowflake:n(6),SnowflakeUtil:n(6),Util:i,util:i,version:n(41).version,escapeMarkdown:i.escapeMarkdown,fetchRecommendedShards:i.fetchRecommendedShards,splitMessage:i.splitMessage,Channel:n(16),ClientUser:n(42),ClientUserSettings:n(43),Collector:n(32),DMChannel:n(44),Emoji:n(17),Game:n(13).Game,GroupDMChannel:n(30),Guild:n(18),GuildAuditLogs:n(45),GuildChannel:n(26),GuildMember:n(19),Invite:n(27),Message:n(8),MessageAttachment:n(46),MessageCollector:n(47),MessageEmbed:n(48),MessageMentions:n(49),MessageReaction:n(50),OAuth2Application:n(28),ClientOAuth2Application:n(28),PartialGuild:n(51),PartialGuildChannel:n(52),PermissionOverwrites:n(53),Presence:n(13).Presence,ReactionEmoji:n(31),ReactionCollector:n(54),RichEmbed:n(74),Role:n(20),TextChannel:n(55),User:n(12),VoiceChannel:n(56),Webhook:n(21)},"browser"===n(25).platform()&&(window.Discord=t.exports)},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(184);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 e of t.connected_accounts)this.connections.set(e.id,new s(this.user,e))}}t.exports=r},function(t,e,n){const i=n(34);t.exports=function(t,e){if("string"==typeof e&&(e={content:e}),e.before&&(e.before instanceof Date||(e.before=new Date(e.before)),e.maxID=i.fromNumber(e.before.getTime()-14200704e5).shiftLeft(22).toString()),e.after&&(e.after instanceof Date||(e.after=new Date(e.after)),e.minID=i.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=i.fromNumber(t).shiftLeft(22).toString(),e.maxID=i.fromNumber(t+864e5).shiftLeft(22).toString()}e.channel&&(e.channel=t.client.resolver.resolveChannelID(e.channel)),e.author&&(e.author=t.client.resolver.resolveUserID(e.author)),e.mentions&&(e.mentions=t.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};const s=n(16),r=n(18),o=n(8);if(!(t instanceof s||t instanceof r))throw new TypeError("Target must be a TextChannel, DMChannel, GroupDMChannel, or Guild.");return t.client.api[t instanceof s?"channels":"guilds"](t.id).messages().search.get({query:e}).then(e=>{const n=e.messages.map(e=>e.map(e=>new o(t.client.channels.get(e.channel_id),e,t.client)));return{totalResults:e.total_results,messages:n}})}},function(t,e,n){const i=n(4);t.exports=function(t,e){const s=n(12);if(t instanceof s)return t.createDM().then(t=>t.send(e));const r=n(19);let{content:content,nonce:nonce,reply:reply,code:code,disableEveryone:disableEveryone,tts:tts,embed:embed,files:files,split:split}=e;if(void 0!==nonce&&(nonce=parseInt(nonce),isNaN(nonce)||nonce<0))throw new RangeError("Message nonce must fit in an unsigned 64-bit integer.");if(content&&(split&&"object"!=typeof split&&(split={}),void 0===code||"boolean"==typeof code&&!0!==code||(content=i.escapeMarkdown(t.client.resolver.resolveString(content),!0),content=`\`\`\`${"boolean"!=typeof code?code||"":""} +${content} \`\`\``,split&&(split.prepend=`\`\`\`${"boolean"!=typeof code?code||"":""} -`,split.append="\n```")),(disableEveryone||void 0===disableEveryone&&this.client.options.disableEveryone)&&(t=t.replace(/@(everyone|here)/g,"@​$1")),reply&&!(e instanceof h||e instanceof p)&&"dm"!==e.type){const e=this.client.resolver.resolveUserID(reply),n=`<@${reply instanceof p&&reply.nickname?"!":""}${e}>`;t=`${n}${t?`, ${t}`:""}`,split&&(split.prepend=`${n}, ${split.prepend||""}`)}split&&(t=l.splitMessage(t,split))}else if(reply&&!(e instanceof h||e instanceof p)&&"dm"!==e.type){const e=this.client.resolver.resolveUserID(reply);t=`<@${reply instanceof p&&reply.nickname?"!":""}${e}>`}const r=e=>{if(t instanceof Array){const s=[];!function t(r,o){const a=o===r.length?{tts:tts,embed:embed}:{tts:tts};e.send(r[o],a,o===r.length?n:null).then(e=>{s.push(e);if(o>=r.length-1)return i(s);return t(r,++o)})}(t,0)}else this.rest.makeRequest("post",a.Channel(e).messages,!0,{content:t,tts:tts,nonce:nonce,embed:embed},n).then(e=>i(this.client.actions.MessageCreate.handle(e).message),s)};e instanceof h||e instanceof p?this.createDM(e).then(r,s):r(e)})}updateMessage(e,t,{embed:embed,code:code,reply:reply}={}){if(void 0!==t&&(t=this.client.resolver.resolveString(t)),void 0===code||"boolean"==typeof code&&!0!==code||(t=l.escapeMarkdown(this.client.resolver.resolveString(t),!0),t=`\`\`\`${"boolean"!=typeof code?code||"":""} -${t} -\`\`\``),reply&&"dm"!==e.channel.type){const e=this.client.resolver.resolveUserID(reply),n=`<@${reply instanceof p&&reply.nickname?"!":""}${e}>`;t=`${n}${t?`, ${t}`:""}`}return this.rest.makeRequest("patch",a.Message(e),!0,{content:t,embed:embed}).then(e=>this.client.actions.MessageUpdate.handle(e).updated)}deleteMessage(e){return this.rest.makeRequest("delete",a.Message(e),!0).then(()=>this.client.actions.MessageDelete.handle({id:e.id,channel_id:e.channel.id}).message)}ackMessage(e){return this.rest.makeRequest("post",a.Message(e).ack,!0,{token:this._ackToken}).then(t=>{t.token&&(this._ackToken=t.token);return e})}ackTextChannel(e){return this.rest.makeRequest("post",a.Channel(e).Message(e.lastMessageID).ack,!0,{token:this._ackToken}).then(t=>{t.token&&(this._ackToken=t.token);return e})}ackGuild(e){return this.rest.makeRequest("post",a.Guild(e).ack,!0).then(()=>e)}bulkDeleteMessages(e,t,n){return n&&(t=t.filter(e=>Date.now()-u.deconstruct(e).date.getTime()<12096e5)),this.rest.makeRequest("post",a.Channel(e).messages.bulkDelete,!0,{messages:t}).then(()=>this.client.actions.MessageDeleteBulk.handle({channel_id:e.id,ids:t}).messages)}search(e,t){if("string"==typeof t&&(t={content:t}),t.before&&(t.before instanceof Date||(t.before=new Date(t.before)),t.maxID=s.fromNumber(t.before.getTime()-14200704e5).shiftLeft(22).toString()),t.after&&(t.after instanceof Date||(t.after=new Date(t.after)),t.minID=s.fromNumber(t.after.getTime()-14200704e5).shiftLeft(22).toString()),t.during){t.during instanceof Date||(t.during=new Date(t.during));const e=t.during.getTime()-14200704e5;t.minID=s.fromNumber(e).shiftLeft(22).toString(),t.maxID=s.fromNumber(e+864e5).shiftLeft(22).toString()}t.channel&&(t.channel=this.client.resolver.resolveChannelID(t.channel)),t.author&&(t.author=this.client.resolver.resolveUserID(t.author)),t.mentions&&(t.mentions=this.client.resolver.resolveUserID(t.options.mentions)),t={content:t.content,max_id:t.maxID,min_id:t.minID,has:t.has,channel_id:t.channel,author_id:t.author,author_type:t.authorType,context_size:t.contextSize,sort_by:t.sortBy,sort_order:t.sortOrder,limit:t.limit,offset:t.offset,mentions:t.mentions,mentions_everyone:t.mentionsEveryone,link_hostname:t.linkHostname,embed_provider:t.embedProvider,embed_type:t.embedType,attachment_filename:t.attachmentFilename,attachment_extension:t.attachmentExtension};for(const e in t)void 0===t[e]&&delete t[e];const n=(i.stringify(t).match(/[^=&?]+=[^=&?]+/g)||[]).join("&");let r;if(e instanceof b)r=a.Channel(e).search;else{if(!(e instanceof _))throw new TypeError("Target must be a TextChannel, DMChannel, GroupDMChannel, or Guild.");r=a.Guild(e).search}return this.rest.makeRequest("get",`${r}?${n}`,!0).then(e=>{const t=e.messages.map(e=>e.map(e=>new d(this.client.channels.get(e.channel_id),e,this.client)));return{totalResults:e.total_results,messages:t}})}createChannel(e,t,n,i){return i instanceof c&&(i=i.array()),this.rest.makeRequest("post",a.Guild(e).channels,!0,{name:t,type:n,permission_overwrites:i}).then(e=>this.client.actions.ChannelCreate.handle(e).channel)}createDM(e){const t=this.getExistingDM(e);return t?Promise.resolve(t):this.rest.makeRequest("post",a.User(this.client.user).channels,!0,{recipient_id:e.id}).then(e=>this.client.actions.ChannelCreate.handle(e).channel)}createGroupDM(e){const t=this.client.user.bot?{access_tokens:e.accessTokens,nicks:e.nicks}:{recipients:e.recipients};return this.rest.makeRequest("post",a.User("@me").channels,!0,t).then(e=>new w(this.client,e))}addUserToGroupDM(e,t){const n=this.client.user.bot?{nick:t.nick,access_token:t.accessToken}:{recipient:t.id};return this.rest.makeRequest("put",a.Channel(e).Recipient(t.id),!0,n).then(()=>e)}getExistingDM(e){return this.client.channels.find(t=>t.recipient&&t.recipient.id===e.id)}deleteChannel(e){return(e instanceof h||e instanceof p)&&(e=this.getExistingDM(e)),e?this.rest.makeRequest("delete",a.Channel(e),!0).then(t=>{t.id=e.id;return this.client.actions.ChannelDelete.handle(t).channel}):Promise.reject(new Error("No channel to delete."))}updateChannel(e,t){const n={};return n.name=(t.name||e.name).trim(),n.topic=t.topic||e.topic,n.position=t.position||e.position,n.bitrate=t.bitrate||e.bitrate,n.user_limit=t.userLimit||e.userLimit,this.rest.makeRequest("patch",a.Channel(e),!0,n).then(e=>this.client.actions.ChannelUpdate.handle(e).updated)}leaveGuild(e){return e.ownerID===this.client.user.id?Promise.reject(new Error("Guild is owned by the client.")):this.rest.makeRequest("delete",a.User("@me").Guild(e.id),!0).then(()=>this.client.actions.GuildDelete.handle({id:e.id}).guild)}createGuild(e){return e.icon=this.client.resolver.resolveBase64(e.icon)||null,e.region=e.region||"us-central",new Promise((t,n)=>{this.rest.makeRequest("post",a.guilds,!0,e).then(e=>{if(this.client.guilds.has(e.id))return t(this.client.guilds.get(e.id));const i=n=>{n.id===e.id&&(this.client.removeListener(o.Events.GUILD_CREATE,i),this.client.clearTimeout(s),t(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);return},n)})}deleteGuild(e){return this.rest.makeRequest("delete",a.Guild(e),!0).then(()=>this.client.actions.GuildDelete.handle({id:e.id}).guild)}getUser(e,t){return this.rest.makeRequest("get",a.User(e),!0).then(e=>t?this.client.actions.UserGet.handle(e).user:new h(this.client,e))}updateCurrentUser(e,t){const n=this.client.user,i={};return i.username=e.username||n.username,i.avatar=this.client.resolver.resolveBase64(e.avatar)||n.avatar,n.bot||(i.email=e.email||n.email,i.password=t,e.new_password&&(i.new_password=e.newPassword)),this.rest.makeRequest("patch",a.User("@me"),!0,i).then(e=>this.client.actions.UserUpdate.handle(e).updated)}updateGuild(e,t){const n={};return t.name&&(n.name=t.name),t.region&&(n.region=t.region),t.verificationLevel&&(n.verification_level=Number(t.verificationLevel)),t.afkChannel&&(n.afk_channel_id=this.client.resolver.resolveChannel(t.afkChannel).id),t.afkTimeout&&(n.afk_timeout=Number(t.afkTimeout)),t.icon&&(n.icon=this.client.resolver.resolveBase64(t.icon)),t.owner&&(n.owner_id=this.client.resolver.resolveUser(t.owner).id),t.splash&&(n.splash=this.client.resolver.resolveBase64(t.splash)),this.rest.makeRequest("patch",a.Guild(e),!0,n).then(e=>this.client.actions.GuildUpdate.handle(e).updated)}kickGuildMember(e,t,n){const i=`${a.Guild(e).Member(t)}?reason=${n}`;return this.rest.makeRequest("delete",i,!0).then(()=>this.client.actions.GuildMemberRemove.handle({guild_id:e.id,user:t.user}).member)}createGuildRole(e,t){return t.color&&(t.color=this.client.resolver.resolveColor(t.color)),t.permissions&&(t.permissions=r.resolve(t.permissions)),this.rest.makeRequest("post",a.Guild(e).roles,!0,t).then(t=>this.client.actions.GuildRoleCreate.handle({guild_id:e.id,role:t}).role)}deleteGuildRole(e){return this.rest.makeRequest("delete",a.Guild(e.guild).Role(e.id),!0).then(()=>this.client.actions.GuildRoleDelete.handle({guild_id:e.guild.id,role_id:e.id}).role)}setChannelOverwrite(e,t){return this.rest.makeRequest("put",`${a.Channel(e).permissions}/${t.id}`,!0,t)}deletePermissionOverwrites(e){return this.rest.makeRequest("delete",`${a.Channel(e.channel).permissions}/${e.id}`,!0).then(()=>e)}getChannelMessages(e,t={}){const n=[];t.limit&&n.push(`limit=${t.limit}`),t.around?n.push(`around=${t.around}`):t.before?n.push(`before=${t.before}`):t.after&&n.push(`after=${t.after}`);let i=a.Channel(e).messages;return n.length>0&&(i+=`?${n.join("&")}`),this.rest.makeRequest("get",i,!0)}getChannelMessage(e,t){const n=e.messages.get(t);return n?Promise.resolve(n):this.rest.makeRequest("get",a.Channel(e).Message(t),!0)}putGuildMember(e,t,n){if(n.access_token=n.accessToken,n.roles){const e=n.roles;(e instanceof c||e instanceof Array&&e[0]instanceof f)&&(n.roles=e.map(e=>e.id))}return this.rest.makeRequest("put",a.Guild(e).Member(t.id),!0,n).then(t=>this.client.actions.GuildMemberGet.handle(e,t).member)}getGuildMember(e,t,n){return this.rest.makeRequest("get",a.Guild(e).Member(t.id),!0).then(t=>n?this.client.actions.GuildMemberGet.handle(e,t).member:new p(e,t))}updateGuildMember(e,t){t.channel&&(t.channel_id=this.client.resolver.resolveChannel(t.channel).id,t.channel=null),t.roles&&(t.roles=t.roles.map(e=>e instanceof f?e.id:e));let n=a.Member(e);if(e.id===this.client.user.id){const i=Object.keys(t);1===i.length&&"nick"===i[0]&&(n=a.Member(e).nickname)}return this.rest.makeRequest("patch",n,!0,t).then(t=>e.guild._updateMember(e,t).mem)}addMemberRole(e,t){return new Promise((n,i)=>{if(e._roles.includes(t.id))return n(e);const s=(e,i)=>{!e._roles.includes(t.id)&&i._roles.includes(t.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",a.Member(e).Role(t.id),!0).catch(e=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,s);this.client.clearTimeout(r);i(e)})})}removeMemberRole(e,t){return new Promise((n,i)=>{if(!e._roles.includes(t.id))return n(e);const s=(e,i)=>{e._roles.includes(t.id)&&!i._roles.includes(t.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",a.Member(e).Role(t.id),!0).catch(e=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,s);this.client.clearTimeout(r);i(e)})})}sendTyping(e){return this.rest.makeRequest("post",a.Channel(e).typing,!0)}banGuildMember(e,t,n){const s=this.client.resolver.resolveUserID(t);if(!s)return Promise.reject(new Error("Couldn't resolve the user ID to ban."));const r=`${a.Guild(e).bans}/${s}?${i.stringify(n)}`;return this.rest.makeRequest("put",r,!0).then(()=>{if(t instanceof p)return t;const n=this.client.resolver.resolveUser(s);if(n)return(t=this.client.resolver.resolveGuildMember(e,n))||n;return s})}unbanGuildMember(e,t){return new Promise((n,i)=>{const s=this.client.resolver.resolveUserID(t);if(!s)throw new Error("Couldn't resolve the user ID to unban.");const r=(t,i)=>{t.id===e.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("delete",`${a.Guild(e).bans}/${s}`,!0).catch(e=>{this.client.removeListener(o.Events.GUILD_BAN_REMOVE,r);this.client.clearTimeout(c);i(e)})})}getGuildBans(e){return this.rest.makeRequest("get",a.Guild(e).bans,!0).then(e=>e.reduce((e,t)=>{e.set(t.user.id,{reason:t.reason,user:this.client.dataManager.newUser(t.user)});return e},new c))}updateGuildRole(e,t){const n={};return n.name=t.name||e.name,n.position=void 0!==t.position?t.position:e.position,n.color=this.client.resolver.resolveColor(t.color||e.color),n.hoist=void 0!==t.hoist?t.hoist:e.hoist,n.mentionable=void 0!==t.mentionable?t.mentionable:e.mentionable,t.permissions?n.permissions=r.resolve(t.permissions):n.permissions=e.permissions,this.rest.makeRequest("patch",a.Guild(e.guild).Role(e.id),!0,n).then(t=>this.client.actions.GuildRoleUpdate.handle({role:t,guild_id:e.guild.id}).updated)}pinMessage(e){return this.rest.makeRequest("put",a.Channel(e.channel).Pin(e.id),!0).then(()=>e)}unpinMessage(e){return this.rest.makeRequest("delete",a.Channel(e.channel).Pin(e.id),!0).then(()=>e)}getChannelPinnedMessages(e){return this.rest.makeRequest("get",a.Channel(e).pins,!0)}createChannelInvite(e,t){const n={};return n.temporary=t.temporary,n.max_age=t.maxAge,n.max_uses=t.maxUses,this.rest.makeRequest("post",a.Channel(e).invites,!0,n).then(e=>new m(this.client,e))}deleteInvite(e){return this.rest.makeRequest("delete",a.Invite(e.code),!0).then(()=>e)}getInvite(e){return this.rest.makeRequest("get",a.Invite(e),!0).then(e=>new m(this.client,e))}getGuildInvites(e){return this.rest.makeRequest("get",a.Guild(e).invites,!0).then(e=>{const t=new c;for(const n of e){const e=new m(this.client,n);t.set(e.code,e)}return t})}pruneGuildMembers(e,t,n){return this.rest.makeRequest(n?"get":"post",`${a.Guild(e).prune}?days=${t}`,!0).then(e=>e.pruned)}createEmoji(e,t,n,i){const s={image:t,name:n};return i&&(s.roles=i.map(e=>e.id?e.id:e)),this.rest.makeRequest("post",a.Guild(e).emojis,!0,s).then(t=>this.client.actions.GuildEmojiCreate.handle(e,t).emoji)}updateEmoji(e,t){const n={};return t.name&&(n.name=t.name),t.roles&&(n.roles=t.roles.map(e=>e.id?e.id:e)),this.rest.makeRequest("patch",a.Guild(e.guild).Emoji(e.id),!0,n).then(t=>this.client.actions.GuildEmojiUpdate.handle(e,t).emoji)}deleteEmoji(e){return this.rest.makeRequest("delete",a.Guild(e.guild).Emoji(e.id),!0).then(()=>this.client.actions.GuildEmojiDelete.handle(e).data)}getGuildAuditLogs(e,t={}){t.before&&t.before instanceof x.Entry&&(t.before=t.before.id),t.after&&t.after instanceof x.Entry&&(t.after=t.after.id),"string"==typeof t.type&&(t.type=x.Actions[t.type]);const n=(i.stringify({before:t.before,after:t.after,limit:t.limit,user_id:this.client.resolver.resolveUserID(t.user),action_type:t.type}).match(/[^=&?]+=[^=&?]+/g)||[]).join("&");return this.rest.makeRequest("get",`${a.Guild(e).auditLogs}?${n}`,!0).then(t=>x.build(e,t))}getWebhook(e,t){return this.rest.makeRequest("get",a.Webhook(e,t),!t).then(e=>new g(this.client,e))}getGuildWebhooks(e){return this.rest.makeRequest("get",a.Guild(e).webhooks,!0).then(e=>{const t=new c;for(const n of e)t.set(n.id,new g(this.client,n));return t})}getChannelWebhooks(e){return this.rest.makeRequest("get",a.Channel(e).webhooks,!0).then(e=>{const t=new c;for(const n of e)t.set(n.id,new g(this.client,n));return t})}createWebhook(e,t,n){return this.rest.makeRequest("post",a.Channel(e).webhooks,!0,{name:t,avatar:n}).then(e=>new g(this.client,e))}editWebhook(e,t,n){return this.rest.makeRequest("patch",a.Webhook(e.id,e.token),!1,{name:t,avatar:n}).then(t=>{e.name=t.name;e.avatar=t.avatar;return e})}deleteWebhook(e){return this.rest.makeRequest("delete",a.Webhook(e.id,e.token),!1)}sendWebhookMessage(e,t,{avatarURL:avatarURL,tts:tts,disableEveryone:disableEveryone,embeds:embeds,username:username}={},n=null){return username=username||e.name,void 0!==t&&(t=this.client.resolver.resolveString(t)),t&&(disableEveryone||void 0===disableEveryone&&this.client.options.disableEveryone)&&(t=t.replace(/@(everyone|here)/g,"@​$1")),this.rest.makeRequest("post",`${a.Webhook(e.id,e.token)}?wait=true`,!1,{username:username,avatar_url:avatarURL,content:t,tts:tts,embeds:embeds},n)}sendSlackWebhookMessage(e,t){return this.rest.makeRequest("post",`${a.Webhook(e.id,e.token)}/slack?wait=true`,!1,t)}fetchUserProfile(e){return this.rest.makeRequest("get",a.User(e).profile,!0).then(t=>new v(e,t))}fetchMentions(e){return e.guild instanceof _&&(e.guild=e.guild.id),l.mergeDefault({limit:25,roles:!0,everyone:!0,guild:null},e),this.rest.makeRequest("get",a.User("@me").Mentions(e.limit,e.roles,e.everyone,e.guild),!0).then(e=>e.map(e=>new d(this.client.channels.get(e.channel_id),e,this.client)))}addFriend(e){return this.rest.makeRequest("post",a.User("@me"),!0,{username:e.username,discriminator:e.discriminator}).then(()=>e)}removeFriend(e){return this.rest.makeRequest("delete",a.User("@me").Relationship(e.id),!0).then(()=>e)}blockUser(e){return this.rest.makeRequest("put",a.User("@me").Relationship(e.id),!0,{type:2}).then(()=>e)}unblockUser(e){return this.rest.makeRequest("delete",a.User("@me").Relationship(e.id),!0).then(()=>e)}updateChannelPositions(e,t){const n=new Array(t.length);for(let e=0;ethis.client.actions.GuildChannelsPositionUpdate.handle({guild_id:e,channels:t}).guild)}setRolePositions(e,t){return this.rest.makeRequest("patch",a.Guild(e).roles,!0,t).then(()=>this.client.actions.GuildRolesPositionUpdate.handle({guild_id:e,roles:t}).guild)}setChannelPositions(e,t){return this.rest.makeRequest("patch",a.Guild(e).channels,!0,t).then(()=>this.client.actions.GuildChannelsPositionUpdate.handle({guild_id:e,channels:t}).guild)}addMessageReaction(e,t){return this.rest.makeRequest("put",a.Message(e).Reaction(t).User("@me"),!0).then(()=>e._addReaction(l.parseEmoji(t),e.client.user))}removeMessageReaction(e,t,n){const i=a.Message(e).Reaction(t).User(n===this.client.user.id?"@me":n);return this.rest.makeRequest("delete",i,!0).then(()=>this.client.actions.MessageReactionRemove.handle({user_id:n,message_id:e.id,emoji:l.parseEmoji(t),channel_id:e.channel.id}).reaction)}removeMessageReactions(e){return this.rest.makeRequest("delete",a.Message(e).reactions,!0).then(()=>e)}getMessageReactionUsers(e,t,n=100){return this.rest.makeRequest("get",a.Message(e).Reaction(t,n),!0)}getApplication(e){return this.rest.makeRequest("get",a.OAUTH2.Application(e),!0).then(e=>new E(this.client,e))}resetApplication(e){return this.rest.makeRequest("post",a.OAUTH2.Application(e).reset,!0).then(e=>new E(this.client,e))}setNote(e,t){return this.rest.makeRequest("put",a.User(e).note,!0,{note:t}).then(()=>e)}acceptInvite(e){return e.id&&(e=e.id),new Promise((t,n)=>this.rest.makeRequest("post",a.Invite(e),!0).then(e=>{const i=n=>{n.id===e.id&&(t(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)}))}patchUserSettings(e){return this.rest.makeRequest("patch",o.Endpoints.User("@me").settings,!0,e)}}e.exports=A},function(e,t,n){const i=n(68),s=n(66);class r extends i{constructor(e,t){super(e,t),this.client=e.client,this.limit=1/0,this.resetTime=null,this.remaining=1,this.timeDifference=0,this.resetTimeout=null}push(e){super.push(e),this.handle()}execute(e){e&&e.request.gen().end((t,n)=>{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());if(t)if(429===t.status){if(this.queue.unshift(e),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 e.reject(400===t.status?new s(n.body):t),this.handle();else{this.globalLimit=!1;const t=n&&n.body?n.body:{};e.resolve(t),this.handle()}})}handle(){super.handle(),this.remaining<=0||0===this.queue.length||this.globalLimit||(this.execute(this.queue.shift()),this.remaining--,this.handle())}}e.exports=r},function(e,t,n){const i=n(68),s=n(66);class r extends i{constructor(e,t){super(e,t),this.endpoint=t,this.timeDifference=0,this.busy=!1}push(e){super.push(e),this.handle()}execute(e){return this.busy=!0,new Promise(t=>{e.request.gen().end((n,i)=>{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());if(n)429===n.status?(this.queue.unshift(e),this.restManager.client.setTimeout(()=>{this.globalLimit=!1;t()},Number(i.headers["retry-after"])+this.restManager.client.options.restTimeOffset),i.headers["x-ratelimit-global"]&&(this.globalLimit=!0)):(e.reject(n.status>=400&&n.status<500?new s(i.body):n),t(n));else{this.globalLimit=!1;const n=i&&i.body?i.body:{};e.resolve(n),0===this.requestRemaining?this.restManager.client.setTimeout(()=>t(n),this.requestResetTime-Date.now()+this.timeDifference+this.restManager.client.options.restTimeOffset):t(n)}})})}handle(){super.handle(),this.busy||0===this.remaining||0===this.queue.length||this.globalLimit||this.execute(this.queue.shift()).then(()=>{this.busy=!1;this.handle()})}}e.exports=r},function(e,t,n){(function(t){const i=n(0);class s{constructor(){this.build(this.constructor.DEFAULT)}set({url:url,version:version}={}){this.build({url:url||this.constructor.DFEAULT.url,version:version||this.constructor.DEFAULT.version})}build(e){this.userAgent=`DiscordBot (${e.url}, ${e.version}) Node.js/${t.version}`}}s.DEFAULT={url:i.Package.homepage.split("#")[0],version:i.Package.version},e.exports=s}).call(t,n(7))},function(e,t,n){const i=n(12).EventEmitter,s=n(0),r=n(69);class o extends i{constructor(e){super(),this.client=e,this.connection=null}heartbeat(){return this.connection?this.connection.heartbeat():this.debug("No connection to heartbeat")}debug(e){return this.client.emit("debug",`[ws] ${e}`)}destroy(){return this.connection?this.connection.destroy():(this.debug("Attempted to destroy WebSocket but no connection exists!"),!1)}send(e){if(!this.connection)return void this.debug("No connection to websocket");this.connection.send(e)}connect(e){if(!this.connection)return this.connection=new r(this,e),!0;switch(this.connection.status){case s.Status.IDLE:case s.Status.DISCONNECTED:return this.connection.connect(e,5500),!0;default:return this.debug(`Couldn't connect to ${e} as the websocket is at state ${this.connection.status}`),!1}}}e.exports=o},function(e,t,n){const i=n(0),s=[i.WSEvents.READY,i.WSEvents.RESUMED,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(e){this.ws=e,this.handlers={},this.queue=[],this.register(i.WSEvents.READY,n(168)),this.register(i.WSEvents.RESUMED,n(171)),this.register(i.WSEvents.GUILD_CREATE,n(148)),this.register(i.WSEvents.GUILD_DELETE,n(149)),this.register(i.WSEvents.GUILD_UPDATE,n(159)),this.register(i.WSEvents.GUILD_BAN_ADD,n(146)),this.register(i.WSEvents.GUILD_BAN_REMOVE,n(147)),this.register(i.WSEvents.GUILD_MEMBER_ADD,n(151)),this.register(i.WSEvents.GUILD_MEMBER_REMOVE,n(152)),this.register(i.WSEvents.GUILD_MEMBER_UPDATE,n(153)),this.register(i.WSEvents.GUILD_ROLE_CREATE,n(155)),this.register(i.WSEvents.GUILD_ROLE_DELETE,n(156)),this.register(i.WSEvents.GUILD_ROLE_UPDATE,n(157)),this.register(i.WSEvents.GUILD_EMOJIS_UPDATE,n(150)),this.register(i.WSEvents.GUILD_MEMBERS_CHUNK,n(154)),this.register(i.WSEvents.CHANNEL_CREATE,n(142)),this.register(i.WSEvents.CHANNEL_DELETE,n(143)),this.register(i.WSEvents.CHANNEL_UPDATE,n(145)),this.register(i.WSEvents.CHANNEL_PINS_UPDATE,n(144)),this.register(i.WSEvents.PRESENCE_UPDATE,n(167)),this.register(i.WSEvents.USER_UPDATE,n(175)),this.register(i.WSEvents.USER_NOTE_UPDATE,n(173)),this.register(i.WSEvents.USER_SETTINGS_UPDATE,n(174)),this.register(i.WSEvents.VOICE_STATE_UPDATE,n(177)),this.register(i.WSEvents.TYPING_START,n(172)),this.register(i.WSEvents.MESSAGE_CREATE,n(160)),this.register(i.WSEvents.MESSAGE_DELETE,n(161)),this.register(i.WSEvents.MESSAGE_UPDATE,n(166)),this.register(i.WSEvents.MESSAGE_DELETE_BULK,n(162)),this.register(i.WSEvents.VOICE_SERVER_UPDATE,n(176)),this.register(i.WSEvents.GUILD_SYNC,n(158)),this.register(i.WSEvents.RELATIONSHIP_ADD,n(169)),this.register(i.WSEvents.RELATIONSHIP_REMOVE,n(170)),this.register(i.WSEvents.MESSAGE_REACTION_ADD,n(163)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE,n(164)),this.register(i.WSEvents.MESSAGE_REACTION_REMOVE_ALL,n(165))}get client(){return this.ws.client}register(e,t){this.handlers[e]=new t(this)}handleQueue(){this.queue.forEach((e,t)=>{this.handle(this.queue[t],!0);this.queue.splice(t,1)})}handle(e,t=!1){return e.op===i.OPCodes.HEARTBEAT_ACK?(this.ws.client._pong(this.ws.client._pingTimestamp),this.ws.lastHeartbeatAck=!0,this.ws.client.emit("debug","Heartbeat acknowledged")):e.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.ws.setSequence(e.s),void 0===this.ws.disabledEvents[e.t]&&(this.ws.status!==i.Status.READY&&-1===s.indexOf(e.t)?(this.queue.push(e),!1):(!t&&this.queue.length>0&&this.handleQueue(),!!this.handlers[e.t]&&this.handlers[e.t].handle(e)))}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.ChannelCreate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.ChannelDelete.handle(n);i.channel&&t.emit(s.Events.CHANNEL_DELETE,i.channel)}}e.exports=r},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.channels.get(n.channel_id),r=new Date(n.last_pin_timestamp);i&&r&&t.emit(s.Events.CHANNEL_PINS_UPDATE,i,r)}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.ChannelUpdate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id),r=t.users.get(n.user.id);i&&r&&t.emit(s.Events.GUILD_BAN_ADD,i,r)}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildBanRemove.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.id);i?i.available||n.unavailable||(i.setup(n),this.packetManager.ws.checkIfReady()):t.dataManager.newGuild(n)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.GuildDelete.handle(n);i.guild&&t.emit(s.Events.GUILD_DELETE,i.guild)}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildEmojisUpdate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);i&&(i.memberCount++,i._addMember(n))}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildMemberRemove.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);if(i){const e=i.members.get(n.user.id);e&&i._updateMember(e,n)}}}e.exports=s},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);if(i){const e=n.members.map(e=>i._addMember(e,!1));t.emit(s.Events.GUILD_MEMBERS_CHUNK,e,i),t.ws.lastHeartbeatAck=!0}}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleCreate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleDelete.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildRoleUpdate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildSync.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.GuildUpdate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.MessageCreate.handle(n);i.message&&t.emit(s.Events.MESSAGE_CREATE,i.message)}}e.exports=r},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.actions.MessageDelete.handle(n);i.message&&t.emit(s.Events.MESSAGE_DELETE,i.message)}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageDeleteBulk.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionAdd.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionRemove.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageReactionRemoveAll.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.MessageUpdate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0),r=n(4);class o extends i{handle(e){const t=this.packetManager.client,n=e.d;let i=t.users.get(n.user.id);const o=t.guilds.get(n.guild_id);if(!i){if(!n.user.username)return;i=t.dataManager.newUser(n.user)}const a=r.cloneObject(i);if(i.patch(n.user),i.equals(a)||t.emit(s.Events.USER_UPDATE,a,i),o){let e=o.members.get(i.id);if(e||"offline"===n.status||(e=o._addMember({user:i,roles:n.roles,deaf:!1,mute:!1},!1),t.emit(s.Events.GUILD_MEMBER_AVAILABLE,e)),e){if(0===t.listenerCount(s.Events.PRESENCE_UPDATE))return void o._setPresence(i.id,n);const a=r.cloneObject(e);e.presence&&(a.frozenPresence=r.cloneObject(e.presence)),o._setPresence(i.id,n),t.emit(s.Events.PRESENCE_UPDATE,a,e)}else o._setPresence(i.id,n)}}}e.exports=o},function(e,t,n){const i=n(1),s=n(41);class r extends i{handle(e){const t=this.packetManager.client,n=e.d;t.ws.heartbeat(),n.user.user_settings=n.user_settings;const i=new s(t,n.user);t.user=i,t.readyAt=new Date,t.users.set(i.id,i);for(const e of n.guilds)t.dataManager.newGuild(e);for(const e of n.private_channels)t.dataManager.newChannel(e);for(const e of n.relationships){const n=t.dataManager.newUser(e.user);1===e.type?t.user.friends.set(n.id,n):2===e.type&&t.user.blocked.set(n.id,n)}n.presences=n.presences||[];for(const e of n.presences)t.dataManager.newUser(e.user),t._setPresence(e.user.id,e);if(n.notes)for(const e in n.notes){let i=n.notes[e];i.length||(i=null),t.user.notes.set(e,i)}!t.user.bot&&t.options.sync&&t.setInterval(t.syncGuilds.bind(t),3e4),t.users.has("1")||t.dataManager.newUser({id:"1",username:"Clyde",discriminator:"0000",avatar:"https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png",bot:!0,status:"online",game:null,verified:!0});const r=t.setTimeout(()=>{t.ws.connection.triggerReady()},1200*n.guilds.length);t.setMaxListeners(n.guilds.length+10),t.once("ready",()=>{t.syncGuilds();t.setMaxListeners(10);t.clearTimeout(r)});const o=this.packetManager.ws;o.sessionID=n.session_id,o._trace=n._trace,t.emit("debug",`READY ${o._trace.join(" -> ")} ${o.sessionID}`),o.checkIfReady()}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;1===n.type?t.fetchUser(n.id).then(e=>{t.user.friends.set(e.id,e)}):2===n.type&&t.fetchUser(n.id).then(e=>{t.user.blocked.set(e.id,e)})}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;2===n.type?t.user.blocked.has(n.id)&&t.user.blocked.delete(n.id):1===n.type&&t.user.friends.has(n.id)&&t.user.friends.delete(n.id)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client,n=t.ws.connection;n._trace=e.d._trace,n.status=s.Status.READY,this.packetManager.handleQueue();const i=n.sequence-n.closeSequence;n.debug(`RESUMED ${n._trace.join(" -> ")} | replayed ${i} events.`),t.emit("resume",i),n.heartbeat()}}e.exports=r},function(e,t,n){function i(e,t){return e.client.setTimeout(()=>{e.client.emit(r.Events.TYPING_STOP,e,t,e._typing.get(t.id));e._typing.delete(t.id)},6e3)}const s=n(1),r=n(0);class o extends s{handle(e){const t=this.packetManager.client,n=e.d,s=t.channels.get(n.channel_id),o=t.users.get(n.user_id),c=new Date(1e3*n.timestamp);if(s&&o){if("voice"===s.type)return void t.emit(r.Events.WARN,`Discord sent a typing packet to voice channel ${s.id}`);if(s._typing.has(o.id)){const e=s._typing.get(o.id);e.lastTimestamp=c,e.resetTimeout(i(s,o))}else s._typing.set(o.id,new a(t,c,c,i(s,o))),t.emit(r.Events.TYPING_START,s,o)}}}class a{constructor(e,t,n,i){this.client=e,this.since=t,this.lastTimestamp=n,this._timeout=i}resetTimeout(e){this.client.clearTimeout(this._timeout),this._timeout=e}get elapsedTime(){return Date.now()-this.since}}e.exports=o},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.UserNoteUpdate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0);class r extends i{handle(e){const t=this.packetManager.client;t.user.settings.patch(e.d),t.emit(s.Events.USER_SETTINGS_UPDATE,t.user.settings)}}e.exports=r},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.actions.UserUpdate.handle(n)}}e.exports=s},function(e,t,n){const i=n(1);class s extends i{handle(e){const t=this.packetManager.client,n=e.d;t.emit("self.voiceServer",n)}}e.exports=s},function(e,t,n){const i=n(1),s=n(0),r=n(4);class o extends i{handle(e){const t=this.packetManager.client,n=e.d,i=t.guilds.get(n.guild_id);if(i){const e=i.members.get(n.user_id);if(e){const i=r.cloneObject(e);e.voiceChannel&&e.voiceChannel.id!==n.channel_id&&e.voiceChannel.members.delete(i.id),n.channel_id||(e.speaking=null),e.user.id===t.user.id&&n.channel_id&&t.emit("self.voiceStateUpdate",n);const o=t.channels.get(n.channel_id);o&&o.members.set(e.user.id,e),e.serverMute=n.mute,e.serverDeaf=n.deaf,e.selfMute=n.self_mute,e.selfDeaf=n.self_deaf,e.voiceSessionID=n.session_id,e.voiceChannelID=n.channel_id,t.emit(s.Events.VOICE_STATE_UPDATE,i,e)}}}}e.exports=o},function(e,t,n){const i=n(4);e.exports={Client:n(70),Shard:n(73),ShardClientUtil:n(74),ShardingManager:n(75),WebhookClient:n(71),Collection:n(3),Constants:n(0),EvaluatedPermissions:n(8),Permissions:n(8),Snowflake:n(6),SnowflakeUtil:n(6),Util:i,util:i,version:n(40).version,escapeMarkdown:i.escapeMarkdown,fetchRecommendedShards:i.fetchRecommendedShards,splitMessage:i.splitMessage,Channel:n(14),ClientUser:n(41),ClientUserSettings:n(42),Collector:n(31),DMChannel:n(43),Emoji:n(17),Game:n(11).Game,GroupDMChannel:n(28),Guild:n(24),GuildAuditLogs:n(44),GuildChannel:n(25),GuildMember:n(18),Invite:n(45),Message:n(19),MessageAttachment:n(46),MessageCollector:n(47),MessageEmbed:n(48),MessageMentions:n(49),MessageReaction:n(50),OAuth2Application:n(26),ClientOAuth2Application:n(26),PartialGuild:n(51),PartialGuildChannel:n(52),PermissionOverwrites:n(53),Presence:n(11).Presence,ReactionEmoji:n(29),ReactionCollector:n(54),RichEmbed:n(72),Role:n(15),TextChannel:n(55),User:n(16),VoiceChannel:n(56),Webhook:n(30)},"browser"===n(23).platform()&&(window.Discord=e.exports)},function(e,t){class n{constructor(e,t){this.user=e,this.setup(t)}setup(e){this.type=e.type,this.name=e.name,this.id=e.id,this.revoked=e.revoked,this.integrations=e.integrations}}e.exports=n},function(e,t,n){const i=n(3),s=n(179);class r{constructor(e,t){this.user=e,Object.defineProperty(this,"client",{value:e.client}),this.mutualGuilds=new i,this.connections=new i,this.setup(t)}setup(e){this.premium=e.premium,this.premiumSince=e.premium_since?new Date(e.premium_since):null;for(const t of e.mutual_guilds)this.client.guilds.has(t.id)&&this.mutualGuilds.set(t.id,this.client.guilds.get(t.id));for(const t of e.connected_accounts)this.connections.set(t.id,new s(this.user,t))}}e.exports=r},function(e,t){class n{constructor(e){this.id=e.id,this.name=e.name,this.vip=e.vip,this.deprecated=e.deprecated,this.optimal=e.optimal,this.custom=e.custom,this.sampleHostname=e.sample_hostname}}e.exports=n},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){}]); \ No newline at end of file +`,split.append="\n```")),(disableEveryone||void 0===disableEveryone&&t.client.options.disableEveryone)&&(content=content.replace(/@(everyone|here)/g,"@​$1")),split&&(content=i.splitMessage(content,split))),reply&&!(t instanceof s||t instanceof r)&&"dm"!==t.type){const e=t.client.resolver.resolveUserID(reply),n=`<@${reply instanceof r&&reply.nickname?"!":""}${e}>`;split&&(split.prepend=`${n}, ${split.prepend||""}`),content=`${n}${void 0!==content?`, ${content}`:""}`}return content instanceof Array?new Promise((e,n)=>{const i=[];!function s(){const r=content.length?{tts:tts}:{tts:tts,embed:embed,files:files};t.send(content.shift(),r).then(t=>{i.push(t);if(0===content.length)return e(i);return s()}).catch(n)}()}):t.client.api.channels(t.id).messages.post({data:{content:content,tts:tts,nonce:nonce,embed:embed},files:files}).then(e=>t.client.actions.MessageCreate.handle(e).message)}},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){}]); \ No newline at end of file