diff --git a/discord.master.js b/discord.master.js index e0e8fab1..4438bba4 100644 --- a/discord.master.js +++ b/discord.master.js @@ -2361,7 +2361,7 @@ class Role { * @type {number} */ get calculatedPosition() { - const sorted = this.guild._sortedRoles(); + const sorted = this.guild._sortedRoles; return sorted.array().indexOf(sorted.get(this.id)); } diff --git a/discord.master.min.js b/discord.master.min.js index cb55c9c6..fdff176e 100644 --- a/discord.master.min.js +++ b/discord.master.min.js @@ -1,6 +1,6 @@ !function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var i={};return e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=144)}([function(t,e,i){(function(t){e.Package=i(28),e.DefaultOptions={apiRequestMethod:"sequential",shardId:0,shardCount:0,messageCacheMaxSize:200,messageCacheLifetime:0,messageSweepInterval:0,fetchAllMembers:!1,disableEveryone:!1,sync:!1,restWsBridgeTimeout:5e3,disabledEvents:[],restTimeOffset:500,ws:{large_threshold:250,compress:"browser"!==i(16).platform(),properties:{$os:t?t.platform:"discord.js",$browser:"discord.js",$device:"discord.js",$referrer:"",$referring_domain:""},version:6},http:{version:6,host:"https://discordapp.com",cdn:"https://cdn.discordapp.com"}},e.Errors={NO_TOKEN:"Request to use token, but token was unavailable to the client.",NO_BOT_ACCOUNT:"Only bot accounts are able to make use of this feature.",NO_USER_ACCOUNT:"Only user accounts are able to make use of this feature.",BAD_WS_MESSAGE:"A bad message was received from the websocket; either bad compression, or not JSON.",TOOK_TOO_LONG:"Something took too long to do.",NOT_A_PERMISSION:"Invalid permission string or number.",INVALID_RATE_LIMIT_METHOD:"Unknown rate limiting method.",BAD_LOGIN:"Incorrect login details were provided.",INVALID_SHARD:"Invalid shard settings were provided.",SHARDING_REQUIRED:"This session would have handled too many guilds - Sharding is required.",INVALID_TOKEN:"An invalid token was provided."};const n=e.Endpoints={User:t=>{t.id&&(t=t.id);const e=`/users/${t}`;return{toString:()=>e,channels:`${e}/channels`,profile:`${e}/profile`,relationships:`${e}/relationships`,Relationship:t=>`${e}/relationships/${t}`,Guild:t=>`${e}/guilds/${t}`,Note:t=>`${e}/notes/${t}`,Mentions:(t,i,n,s)=>`${e}/mentions?limit=${t}&roles=${i}&everyone=${n}${s?`&guild_id=${s}`:""}`,Avatar:(e,i)=>{return"1"===t?i:n.CDN(e).Avatar(t,i)}}},guilds:"/guilds",Guild:t=>{t.id&&(t=t.id);const e=`/guilds/${t}`;return{toString:()=>e,prune:`${e}/prune`,embed:`${e}/embed`,bans:`${e}/bans`,integrations:`${e}/integrations`,members:`${e}/members`,channels:`${e}/channels`,invites:`${e}/invites`,roles:`${e}/roles`,emojis:`${e}/emojis`,search:`${e}/messages/search`,voiceRegions:`${e}/regions`,webhooks:`${e}/webhooks`,ack:`${e}/ack`,settings:`${e}/settings`,Emoji:t=>`${e}/emojis/${t}`,Icon:(e,i)=>n.CDN(e).Icon(t,i),Splash:(e,i)=>n.CDN(e).Splash(t,i),Role:t=>`${e}/roles/${t}`,Member:t=>{t.id&&(t=t.id);const i=`${e}/members/${t}`;return{toString:()=>i,Role:t=>`${i}/roles/${t}`,nickname:`${e}/members/@me/nick`}}}},channels:"/channels",Channel:t=>{t.id&&(t=t.id);const e=`/channels/${t}`;return{toString:()=>e,messages:{toString:()=>`${e}/messages`,bulkDelete:`${e}/messages/bulk-delete`},invites:`${e}/invites`,typing:`${e}/typing`,permissions:`${e}/permissions`,webhooks:`${e}/webhooks`,search:`${e}/search`,ack:`${e}/ack`,pins:`${e}/pins`,Pin:t=>`${e}/pins/${t}`,Recipient:t=>`${e}/recipients/${t}`,Message:t=>{t.id&&(t=t.id);const i=`${e}/messages/${t}`;return{toString:()=>i,reactions:`${i}/reactions`,ack:`${e}/ack`,Reaction:(t,e)=>{const n=`${i}/reactions/${t}${e?`?limit=${e}`:""}`;return{toString:()=>n,User:t=>`${n}/${t}`}}}}}},Message:t=>e.Endpoints.Channel(t.channel).Message(t),Member:t=>e.Endpoints.Guild(t.guild).Member(t),CDN(t){return{Emoji:e=>`${t}/emojis/$${e}.png`,Asset:e=>`${t}/assets/${e}`,Avatar:(e,i)=>`${t}/avatars/${e}/${i}.${i.startsWith("a_")?"gif":"png"}?size=2048`,Icon:(e,i)=>`${t}/icons/${e}/${i}.jpg`,Splash:(e,i)=>`${t}/splashes/${e}/${i}.jpg`}},OAUTH2:{Application:t=>{const e=`/oauth2/applications/${t}`;return{toString:()=>e,reset:`${e}/reset`}},App:t=>`/oauth2/authorize?client_id=${t}`},login:"/auth/login",logout:"/auth/logout",voiceRegions:"/voice/regions",gateway:{toString:()=>"/gateway",bot:"/gateway/bot"},Invite:t=>`/invite/${t}`,Webhook:(t,e)=>`/webhooks/${t}${e?`/${e}`:""}`};e.Status={READY:0,CONNECTING:1,RECONNECTING:2,IDLE:3,NEARLY:4,DISCONNECTED:5},e.VoiceStatus={CONNECTED:0,CONNECTING:1,AUTHENTICATING:2,RECONNECTING:3,DISCONNECTED:4},e.ChannelTypes={TEXT:0,DM:1,VOICE:2,GROUP_DM:3},e.OPCodes={DISPATCH:0,HEARTBEAT:1,IDENTIFY:2,STATUS_UPDATE:3,VOICE_STATE_UPDATE:4,VOICE_GUILD_PING:5,RESUME:6,RECONNECT:7,REQUEST_GUILD_MEMBERS:8,INVALID_SESSION:9,HELLO:10,HEARTBEAT_ACK:11},e.VoiceOPCodes={IDENTIFY:0,SELECT_PROTOCOL:1,READY:2,HEARTBEAT:3,SESSION_DESCRIPTION:4,SPEAKING:5},e.Events={READY:"ready",GUILD_CREATE:"guildCreate",GUILD_DELETE:"guildDelete",GUILD_UPDATE:"guildUpdate",GUILD_UNAVAILABLE:"guildUnavailable",GUILD_AVAILABLE:"guildAvailable",GUILD_MEMBER_ADD:"guildMemberAdd",GUILD_MEMBER_REMOVE:"guildMemberRemove",GUILD_MEMBER_UPDATE:"guildMemberUpdate",GUILD_MEMBER_AVAILABLE:"guildMemberAvailable",GUILD_MEMBER_SPEAKING:"guildMemberSpeaking",GUILD_MEMBERS_CHUNK:"guildMembersChunk",GUILD_ROLE_CREATE:"roleCreate",GUILD_ROLE_DELETE:"roleDelete",GUILD_ROLE_UPDATE:"roleUpdate",GUILD_EMOJI_CREATE:"emojiCreate",GUILD_EMOJI_DELETE:"emojiDelete",GUILD_EMOJI_UPDATE:"emojiUpdate",GUILD_BAN_ADD:"guildBanAdd",GUILD_BAN_REMOVE:"guildBanRemove",CHANNEL_CREATE:"channelCreate",CHANNEL_DELETE:"channelDelete",CHANNEL_UPDATE:"channelUpdate",CHANNEL_PINS_UPDATE:"channelPinsUpdate",MESSAGE_CREATE:"message",MESSAGE_DELETE:"messageDelete",MESSAGE_UPDATE:"messageUpdate",MESSAGE_BULK_DELETE:"messageDeleteBulk",MESSAGE_REACTION_ADD:"messageReactionAdd",MESSAGE_REACTION_REMOVE:"messageReactionRemove",MESSAGE_REACTION_REMOVE_ALL:"messageReactionRemoveAll",USER_UPDATE:"userUpdate",USER_NOTE_UPDATE:"userNoteUpdate",PRESENCE_UPDATE:"presenceUpdate",VOICE_STATE_UPDATE:"voiceStateUpdate",TYPING_START:"typingStart",TYPING_STOP:"typingStop",DISCONNECT:"disconnect",RECONNECTING:"reconnecting",ERROR:"error",WARN:"warn",DEBUG:"debug"},e.WSEvents={READY:"READY",GUILD_SYNC:"GUILD_SYNC",GUILD_CREATE:"GUILD_CREATE",GUILD_DELETE:"GUILD_DELETE",GUILD_UPDATE:"GUILD_UPDATE",GUILD_MEMBER_ADD:"GUILD_MEMBER_ADD",GUILD_MEMBER_REMOVE:"GUILD_MEMBER_REMOVE",GUILD_MEMBER_UPDATE:"GUILD_MEMBER_UPDATE",GUILD_MEMBERS_CHUNK:"GUILD_MEMBERS_CHUNK",GUILD_ROLE_CREATE:"GUILD_ROLE_CREATE",GUILD_ROLE_DELETE:"GUILD_ROLE_DELETE",GUILD_ROLE_UPDATE:"GUILD_ROLE_UPDATE",GUILD_BAN_ADD:"GUILD_BAN_ADD",GUILD_BAN_REMOVE:"GUILD_BAN_REMOVE",GUILD_EMOJIS_UPDATE:"GUILD_EMOJIS_UPDATE",CHANNEL_CREATE:"CHANNEL_CREATE",CHANNEL_DELETE:"CHANNEL_DELETE",CHANNEL_UPDATE:"CHANNEL_UPDATE",CHANNEL_PINS_UPDATE:"CHANNEL_PINS_UPDATE",MESSAGE_CREATE:"MESSAGE_CREATE",MESSAGE_DELETE:"MESSAGE_DELETE",MESSAGE_UPDATE:"MESSAGE_UPDATE",MESSAGE_DELETE_BULK:"MESSAGE_DELETE_BULK",MESSAGE_REACTION_ADD:"MESSAGE_REACTION_ADD",MESSAGE_REACTION_REMOVE:"MESSAGE_REACTION_REMOVE",MESSAGE_REACTION_REMOVE_ALL:"MESSAGE_REACTION_REMOVE_ALL",USER_UPDATE:"USER_UPDATE",USER_NOTE_UPDATE:"USER_NOTE_UPDATE",PRESENCE_UPDATE:"PRESENCE_UPDATE",VOICE_STATE_UPDATE:"VOICE_STATE_UPDATE",TYPING_START:"TYPING_START",VOICE_SERVER_UPDATE:"VOICE_SERVER_UPDATE",RELATIONSHIP_ADD:"RELATIONSHIP_ADD",RELATIONSHIP_REMOVE:"RELATIONSHIP_REMOVE"},e.MessageTypes=["DEFAULT","RECIPIENT_ADD","RECIPIENT_REMOVE","CALL","CHANNEL_NAME_CHANGE","CHANNEL_ICON_CHANGE","PINS_ADD","GUILD_MEMBER_JOIN"],e.DefaultAvatars={BLURPLE:"6debd47ed13483642cf09e832ed0bc1b",GREY:"322c936a8c8be1b803cd94861bdfa868",GREEN:"dd4dbc0016779df1378e7812eabaa04d",ORANGE:"0e291f67c9274a1abdddeb3fd919cbaa",RED:"1cbd08c76f8af6dddce02c5138971129"},e.Colors={DEFAULT:0,AQUA:1752220,GREEN:3066993,BLUE:3447003,PURPLE:10181046,GOLD:15844367,ORANGE:15105570,RED:15158332,GREY:9807270,NAVY:3426654,DARK_AQUA:1146986,DARK_GREEN:2067276,DARK_BLUE:2123412,DARK_PURPLE:7419530,DARK_GOLD:12745742,DARK_ORANGE:11027200,DARK_RED:10038562,DARK_GREY:9936031,DARKER_GREY:8359053,LIGHT_GREY:12370112,DARK_NAVY:2899536,BLURPLE:7506394,GREYPLE:10070709,DARK_BUT_NOT_BLACK:2895667,NOT_QUITE_BLACK:2303786}}).call(e,i(20))},function(t,e){class i{constructor(t){this.packetManager=t}handle(t){return t}}t.exports=i},function(t,e){class i{constructor(t){this.client=t}handle(t){return t}}t.exports=i},function(t,e){class i extends Map{constructor(t){super(t),Object.defineProperty(this,"_array",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"_keyArray",{value:null,writable:!0,configurable:!0})}set(t,e){return this._array=null,this._keyArray=null,super.set(t,e)}delete(t){return this._array=null,this._keyArray=null,super.delete(t)}array(){return this._array&&this._array.length===this.size||(this._array=Array.from(this.values())),this._array}keyArray(){return this._keyArray&&this._keyArray.length===this.size||(this._keyArray=Array.from(this.keys())),this._keyArray}first(){return this.values().next().value}firstKey(){return this.keys().next().value}last(){const t=this.array();return t[t.length-1]}lastKey(){const t=this.keyArray();return t[t.length-1]}random(){const t=this.array();return t[Math.floor(Math.random()*t.length)]}randomKey(){const t=this.keyArray();return t[Math.floor(Math.random()*t.length)]}findAll(t,e){if("string"!=typeof t)throw new TypeError("Key must be a string.");if("undefined"==typeof e)throw new Error("Value must be specified.");const i=[];for(const n of this.values())n[t]===e&&i.push(n);return i}find(t,e){if("string"==typeof t){if("undefined"==typeof e)throw new Error("Value must be specified.");for(const i of this.values())if(i[t]===e)return i;return null}if("function"==typeof t){for(const[e,i]of this)if(t(i,e,this))return i;return null}throw new Error("First argument must be a property string or a function.")}findKey(t,e){if("string"==typeof t){if("undefined"==typeof e)throw new Error("Value must be specified.");for(const[i,n]of this)if(n[t]===e)return i;return null}if("function"==typeof t){for(const[e,i]of this)if(t(i,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 n=new i;for(const[s,o]of this)t(o,s,this)&&n.set(s,o);return n}filterArray(t,e){e&&(t=t.bind(e));const i=[];for(const[n,s]of this)t(s,n,this)&&i.push(s);return i}map(t,e){e&&(t=t.bind(e));const i=new Array(this.size);let n=0;for(const[s,o]of this)i[n++]=t(o,s,this);return i}some(t,e){e&&(t=t.bind(e));for(const[i,n]of this)if(t(n,i,this))return!0;return!1}every(t,e){e&&(t=t.bind(e));for(const[i,n]of this)if(!t(n,i,this))return!1;return!0}reduce(t,e){let i;if("undefined"!=typeof e){i=e;for(const[n,s]of this)i=t(i,s,n,this)}else{let e=!0;for(const[n,s]of this)e?(i=s,e=!1):i=t(i,s,n,this)}return i}clone(){return new this.constructor(this)}concat(...t){const e=this.clone();for(const i of t)for(const[n,s]of i)e.set(n,s);return e}deleteAll(){const t=[];for(const e of this.values())e.delete&&t.push(e.delete());return t}equals(t){return!!t&&(this===t||this.size===t.size&&!this.find((e,i)=>{const n=t.get(i);return n!==e||void 0===n&&!t.has(i)}))}sort(t=(t,e)=>+(t>e)||+(t===e)-1){return new i(Array.from(this.entries()).sort((e,i)=>t(e[1],i[1],e[0],i[0])))}}t.exports=i},function(t,e,i){(function(e){const n=i(26),s=i(0);class o{constructor(){throw new Error(`The ${this.constructor.name} class may not be instantiated.`)}static splitMessage(t,{maxLength=1950,char="\n",prepend="",append=""}={}){if(t.length<=maxLength)return t;const e=t.split(char);if(1===e.length)throw new Error("Message exceeds the max length and contains no split characters.");const i=[""];let n=0;for(let s=0;smaxLength&&(i[n]+=append,i.push(prepend),n++),i[n]+=(i[n].length>0&&i[n]!==prepend?char:"")+e[s];return i}static escapeMarkdown(t,e=false,i=false){return e?t.replace(/```/g,"`​``"):i?t.replace(/\\(`|\\)/g,"$1").replace(/(`|\\)/g,"\\$1"):t.replace(/\\(\*|_|`|~|\\)/g,"$1").replace(/(\*|_|`|~|\\)/g,"\\$1")}static fetchRecommendedShards(t,e=1e3){return new Promise((i,o)=>{if(!t)throw new Error("A token must be provided.");n.get(s.Endpoints.gateway.bot).set("Authorization",`Bot ${t.replace(/^Bot\s*/i,"")}`).end((t,n)=>{t&&o(t),i(n.body.shards*(1e3/e))})})}static parseEmoji(t){if(t.includes("%")&&(t=decodeURIComponent(t)),t.includes(":")){const[e,i]=t.split(":");return{name:e,id:i}}return{name:t,id:null}}static arraysEqual(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(const i in t){const n=t[i],s=e.indexOf(n);s&&e.splice(s,1)}return 0===e.length}static cloneObject(t){return Object.assign(Object.create(t),t)}static mergeDefault(t,e){if(!e)return t;for(const i in t)({}).hasOwnProperty.call(e,i)?e[i]===Object(e[i])&&(e[i]=this.mergeDefault(t[i],e[i])):e[i]=t[i];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),i=new Uint16Array(e);for(var n=0,s=t.length;n-1&&i=e?String(t):(String(i).repeat(e)+t).slice(-e)}const s=i(25),o=14200704e5;let r=0;class a{static generate(){r>=4095&&(r=0);const t=`${n((Date.now()-o).toString(2),42)}0000100000${n((r++).toString(2),12)}`;return s.fromString(t,2).toString()}static deconstruct(t){const e=n(s.fromString(t).toString(2),64),i={timestamp:parseInt(e.substring(0,42),2)+o,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(i,"date",{get:function(){return new Date(this.timestamp)},enumerable:!0}),i}}t.exports=a},function(t,e,i){const n=i(0);class s{constructor(t,e){e="object"!=typeof t||t instanceof Array?t:e,this.member="object"==typeof t?t:null,this.bitfield="number"==typeof e?e:this.constructor.resolve(e)}get raw(){return this.bitfield}set raw(t){this.bitfield=t}has(t,e=true){return t instanceof Array?t.every(t=>this.has(t,e)):(t=this.constructor.resolve(t),!!(e&&(this.bitfield&this.constructor.FLAGS.ADMINISTRATOR)>0)||(this.bitfield&t)===t)}missing(t,e=true){return t.filter(t=>!this.has(t,e))}add(...t){let e=0;for(let i=0;ithis.resolve(t)).reduce((t,e)=>t|e,0);if("string"==typeof t&&(t=this.FLAGS[t]),"number"!=typeof t||t<1)throw new RangeError(n.Errors.NOT_A_PERMISSION);return t}}s.FLAGS={CREATE_INSTANT_INVITE:1,KICK_MEMBERS:2,BAN_MEMBERS:4,ADMINISTRATOR:8,MANAGE_CHANNELS:16,MANAGE_GUILD:32,ADD_REACTIONS:64,READ_MESSAGES:1024,SEND_MESSAGES:2048,SEND_TTS_MESSAGES:4096,MANAGE_MESSAGES:8192,EMBED_LINKS:16384,ATTACH_FILES:32768,READ_MESSAGE_HISTORY:65536,MENTION_EVERYONE:1<<17,EXTERNAL_EMOJIS:1<<18,USE_EXTERNAL_EMOJIS:1<<18,CONNECT:1<<20,SPEAK:1<<21,MUTE_MEMBERS:1<<22,DEAFEN_MEMBERS:1<<23,MOVE_MEMBERS:1<<24,USE_VAD:1<<25,CHANGE_NICKNAME:1<<26,MANAGE_NICKNAMES:1<<27,MANAGE_ROLES:1<<28,MANAGE_ROLES_OR_PERMISSIONS:1<<28,MANAGE_WEBHOOKS:1<<29,MANAGE_EMOJIS:1<<30},s.ALL=Object.keys(s.FLAGS).reduce((t,e)=>t|s.FLAGS[e],0),s.DEFAULT=104324097,t.exports=s},function(t,e){class i{constructor(t={}){this.status=t.status||"offline",this.game=t.game?new n(t.game):null}update(t){this.status=t.status||this.status,this.game=t.game?new n(t.game):null}equals(t){return this===t||(t&&this.status===t.status&&this.game?this.game.equals(t.game):!t.game)}}class n{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=i,e.Game=n},function(t,e,i){const n=i(5);class s{constructor(t,e){Object.defineProperty(this,"client",{value:t}),this.type=null,e&&this.setup(e)}setup(t){this.id=t.id}get createdTimestamp(){return n.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}delete(){return this.client.rest.methods.deleteChannel(this)}}t.exports=s},function(t,e,i){const n=i(32),s=i(34),o=i(35),r=i(4),a=i(3),c=i(0),l=i(6);let u;class h{constructor(t,e,i){Object.defineProperty(this,"client",{value:i}),this.channel=t,e&&this.setup(e)}setup(t){this.id=t.id,this.type=c.MessageTypes[t.type],this.content=t.content,this.author=this.client.dataManager.newUser(t.author),this.member=this.guild?this.guild.member(this.author)||null:null,this.pinned=t.pinned,this.tts=t.tts,this.nonce=t.nonce,this.system=6===t.type,this.embeds=t.embeds.map(t=>new s(this,t)),this.attachments=new a;for(const e of t.attachments)this.attachments.set(e.id,new n(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 a,roles:new a,channels:new a,everyone:t.mention_everyone};for(const i of t.mentions){let t=this.client.users.get(i.id);t||(t=this.client.dataManager.newUser(i)),this.mentions.users.set(t.id,t)}if(Object.defineProperty(this.mentions,"members",{get:()=>{if("text"!==this.channel.type)return null;const t=new a;return this.mentions.users.forEach(e=>{const i=this.client.resolver.resolveGuildMember(this.channel.guild,e);i&&t.set(i.id,i)}),t}}),t.mention_roles)for(const i of t.mention_roles){const t=this.channel.guild.roles.get(i);t&&this.mentions.roles.set(t.id,t)}if("text"===this.channel.type){const e=t.content.match(/<#([0-9]{14,20})>/g)||[];for(const i of e){const t=this.channel.guild.channels.get(i.match(/([0-9]{14,20})/g)[0]);t&&this.mentions.channels.set(t.id,t)}}if(this._edits=[],this.reactions=new a,t.reactions&&t.reactions.length>0)for(const r of t.reactions){const t=r.emoji.id?`${r.emoji.name}:${r.emoji.id}`:r.emoji.name;this.reactions.set(t,new o(this,r.emoji,r.count,r.me))}this.webhookID=t.webhook_id||null,this.hit="boolean"==typeof t.hit?t.hit:null}get createdAt(){return new Date(this.createdTimestamp)}get editedAt(){return this.editedTimestamp?new Date(this.editedTimestamp):null}get guild(){return this.channel.guild||null}get cleanContent(){return this.content.replace(/@(everyone|here)/g,"@​$1").replace(/<@!?[0-9]+>/g,t=>{const e=t.replace(/<|!|>|@/g,"");if("dm"===this.channel.type||"group"===this.channel.type)return this.client.users.has(e)?`@${this.client.users.get(e).username}`:t;const i=this.channel.guild.members.get(e);if(i)return i.nickname?`@${i.nickname}`:`@${i.user.username}`;{const i=this.client.users.get(e);return i?`@${i.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(l.FLAGS.MANAGE_MESSAGES)}get pinnable(){return!this.guild||this.channel.permissionsFor(this.client.user).hasPermission(l.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 u||(u=i(13)),!!this.mentions.everyone||(!!this.mentions.users.has(t.id)||!!(t instanceof u&&t.roles.some(t=>this.mentions.roles.has(t.id))))}edit(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),this.client.rest.methods.updateMessage(this,t,e)}editCode(t,e){return e=r.escapeMarkdown(this.client.resolver.resolveString(e),!0),this.edit(`\`\`\`${t||""} ${e} -\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(t){if(t=this.client.resolver.resolveEmojiIdentifier(t),!t)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,t)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(t=0){return t<=0?this.client.rest.methods.deleteMessage(this):new Promise(e=>{this.client.setTimeout(()=>{e(this.delete())},t)})}reply(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),this.channel.send(t,Object.assign(e,{reply:this.member||this.author}))}acknowledge(){return this.client.rest.methods.ackMessage(this)}fetchWebhook(){return this.webhookID?this.client.fetchWebhook(this.webhookID):Promise.reject(new Error("The message was not sent by a webhook."))}equals(t,e){if(!t)return!1;const i=!t.author&&!t.attachments;if(i)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 i=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);let n;return this.reactions.has(i)?(n=this.reactions.get(i),n.me||(n.me=e.id===this.client.user.id)):(n=new o(this,t,0,e.id===this.client.user.id),this.reactions.set(i,n)),n.users.has(e.id)||n.users.set(e.id,e),n.count++,n}_removeReaction(t,e){const i=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);if(this.reactions.has(i)){const t=this.reactions.get(i);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=h},function(t,e,i){const n=i(5),s=i(6);class o{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 n.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get hexColor(){let t=this.color.toString(16);for(;t.length<6;)t=`0${t}`;return`#${t}`}get members(){return this.guild.members.filter(t=>t.roles.has(this.id))}get editable(){if(this.managed)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(s.FLAGS.MANAGE_ROLES_OR_PERMISSIONS)&&t.highestRole.comparePositionTo(this)>0}get calculatedPosition(){const t=this.guild._sortedRoles();return t.array().indexOf(t.get(this.id))}serialize(){return new s(this.permissions).serialize()}hasPermission(t,e=false,i){return new s(this.permissions).has(t,"undefined"!=typeof i?i:!e)}hasPermissions(t,e=false){return new s(this.permissions).has(t,!e)}comparePositionTo(t){return this.constructor.comparePositions(this,t)}edit(t){return this.client.rest.methods.updateGuildRole(this,t)}setName(t){return this.edit({name:t})}setColor(t){return this.edit({color:t})}setHoist(t){return this.edit({hoist:t})}setPosition(t,e){return this.guild.setRolePosition(this,t,e).then(()=>this)}setPermissions(t){return this.edit({permissions:t})}setMentionable(t){return this.edit({mentionable:t})}delete(){return this.client.rest.methods.deleteGuildRole(this)}equals(t){return t&&this.id===t.id&&this.name===t.name&&this.color===t.color&&this.hoist===t.hoist&&this.position===t.position&&this.permissions===t.permissions&&this.managed===t.managed}toString(){return this.id===this.guild.id?"@everyone":`<@&${this.id}>`}static comparePositions(t,e){return t.position===e.position?e.id-t.id:t.position-e.position}}t.exports=o},function(t,e,i){const n=i(15),s=i(0),o=i(7).Presence,r=i(5);class a{constructor(t,e){Object.defineProperty(this,"client",{value:t}),e&&this.setup(e)}setup(t){this.id=t.id,this.username=t.username,this.discriminator=t.discriminator,this.avatar=t.avatar,this.bot=Boolean(t.bot),this.lastMessageID=null,this.lastMessage=null}patch(t){for(const e of["id","username","discriminator","avatar","bot"])"undefined"!=typeof t[e]&&(this[e]=t[e]);t.token&&(this.client.token=t.token)}get createdTimestamp(){return r.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 o}get avatarURL(){return this.avatar?s.Endpoints.User(this).Avatar(this.client.options.http.cdn,this.avatar):null}get defaultAvatarURL(){const t=Object.keys(s.DefaultAvatars),e=t[this.discriminator%t.length];return s.Endpoints.assets(`${s.DefaultAvatars[e]}.png`)}get displayAvatarURL(){return this.avatarURL||this.defaultAvatarURL}get note(){return this.client.user.notes.get(this.id)||null}typingIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)}typingSinceIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?new Date(t._typing.get(this.id).since):null}typingDurationIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?t._typing.get(this.id).elapsedTime:-1}get dmChannel(){return this.client.channels.filter(t=>"dm"===t.type).find(t=>t.recipient.id===this.id)}createDM(){return this.client.rest.methods.createDM(this)}deleteDM(){return this.client.rest.methods.deleteChannel(this)}addFriend(){return this.client.rest.methods.addFriend(this)}removeFriend(){return this.client.rest.methods.removeFriend(this)}block(){return this.client.rest.methods.blockUser(this)}unblock(){return this.client.rest.methods.unblockUser(this)}fetchProfile(){return this.client.rest.methods.fetchUserProfile(this)}setNote(t){return this.client.rest.methods.setNote(this,t)}equals(t){let e=t&&this.id===t.id&&this.username===t.username&&this.discriminator===t.discriminator&&this.avatar===t.avatar&&this.bot===Boolean(t.bot);return e}toString(){return`<@${this.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}n.applyToClass(a),t.exports=a},function(t,e,i){const n=i(0),s=i(3),o=i(5);class r{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 o.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 n.Endpoints.emoji(this.id)}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}edit(t){return this.client.rest.methods.updateEmoji(this,t)}toString(){return this.requiresColons?`<:${this.name}:${this.id}>`:this.name}equals(t){return t instanceof r?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=r},function(t,e,i){const n=i(15),s=i(10),o=i(6),r=i(3),a=i(7).Presence;class c{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,this.user={},this._roles=[],e&&this.setup(e),this.lastMessageID=null,this.lastMessage=null}setup(t){this.serverDeaf=t.deaf,this.serverMute=t.mute,this.selfMute=t.self_mute,this.selfDeaf=t.self_deaf,this.voiceSessionID=t.session_id,this.voiceChannelID=t.channel_id,this.speaking=!1,this.nickname=t.nick||null,this.joinedTimestamp=new Date(t.joined_at).getTime(),this.user=t.user,this._roles=t.roles}get joinedAt(){return new Date(this.joinedTimestamp)}get presence(){return this.frozenPresence||this.guild.presences.get(this.id)||new a}get roles(){const t=new r,e=this.guild.roles.get(this.guild.id);e&&t.set(e.id,e);for(const i of this._roles){const e=this.guild.roles.get(i);e&&t.set(e.id,e)}return t}get highestRole(){return this.roles.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t)}get colorRole(){const t=this.roles.filter(t=>t.color);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get displayColor(){const t=this.colorRole;return t&&t.color||0}get displayHexColor(){const t=this.colorRole;return t&&t.hexColor||"#000000"}get hoistRole(){const t=this.roles.filter(t=>t.hoist);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get mute(){return this.selfMute||this.serverMute}get deaf(){return this.selfDeaf||this.serverDeaf}get voiceChannel(){return this.guild.channels.get(this.voiceChannelID)}get id(){return this.user.id}get displayName(){return this.nickname||this.user.username}get permissions(){if(this.user.id===this.guild.ownerID)return new o(this,o.ALL);let t=0;const e=this.roles;for(const i of e.values())t|=i.permissions;return new o(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.FLAGS.KICK_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}get bannable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(o.FLAGS.BAN_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(t){if(t=this.client.resolver.resolveChannel(t),!t||!t.guild)throw new Error("Could not resolve channel to a guild channel.");return t.permissionsFor(this)}hasPermission(t,e=false,i,n){return"undefined"==typeof i&&(i=!e),"undefined"==typeof n&&(n=!e),!(!n||this.user.id!==this.guild.ownerID)||this.roles.some(e=>e.hasPermission(t,void 0,i))}hasPermissions(t,e=false){return!e&&this.user.id===this.guild.ownerID||t.every(t=>this.hasPermission(t,e))}missingPermissions(t,e=false){return t.filter(t=>!this.hasPermission(t,e))}edit(t){return this.client.rest.methods.updateGuildMember(this,t)}setMute(t){return this.edit({mute:t})}setDeaf(t){return this.edit({deaf:t})}setVoiceChannel(t){return this.edit({channel:t})}setRoles(t){return this.edit({roles:t})}addRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.addMemberRole(this,t)}addRoles(t){let e;if(t instanceof r){e=this._roles.slice();for(const i of t.values())e.push(i.id)}else e=this._roles.concat(t);return this.edit({roles:e})}removeRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.removeMemberRole(this,t)}removeRoles(t){const e=this._roles.slice();if(t instanceof r)for(const i of t.values()){const t=e.indexOf(i.id);t>=0&&e.splice(t,1)}else for(const i of t){const t=e.indexOf(i instanceof s?i.id:i);t>=0&&e.splice(t,1)}return this.edit({roles:e})}setNickname(t){return this.edit({nick:t})}createDM(){return this.user.createDM()}deleteDM(){return this.user.deleteDM()}kick(){return this.client.rest.methods.kickGuildMember(this.guild,this)}ban(t=0){return this.client.rest.methods.banGuildMember(this.guild,this,t)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}n.applyToClass(c),t.exports=c},function(t,e,i){"use strict";(function(t){function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function s(){return r.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,e){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),r.alloc(+t)}function v(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 i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return K(t).length;default:if(n)return Y(t).length;e=(""+e).toLowerCase(),n=!0}}function E(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if(i>>>=0,e>>>=0,i<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,i);case"utf8":case"utf-8":return M(this,e,i);case"ascii":return I(this,e,i);case"latin1":case"binary":return U(this,e,i);case"base64":return D(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function b(t,e,i,n,s){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(s)return-1;i=t.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof e&&(e=r.from(e,n)),r.isBuffer(e))return 0===e.length?-1:w(t,e,i,n,s);if("number"==typeof e)return e&=255,r.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):w(t,[e],i,n,s);throw new TypeError("val must be string, number or Buffer")}function w(t,e,i,n,s){function o(t,e){return 1===r?t[e]:t.readUInt16BE(e*r)}var r=1,a=t.length,c=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;r=2,a/=2,c/=2,i/=2}var l;if(s){var u=-1;for(l=i;la&&(i=a-c),l=i;l>=0;l--){for(var h=!0,p=0;ps&&(n=s)):n=s;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var r=0;r239?4:o>223?3:o>191?2:1;if(s+a<=i){var c,l,u,h;switch(a){case 1:o<128&&(r=o);break;case 2:c=t[s+1],128===(192&c)&&(h=(31&o)<<6|63&c,h>127&&(r=h));break;case 3:c=t[s+1],l=t[s+2],128===(192&c)&&128===(192&l)&&(h=(15&o)<<12|(63&c)<<6|63&l,h>2047&&(h<55296||h>57343)&&(r=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&o)<<18|(63&c)<<12|(63&l)<<6|63&u,h>65535&&h<1114112&&(r=h))}}null===r?(r=65533,a=1):r>65535&&(r-=65536,n.push(r>>>10&1023|55296),r=56320|1023&r),n.push(r),s+=a}return S(n)}function S(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var i="",n=0;nn)&&(i=n);for(var s="",o=e;oi)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,i,n,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 P(t,e,i,n){e<0&&(e=65535+e+1);for(var s=0,o=Math.min(t.length-i,2);s>>8*(n?s:1-s)}function G(t,e,i,n){e<0&&(e=4294967295+e+1);for(var s=0,o=Math.min(t.length-i,4);s>>8*(n?s:3-s)&255}function j(t,e,i,n,s,o){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function q(t,e,i,n,s){return s||j(t,e,i,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,i,n,23,4),i+4}function B(t,e,i,n,s){return s||j(t,e,i,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,i,n,52,8),i+8}function z(t){if(t=V(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function V(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function Y(t,e){e=e||1/0;for(var i,n=t.length,s=null,o=[],r=0;r55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(r+1===n){(e-=3)>-1&&o.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&o.push(239,191,189),s=i;continue}i=(s-55296<<10|i-56320)+65536}else s&&(e-=3)>-1&&o.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;o.push(i)}else if(i<2048){if((e-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function H(t){for(var e=[],i=0;i>8,s=i%256,o.push(s),o.push(n);return o}function K(t){return Q.toByteArray(z(t))}function J(t,e,i,n){for(var s=0;s=e.length||s>=t.length);++s)e[s+i]=t[s];return s}function $(t){return t!==t}/*! +\`\`\``)}pin(){return this.client.rest.methods.pinMessage(this)}unpin(){return this.client.rest.methods.unpinMessage(this)}react(t){if(t=this.client.resolver.resolveEmojiIdentifier(t),!t)throw new TypeError("Emoji must be a string or Emoji/ReactionEmoji");return this.client.rest.methods.addMessageReaction(this,t)}clearReactions(){return this.client.rest.methods.removeMessageReactions(this)}delete(t=0){return t<=0?this.client.rest.methods.deleteMessage(this):new Promise(e=>{this.client.setTimeout(()=>{e(this.delete())},t)})}reply(t,e){return e||"object"!=typeof t||t instanceof Array?e||(e={}):(e=t,t=""),this.channel.send(t,Object.assign(e,{reply:this.member||this.author}))}acknowledge(){return this.client.rest.methods.ackMessage(this)}fetchWebhook(){return this.webhookID?this.client.fetchWebhook(this.webhookID):Promise.reject(new Error("The message was not sent by a webhook."))}equals(t,e){if(!t)return!1;const i=!t.author&&!t.attachments;if(i)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 i=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);let n;return this.reactions.has(i)?(n=this.reactions.get(i),n.me||(n.me=e.id===this.client.user.id)):(n=new o(this,t,0,e.id===this.client.user.id),this.reactions.set(i,n)),n.users.has(e.id)||n.users.set(e.id,e),n.count++,n}_removeReaction(t,e){const i=t.id?`${t.name}:${t.id}`:encodeURIComponent(t.name);if(this.reactions.has(i)){const t=this.reactions.get(i);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=h},function(t,e,i){const n=i(5),s=i(6);class o{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 n.deconstruct(this.id).timestamp}get createdAt(){return new Date(this.createdTimestamp)}get hexColor(){let t=this.color.toString(16);for(;t.length<6;)t=`0${t}`;return`#${t}`}get members(){return this.guild.members.filter(t=>t.roles.has(this.id))}get editable(){if(this.managed)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(s.FLAGS.MANAGE_ROLES_OR_PERMISSIONS)&&t.highestRole.comparePositionTo(this)>0}get calculatedPosition(){const t=this.guild._sortedRoles;return t.array().indexOf(t.get(this.id))}serialize(){return new s(this.permissions).serialize()}hasPermission(t,e=false,i){return new s(this.permissions).has(t,"undefined"!=typeof i?i:!e)}hasPermissions(t,e=false){return new s(this.permissions).has(t,!e)}comparePositionTo(t){return this.constructor.comparePositions(this,t)}edit(t){return this.client.rest.methods.updateGuildRole(this,t)}setName(t){return this.edit({name:t})}setColor(t){return this.edit({color:t})}setHoist(t){return this.edit({hoist:t})}setPosition(t,e){return this.guild.setRolePosition(this,t,e).then(()=>this)}setPermissions(t){return this.edit({permissions:t})}setMentionable(t){return this.edit({mentionable:t})}delete(){return this.client.rest.methods.deleteGuildRole(this)}equals(t){return t&&this.id===t.id&&this.name===t.name&&this.color===t.color&&this.hoist===t.hoist&&this.position===t.position&&this.permissions===t.permissions&&this.managed===t.managed}toString(){return this.id===this.guild.id?"@everyone":`<@&${this.id}>`}static comparePositions(t,e){return t.position===e.position?e.id-t.id:t.position-e.position}}t.exports=o},function(t,e,i){const n=i(15),s=i(0),o=i(7).Presence,r=i(5);class a{constructor(t,e){Object.defineProperty(this,"client",{value:t}),e&&this.setup(e)}setup(t){this.id=t.id,this.username=t.username,this.discriminator=t.discriminator,this.avatar=t.avatar,this.bot=Boolean(t.bot),this.lastMessageID=null,this.lastMessage=null}patch(t){for(const e of["id","username","discriminator","avatar","bot"])"undefined"!=typeof t[e]&&(this[e]=t[e]);t.token&&(this.client.token=t.token)}get createdTimestamp(){return r.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 o}get avatarURL(){return this.avatar?s.Endpoints.User(this).Avatar(this.client.options.http.cdn,this.avatar):null}get defaultAvatarURL(){const t=Object.keys(s.DefaultAvatars),e=t[this.discriminator%t.length];return s.Endpoints.assets(`${s.DefaultAvatars[e]}.png`)}get displayAvatarURL(){return this.avatarURL||this.defaultAvatarURL}get note(){return this.client.user.notes.get(this.id)||null}typingIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)}typingSinceIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?new Date(t._typing.get(this.id).since):null}typingDurationIn(t){return t=this.client.resolver.resolveChannel(t),t._typing.has(this.id)?t._typing.get(this.id).elapsedTime:-1}get dmChannel(){return this.client.channels.filter(t=>"dm"===t.type).find(t=>t.recipient.id===this.id)}createDM(){return this.client.rest.methods.createDM(this)}deleteDM(){return this.client.rest.methods.deleteChannel(this)}addFriend(){return this.client.rest.methods.addFriend(this)}removeFriend(){return this.client.rest.methods.removeFriend(this)}block(){return this.client.rest.methods.blockUser(this)}unblock(){return this.client.rest.methods.unblockUser(this)}fetchProfile(){return this.client.rest.methods.fetchUserProfile(this)}setNote(t){return this.client.rest.methods.setNote(this,t)}equals(t){let e=t&&this.id===t.id&&this.username===t.username&&this.discriminator===t.discriminator&&this.avatar===t.avatar&&this.bot===Boolean(t.bot);return e}toString(){return`<@${this.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}n.applyToClass(a),t.exports=a},function(t,e,i){const n=i(0),s=i(3),o=i(5);class r{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 o.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 n.Endpoints.emoji(this.id)}get identifier(){return this.id?`${this.name}:${this.id}`:encodeURIComponent(this.name)}edit(t){return this.client.rest.methods.updateEmoji(this,t)}toString(){return this.requiresColons?`<:${this.name}:${this.id}>`:this.name}equals(t){return t instanceof r?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=r},function(t,e,i){const n=i(15),s=i(10),o=i(6),r=i(3),a=i(7).Presence;class c{constructor(t,e){Object.defineProperty(this,"client",{value:t.client}),this.guild=t,this.user={},this._roles=[],e&&this.setup(e),this.lastMessageID=null,this.lastMessage=null}setup(t){this.serverDeaf=t.deaf,this.serverMute=t.mute,this.selfMute=t.self_mute,this.selfDeaf=t.self_deaf,this.voiceSessionID=t.session_id,this.voiceChannelID=t.channel_id,this.speaking=!1,this.nickname=t.nick||null,this.joinedTimestamp=new Date(t.joined_at).getTime(),this.user=t.user,this._roles=t.roles}get joinedAt(){return new Date(this.joinedTimestamp)}get presence(){return this.frozenPresence||this.guild.presences.get(this.id)||new a}get roles(){const t=new r,e=this.guild.roles.get(this.guild.id);e&&t.set(e.id,e);for(const i of this._roles){const e=this.guild.roles.get(i);e&&t.set(e.id,e)}return t}get highestRole(){return this.roles.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t)}get colorRole(){const t=this.roles.filter(t=>t.color);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get displayColor(){const t=this.colorRole;return t&&t.color||0}get displayHexColor(){const t=this.colorRole;return t&&t.hexColor||"#000000"}get hoistRole(){const t=this.roles.filter(t=>t.hoist);return t.size?t.reduce((t,e)=>!t||e.comparePositionTo(t)>0?e:t):null}get mute(){return this.selfMute||this.serverMute}get deaf(){return this.selfDeaf||this.serverDeaf}get voiceChannel(){return this.guild.channels.get(this.voiceChannelID)}get id(){return this.user.id}get displayName(){return this.nickname||this.user.username}get permissions(){if(this.user.id===this.guild.ownerID)return new o(this,o.ALL);let t=0;const e=this.roles;for(const i of e.values())t|=i.permissions;return new o(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.FLAGS.KICK_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}get bannable(){if(this.user.id===this.guild.ownerID)return!1;if(this.user.id===this.client.user.id)return!1;const t=this.guild.member(this.client.user);return!!t.hasPermission(o.FLAGS.BAN_MEMBERS)&&t.highestRole.comparePositionTo(this.highestRole)>0}permissionsIn(t){if(t=this.client.resolver.resolveChannel(t),!t||!t.guild)throw new Error("Could not resolve channel to a guild channel.");return t.permissionsFor(this)}hasPermission(t,e=false,i,n){return"undefined"==typeof i&&(i=!e),"undefined"==typeof n&&(n=!e),!(!n||this.user.id!==this.guild.ownerID)||this.roles.some(e=>e.hasPermission(t,void 0,i))}hasPermissions(t,e=false){return!e&&this.user.id===this.guild.ownerID||t.every(t=>this.hasPermission(t,e))}missingPermissions(t,e=false){return t.filter(t=>!this.hasPermission(t,e))}edit(t){return this.client.rest.methods.updateGuildMember(this,t)}setMute(t){return this.edit({mute:t})}setDeaf(t){return this.edit({deaf:t})}setVoiceChannel(t){return this.edit({channel:t})}setRoles(t){return this.edit({roles:t})}addRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.addMemberRole(this,t)}addRoles(t){let e;if(t instanceof r){e=this._roles.slice();for(const i of t.values())e.push(i.id)}else e=this._roles.concat(t);return this.edit({roles:e})}removeRole(t){return t instanceof s||(t=this.guild.roles.get(t)),this.client.rest.methods.removeMemberRole(this,t)}removeRoles(t){const e=this._roles.slice();if(t instanceof r)for(const i of t.values()){const t=e.indexOf(i.id);t>=0&&e.splice(t,1)}else for(const i of t){const t=e.indexOf(i instanceof s?i.id:i);t>=0&&e.splice(t,1)}return this.edit({roles:e})}setNickname(t){return this.edit({nick:t})}createDM(){return this.user.createDM()}deleteDM(){return this.user.deleteDM()}kick(){return this.client.rest.methods.kickGuildMember(this.guild,this)}ban(t=0){return this.client.rest.methods.banGuildMember(this.guild,this,t)}toString(){return`<@${this.nickname?"!":""}${this.user.id}>`}send(){}sendMessage(){}sendEmbed(){}sendFile(){}sendCode(){}}n.applyToClass(c),t.exports=c},function(t,e,i){"use strict";(function(t){function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function s(){return r.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,e){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),r.alloc(+t)}function v(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 i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return K(t).length;default:if(n)return Y(t).length;e=(""+e).toLowerCase(),n=!0}}function E(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if(i>>>=0,e>>>=0,i<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,i);case"utf8":case"utf-8":return M(this,e,i);case"ascii":return I(this,e,i);case"latin1":case"binary":return U(this,e,i);case"base64":return D(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function b(t,e,i,n,s){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=s?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(s)return-1;i=t.length-1}else if(i<0){if(!s)return-1;i=0}if("string"==typeof e&&(e=r.from(e,n)),r.isBuffer(e))return 0===e.length?-1:w(t,e,i,n,s);if("number"==typeof e)return e&=255,r.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):w(t,[e],i,n,s);throw new TypeError("val must be string, number or Buffer")}function w(t,e,i,n,s){function o(t,e){return 1===r?t[e]:t.readUInt16BE(e*r)}var r=1,a=t.length,c=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;r=2,a/=2,c/=2,i/=2}var l;if(s){var u=-1;for(l=i;la&&(i=a-c),l=i;l>=0;l--){for(var h=!0,p=0;ps&&(n=s)):n=s;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var r=0;r239?4:o>223?3:o>191?2:1;if(s+a<=i){var c,l,u,h;switch(a){case 1:o<128&&(r=o);break;case 2:c=t[s+1],128===(192&c)&&(h=(31&o)<<6|63&c,h>127&&(r=h));break;case 3:c=t[s+1],l=t[s+2],128===(192&c)&&128===(192&l)&&(h=(15&o)<<12|(63&c)<<6|63&l,h>2047&&(h<55296||h>57343)&&(r=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&o)<<18|(63&c)<<12|(63&l)<<6|63&u,h>65535&&h<1114112&&(r=h))}}null===r?(r=65533,a=1):r>65535&&(r-=65536,n.push(r>>>10&1023|55296),r=56320|1023&r),n.push(r),s+=a}return S(n)}function S(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var i="",n=0;nn)&&(i=n);for(var s="",o=e;oi)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,i,n,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 P(t,e,i,n){e<0&&(e=65535+e+1);for(var s=0,o=Math.min(t.length-i,2);s>>8*(n?s:1-s)}function G(t,e,i,n){e<0&&(e=4294967295+e+1);for(var s=0,o=Math.min(t.length-i,4);s>>8*(n?s:3-s)&255}function j(t,e,i,n,s,o){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function q(t,e,i,n,s){return s||j(t,e,i,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,i,n,23,4),i+4}function B(t,e,i,n,s){return s||j(t,e,i,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,i,n,52,8),i+8}function z(t){if(t=V(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function V(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function W(t){return t<16?"0"+t.toString(16):t.toString(16)}function Y(t,e){e=e||1/0;for(var i,n=t.length,s=null,o=[],r=0;r55295&&i<57344){if(!s){if(i>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(r+1===n){(e-=3)>-1&&o.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&o.push(239,191,189),s=i;continue}i=(s-55296<<10|i-56320)+65536}else s&&(e-=3)>-1&&o.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;o.push(i)}else if(i<2048){if((e-=2)<0)break;o.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;o.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return o}function H(t){for(var e=[],i=0;i>8,s=i%256,o.push(s),o.push(n);return o}function K(t){return Q.toByteArray(z(t))}function J(t,e,i,n){for(var s=0;s=e.length||s>=t.length);++s)e[s+i]=t[s];return s}function $(t){return t!==t}/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh