UNPKG

@bastion/tesseract

Version:

The heart and soul of the Bastion bot.

1 lines 14.8 kB
const a0_0x35f30a=a0_0x2181;(function(_0x5c7eed,_0x66ca53){const _0x194fe0=a0_0x2181,_0x4909f7=_0x5c7eed();while(!![]){try{const _0x3eb486=-parseInt(_0x194fe0(0x1b5))/0x1*(parseInt(_0x194fe0(0x19f))/0x2)+-parseInt(_0x194fe0(0x1ad))/0x3+-parseInt(_0x194fe0(0x17f))/0x4*(-parseInt(_0x194fe0(0x1c7))/0x5)+parseInt(_0x194fe0(0x1a2))/0x6*(parseInt(_0x194fe0(0x1f7))/0x7)+parseInt(_0x194fe0(0x1d1))/0x8*(parseInt(_0x194fe0(0x1b7))/0x9)+-parseInt(_0x194fe0(0x1df))/0xa+-parseInt(_0x194fe0(0x1ef))/0xb*(-parseInt(_0x194fe0(0x1b8))/0xc);if(_0x3eb486===_0x66ca53)break;else _0x4909f7['push'](_0x4909f7['shift']());}catch(_0x21cd97){_0x4909f7['push'](_0x4909f7['shift']());}}}(a0_0x16eb,0xc53f6));const a0_0x5e04af=(function(){let _0x4775b2=!![];return function(_0x990d97,_0x464af7){const _0x62416a=_0x4775b2?function(){const _0x33c1f2=a0_0x2181;if(_0x464af7){const _0x3e36c2=_0x464af7[_0x33c1f2(0x1ba)](_0x990d97,arguments);return _0x464af7=null,_0x3e36c2;}}:function(){};return _0x4775b2=![],_0x62416a;};}()),a0_0x3c3d94=a0_0x5e04af(this,function(){const _0x1f2d77=a0_0x2181;return a0_0x3c3d94['toString']()[_0x1f2d77(0x198)](_0x1f2d77(0x1db))['toString']()[_0x1f2d77(0x18f)](a0_0x3c3d94)['search'](_0x1f2d77(0x1db));});a0_0x3c3d94();import a0_0x28cb6a from'node:fs';import a0_0x11792b from'node:path';import a0_0x4c1eba from'node:url';import a0_0x388649 from'mongoose';import{Client,Collection,Events,Team}from'discord.js';import{Locke}from'@iamtraction/locke';import{CronJob}from'cron';import a0_0x3d9c1d from'./TesseractLogger.js';import a0_0x1a0fa2 from'./TesseractSettings.js';import a0_0x2d264d from'./utils/walkDirectory.js';function a0_0x2181(_0x43288c,_0x11a698){const _0x37403d=a0_0x16eb();return a0_0x2181=function(_0x3c3d94,_0x5e04af){_0x3c3d94=_0x3c3d94-0x17c;let _0x16ebb8=_0x37403d[_0x3c3d94];return _0x16ebb8;},a0_0x2181(_0x43288c,_0x11a698);}import a0_0x108779 from'./utils/isConstructor.js';function a0_0x16eb(){const _0x26b4b3=['token','loadCommands','.js','channel','client','MessageCreate','6IIBNcp','unsafe','initFilters','6saSafV','nsfw','initSchedulers','unref','connectMongo','schedulers','size','length','This\x20command\x20can\x20only\x20be\x20used\x20if\x20unsafe\x20mode\x20is\x20enabled\x20before\x20boot.','login','presences','4095267pgoAPx','fetch','isContextMenuCommand','loadMessageComponents','settings','You\x20don\x27t\x20have\x20the\x20permissions\x20to\x20use\x20this\x20command.','shard','close','57533TxIhxh','relative','2791251fbrxuF','7199004VNCyVB','command','apply','error','isChatInputCommand','MessageUpdate','267035345537728512','mongoURI','messageComponents','delete','commandName','locales','isAnySelectMenu','connect','find','4955470uvPpSn','href','listeners','user','Tesseract','deletable','customId','values','app','applyFilters','24hRkokE','members','actions','from','getSubcommandGroup','set','push','You\x20can\x20only\x20use\x20this\x20command\x20in\x20NSFW\x20channels.','has','botPublic','(((.+)+)+)+$','utf-8','toString','presence','10999530JSVaEy','userPermissions','catch','owners','setInterval','studio','options','dirname','unsafeMode','broadcastEval','resolve','directory','This\x20command\x20is\x20disabled\x20and\x20cannot\x20be\x20used\x20at\x20this\x20time.','commands','enabled','clientPermissions','11KbUQOV','\x0a\x0a\x0a','group','InteractionCreate','initListeners','RkFUQUwgRVJST1I6IDB4QkFBREIwMDIKCkdvIHRvIHlvdXIgQm90J3MgYXBwbGljYXRpb24gcGFnZSBpbiBEaXNjb3JkIERldmVsb3BlcnMgc2l0ZSBhbmQgZGlzYWJsZSB0aGUgIlB1YmxpYyBCb3QiIG9wdGlvbi4KClBsZWFzZSBjb250YWN0IHRoZSBzdXBwb3J0IHRlYW0gYXQgQmFzdGlvbiBIUSAtIGh0dHBzOi8vZGlzY29yZC5nZy9meng4Zmt0IC0gZm9yIG1vcmUgaW5mb3JtYXRpb24u','getSubcommand','initInteractions','6468973TQDgXZ','destroy','memberPermissions','exit','name','266290969974931457','This\x20command\x20can\x20only\x20be\x20used\x20in\x20a\x20server.','4mQOKST','existsSync','exec','write','inCachedGuild','init','pathToFileURL','split','filters','filter','owner','I\x20don\x27t\x20have\x20permission\x20to\x20use\x20this\x20command.','includes','This\x20command\x20can\x20only\x20be\x20used\x20by\x20the\x20bot\x20owner.','guild','stderr','constructor','components','connection','application','endsWith','tesseractSettings','deferUpdate','sep','reply','search'];a0_0x16eb=function(){return _0x26b4b3;};return a0_0x16eb();}class TesseractClient extends Client{[a0_0x35f30a(0x1cf)];[a0_0x35f30a(0x1c3)];['directory'];[a0_0x35f30a(0x187)];['commands'];['messageComponents'];[a0_0x35f30a(0x1b1)];['studio'];constructor(_0x5e7b19){const _0xb4dc0f=a0_0x35f30a;super(_0x5e7b19),this[_0xb4dc0f(0x1ea)]='dist',this['filters']=new Collection(),this[_0xb4dc0f(0x1e4)]=new WeakMap(),this['commands']=[],this[_0xb4dc0f(0x1c0)]=[],this[_0xb4dc0f(0x1c3)]=new Locke(),this[_0xb4dc0f(0x1b1)]=_0x5e7b19?.['tesseractSettings']instanceof a0_0x1a0fa2?_0x5e7b19[_0xb4dc0f(0x194)]:new a0_0x1a0fa2(),setInterval(async()=>{const _0x4f1904=_0xb4dc0f;if(this['user']['id']===_0x4f1904(0x1be))return;if(this[_0x4f1904(0x1cf)]){this[_0x4f1904(0x1cf)]=await this[_0x4f1904(0x192)][_0x4f1904(0x1ae)]()[_0x4f1904(0x1e1)](a0_0x3d9c1d['error']);if(!this[_0x4f1904(0x1cf)])return;const _0x1e24ff=this[_0x4f1904(0x1cf)]?.[_0x4f1904(0x189)]instanceof Team?this['app']?.[_0x4f1904(0x189)]?.[_0x4f1904(0x189)]?.['user']:this['app']?.['owner'];if(_0x1e24ff?.['id']===_0x4f1904(0x17d))return;this[_0x4f1904(0x1cf)]?.[_0x4f1904(0x1da)]&&(process[_0x4f1904(0x18e)][_0x4f1904(0x182)]('\x0a\x0a'+Buffer[_0x4f1904(0x1d4)](_0x4f1904(0x1f4),'base64')[_0x4f1904(0x1dd)](_0x4f1904(0x1dc))+_0x4f1904(0x1f0)),this[_0x4f1904(0x1b3)]?await this['shard'][_0x4f1904(0x1e8)](_0x28b201=>{const _0x3feb73=_0x4f1904;_0x28b201[_0x3feb73(0x1f8)](),process['exitCode']=0xbaadb002;})[_0x4f1904(0x1e1)](a0_0x3d9c1d[_0x4f1904(0x1bb)]):(this['destroy'](),process['exitCode']=0xbaadb002,process[_0x4f1904(0x1fa)](0xbaadb002)));}},0x2bf20);}[a0_0x35f30a(0x1e3)](_0x5f9604,_0x1640f1){const _0x1e9cca=a0_0x35f30a;_0x5f9604(),setTimeout(()=>this['setInterval'](_0x5f9604,_0x1640f1),_0x1640f1)[_0x1e9cca(0x1a5)]();}[a0_0x35f30a(0x1d0)]=async _0xa69a73=>{const _0x45b055=a0_0x35f30a;if(this['filters'][_0x45b055(0x1a8)]===0x0)return;let _0x17e37c=![];if(_0xa69a73['partial'])await _0xa69a73['fetch']();for(const _0x50c588 of this[_0x45b055(0x187)][_0x45b055(0x1ce)]()){_0x17e37c=await _0x50c588['exec'](_0xa69a73);if(_0x17e37c&&_0xa69a73[_0x45b055(0x1cc)]){await _0xa69a73[_0x45b055(0x1c1)]();break;}}};[a0_0x35f30a(0x19a)]=async _0x2ed217=>{const _0x2746bb=a0_0x35f30a,_0xa574e9=a0_0x11792b[_0x2746bb(0x1e9)](this[_0x2746bb(0x1ea)],_0x2ed217);if(a0_0x28cb6a['existsSync'](_0xa574e9)){const _0x325c2f=a0_0x2d264d(_0xa574e9);for(const _0x339452 of _0x325c2f[_0x2746bb(0x188)](_0x53e9c5=>_0x53e9c5['endsWith'](_0x2746bb(0x19b)))){const {Command:_0x44570c}=await import(a0_0x4c1eba['pathToFileURL'](_0x339452)[_0x2746bb(0x1c8)]);if(a0_0x108779(_0x44570c)){const _0x1f082b=new _0x44570c(),[_0x15b6d3,_0x219e82]=a0_0x11792b[_0x2746bb(0x1b6)](_0xa574e9,a0_0x11792b[_0x2746bb(0x1e6)](_0x339452))[_0x2746bb(0x186)](a0_0x11792b[_0x2746bb(0x196)]);_0x1f082b[_0x2746bb(0x1f1)]=_0x219e82?_0x15b6d3+'.'+_0x219e82:_0x15b6d3?_0x15b6d3:undefined,this[_0x2746bb(0x1ec)]['push'](_0x1f082b);}}}};['loadMessageComponents']=async()=>{const _0x3949de=a0_0x35f30a,_0x2165ab=a0_0x11792b[_0x3949de(0x1e9)](this[_0x3949de(0x1ea)],_0x3949de(0x190));if(a0_0x28cb6a['existsSync'](_0x2165ab)){const _0x1c4d12=a0_0x2d264d(_0x2165ab);for(const _0x2c7761 of _0x1c4d12['filter'](_0x547e56=>_0x547e56[_0x3949de(0x193)]('.js'))){const {MessageComponent:_0x42ab07}=await import(a0_0x4c1eba[_0x3949de(0x185)](_0x2c7761)[_0x3949de(0x1c8)]);if(a0_0x108779(_0x42ab07)){const _0x276072=new _0x42ab07();this[_0x3949de(0x1c0)][_0x3949de(0x1d7)](_0x276072);}}}};[a0_0x35f30a(0x1f6)]=async()=>{const _0xfb0d97=a0_0x35f30a;await this[_0xfb0d97(0x19a)](_0xfb0d97(0x1d3)),await this['loadCommands'](_0xfb0d97(0x1ec)),await this[_0xfb0d97(0x1b0)](),this['on'](Events[_0xfb0d97(0x1f2)],async _0xaf4b0=>{const _0x3212ec=_0xfb0d97;try{if(_0xaf4b0[_0x3212ec(0x1bc)]()){const _0x15666f=_0xaf4b0['options'][_0x3212ec(0x1f5)](![]),_0x167e43=_0xaf4b0[_0x3212ec(0x1e5)][_0x3212ec(0x1d5)](![]),_0x5174a8=_0x15666f?this[_0x3212ec(0x1ec)][_0x3212ec(0x188)](_0x26e330=>_0x26e330[_0x3212ec(0x1f1)]===(_0x167e43?_0xaf4b0['commandName']+'.'+_0x167e43:_0xaf4b0[_0x3212ec(0x1c2)])):this['commands'],_0x1b9f1f=_0x5174a8[_0x3212ec(0x1c6)](_0x214b9c=>_0x214b9c[_0x3212ec(0x17c)]===(_0x15666f||_0xaf4b0[_0x3212ec(0x1c2)]));if(_0x1b9f1f){if(!_0xaf4b0[_0x3212ec(0x183)]())return _0xaf4b0['reply']({'content':_0x3212ec(0x17e),'ephemeral':!![]});a0_0x3d9c1d[_0x3212ec(0x1b9)](_0xaf4b0);if(!_0x1b9f1f[_0x3212ec(0x1ed)])return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x1eb),'ephemeral':!![]});if(_0x1b9f1f[_0x3212ec(0x189)]&&!this[_0x3212ec(0x1b1)][_0x3212ec(0x1e2)]?.[_0x3212ec(0x18b)](_0xaf4b0[_0x3212ec(0x1ca)]['id']))return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x18c),'ephemeral':!![]});if(!_0xaf4b0[_0x3212ec(0x18d)][_0x3212ec(0x1d2)]['me']['permissions'][_0x3212ec(0x1d9)](_0x1b9f1f[_0x3212ec(0x1ee)]))return _0xaf4b0['reply']({'content':'I\x20don\x27t\x20have\x20permission\x20to\x20use\x20this\x20command.','ephemeral':!![]});if(!_0xaf4b0['memberPermissions'][_0x3212ec(0x1d9)](_0x1b9f1f[_0x3212ec(0x1e0)]))return _0xaf4b0[_0x3212ec(0x197)]({'content':'You\x20don\x27t\x20have\x20the\x20permissions\x20to\x20use\x20this\x20command.','ephemeral':!![]});if(_0x1b9f1f[_0x3212ec(0x1a0)]&&!this[_0x3212ec(0x1b1)][_0x3212ec(0x1e7)])return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x1aa),'ephemeral':!![]});if(_0x1b9f1f['nsfw']&&!_0xaf4b0[_0x3212ec(0x19c)][_0x3212ec(0x1a3)])return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x1d8),'ephemeral':!![]});return _0x1b9f1f[_0x3212ec(0x181)](_0xaf4b0);}}if(_0xaf4b0[_0x3212ec(0x1af)]()){const _0x479f71=this[_0x3212ec(0x1ec)]['find'](_0x317819=>_0x317819[_0x3212ec(0x17c)]===_0xaf4b0[_0x3212ec(0x1c2)]);if(_0x479f71){if(!_0xaf4b0[_0x3212ec(0x183)]())return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x17e),'ephemeral':!![]});a0_0x3d9c1d[_0x3212ec(0x1b9)](_0xaf4b0);if(!_0x479f71[_0x3212ec(0x1ed)])return _0xaf4b0['reply']({'content':'This\x20command\x20is\x20disabled\x20and\x20cannot\x20be\x20used\x20at\x20this\x20time.','ephemeral':!![]});if(_0x479f71[_0x3212ec(0x189)]&&!this['settings'][_0x3212ec(0x1e2)]?.[_0x3212ec(0x18b)](_0xaf4b0[_0x3212ec(0x1ca)]['id']))return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x18c),'ephemeral':!![]});if(!_0xaf4b0[_0x3212ec(0x18d)][_0x3212ec(0x1d2)]['me']['permissions']['has'](_0x479f71['clientPermissions']))return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x18a),'ephemeral':!![]});if(!_0xaf4b0[_0x3212ec(0x1f9)][_0x3212ec(0x1d9)](_0x479f71[_0x3212ec(0x1e0)]))return _0xaf4b0[_0x3212ec(0x197)]({'content':_0x3212ec(0x1b2),'ephemeral':!![]});return _0x479f71[_0x3212ec(0x181)](_0xaf4b0);}}if(_0xaf4b0['isButton']()||_0xaf4b0['isModalSubmit']()||_0xaf4b0[_0x3212ec(0x1c4)]()){const [_0x1e6361]=_0xaf4b0[_0x3212ec(0x1cd)][_0x3212ec(0x186)](':'),_0x1188c9=this[_0x3212ec(0x1c0)][_0x3212ec(0x1c6)](_0x513cab=>_0x513cab['id']===_0x1e6361);if(_0x1188c9){if(!_0xaf4b0['inCachedGuild']())return;if(_0x1188c9[_0x3212ec(0x189)]&&!this[_0x3212ec(0x1b1)]['owners']?.[_0x3212ec(0x18b)](_0xaf4b0[_0x3212ec(0x1ca)]['id']))return _0xaf4b0[_0x3212ec(0x195)]();if(!_0xaf4b0[_0x3212ec(0x1f9)][_0x3212ec(0x1d9)](_0x1188c9[_0x3212ec(0x1e0)]))return _0xaf4b0[_0x3212ec(0x195)]();return _0x1188c9[_0x3212ec(0x181)](_0xaf4b0);}}return Promise[_0x3212ec(0x1e9)](undefined);}catch(_0x1d5928){a0_0x3d9c1d[_0x3212ec(0x1bb)](_0x1d5928);}});};[a0_0x35f30a(0x1a1)]=async()=>{const _0x1f9fc8=a0_0x35f30a,_0x1ef8ac=a0_0x11792b[_0x1f9fc8(0x1e9)](this[_0x1f9fc8(0x1ea)],_0x1f9fc8(0x187));if(a0_0x28cb6a[_0x1f9fc8(0x180)](_0x1ef8ac)){const _0x4cb01e=a0_0x2d264d(_0x1ef8ac);for(const _0x2f78cd of _0x4cb01e[_0x1f9fc8(0x188)](_0x2dcb3a=>_0x2dcb3a[_0x1f9fc8(0x193)](_0x1f9fc8(0x19b)))){const {Filter:_0x1965c1}=await import(a0_0x4c1eba[_0x1f9fc8(0x185)](_0x2f78cd)[_0x1f9fc8(0x1c8)]);if(a0_0x108779(_0x1965c1)){const _0x2a7517=new _0x1965c1();this[_0x1f9fc8(0x187)][_0x1f9fc8(0x1d6)](_0x2a7517[_0x1f9fc8(0x17c)],_0x2a7517);}}}this['on'](Events[_0x1f9fc8(0x19e)],async _0x5a4ce8=>this[_0x1f9fc8(0x1d0)](_0x5a4ce8)),this['on'](Events[_0x1f9fc8(0x1bd)],async(_0x1270c6,_0x21d0f7)=>this[_0x1f9fc8(0x1d0)](_0x21d0f7));};[a0_0x35f30a(0x1f3)]=async()=>{const _0x5877e5=a0_0x35f30a,_0x3f3d0a=a0_0x11792b[_0x5877e5(0x1e9)](this['directory'],_0x5877e5(0x1c9));if(a0_0x28cb6a[_0x5877e5(0x180)](_0x3f3d0a)){const _0x439aff=a0_0x2d264d(_0x3f3d0a);for(const _0x37aee5 of _0x439aff[_0x5877e5(0x188)](_0x2f94e8=>_0x2f94e8['endsWith']('.js'))){const {Listener:_0x469104}=await import(a0_0x4c1eba[_0x5877e5(0x185)](_0x37aee5)[_0x5877e5(0x1c8)]);if(a0_0x108779(_0x469104)){const _0x45dc47=new _0x469104();this[_0x45dc47['isOnce']?'once':'on'](_0x45dc47[_0x5877e5(0x17c)],async(..._0x2869ea)=>{const _0x632ed2=_0x5877e5;try{await _0x45dc47[_0x632ed2(0x181)](..._0x2869ea);}catch(_0x4223ae){a0_0x3d9c1d[_0x632ed2(0x1bb)](_0x4223ae);}});}}}};[a0_0x35f30a(0x1a4)]=async()=>{const _0x4a9d1c=a0_0x35f30a,_0xa5ec71=a0_0x11792b[_0x4a9d1c(0x1e9)](this[_0x4a9d1c(0x1ea)],_0x4a9d1c(0x1a7));if(a0_0x28cb6a[_0x4a9d1c(0x180)](_0xa5ec71)){const _0x71ac56=a0_0x2d264d(_0xa5ec71);for(const _0xc5f753 of _0x71ac56[_0x4a9d1c(0x188)](_0x1b1af2=>_0x1b1af2[_0x4a9d1c(0x193)](_0x4a9d1c(0x19b)))){const {Scheduler:_0x5ac113}=await import(a0_0x4c1eba[_0x4a9d1c(0x185)](_0xc5f753)[_0x4a9d1c(0x1c8)]);if(a0_0x108779(_0x5ac113)){const _0x4aac68=new _0x5ac113();_0x4aac68[_0x4a9d1c(0x19d)]=this,CronJob[_0x4a9d1c(0x1d4)]({'cronTime':_0x4aac68['cronTime'],'onTick':_0x4aac68[_0x4a9d1c(0x181)],'context':_0x4aac68,'start':!![],'unrefTimeout':!![]});}}}};[a0_0x35f30a(0x1a6)]=()=>a0_0x388649[a0_0x35f30a(0x1c5)](this['settings'][a0_0x35f30a(0x1bf)]);['disconnectMongo']=()=>a0_0x388649[a0_0x35f30a(0x191)][a0_0x35f30a(0x1b4)]();async[a0_0x35f30a(0x184)](){const _0x3329d9=a0_0x35f30a;await this[_0x3329d9(0x1a6)](),await this[_0x3329d9(0x1f6)](),await this[_0x3329d9(0x1a1)](),await this['initListeners'](),await this[_0x3329d9(0x1a4)]();const _0xb93c82=await this[_0x3329d9(0x1ab)](this['settings'][_0x3329d9(0x199)]);return this['setInterval'](()=>{const _0x26494e=_0x3329d9;if(this[_0x26494e(0x1b1)]?.['presences']instanceof Array&&this['settings'][_0x26494e(0x1ac)][_0x26494e(0x1a9)]){const _0x513da8=this[_0x26494e(0x1b1)][_0x26494e(0x1ac)][Math['floor'](Math['random']()*this['settings'][_0x26494e(0x1ac)]['length'])];this[_0x26494e(0x1ca)][_0x26494e(0x1de)][_0x26494e(0x1d6)]({'status':_0x513da8?.['status'],'activities':[{'name':_0x513da8?.[_0x26494e(0x17c)],'type':_0x513da8?.['activity'],'url':_0x513da8?.['url']}]});}},0x2255100),_0xb93c82;}[a0_0x35f30a(0x1dd)]=()=>a0_0x35f30a(0x1cb);}export default TesseractClient;