diff --git a/discord.indev.js b/discord.indev.js index 4c4bf828..8f4bf4fe 100644 --- a/discord.indev.js +++ b/discord.indev.js @@ -5358,6 +5358,12 @@ class Guild { */ this.roles = new Collection(); + /** + * A collection of presences in this guild + * @type {Collection} + */ + this.presences = new Collection(); + if (!data) return; if (data.unavailable) { /** @@ -5419,12 +5425,6 @@ class Guild { */ this.large = data.large || this.large; - /** - * A collection of presences in this guild - * @type {Collection} - */ - this.presences = new Collection(); - /** * An array of guild features. * @type {Object[]} diff --git a/discord.indev.min.js b/discord.indev.min.js index 2881536e..946322d0 100644 --- a/discord.indev.min.js +++ b/discord.indev.min.js @@ -3,7 +3,7 @@ ${e} \`\`\``,n)}fetchMessage(t){return this.client.rest.methods.getChannelMessage(this,t).then(t=>{const e=t instanceof r?t:new r(this,t,this.client);return this._cacheMessage(e),e})}fetchMessages(t={}){return this.client.rest.methods.getChannelMessages(this,t).then(t=>{const e=new a;for(const n of t){const t=new r(this,n,this.client);e.set(n.id,t),this._cacheMessage(t)}return e})}fetchPinnedMessages(){return this.client.rest.methods.getChannelPinnedMessages(this).then(t=>{const e=new a;for(const n of t){const t=new r(this,n,this.client);e.set(n.id,t),this._cacheMessage(t)}return e})}startTyping(t){if("undefined"!=typeof t&&t<1)throw new RangeError("Count must be at least 1.");if(this.client.user._typing.has(this.id)){const e=this.client.user._typing.get(this.id);e.count=t||e.count+1}else this.client.user._typing.set(this.id,{count:t||1,interval:this.client.setInterval(()=>{this.client.rest.methods.sendTyping(this.id)},4e3)}),this.client.rest.methods.sendTyping(this.id)}stopTyping(t=false){if(this.client.user._typing.has(this.id)){const e=this.client.user._typing.get(this.id);e.count--,(e.count<=0||t)&&(this.client.clearInterval(e.interval),this.client.user._typing.delete(this.id))}}get typing(){return this.client.user._typing.has(this.id)}get typingCount(){return this.client.user._typing.has(this.id)?this.client.user._typing.get(this.id).count:0}createCollector(t,e={}){return new o(this,t,e)}awaitMessages(t,e={}){return new Promise((n,i)=>{const s=this.createCollector(t,e);s.on("end",(t,s)=>{e.errors&&e.errors.includes(s)?i(t):n(t)})})}bulkDelete(t){if(!isNaN(t))return this.fetchMessages({limit:t}).then(t=>this.bulkDelete(t));if(t instanceof Array||t instanceof a){const e=t instanceof a?t.keyArray():t.map(t=>t.id);return this.client.rest.methods.bulkDeleteMessages(this,e)}throw new TypeError("The messages must be an Array, Collection, or number.")}_cacheMessage(t){const e=this.client.options.messageCacheMaxSize;return 0===e?null:(this.messages.size>=e&&e>0&&this.messages.delete(this.messages.firstKey()),this.messages.set(t.id,t),t)}}e.applyToClass=((t,e=false)=>{const n=["sendMessage","sendTTSMessage","sendFile","sendCode"];e&&(n.push("_cacheMessage"),n.push("fetchMessages"),n.push("fetchMessage"),n.push("bulkDelete"),n.push("startTyping"),n.push("stopTyping"),n.push("typing"),n.push("typingCount"),n.push("fetchPinnedMessages"),n.push("createCollector"),n.push("awaitMessages"));for(const s of n)i(t,s)})},function(t,e,n){const i=n(9),s=n(8),r=n(41),o=n(17),a=n(0),h=n(3),u=n(27);class c extends i{constructor(t,e){super(t.client,e),this.guild=t}setup(t){if(super.setup(t),this.name=t.name,this.position=t.position,this.permissionOverwrites=new h,t.permission_overwrites)for(const e of t.permission_overwrites)this.permissionOverwrites.set(e.id,new r(this,e))}permissionsFor(t){if(t=this.client.resolver.resolveGuildMember(this.guild,t),!t)return null;if(t.id===this.guild.ownerID)return new o(t,a.ALL_PERMISSIONS);let e=0;const n=t.roles;for(const i of n.values())e|=i.permissions;const s=this.overwritesFor(t,!0,n);for(const r of s.role.concat(s.member))e&=~r.denyData,e|=r.allowData;const h=Boolean(e&a.PermissionFlags.ADMINISTRATOR);return h&&(e=a.ALL_PERMISSIONS),new o(t,e)}overwritesFor(t,e=false,n=null){if(e||(t=this.client.resolver.resolveGuildMember(this.guild,t)),!t)return[];n=n||t.roles;const i=[],s=[];for(const r of this.permissionOverwrites.values())r.id===t.id?s.push(r):n.has(r.id)&&i.push(r);return{role:i,member:s}}overwritePermissions(t,e){const n={allow:0,deny:0};if(t instanceof s)n.type="role";else if(this.guild.roles.has(t))t=this.guild.roles.get(t),n.type="role";else if(t=this.client.resolver.resolveUser(t),n.type="member",!t)return Promise.reject(new TypeError("Supplied parameter was neither a User nor a Role."));n.id=t.id;const i=this.permissionOverwrites.get(t.id);i&&(n.allow=i.allowData,n.deny=i.denyData);for(const r in e)e[r]===!0?(n.allow|=a.PermissionFlags[r]||0,n.deny&=~(a.PermissionFlags[r]||0)):e[r]===!1?(n.allow&=~(a.PermissionFlags[r]||0),n.deny|=a.PermissionFlags[r]||0):null===e[r]&&(n.allow&=~(a.PermissionFlags[r]||0),n.deny&=~(a.PermissionFlags[r]||0));return this.client.rest.methods.setChannelOverwrite(this,n)}edit(t){return this.client.rest.methods.updateChannel(this,t)}setName(t){return this.edit({name:t})}setPosition(t){return this.client.rest.methods.updateChannel(this,{position:t})}setTopic(t){return this.client.rest.methods.updateChannel(this,{topic:t})}createInvite(t={}){return this.client.rest.methods.createChannelInvite(this,t)}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;if(e)if(this.permissionOverwrites&&t.permissionOverwrites){const n=this.permissionOverwrites.keyArray(),i=t.permissionOverwrites.keyArray();e=u(n,i)}else e=!this.permissionOverwrites&&!t.permissionOverwrites;return e}toString(){return`<#${this.id}>`}}t.exports=c},function(t,e,n){const i=n(11),s=n(8),r=n(17),o=n(0),a=n(3),h=n(7).Presence;class u{constructor(t,e){this.client=t.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.guild=t,this.user={},this._roles=[],e&&this.setup(e)}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 h}get roles(){const t=new a,e=this.guild.roles.get(this.guild.id);e&&t.set(e.id,e);for(const n of this._roles){const e=this.guild.roles.get(n);e&&t.set(e.id,e)}return t}get highestRole(){return this.roles.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t)}get 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 permissions(){if(this.user.id===this.guild.ownerID)return new r(this,o.ALL_PERMISSIONS);let t=0;const e=this.roles;for(const n of e.values())t|=n.permissions;const i=Boolean(t&o.PermissionFlags.ADMINISTRATOR);return i&&(t=o.ALL_PERMISSIONS),new r(this,t)}get kickable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(o.PermissionFlags.KICK_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}get bannable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(o.PermissionFlags.BAN_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(t){if(t=this.client.resolver.resolveChannel(t),!t||!t.guild)throw new Error("Could not resolve channel to a guild channel.");return t.permissionsFor(this)}hasPermission(t,e=false){return!e&&this.user.id===this.guild.ownerID||this.roles.some(n=>n.hasPermission(t,e))}hasPermissions(t,e=false){return!e&&this.user.id===this.guild.ownerID||t.every(t=>this.hasPermission(t,e))}missingPermissions(t,e=false){return t.filter(t=>!this.hasPermission(t,e))}edit(t){return this.client.rest.methods.updateGuildMember(this,t)}setMute(t){return this.edit({mute:t})}setDeaf(t){return this.edit({deaf:t})}setVoiceChannel(t){return this.edit({channel:t})}setRoles(t){return this.edit({roles:t})}addRole(t){return this.addRoles([t])}addRoles(t){let e;if(t instanceof a){e=this._roles.slice();for(const n of t.values())e.push(n.id)}else e=this._roles.concat(t);return this.edit({roles:e})}removeRole(t){return this.removeRoles([t])}removeRoles(t){const e=this._roles.slice();if(t instanceof a)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})}deleteDM(){return this.client.rest.methods.deleteChannel(this)}kick(){return this.client.rest.methods.kickGuildMember(this.guild,this)}ban(t=0){return this.client.rest.methods.banGuildMember(this.guild,this,t)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}}i.applyToClass(u),t.exports=u},function(t,e,n){const i=n(34),s=n(36),r=n(3),o=n(0),a=n(15),h=n(37);class u{constructor(t,e,n){this.client=n,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.channel=t,e&&this.setup(e)}setup(t){this.id=t.id,this.type=o.MessageTypes[t.type],this.content=t.content,this.author=this.client.dataManager.newUser(t.author),this.member=this.guild?this.guild.member(this.author)||null:null,this.pinned=t.pinned,this.tts=t.tts,this.nonce=t.nonce,this.system=6===t.type,this.embeds=t.embeds.map(t=>new s(this,t)),this.attachments=new r;for(const e of t.attachments)this.attachments.set(e.id,new i(this,e));this.createdTimestamp=new Date(t.timestamp).getTime(),this.editedTimestamp=t.edited_timestamp?new Date(t.edited_timestamp).getTime():null,this.mentions={users:new r,roles:new r,channels:new r,everyone:t.mention_everyone};for(const n of t.mentions){let t=this.client.users.get(n.id);t?this.mentions.users.set(t.id,t):(t=this.client.dataManager.newUser(n),this.mentions.users.set(t.id,t))}if(t.mention_roles)for(const n of t.mention_roles){const t=this.channel.guild.roles.get(n);t&&this.mentions.roles.set(t.id,t)}if(this.channel.guild){const e=t.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of e){const t=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);t&&this.mentions.channels.set(t.id,t)}}if(this._edits=[],this.reactions=new r,t.reactions&&t.reactions.length>0)for(const a of t.reactions){const t=a.emoji.id?`${a.emoji.name}:${a.emoji.id}`:a.emoji.name;this.reactions.set(t,new h(this,a.emoji,a.count,a.me))}}patch(t){if(t.author&&(this.author=this.client.users.get(t.author.id),this.guild&&(this.member=this.guild.member(this.author))),t.content&&(this.content=t.content),t.timestamp&&(this.createdTimestamp=new Date(t.timestamp).getTime()),t.edited_timestamp&&(this.editedTimestamp=t.edited_timestamp?new Date(t.edited_timestamp).getTime():null),"tts"in t&&(this.tts=t.tts),"mention_everyone"in t&&(this.mentions.everyone=t.mention_everyone),t.nonce&&(this.nonce=t.nonce),t.embeds&&(this.embeds=t.embeds.map(t=>new s(this,t))),t.type>-1&&(this.system=!1,6===t.type&&(this.system=!0)),t.attachments){this.attachments=new r;for(const e of t.attachments)this.attachments.set(e.id,new i(this,e))}if(t.mentions)for(const e of t.mentions){let t=this.client.users.get(e.id);t?this.mentions.users.set(t.id,t):(t=this.client.dataManager.newUser(e),this.mentions.users.set(t.id,t))}if(t.mention_roles)for(const e of t.mention_roles){const t=this.channel.guild.roles.get(e);t&&this.mentions.roles.set(t.id,t)}if(t.id&&(this.id=t.id),this.channel.guild&&t.content){const e=t.content.match(/<#([0-9]{14,20})>/g)||[];for(const n of e){const t=this.channel.guild.channels.get(n.match(/([0-9]{14,20})/g)[0]);t&&this.mentions.channels.set(t.id,t)}}if(t.reactions&&(this.reactions=new r,t.reactions.length>0))for(const n of t.reactions){const e=n.emoji.id?`${n.emoji.name}:${n.emoji.id}`:n.emoji.name;this.reactions.set(e,new h(this,t.emoji,t.count,t.me))}}get createdAt(){return new Date(this.createdTimestamp)}get editedAt(){return this.editedTimestamp?new Date(this.editedTimestamp):null}get guild(){return this.channel.guild||null}get cleanContent(){return this.content.replace(/@(everyone|here)/g,"@​$1").replace(/<@!?[0-9]+>/g,t=>{const e=t.replace(/<|!|>|@/g,"");if("dm"===this.channel.type||"group"===this.channel.type)return this.client.users.has(e)?`@${this.client.users.get(e).username}`:t;const n=this.channel.guild.members.get(e);if(n)return n.nickname?`@${n.nickname}`:`@${n.user.username}`;{const n=this.client.users.get(e);return n?`@${n.username}`:t}}).replace(/<#[0-9]+>/g,t=>{const e=this.client.channels.get(t.replace(/<|#|>/g,""));return e?`#${e.name}`:t}).replace(/<@&[0-9]+>/g,t=>{if("dm"===this.channel.type||"group"===this.channel.type)return t;const e=this.guild.roles.get(t.replace(/<|@|>|&/g,""));return e?`@${e.name}`:t})}get edits(){const t=this._edits.slice();return t.unshift(this),t}get editable(){return this.author.id===this.client.user.id}get deletable(){return this.author.id===this.client.user.id||this.guild&&this.channel.permissionsFor(this.client.user).hasPermission(o.PermissionFlags.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).hasPermission(o.PermissionFlags.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)}edit(t,e={}){return this.client.rest.methods.updateMessage(this,t,e)}editCode(t,e){return e=a(this.client.resolver.resolveString(e),!0),this.edit(`\`\`\`${t||""} ${e} -\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(t){if(t=this.client.resolver.resolveEmojiIdentifier(t),!t)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,t)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(t=0){return t<=0?this.client.rest.methods.deleteMessage(this):new Promise(e=>{this.client.setTimeout(()=>{e(this.delete())},t)})}reply(t,e={}){t=this.client.resolver.resolveString(t);const n=this.guild?`${this.author}, `:"";return t=`${n}${t}`,e.split&&("object"!=typeof e.split&&(e.split={}),e.split.prepend||(e.split.prepend=n)),this.client.rest.methods.sendMessage(this.channel,t,e)}equals(t,e){if(!t)return!1;const n=!t.author&&!t.attachments;if(n)return this.id===t.id&&this.embeds.length===t.embeds.length;let i=this.id===t.id&&this.author.id===t.author.id&&this.content===t.content&&this.tts===t.tts&&this.nonce===t.nonce&&this.embeds.length===t.embeds.length&&this.attachments.length===t.attachments.length;return i&&e&&(i=this.mentions.everyone===t.mentions.everyone&&this.createdTimestamp===new Date(e.timestamp).getTime()&&this.editedTimestamp===new Date(e.edited_timestamp).getTime()),i}toString(){return this.content}_addReaction(t,e){const n=t.id?`${t.name}:${t.id}`: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 h(this,t,0,e.id===this.client.user.id),this.reactions.set(n,i)),i.users.has(e.id)?null:(i.users.set(e.id,e),i.count++,i)}_removeReaction(t,e){const n=t.id||t;if(this.reactions.has(n)){const t=this.reactions.get(n);if(t.users.has(e.id))return t.users.delete(e.id),t.count--,e.id===this.client.user.id&&(t.me=!1),t}return null}_clearReactions(){this.reactions.clear()}}t.exports=u},function(t,e){t.exports=function(t,e=false,n=false){return e?t.replace(/```/g,"`​``"):n?t.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):t.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}},function(t,e,n){"use strict";(function(t,i){function s(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function r(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,n){if(r()=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function g(e){return+e!=e&&(e=0),t.alloc(+e)}function _(e,n){if(t.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 i=e.length;if(0===i)return 0;for(var s=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return Z(e).length;default:if(s)return F(e).length;n=(""+n).toLowerCase(),s=!0}}function E(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 L(this,e,n);case"utf8":case"utf-8":return S(this,e,n);case"ascii":return C(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return M(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function w(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function v(e,n,i,s,r){if(0===e.length)return-1;if("string"==typeof i?(s=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof n&&(n=t.from(n,s)),t.isBuffer(n))return 0===n.length?-1:b(e,n,i,s,r);if("number"==typeof n)return n&=255,t.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,n,i):Uint8Array.prototype.lastIndexOf.call(e,n,i):b(e,[n],i,s,r);throw new TypeError("val must be string, number or Buffer")}function b(t,e,n,i,s){function r(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,a=t.length,h=e.length;if(void 0!==i&&(i=String(i).toLowerCase(),"ucs2"===i||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,n/=2}var u;if(s){var c=-1;for(u=n;ua&&(n=a-h),u=n;u>=0;u--){for(var l=!0,d=0;ds&&(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 h,u,c,l;switch(a){case 1:r<128&&(o=r);break;case 2:h=t[s+1],128===(192&h)&&(l=(31&r)<<6|63&h,l>127&&(o=l));break;case 3:h=t[s+1],u=t[s+2],128===(192&h)&&128===(192&u)&&(l=(15&r)<<12|(63&h)<<6|63&u,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:h=t[s+1],u=t[s+2],c=t[s+3],128===(192&h)&&128===(192&u)&&128===(192&c)&&(l=(15&r)<<18|(63&h)<<12|(63&u)<<6|63&c,l>65535&&l<1114112&&(o=l))}}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 I(i)}function I(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var n="",i=0;ii)&&(n=i);for(var s="",r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function N(e,n,i,s,r,o){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>r||ne.length)throw new RangeError("Index out of range")}function O(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 B(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 G(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 j(t,e,n,i,s){return s||G(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(t,e,n,i,23,4),n+4}function q(t,e,n,i,s){return s||G(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(t,e,n,i,52,8),n+8}function z(t){if(t=H(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function H(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function F(t,e){e=e||1/0;for(var n,i=t.length,s=null,r=[],o=0;o55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&r.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&r.push(239,191,189),s=n;continue}n=(s-55296<<10|n-56320)+65536}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;r.push(n)}else if(n<2048){if((e-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;r.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function Y(t){for(var e=[],n=0;n>8,s=n%256,r.push(s),r.push(i);return r}function Z(t){return X.toByteArray(z(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 $(t){return t!==t}var X=n(61),J=n(63),Q=n(64);e.Buffer=t,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=void 0!==i.TYPED_ARRAY_SUPPORT?i.TYPED_ARRAY_SUPPORT:s(),e.kMaxLength=r(),t.poolSize=8192,t._augment=function(e){return e.__proto__=t.prototype,e},t.from=function(t,e,n){return a(null,t,e,n)},t.TYPED_ARRAY_SUPPORT&&(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0})),t.alloc=function(t,e,n){return u(null,t,e,n)},t.allocUnsafe=function(t){return c(null,t)},t.allocUnsafeSlow=function(t){return c(null,t)},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,n){if(!t.isBuffer(e)||!t.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(e===n)return 0;for(var i=e.length,s=n.length,r=0,o=Math.min(i,s);r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},t.prototype.compare=function(e,n,i,s,r){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===i&&(i=e?e.length:0),void 0===s&&(s=0),void 0===r&&(r=this.length),n<0||i>e.length||s<0||r>this.length)throw new RangeError("out of range index");if(s>=r&&n>=i)return 0;if(s>=r)return-1;if(n>=i)return 1;if(n>>>=0,i>>>=0,s>>>=0,r>>>=0,this===e)return 0;for(var o=r-s,a=i-n,h=Math.min(o,a),u=this.slice(s,r),c=e.slice(n,i),l=0;ls)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var r=!1;;)switch(i){case"hex":return y(this,t,e,n);case"utf8":case"utf-8":return A(this,t,e,n);case"ascii":return k(this,t,e,n);case"latin1":case"binary":return R(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,e,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;t.prototype.slice=function(e,n){var i=this.length;e=~~e,n=void 0===n?i:~~n,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),n<0?(n+=i,n<0&&(n=0)):n>i&&(n=i),n0&&(s*=256);)i+=this[t+--e]*s;return i},t.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||P(t,e,this.length);for(var i=this[t],s=1,r=0;++r=s&&(i-=Math.pow(2,8*e)),i},t.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||P(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},t.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),J.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),J.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),J.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),J.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e|=0,n|=0,!i){var s=Math.pow(2,8*n)-1;N(this,t,e,n,s,0)}var r=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+r]=t/o&255;return e+n},t.prototype.writeUInt8=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[n]=255&e,n+1},t.prototype.writeUInt16LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8):O(this,e,n,!0),n+2},t.prototype.writeUInt16BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>8,this[n+1]=255&e):O(this,e,n,!1),n+2},t.prototype.writeUInt32LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=255&e):B(this,e,n,!0),n+4},t.prototype.writeUInt32BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e):B(this,e,n,!1),n+4},t.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},t.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},t.prototype.writeInt8=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[n]=255&e,n+1},t.prototype.writeInt16LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8):O(this,e,n,!0),n+2},t.prototype.writeInt16BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>8,this[n+1]=255&e):O(this,e,n,!1),n+2},t.prototype.writeInt32LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24):B(this,e,n,!0),n+4},t.prototype.writeInt32BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e):B(this,e,n,!1),n+4},t.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n)},t.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n)},t.prototype.writeDoubleLE=function(t,e,n){return q(this,t,e,!0,n)},t.prototype.writeDoubleBE=function(t,e,n){return q(this,t,e,!1,n)},t.prototype.copy=function(e,n,i,s){if(i||(i=0),s||0===s||(s=this.length),n>=e.length&&(n=e.length),n||(n=0),s>0&&s=this.length)throw new RangeError("sourceStart out of bounds");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-n=0;--r)e[r+n]=this[r+i];else if(o<1e3||!t.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,e||(e=0);var o;if("number"==typeof e)for(o=n;o0||(this.raw&t)>0}hasPermissions(t,e=false){return t.every(t=>this.hasPermission(t,e))}missingPermissions(t,e=false){return t.filter(t=>!this.hasPermission(t,e))}}t.exports=s},function(t,e,n){const i=n(6),s=n(8),r=n(10),o=n(7).Presence,a=n(13),h=n(0),u=n(3),c=n(4),l=n(27);class d{constructor(t,e){this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.members=new u,this.channels=new u,this.roles=new u,e&&(e.unavailable?(this.available=!1,this.id=e.id):(this.available=!0,this.setup(e)))}setup(t){this.name=t.name,this.icon=t.icon,this.splash=t.splash,this.region=t.region,this.memberCount=t.member_count||this.memberCount,this.large=t.large||this.large,this.presences=new u,this.features=t.features,this.emojis=new u;for(const e of t.emojis)this.emojis.set(e.id,new r(this,e));if(this.afkTimeout=t.afk_timeout,this.afkChannelID=t.afk_channel_id,this.embedEnabled=t.embed_enabled,this.verificationLevel=t.verification_level,this.joinedTimestamp=t.joined_at?new Date(t.joined_at).getTime():this.joinedTimestamp,this.id=t.id,this.available=!t.unavailable,this.features=t.features||this.features||[],t.members){this.members.clear();for(const e of t.members)this._addMember(e,!1)}if(t.owner_id&&(this.ownerID=t.owner_id),t.channels){this.channels.clear();for(const e of t.channels)this.client.dataManager.newChannel(e,this)}if(t.roles){this.roles.clear();for(const e of t.roles){const t=new s(this,e);this.roles.set(t.id,t)}}if(t.presences)for(const n of t.presences)this._setPresence(n.user.id,n);if(this._rawVoiceStates=new u,t.voice_states)for(const i of t.voice_states){this._rawVoiceStates.set(i.user_id,i);const t=this.members.get(i.user_id);t&&(t.serverMute=i.mute,t.serverDeaf=i.deaf,t.selfMute=i.self_mute,t.selfDeaf=i.self_deaf,t.voiceSessionID=i.session_id,t.voiceChannelID=i.channel_id,this.channels.get(i.channel_id).members.set(t.user.id,t))}}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}get iconURL(){return this.icon?h.Endpoints.guildIcon(this.id,this.icon):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)}member(t){return this.client.resolver.resolveGuildMember(this,t)}fetchBans(){return this.client.rest.methods.getGuildBans(this)}fetchInvites(){return this.client.rest.methods.getGuildInvites(this)}fetchWebhooks(){return this.client.rest.methods.getGuildWebhooks(this)}fetchMember(t){return this._fetchWaiter?Promise.reject(new Error("Already fetching guild members.")):(t=this.client.resolver.resolveUser(t),t?this.members.has(t.id)?Promise.resolve(this.members.get(t.id)):this.client.rest.methods.getGuildMember(this,t):Promise.reject(new Error("User is not cached. Use Client.fetchUser first.")))}fetchMembers(t=""){return new Promise((e,n)=>{if(this._fetchWaiter)throw new Error("Already fetching guild members in ${this.id}.");return this.memberCount===this.members.size?void e(this):(this._fetchWaiter=e,this.client.ws.send({op:h.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:t,limit:0}}),this._checkChunks(),void this.client.setTimeout(()=>n(new Error("Members didn't arrive in time.")),12e4))})}edit(t){return this.client.rest.methods.updateGuild(this,t)}setName(t){return this.edit({name:t})}setRegion(t){return this.edit({region:t})}setVerificationLevel(t){return this.edit({verificationLevel:t})}setAFKChannel(t){return this.edit({afkChannel:t})}setAFKTimeout(t){return this.edit({afkTimeout:t})}setIcon(t){return this.edit({icon:t})}setOwner(t){return this.edit({owner:t})}setSplash(t){return this.edit({splash:t})}ban(t,e=0){return this.client.rest.methods.banGuildMember(this,t,e)}unban(t){return this.client.rest.methods.unbanGuildMember(this,t)}pruneMembers(t,e=false){if("number"!=typeof t)throw new TypeError("Days must be a number.");return this.client.rest.methods.pruneGuildMembers(this,t,e)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(t,e){return this.client.rest.methods.createChannel(this,t,e)}createRole(t){const e=this.client.rest.methods.createGuildRole(this);return t?e.then(e=>e.edit(t)):e}createEmoji(t,e){return new Promise(n=>{t.startsWith("data:")?n(this.client.rest.methods.createEmoji(this,t,e)):this.client.resolver.resolveBuffer(t).then(t=>n(this.client.rest.methods.createEmoji(this,t,e)))})}deleteEmoji(t){return t instanceof r||(t=this.emojis.get(t)),this.client.rest.methods.deleteEmoji(t)}leave(){return this.client.rest.methods.leaveGuild(this)}delete(){return this.client.rest.methods.deleteGuild(this)}setRolePosition(t,e){if(t instanceof s)t=t.id;else if("string"!=typeof t)return Promise.reject(new Error("Supplied role is not a role or string."));if(e=Number(e),isNaN(e))return Promise.reject(new Error("Supplied position is not a number."));const n=this.roles.map(n=>({id:n.id,position:n.id===t?e:n.position`:this.name}}t.exports=n},function(t,e,n){const i=n(23),s=n(15);class r{constructor(t,e,n){t?(this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),e&&this.setup(e)):(this.id=e,this.token=n,this.client=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=t.user)}sendMessage(t,e={}){return this.client.rest.methods.sendWebhookMessage(this,t,e)}sendSlackMessage(t){return this.client.rest.methods.sendSlackWebhookMessage(this,t)}sendTTSMessage(t,e={}){return Object.assign(e,{tts:!0}),this.client.rest.methods.sendWebhookMessage(this,t,e)}sendFile(t,e,n,s={}){return e||(e="string"==typeof t?i.basename(t):t&&t.path?i.basename(t.path):"file.jpg"),this.client.resolver.resolveBuffer(t).then(t=>this.client.rest.methods.sendWebhookMessage(this,n,s,{file:t,name:e}))}sendCode(t,e,n={}){return n.split&&("object"!=typeof n.split&&(n.split={}),n.split.prepend||(n.split.prepend=`\`\`\`${t||""} +\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(t){if(t=this.client.resolver.resolveEmojiIdentifier(t),!t)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,t)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(t=0){return t<=0?this.client.rest.methods.deleteMessage(this):new Promise(e=>{this.client.setTimeout(()=>{e(this.delete())},t)})}reply(t,e={}){t=this.client.resolver.resolveString(t);const n=this.guild?`${this.author}, `:"";return t=`${n}${t}`,e.split&&("object"!=typeof e.split&&(e.split={}),e.split.prepend||(e.split.prepend=n)),this.client.rest.methods.sendMessage(this.channel,t,e)}equals(t,e){if(!t)return!1;const n=!t.author&&!t.attachments;if(n)return this.id===t.id&&this.embeds.length===t.embeds.length;let i=this.id===t.id&&this.author.id===t.author.id&&this.content===t.content&&this.tts===t.tts&&this.nonce===t.nonce&&this.embeds.length===t.embeds.length&&this.attachments.length===t.attachments.length;return i&&e&&(i=this.mentions.everyone===t.mentions.everyone&&this.createdTimestamp===new Date(e.timestamp).getTime()&&this.editedTimestamp===new Date(e.edited_timestamp).getTime()),i}toString(){return this.content}_addReaction(t,e){const n=t.id?`${t.name}:${t.id}`: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 h(this,t,0,e.id===this.client.user.id),this.reactions.set(n,i)),i.users.has(e.id)?null:(i.users.set(e.id,e),i.count++,i)}_removeReaction(t,e){const n=t.id||t;if(this.reactions.has(n)){const t=this.reactions.get(n);if(t.users.has(e.id))return t.users.delete(e.id),t.count--,e.id===this.client.user.id&&(t.me=!1),t}return null}_clearReactions(){this.reactions.clear()}}t.exports=u},function(t,e){t.exports=function(t,e=false,n=false){return e?t.replace(/```/g,"`​``"):n?t.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):t.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}},function(t,e,n){"use strict";(function(t,i){function s(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function r(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,n){if(r()=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|t}function g(e){return+e!=e&&(e=0),t.alloc(+e)}function _(e,n){if(t.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 i=e.length;if(0===i)return 0;for(var s=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return Z(e).length;default:if(s)return F(e).length;n=(""+n).toLowerCase(),s=!0}}function E(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 L(this,e,n);case"utf8":case"utf-8":return S(this,e,n);case"ascii":return C(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return M(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function w(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function v(e,n,i,s,r){if(0===e.length)return-1;if("string"==typeof i?(s=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof n&&(n=t.from(n,s)),t.isBuffer(n))return 0===n.length?-1:b(e,n,i,s,r);if("number"==typeof n)return n&=255,t.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,n,i):Uint8Array.prototype.lastIndexOf.call(e,n,i):b(e,[n],i,s,r);throw new TypeError("val must be string, number or Buffer")}function b(t,e,n,i,s){function r(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,a=t.length,h=e.length;if(void 0!==i&&(i=String(i).toLowerCase(),"ucs2"===i||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,n/=2}var u;if(s){var c=-1;for(u=n;ua&&(n=a-h),u=n;u>=0;u--){for(var l=!0,d=0;ds&&(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 h,u,c,l;switch(a){case 1:r<128&&(o=r);break;case 2:h=t[s+1],128===(192&h)&&(l=(31&r)<<6|63&h,l>127&&(o=l));break;case 3:h=t[s+1],u=t[s+2],128===(192&h)&&128===(192&u)&&(l=(15&r)<<12|(63&h)<<6|63&u,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:h=t[s+1],u=t[s+2],c=t[s+3],128===(192&h)&&128===(192&u)&&128===(192&c)&&(l=(15&r)<<18|(63&h)<<12|(63&u)<<6|63&c,l>65535&&l<1114112&&(o=l))}}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 I(i)}function I(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var n="",i=0;ii)&&(n=i);for(var s="",r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function N(e,n,i,s,r,o){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>r||ne.length)throw new RangeError("Index out of range")}function O(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 B(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 G(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 j(t,e,n,i,s){return s||G(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(t,e,n,i,23,4),n+4}function q(t,e,n,i,s){return s||G(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(t,e,n,i,52,8),n+8}function z(t){if(t=H(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function H(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function F(t,e){e=e||1/0;for(var n,i=t.length,s=null,r=[],o=0;o55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&r.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&r.push(239,191,189),s=n;continue}n=(s-55296<<10|n-56320)+65536}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;r.push(n)}else if(n<2048){if((e-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;r.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function Y(t){for(var e=[],n=0;n>8,s=n%256,r.push(s),r.push(i);return r}function Z(t){return X.toByteArray(z(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 $(t){return t!==t}var X=n(61),J=n(63),Q=n(64);e.Buffer=t,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,t.TYPED_ARRAY_SUPPORT=void 0!==i.TYPED_ARRAY_SUPPORT?i.TYPED_ARRAY_SUPPORT:s(),e.kMaxLength=r(),t.poolSize=8192,t._augment=function(e){return e.__proto__=t.prototype,e},t.from=function(t,e,n){return a(null,t,e,n)},t.TYPED_ARRAY_SUPPORT&&(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0})),t.alloc=function(t,e,n){return u(null,t,e,n)},t.allocUnsafe=function(t){return c(null,t)},t.allocUnsafeSlow=function(t){return c(null,t)},t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(e,n){if(!t.isBuffer(e)||!t.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(e===n)return 0;for(var i=e.length,s=n.length,r=0,o=Math.min(i,s);r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},t.prototype.compare=function(e,n,i,s,r){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===i&&(i=e?e.length:0),void 0===s&&(s=0),void 0===r&&(r=this.length),n<0||i>e.length||s<0||r>this.length)throw new RangeError("out of range index");if(s>=r&&n>=i)return 0;if(s>=r)return-1;if(n>=i)return 1;if(n>>>=0,i>>>=0,s>>>=0,r>>>=0,this===e)return 0;for(var o=r-s,a=i-n,h=Math.min(o,a),u=this.slice(s,r),c=e.slice(n,i),l=0;ls)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var r=!1;;)switch(i){case"hex":return y(this,t,e,n);case"utf8":case"utf-8":return A(this,t,e,n);case"ascii":return k(this,t,e,n);case"latin1":case"binary":return R(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,e,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;t.prototype.slice=function(e,n){var i=this.length;e=~~e,n=void 0===n?i:~~n,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),n<0?(n+=i,n<0&&(n=0)):n>i&&(n=i),n0&&(s*=256);)i+=this[t+--e]*s;return i},t.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||P(t,e,this.length);for(var i=this[t],s=1,r=0;++r=s&&(i-=Math.pow(2,8*e)),i},t.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||P(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},t.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),J.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),J.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),J.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),J.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e|=0,n|=0,!i){var s=Math.pow(2,8*n)-1;N(this,t,e,n,s,0)}var r=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+r]=t/o&255;return e+n},t.prototype.writeUInt8=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,1,255,0),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[n]=255&e,n+1},t.prototype.writeUInt16LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8):O(this,e,n,!0),n+2},t.prototype.writeUInt16BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>8,this[n+1]=255&e):O(this,e,n,!1),n+2},t.prototype.writeUInt32LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=255&e):B(this,e,n,!0),n+4},t.prototype.writeUInt32BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e):B(this,e,n,!1),n+4},t.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},t.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},t.prototype.writeInt8=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,1,127,-128),t.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[n]=255&e,n+1},t.prototype.writeInt16LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8):O(this,e,n,!0),n+2},t.prototype.writeInt16BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>8,this[n+1]=255&e):O(this,e,n,!1),n+2},t.prototype.writeInt32LE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[n]=255&e,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24):B(this,e,n,!0),n+4},t.prototype.writeInt32BE=function(e,n,i){return e=+e,n|=0,i||N(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),t.TYPED_ARRAY_SUPPORT?(this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=255&e):B(this,e,n,!1),n+4},t.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n)},t.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n)},t.prototype.writeDoubleLE=function(t,e,n){return q(this,t,e,!0,n)},t.prototype.writeDoubleBE=function(t,e,n){return q(this,t,e,!1,n)},t.prototype.copy=function(e,n,i,s){if(i||(i=0),s||0===s||(s=this.length),n>=e.length&&(n=e.length),n||(n=0),s>0&&s=this.length)throw new RangeError("sourceStart out of bounds");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-n=0;--r)e[r+n]=this[r+i];else if(o<1e3||!t.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,e||(e=0);var o;if("number"==typeof e)for(o=n;o0||(this.raw&t)>0}hasPermissions(t,e=false){return t.every(t=>this.hasPermission(t,e))}missingPermissions(t,e=false){return t.filter(t=>!this.hasPermission(t,e))}}t.exports=s},function(t,e,n){const i=n(6),s=n(8),r=n(10),o=n(7).Presence,a=n(13),h=n(0),u=n(3),c=n(4),l=n(27);class d{constructor(t,e){this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.members=new u,this.channels=new u,this.roles=new u,this.presences=new u,e&&(e.unavailable?(this.available=!1,this.id=e.id):(this.available=!0,this.setup(e)))}setup(t){this.name=t.name,this.icon=t.icon,this.splash=t.splash,this.region=t.region,this.memberCount=t.member_count||this.memberCount,this.large=t.large||this.large,this.features=t.features,this.emojis=new u;for(const e of t.emojis)this.emojis.set(e.id,new r(this,e));if(this.afkTimeout=t.afk_timeout,this.afkChannelID=t.afk_channel_id,this.embedEnabled=t.embed_enabled,this.verificationLevel=t.verification_level,this.joinedTimestamp=t.joined_at?new Date(t.joined_at).getTime():this.joinedTimestamp,this.id=t.id,this.available=!t.unavailable,this.features=t.features||this.features||[],t.members){this.members.clear();for(const e of t.members)this._addMember(e,!1)}if(t.owner_id&&(this.ownerID=t.owner_id),t.channels){this.channels.clear();for(const e of t.channels)this.client.dataManager.newChannel(e,this)}if(t.roles){this.roles.clear();for(const e of t.roles){const t=new s(this,e);this.roles.set(t.id,t)}}if(t.presences)for(const n of t.presences)this._setPresence(n.user.id,n);if(this._rawVoiceStates=new u,t.voice_states)for(const i of t.voice_states){this._rawVoiceStates.set(i.user_id,i);const t=this.members.get(i.user_id);t&&(t.serverMute=i.mute,t.serverDeaf=i.deaf,t.selfMute=i.self_mute,t.selfDeaf=i.self_deaf,t.voiceSessionID=i.session_id,t.voiceChannelID=i.channel_id,this.channels.get(i.channel_id).members.set(t.user.id,t))}}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}get joinedAt(){return new Date(this.joinedTimestamp)}get iconURL(){return this.icon?h.Endpoints.guildIcon(this.id,this.icon):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)}member(t){return this.client.resolver.resolveGuildMember(this,t)}fetchBans(){return this.client.rest.methods.getGuildBans(this)}fetchInvites(){return this.client.rest.methods.getGuildInvites(this)}fetchWebhooks(){return this.client.rest.methods.getGuildWebhooks(this)}fetchMember(t){return this._fetchWaiter?Promise.reject(new Error("Already fetching guild members.")):(t=this.client.resolver.resolveUser(t),t?this.members.has(t.id)?Promise.resolve(this.members.get(t.id)):this.client.rest.methods.getGuildMember(this,t):Promise.reject(new Error("User is not cached. Use Client.fetchUser first.")))}fetchMembers(t=""){return new Promise((e,n)=>{if(this._fetchWaiter)throw new Error("Already fetching guild members in ${this.id}.");return this.memberCount===this.members.size?void e(this):(this._fetchWaiter=e,this.client.ws.send({op:h.OPCodes.REQUEST_GUILD_MEMBERS,d:{guild_id:this.id,query:t,limit:0}}),this._checkChunks(),void this.client.setTimeout(()=>n(new Error("Members didn't arrive in time.")),12e4))})}edit(t){return this.client.rest.methods.updateGuild(this,t)}setName(t){return this.edit({name:t})}setRegion(t){return this.edit({region:t})}setVerificationLevel(t){return this.edit({verificationLevel:t})}setAFKChannel(t){return this.edit({afkChannel:t})}setAFKTimeout(t){return this.edit({afkTimeout:t})}setIcon(t){return this.edit({icon:t})}setOwner(t){return this.edit({owner:t})}setSplash(t){return this.edit({splash:t})}ban(t,e=0){return this.client.rest.methods.banGuildMember(this,t,e)}unban(t){return this.client.rest.methods.unbanGuildMember(this,t)}pruneMembers(t,e=false){if("number"!=typeof t)throw new TypeError("Days must be a number.");return this.client.rest.methods.pruneGuildMembers(this,t,e)}sync(){this.client.user.bot||this.client.syncGuilds([this])}createChannel(t,e){return this.client.rest.methods.createChannel(this,t,e)}createRole(t){const e=this.client.rest.methods.createGuildRole(this);return t?e.then(e=>e.edit(t)):e}createEmoji(t,e){return new Promise(n=>{t.startsWith("data:")?n(this.client.rest.methods.createEmoji(this,t,e)):this.client.resolver.resolveBuffer(t).then(t=>n(this.client.rest.methods.createEmoji(this,t,e)))})}deleteEmoji(t){return t instanceof r||(t=this.emojis.get(t)),this.client.rest.methods.deleteEmoji(t)}leave(){return this.client.rest.methods.leaveGuild(this)}delete(){return this.client.rest.methods.deleteGuild(this)}setRolePosition(t,e){if(t instanceof s)t=t.id;else if("string"!=typeof t)return Promise.reject(new Error("Supplied role is not a role or string."));if(e=Number(e),isNaN(e))return Promise.reject(new Error("Supplied position is not a number."));const n=this.roles.map(n=>({id:n.id,position:n.id===t?e:n.position`:this.name}}t.exports=n},function(t,e,n){const i=n(23),s=n(15);class r{constructor(t,e,n){t?(this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),e&&this.setup(e)):(this.id=e,this.token=n,this.client=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=t.user)}sendMessage(t,e={}){return this.client.rest.methods.sendWebhookMessage(this,t,e)}sendSlackMessage(t){return this.client.rest.methods.sendSlackWebhookMessage(this,t)}sendTTSMessage(t,e={}){return Object.assign(e,{tts:!0}),this.client.rest.methods.sendWebhookMessage(this,t,e)}sendFile(t,e,n,s={}){return e||(e="string"==typeof t?i.basename(t):t&&t.path?i.basename(t.path):"file.jpg"),this.client.resolver.resolveBuffer(t).then(t=>this.client.rest.methods.sendWebhookMessage(this,n,s,{file:t,name:e}))}sendCode(t,e,n={}){return n.split&&("object"!=typeof n.split&&(n.split={}),n.split.prepend||(n.split.prepend=`\`\`\`${t||""} `),n.split.append||(n.split.append="\n```")),e=s(this.client.resolver.resolveString(e),!0),this.sendMessage(`\`\`\`${t||""} ${e} \`\`\``,n)}edit(t=this.name,e){return e?this.client.resolver.resolveBuffer(e).then(e=>{const n=this.client.resolver.resolveBase64(e);return this.client.rest.methods.editWebhook(this,t,n)}):this.client.rest.methods.editWebhook(this,t).then(t=>{return this.setup(t),this})}delete(){return this.client.rest.methods.deleteWebhook(this)}}t.exports=r},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,h,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}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),u=n.slice(),s=u.length,h=0;h0&&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){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},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,h=0;h1)for(var n=1;n=300)&&(i=new Error(e.statusText||"Unsuccessful HTTP response"),i.original=t,i.response=e,i.status=e.status)}catch(t){i=t}i?n.callback(i,e):n.callback(null,e)})}function f(t,e){var n=w("DELETE",t);return e&&n.end(e),n}var p;"undefined"!=typeof window?p=window:"undefined"!=typeof self?p=self:(console.warn("Using browser-only version of superagent in non-browser environment"),p=this);var m=n(62),g=n(75),_=n(26),E=n(74),w=e=t.exports=function(t,n){return"function"==typeof n?new e.Request("GET",t).end(n):1==arguments.length?new e.Request("GET",t):new e.Request(t,n)};e.Request=d,w.getXHR=function(){if(!(!p.XMLHttpRequest||p.location&&"file:"==p.location.protocol&&p.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only verison of superagent could not find XHR")};var v="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};w.serializeObject=s,w.parseString=o,w.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},w.serialize={"application/x-www-form-urlencoded":s,"application/json":JSON.stringify},w.parse={"application/x-www-form-urlencoded":o,"application/json":JSON.parse},l.prototype.get=function(t){return this.header[t.toLowerCase()]},l.prototype._setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=u(e);var n=c(e);for(var i in n)this[i]=n[i]},l.prototype._parseBody=function(t){var e=w.parse[this.type];return!e&&h(this.type)&&(e=w.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null},l.prototype._setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},l.prototype.toError=function(){var t=this.req,e=t.method,n=t.url,i="cannot "+e+" "+n+" ("+this.status+")",s=new Error(i);return s.status=this.status,s.method=e,s.url=n,s},w.Response=l,m(d.prototype),g(d.prototype),d.prototype.type=function(t){return this.set("Content-Type",w.types[t]||t),this},d.prototype.responseType=function(t){return this._responseType=t,this},d.prototype.accept=function(t){return this.set("Accept",w.types[t]||t),this},d.prototype.auth=function(t,e,n){switch(n||(n={type:"basic"}),n.type){case"basic":var i=btoa(t+":"+e);this.set("Authorization","Basic "+i);break;case"auto":this.username=t,this.password=e}return this},d.prototype.query=function(t){return"string"!=typeof t&&(t=s(t)),t&&this._query.push(t),this},d.prototype.attach=function(t,e,n){if(this._data)throw Error("superagent can't mix .send() and .attach()");return this._getFormData().append(t,e,n||e.name),this},d.prototype._getFormData=function(){return this._formData||(this._formData=new p.FormData),this._formData},d.prototype.callback=function(t,e){var n=this._callback;this.clearTimeout(),t&&this.emit("error",t),n(t,e)},d.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},d.prototype.buffer=d.prototype.ca=d.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},d.prototype.pipe=d.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},d.prototype._timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},d.prototype._appendQueryString=function(){var t=this._query.join("&");t&&(this.url+=~this.url.indexOf("?")?"&"+t:"?"+t)},d.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},d.prototype.end=function(t){var e=this,n=this.xhr=w.getXHR(),s=this._timeout,r=this._formData||this._data;this._callback=t||i,n.onreadystatechange=function(){if(4==n.readyState){var t;try{t=n.status}catch(e){t=0}if(0==t){if(e.timedout)return e._timeoutError();if(e._aborted)return;return e.crossDomainError()}e.emit("end")}};var o=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{n.onprogress=o.bind(null,"download"),n.upload&&(n.upload.onprogress=o.bind(null,"upload"))}catch(t){}if(s&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},s)),this._appendQueryString(),this._sort){var a=this.url.indexOf("?");if(~a){var u=this.url.substring(a+1).split("&");E(this._sort)?u.sort(this._sort):u.sort()}this.url=this.url.substring(0,a)+"?"+u.join("&")}if(this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0),this._withCredentials&&(n.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var c=this._header["content-type"],l=this._serializer||w.serialize[c?c.split(";")[0]:""];!l&&h(c)&&(l=w.serialize["application/json"]),l&&(r=l(r))}for(var d in this.header)null!=this.header[d]&&n.setRequestHeader(d,this.header[d]);return this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send("undefined"!=typeof r?r:null),this},w.get=function(t,e,n){var i=w("GET",t);return"function"==typeof e&&(n=e,e=null),e&&i.query(e),n&&i.end(n),i},w.head=function(t,e,n){var i=w("HEAD",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},w.options=function(t,e,n){var i=w("OPTIONS",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},w.del=f,w.delete=f,w.patch=function(t,e,n){var i=w("PATCH",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},w.post=function(t,e,n){var i=w("POST",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i},w.put=function(t,e,n){var i=w("PUT",t);return"function"==typeof e&&(n=e,e=null),e&&i.send(e),n&&i.end(n),i}},function(t,e){function n(t){return null!==t&&"object"==typeof t}t.exports=n},function(t,e){t.exports=function(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(const n in t){const i=t[n],s=e.indexOf(i);s&&e.splice(s,1)}return 0===e.length}},function(t,e){t.exports={name:"discord.js",version:"10.0.1",description:"A powerful library for interacting with the Discord API",main:"./src/index",types:"./typings/index.d.ts",scripts:{test:"eslint src && docgen --source src --custom docs/index.yml",docs:"docgen --source src --custom docs/index.yml --output docs/docs.json","test-docs":"docgen --source src --custom docs",lint:"eslint src","web-dist":"node ./node_modules/parallel-webpack/bin/run.js"},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",dependencies:{"@types/node":"^6.0.51",pako:"^1.0.3",superagent:"^3.0.0",tweetnacl:"^0.14.3",ws:"^1.1.1"},peerDependencies:{"node-opus":"^0.2.0",opusscript:"^0.0.1",uws:"^0.11.1"},devDependencies:{bufferutil:"^1.2.1","discord.js-docgen":"github:hydrabolt/discord.js-docgen",eslint:"^3.10.0","jsdoc-to-markdown":"^2.0.0","json-loader":"^0.5.4","parallel-webpack":"^1.5.0","uglify-js":"github:mishoo/UglifyJS2#harmony","utf-8-validate":"^1.2.1",webpack:"2.1.0-beta.27"},engines:{node:">=6.0.0"},browser:{ws:!1,uws:!1,opusscript:!1,"node-opus":!1,"tweet-nacl":!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/player/BasePlayer.js":!1,"src/client/voice/player/DefaultPlayer.js":!1,"src/client/voice/receiver/VoiceReadable.js":!1,"src/client/voice/receiver/VoiceReceiver.js":!1,"src/client/voice/util/SecretKey.js":!1,"src/client/voice/ClientVoiceManager.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(6),s=n(38);class r extends s{setup(t){super.setup(t),this.flags=t.flags,this.owner=new i(this.client,t.owner)}}t.exports=r},function(t,e,n){const i=n(6),s=n(3);class r extends i{setup(t){super.setup(t),this.verified=t.verified,this.email=t.email,this.localPresence={},this._typing=new Map,this.friends=new s,this.blocked=new s,this.notes=new s}edit(t){return this.client.rest.methods.updateCurrentUser(t)}setUsername(t){return this.client.rest.methods.updateCurrentUser({username:t})}setEmail(t){return this.client.rest.methods.updateCurrentUser({email:t})}setPassword(t){return this.client.rest.methods.updateCurrentUser({password:t})}setAvatar(t){return t.startsWith("data:")?this.client.rest.methods.updateCurrentUser({avatar:t}):this.client.resolver.resolveBuffer(t).then(t=>this.client.rest.methods.updateCurrentUser({avatar:t}))}setStatus(t){return this.setPresence({status:t})}setGame(t,e){return this.setPresence({game:{name:t,url:e}})}setAFK(t){return this.setPresence({afk:t})}addFriend(t){return t=this.client.resolver.resolveUser(t),this.client.rest.methods.addFriend(t)}removeFriend(t){return t=this.client.resolver.resolveUser(t),this.client.rest.methods.removeFriend(t)}createGuild(t,e,n=null){return n?n.startsWith("data:")?this.client.rest.methods.createGuild({name:t,icon:n,region:e}):this.client.resolver.resolveBuffer(n).then(n=>this.client.rest.methods.createGuild({name:t,icon:n,region:e})):this.client.rest.methods.createGuild({name:t,icon:n,region:e})}setPresence(t){return new Promise(e=>{let n=this.localPresence.status||this.presence.status,i=this.localPresence.game,s=this.localPresence.afk||this.presence.afk;if(!i&&this.presence.game&&(i={name:this.presence.game.name,type:this.presence.game.type,url:this.presence.game.url}),t.status){if("string"!=typeof t.status)throw new TypeError("Status must be a string");n=t.status}t.game&&(i=t.game,i.url&&(i.type=1)),"undefined"!=typeof t.afk&&(s=t.afk),s=Boolean(s),this.localPresence={status:n,game:i,afk:s},this.localPresence.since=0,this.localPresence.game=this.localPresence.game||null,this.client.ws.send({op:3,d:this.localPresence}),this.client._setPresence(this.id,this.localPresence),e(this)})}}t.exports=r},function(t,e,n){const i=n(9),s=n(11),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()}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}s.applyToClass(o,!0),t.exports=o},function(t,e,n){const i=n(9),s=n(11),r=n(3),o=n(27);class a extends i{constructor(t,e){super(t,e),this.type="group",this.messages=new r,this._typing=new Map}setup(t){if(super.setup(t),this.name=t.name,this.icon=t.icon,this.ownerID=t.owner_id,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;if(e){const e=this.recipients.keyArray(),n=t.recipients.keyArray();return o(e,n)}return e}toString(){return this.name}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}s.applyToClass(a,!0),t.exports=a},function(t,e,n){const i=n(39),s=n(40),r=n(0);class o{constructor(t,e){this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(e)}setup(t){this.guild=this.client.guilds.get(t.guild.id)||new i(this.client,t.guild),this.code=t.code,this.temporary=t.temporary,this.maxAge=t.max_age,this.uses=t.uses,this.maxUses=t.max_uses,t.inviter&&(this.inviter=this.client.dataManager.newUser(t.inviter)),this.channel=this.client.channels.get(t.channel.id)||new s(this.client,t.channel),this.createdTimestamp=new Date(t.created_at).getTime()}get createdAt(){return new Date(this.createdTimestamp)}get expiresTimestamp(){return this.createdTimestamp+1e3*this.maxAge}get expiresAt(){return new Date(this.expiresTimestamp)}get url(){return r.Endpoints.inviteLink(this.code)}delete(){return this.client.rest.methods.deleteInvite(this)}toString(){return this.url}}t.exports=o},function(t,e){class n{constructor(t,e){this.client=t.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),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(21).EventEmitter,s=n(3);class r extends i{constructor(t,e,n={}){super(),this.channel=t,this.filter=e,this.options=n,this.ended=!1,this.collected=new s,this.listener=(t=>this.verify(t)),this.channel.client.on("message",this.listener),n.time&&this.channel.client.setTimeout(()=>this.stop("time"),n.time)}verify(t){return(!this.channel||this.channel.id===t.channel.id)&&(!!this.filter(t,this)&&(this.collected.set(t.id,t),this.emit("message",t,this),this.collected.size>=this.options.maxMatches?this.stop("matchesLimit"):this.options.max&&this.collected.size===this.options.max&&this.stop("limit"),!0))}get next(){return new Promise((t,e)=>{if(this.ended)return void e(this.collected);const n=()=>{this.removeListener("message",i),this.removeListener("end",s)},i=(...e)=>{n(),t(...e)},s=(...t)=>{n(),e(...t)};this.once("message",i),this.once("end",s)})}stop(t="user"){this.ended||(this.ended=!0,this.channel.client.removeListener("message",this.listener),this.emit("end",this.collected,t))}}t.exports=r},function(t,e){class n{constructor(t,e){this.client=t.client,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.message=t,this.setup(e)}setup(t){if(this.title=t.title,this.type=t.type,this.description=t.description,this.url=t.url,this.fields=[],t.fields)for(const e of t.fields)this.fields.push(new o(this,e));this.createdTimestamp=t.timestamp,this.thumbnail=t.thumbnail?new i(this,t.thumbnail):null,this.author=t.author?new r(this,t.author):null,this.provider=t.provider?new s(this,t.provider):null,this.footer=t.footer?new a(this,t.footer):null}get createdAt(){return new Date(this.createdTimestamp)}}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.name=t.name,this.url=t.url}}class r{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.url=t.url}}class o{constructor(t,e){this.embed=t,this.setup(e)}setup(t){this.name=t.name,this.value=t.value,this.inline=t.inline}}class a{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.Provider=s,n.Author=r,n.Field=o,n.Footer=a,t.exports=n},function(t,e,n){const i=n(3),s=n(10),r=n(19);class o{constructor(t,e,n,s){this.message=t,this.me=s,this.count=n||0,this.users=new i,this._emoji=new r(this,e.name,e.id)}get emoji(){if(this._emoji instanceof s)return this._emoji;if(this._emoji.id){const t=this.message.client.emojis;if(t.has(this._emoji.id)){const e=t.get(this._emoji.id);return this._emoji=e,e}}return this._emoji}remove(t=this.message.client.user){const e=this.message;return t=this.message.client.resolver.resolveUserID(t),t?e.client.rest.methods.removeMessageReaction(e,this.emoji.identifier,t):Promise.reject("Couldn't resolve the user ID to remove from the reaction.")}fetchUsers(t=100){const e=this.message;return e.client.rest.methods.getMessageReactionUsers(e,this.emoji.identifier,t).then(t=>{this.users=new i;for(const e of t){const t=this.message.client.dataManager.newUser(e);this.users.set(t.id,t)}return this.count=this.users.size,t})}}t.exports=o},function(t,e){class n{constructor(t,e){this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),this.setup(e)}setup(t){this.id=t.id,this.name=t.name,this.description=t.description,this.icon=t.icon,this.iconURL=`https://cdn.discordapp.com/app-icons/${this.id}/${this.icon}.jpg`,this.rpcOrigins=t.rpc_origins}get createdTimestamp(){return this.id/4194304+14200704e5}get createdAt(){return new Date(this.createdTimestamp)}toString(){return this.name}}t.exports=n},function(t,e){class n{constructor(t,e){this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),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){this.client=t,Object.defineProperty(this,"client",{enumerable:!1,configurable:!1}),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){this.channel=t,e&&this.setup(e)}setup(t){this.id=t.id,this.type=t.type,this.denyData=t.deny,this.allowData=t.allow}delete(){return this.channel.client.rest.methods.deletePermissionOverwrites(this)}}t.exports=n},function(t,e,n){const i=n(12),s=n(11),r=n(3);class o extends i{constructor(t,e){super(t,e),this.type="text",this.messages=new r,this._typing=new Map}setup(t){super.setup(t),this.topic=t.topic,this.lastMessageID=t.last_message_id}get members(){const t=new r;for(const e of this.guild.members.values())this.permissionsFor(e).hasPermission("READ_MESSAGES")&&t.set(e.id,e);return t}fetchWebhooks(){return this.client.rest.methods.getChannelWebhooks(this)}createWebhook(t,e){return new Promise(n=>{e.startsWith("data:")?n(this.client.rest.methods.createWebhook(this,t,e)):this.client.resolver.resolveBuffer(e).then(e=>n(this.client.rest.methods.createWebhook(this,t,e)))})}sendMessage(){}sendTTSMessage(){}sendFile(){}sendCode(){}fetchMessage(){}fetchMessages(){}fetchPinnedMessages(){}startTyping(){}stopTyping(){}get typing(){}get typingCount(){}createCollector(){}awaitMessages(){}bulkDelete(){}_cacheMessage(){}}s.applyToClass(o,!0),t.exports=o},function(t,e,n){const i=n(12),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 joinable(){return!this.client.browser&&this.permissionsFor(this.client.user).hasPermission("CONNECT")}get speakable(){return this.permissionsFor(this.client.user).hasPermission("SPEAK")}setBitrate(t){return this.edit({bitrate:t})}setUserLimit(t){return this.edit({userLimit:t})}join(){return this.client.browser?Promise.reject(new Error("Voice connections are not available in browsers.")):this.client.voice.joinChannel(this)}leave(){if(!this.client.browser){const t=this.client.voice.connections.get(this.guild.id);t&&t.channel.id===this.id&&t.disconnect()}}}t.exports=r},function(t,e){t.exports=function(t,{maxLength=1950,char="\n",prepend="",append=""}={}){if(t.length<=maxLength)return t;const e=t.split(char);if(1===e.length)throw new Error("Message exceeds the max length and contains no split characters.");const n=[""];let i=0;for(let s=0;smaxLength&&(n[i]+=append,n.push(prepend),i++),n[i]+=(n[i].length>0&&n[i]!==prepend?char:"")+e[s];return n}},function(t,e,n){"use strict";function i(t,e){if(e<65537&&(t.subarray&&o||!t.subarray&&r))return String.fromCharCode.apply(null,s.shrinkBuf(t,e));for(var n="",i=0;i=252?6:h>=248?5:h>=240?4:h>=224?3:h>=192?2:1;a[254]=a[254]=1,e.string2buf=function(t){var e,n,i,r,o,a=t.length,h=0;for(r=0;r>>6,e[o++]=128|63&n):n<65536?(e[o++]=224|n>>>12,e[o++]=128|n>>>6&63,e[o++]=128|63&n):(e[o++]=240|n>>>18,e[o++]=128|n>>>12&63,e[o++]=128|n>>>6&63,e[o++]=128|63&n);return e},e.buf2binstring=function(t){return i(t,t.length)},e.binstring2buf=function(t){for(var e=new s.Buf8(t.length),n=0,i=e.length;n4)u[s++]=65533,n+=o-1;else{for(r&=2===o?31:3===o?15:7;o>1&&n1?u[s++]=65533:r<65536?u[s++]=r:(r-=65536,u[s++]=55296|r>>10&1023,