7 lines
20 KiB
JavaScript
7 lines
20 KiB
JavaScript
(function(I,ne,s,p,N,g,D,i,ae,se,oe){"use strict";const ie=async function(){const e=await(await fetch("https://uselessfacts.jsph.pl/api/v2/facts/random")).json();return{text:e.text,source:e.source,language:e.language}},re=async function(){return{text:(await(await fetch("https://dogapi.dog/api/v2/facts?limit=1")).json()).data[0].attributes.body}},ce=async function(){const e=await(await fetch("https://catfact.ninja/fact")).json();return{text:e.fact,length:e.length}},le=async function(e){return await(await fetch(`https://api.obamabot.me/v2/image/petpet?image=${e.replace("webp","png")}`)).json()},B=p.findByProps("sendMessage"),P=function(e){let n=e.text;return s.storage.factSettings?.includeCitation&&e.source&&(n+=`
|
|
|
|
Source: ${e.source}`),n},de={name:"catfact",displayName:"catfact",description:"Sends a random cat fact.",displayDescription:"Sends a random cat fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,n){try{const t=await ce(),a=Date.now().toString();return B.sendMessage(n.channel.id,{content:P(t)},void 0,{nonce:a}),{type:4}}catch(t){return console.error("[CatFact] Error:",t),{type:4}}}},ue={name:"dogfact",displayName:"dogfact",description:"Sends a dog fact.",displayDescription:"Sends a dog fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,n){try{const t=await re(),a=Date.now().toString();return B.sendMessage(n.channel.id,{content:P(t)},void 0,{nonce:a}),{type:4}}catch(t){return console.error("[DogFact] Error:",t),{type:4}}}},fe={name:"useless",displayName:"useless",description:"Sends a useless fact.",displayDescription:"Sends a useless fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,n){try{const t=await ie(),a=Date.now().toString();return B.sendMessage(n.channel.id,{content:P(t)},void 0,{nonce:a}),{type:4}}catch(t){return console.error("[UselessFact] Error:",t),{type:4}}}},C={CONTENT:"This list is over 2000 characters. Send anyway?",CONFIRM:"Send",CANCEL:"Cancel"},pe={DETAILED:"detailed"},U="",v={SLM_NOT_INSTALLED:"This list is over 2000 characters. Install the Split Large Messages plugin to send it.",SLM_NOT_ENABLED:"This list is over 2000 characters. Enable the Split Large Messages plugin to send it."},_={SEMICOL:"; ",NEW_LINE:`
|
|
`},me="Nothing to see here, huh...",j="github.com/fres621/vendetta-plugins",h={ENABLED:"\u2705",DISABLED:"\u274C",SELECTED:"\u2705",NOT_SELECTED:"\u274C"},ye=p.findByProps("sendMessage","receiveMessage"),E=p.findByProps("sendBotMessage"),x=function(){try{return p.findByStoreName("UserStore").getCurrentUser()?.premiumType===2?4e3:2e3}catch{return 2e3}}(),F=function(e){return Object.keys(e).includes(j)},V=function(e){return Object.values(e).find(function(n){return n.id==j})?.enabled},W=function(e){return e.find(function(n){return n.name===pe.DETAILED})?.value??!1},$=function(e){return!e||!Array.isArray(e)||e.length===0?"Unknown":e.filter(function(n){return n&&(typeof n=="string"||typeof n=="object"&&n.name)}).map(function(n){return typeof n=="string"?n:n.name||"Unknown"}).join(_.SEMICOL)||"Unknown"},K=function(e){return e.join(_.NEW_LINE).trimEnd()},A=function(e){return K(e).length},T=async function(e,n){const t=Date.now().toString();await ye.sendMessage(e,{content:K(n)},void 0,{nonce:t})},q=function(e,n){return[`**My ${e} List | ${n} ${e}s**`,U]};async function ge(e,n){try{const t=W(e),a=s.storage.themeListAlwaysDetailed??!1;if(!N.themes||typeof N.themes!="object"){const f=n.channel.id;return E.sendBotMessage(f,"No themes found or themes not loaded yet."),{type:4}}const o=Object.values(N.themes),l=n.channel.id,r=q("Theme",Object.keys(N.themes).length);if(o.length)for(const f of o){if(!f||typeof f!="object")continue;const{selected:c,data:d,id:y}=f,S=d?.name||"Unknown Theme",L=d?.description||"No description",M=d?.authors;t||a?r.push(`> **Name**: ${S}`,`> **Selected**: ${c?h.SELECTED:h.NOT_SELECTED}`,`> **Description**: ${L}`,`> **Authors**: ${$(M)}`,`> **[Install!](${y||"unknown"})**`,U):r.push(`> ${c?h.SELECTED:h.NOT_SELECTED} **${S}** by ${$(M)}`)}else r.push(me);const u=A(r)>x;if(u&&!F(g.plugins))E.sendBotMessage(l,v.SLM_NOT_INSTALLED);else if(u&&!V(g.plugins))E.sendBotMessage(l,v.SLM_NOT_ENABLED);else{if(A(r)>2e3)return D.alerts.showConfirmationAlert({content:C.CONTENT,confirmText:C.CONFIRM,cancelText:C.CANCEL,onConfirm:async function(){return await T(l,r)}});await T(l,r)}}catch(t){return console.error("[ThemeList] Error:",t),{type:4}}}async function he(e,n){try{const t=W(e),a=s.storage.pluginListAlwaysDetailed??!1,o=n.channel.id;if(!g.plugins||typeof g.plugins!="object")return E.sendBotMessage(o,"No plugins found or plugins not loaded yet."),{type:4};const l=q("Plugin",Object.keys(g.plugins).length);for(const u of Object.values(g.plugins)){if(!u||typeof u!="object")continue;const{enabled:f,manifest:c,id:d}=u,y=c?.name||"Unknown Plugin",S=c?.description||"No description",L=c?.authors;t||a?l.push(`> **Name**: ${y}`,`> **Status**: ${f?h.ENABLED:h.DISABLED}`,`> **Description**: ${S}`,`> **Authors**: ${$(L)}`,`> **[Install!](${d||"unknown"})**`,U):l.push(`> ${f?h.ENABLED:h.DISABLED} **${y}** by ${$(L)}`)}const r=A(l)>x;if(r&&!F(g.plugins))E.sendBotMessage(o,v.SLM_NOT_INSTALLED);else if(r&&!V(g.plugins))E.sendBotMessage(o,v.SLM_NOT_ENABLED);else{if(A(l)>2e3)return D.alerts.showConfirmationAlert({content:C.CONTENT,confirmText:C.CONFIRM,cancelText:C.CANCEL,onConfirm:async function(){return await T(o,l)}});await T(o,l)}}catch(t){return console.error("[PluginList] Error:",t),{type:4}}}const be={name:"plugin-list",displayName:"plugin list",description:"Send your plugin list to the current channel",displayDescription:"Send your plugin list to the current channel",options:[{name:"detailed",description:"Whether to send a list with detailed information.",type:5,required:!1,displayName:"detailed",displayDescription:"Whether to send a list with detailed information."}],execute:he,applicationId:"-1",inputType:1,type:1},we={name:"theme-list",displayName:"theme list",description:"Send your theme list to the current channel",displayDescription:"Send your theme list to the current channel",options:[{name:"detailed",description:"Whether to send a list with detailed information.",type:5,required:!1,displayName:"detailed",displayDescription:"Whether to send a list with detailed information."}],execute:ge,applicationId:"-1",inputType:1,type:1},Ce=p.findByStoreName("UserStore"),Ee=p.findByProps("sendMessage"),Se={name:"petpet",displayName:"petpet",description:"PetPet someone",displayDescription:"PetPet someone",options:[{name:"user",description:"The user(or their id) to be patted",type:6,required:!0,displayName:"user",displayDescription:"The user(or their id) to be patted"}],execute:async function(e,n){try{const t=(await Ce.getUser(e[0].value)).getAvatarURL(512),a=await le(t),o=Date.now().toString();return Ee.sendMessage(n.channel.id,{content:a.url},void 0,{nonce:o}),{type:4}}catch(t){return console.error("[PetPet] Error:",t),{type:4}}},applicationId:"-1",inputType:1,type:1},Le=p.findByProps("sendMessage"),Ne=p.findByProps("sendBotMessage","sendMessage","receiveMessage"),G=async function(e){const n="https://konachan.com/post.json",t=e?"rating:explicit":"rating:safe",a=Math.floor(Math.random()*100);try{const o=await(await fetch(`${n}?tags=${t}&limit=1&page=${a}`)).json();return!Array.isArray(o)||o.length===0?null:o[0].file_url}catch(o){return console.error("[KonoChan Randomizer] Error fetching image:",o),null}},H=function(){return D.alerts.showConfirmationAlert({title:"NSFW Content Warning",content:"NSFW content can only be sent in NSFW channels!",confirmText:"Okay",cancelText:null,confirmColor:"brand",isDismissable:!0})},z={name:"nsfw",description:"Include NSFW content?",type:5,required:!1,displayName:"nsfw",displayDescription:"Include NSFW content?"},De={name:"konoself",displayName:"konoself",description:"Fetch a random image from KonoChan for yourself.",displayDescription:"Fetch a random image from KonoChan for yourself.",options:[z],execute:async function(e,n){try{const t=new Map(e.map(function(o){return[o.name,o]})).get("nsfw")?.value||!1;if(t&&!n.channel.nsfw)return H(),{type:4};const a=await G(t);return a?(Ne.sendBotMessage(n.channel.id,`Here's your random image: ${a}`),{type:4}):{type:4}}catch(t){return console.error("[KonoSelf] Error:",t),{type:4}}},applicationId:"-1",inputType:1,type:1},ve={name:"konosend",displayName:"konosend",description:"Fetch a random image from KonoChan and send it to the channel.",displayDescription:"Fetch a random image from KonoChan and send it to the channel.",options:[z],execute:async function(e,n){try{const t=new Map(e.map(function(l){return[l.name,l]})).get("nsfw")?.value||!1;if(t&&!n.channel.nsfw)return H(),{type:4};const a=await G(t);if(!a)return{type:4};const o=Date.now().toString();return Le.sendMessage(n.channel.id,{content:a},void 0,{nonce:o}),{type:4}}catch(t){return console.error("[KonoSend] Error:",t),{type:4}}},applicationId:"-1",inputType:1,type:1},X=p.findByProps("getAPIBaseURL","get"),$e=p.findByProps("sendMessage"),R=async function(e,n,t){const a=n?`&author_id=${n}`:"",o=t?`&channel_id=${t}`:"",l=n?"":"&min_id=0";return(await X.get({url:`/guilds/${e}/messages/search`,query:`include_nsfw=true${a}${o}${l}&sort_by=timestamp&sort_order=asc&offset=0`})).body.messages[0][0]},Y=async function(e,n){const t=n?`&author_id=${n}`:"",a=n?"":"&min_id=0";return(await X.get({url:`/channels/${e}/messages/search`,query:`&sort_by=timestamp&sort_order=asc&offset=0${t}${a}`})).body.messages[0][0]},Ae={name:"firstmessage",displayName:"firstmessage",description:"Tired of scrolling to first message?",displayDescription:"Tired of scrolling to first message?",options:[{name:"user",displayName:"user",description:"Target user to get their first message in this server/dm",displayDescription:"Target user to get their first message in this server/dm",type:6,required:!1},{name:"channel",displayName:"channel",description:"Target channel to get first message of",displayDescription:"Target channel to get first message of",type:7,required:!1},{name:"send",displayName:"send",description:"Whether to send the resulting url",displayDescription:"Whether to send the resulting url",type:5,required:!1}],execute:async function(e,n){try{const t=new Map(e.map(function(y){return[y.name,y]})),a=t.get("user")?.value,o=t.get("channel")?.value,l=t.get("send")?.value,r=n.guild?.id,u=n.channel.id,f=n.channel.type===1;let c="https://discord.com/channels/",d;if(!a&&!o)f?(d=await Y(u),c+=`@me/${u}/${d.id}`):(d=await R(r),c+=`${r}/${d.channel_id}/${d.id}`);else if(a)f?(d=await Y(u,a),c+=`@me/${u}/${d.id}`):(d=await R(r,a),c+=`${r}/${d.channel_id}/${d.id}`);else if(o){if(f)return{type:4};d=await R(r,null,o),c+=`${r}/${o}/${d.id}`}else{if(f)return{type:4};d=await R(r,a,o),c+=`${r}/${o}/${d.id}`}if(l){const y=Date.now().toString();return $e.sendMessage(n.channel.id,{content:c},void 0,{nonce:y}),{type:4}}else return i.url.openDeeplink(c),{type:4}}catch(t){return console.error("[FirstMessage] Error:",t),{type:4}}},applicationId:"-1",inputType:1,type:1},Te=p.findByProps("sendMessage"),Re=p.findByProps("sendBotMessage","sendMessage","receiveMessage");function Me(){let{height:e,width:n,scale:t}=i.ReactNative.Dimensions.get("screen");return e*=t,n*=t,{width:n,height:e}}function ke(){try{const e=p.findByProps("memory");if(!e)return{cpuCoreCount:"N/A",cpuPerc:"N/A",memUsage:"N/A",netInfo:"N/A"};const{cpuCoreCount:n,cpuPercentage:t,memory:a}=e,o=t?t.toFixed(2)+"%":"N/A",l=a?parseFloat((a/1e3).toPrecision(3))+" MB":"N/A";let r="N/A";try{const u=p.findByProps("useNetInfo");if(u){const f=Object.values(u.fetch()).filter(function(c){return c?.type})[0];if(f){const{type:c,details:d}=f;r={wifi:"WiFi",ethernet:"Ethernet",other:"Unknown",bluetooth:"Bluetooth",wimax:"WiMAX",vpn:"VPN",cellular:d?.cellularGeneration?.toUpperCase()||"Cellular"}[c]??c}}}catch(u){console.warn("Network info unavailable:",u)}return{cpuCoreCount:n,cpuPerc:o,memUsage:l,netInfo:r}}catch(e){return console.warn("Hardware info unavailable:",e),{cpuCoreCount:"N/A",cpuPerc:"N/A",memUsage:"N/A",netInfo:"N/A"}}}function Ie(){try{const{NativeModules:e}=i.ReactNative;return(e.InfoDictionaryManager??e.RTNClientInfoManager)||{}}catch(e){return console.warn("Discord info unavailable:",e),{}}}function Be(){try{const{cpuCoreCount:e,cpuPerc:n,memUsage:t,netInfo:a}=ke(),o=Ie(),{vendetta:l,discord:r,react:u,hermes:f,os:c,device:d}=ae.getDebugInfo(),{version:y,bytecodeVersion:S}=f||{},{version:L,nativeVersion:M}=u||{},{name:Q,version:Ve,sdk:Z}=c||{},{manufacturer:We,brand:ee,model:te,codename:Ke}=d||{},{version:qe}=l||{},{version:Ge,build:He}=r||{},{ReleaseChannel:ze}=o,Xe=Q=="iOS"?Ke:`${ee} ${te}`,{width:Ye,height:Je}=Me();let k={Device:{Device:Xe||"Unknown",Model:te||"Unknown",Manufacturer:We||"Unknown",Brand:ee||"Unknown",Display:`${Ye}x${Je}`},Hardware:{"CPU Cores":e||"N/A",Network:a},Software:{OS:Q||"Unknown",Version:Ve||"Unknown"},Discord:{Branch:ze||"Unknown",Version:Ge||"Unknown",Build:He||"Unknown",Vendetta:qe||"Unknown","CPU Usage":n,"Memory Usage":t},React:{Version:L||"Unknown","Hermes Bytecode":S||"Unknown",Hermes:y||"Unknown",Native:M||"Unknown"}};return window.enmity&&(k.Discord.Enmity=window.enmity.version),window.aliucord&&(k.Discord.Aliucord=window.aliucord.version),Z&&(k.Software["SDK Version"]=Z),k}catch(e){throw console.error("Error generating system info:",e),e}}const J=["device","hardware","software","discord","react","ephemeral"];for(const e of J)s.storage[e]===void 0&&(s.storage[e]=!0);function Pe(e,n){try{let t=[`__System Information__
|
|
`];const a=Be();Object.keys(a).forEach(function(r){const u=s.storage[r.toLowerCase()],f=e.find(function(c){return c.name==r.toLowerCase()})?.value??u;(f||u)&&!(u&&!f)&&(t.push(`[**${r}**]`),Object.keys(a[r]).forEach(function(c){t.push(`> ${c}: ${a[r][c]}`)}))});const o=s.storage.ephemeral,l=e.find(function(r){return r.name=="ephemeral"})?.value??o;if((l||o)&&!(o&&!l))return Re.sendBotMessage(n.channel.id,t.join(`
|
|
`)),{type:4};{const r=Date.now().toString();return Te.sendMessage(n.channel.id,{content:t.join(`
|
|
`)},void 0,{nonce:r}),{type:4}}}catch(t){return console.error("[Sysinfo] Error:",t),{type:4}}}const Ue={name:"sysinfo",displayName:"sysinfo",description:"Display system information",displayDescription:"Display system information",options:[{name:"ephemeral",displayName:"ephemeral",description:"Keep sysinfo ephemeral (default: true)",displayDescription:"Keep sysinfo ephemeral (default: true)",type:5,required:!1},...J.slice(0,-1).map(function(e){return{name:e,displayName:e,description:`Display the ${e} section. Set default in settings.`,displayDescription:`Display the ${e} section. Set default in settings.`,type:5,required:!1}})],execute:Pe,applicationId:"-1",inputType:1,type:1},{ScrollView:Oe}=p.findByProps("ScrollView"),{TableRowGroup:b,TableSwitchRow:m,Stack:_e,TableRow:w}=p.findByProps("TableSwitchRow","TableRowGroup","Stack","TableRow");s.storage.factSettings||(s.storage.factSettings={sendAsReply:!0,includeCitation:!1}),s.storage.listSettings||(s.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1}),s.storage.enabledCommands||(s.storage.enabledCommands={catfact:!0,dogfact:!0,useless:!0,petpet:!0,pluginList:!0,themeList:!0,konoself:!0,konosend:!0,firstmessage:!0,sysinfo:!0}),s.storage.pendingRestart||(s.storage.pendingRestart=!1);function je(){se.useProxy(s.storage);const[e,n]=i.React.useReducer(function(a){return a+1},0);i.React.useEffect(function(){return function(){s.storage.pendingRestart&&(s.storage.pendingRestart=!1,D.alerts.showConfirmationAlert({title:"Restart Required",content:"You have made changes to commands. Please restart Discord to apply these changes.",confirmText:"Okay",cancelText:null}))}},[]);const t=function(a,o){s.storage.enabledCommands[a]=o,s.storage.pendingRestart=!0,n()};return i.React.createElement(oe.View,{style:{flex:1}},i.React.createElement(Oe,{style:{flex:1},contentContainerStyle:{paddingBottom:38}},i.React.createElement(_e,{spacing:8},i.React.createElement(b,{title:"Facts Commands"},i.React.createElement(m,{label:"Send as Reply",subLabel:"Send facts as a reply to the command message",value:s.storage.factSettings?.sendAsReply??!0,onValueChange:function(a){s.storage.factSettings.sendAsReply=a,n()}}),i.React.createElement(m,{label:"Include Source Citation",subLabel:"Include the source of facts when available",value:s.storage.factSettings?.includeCitation??!1,onValueChange:function(a){s.storage.factSettings.includeCitation=a,n()}}),i.React.createElement(m,{label:"/catfact",subLabel:"Get random cat facts",value:s.storage.enabledCommands?.catfact??!0,onValueChange:function(a){return t("catfact",a)}}),i.React.createElement(m,{label:"/dogfact",subLabel:"Get random dog facts",value:s.storage.enabledCommands?.dogfact??!0,onValueChange:function(a){return t("dogfact",a)}}),i.React.createElement(m,{label:"/useless",subLabel:"Get random useless facts",value:s.storage.enabledCommands?.useless??!0,onValueChange:function(a){return t("useless",a)}})),i.React.createElement(b,{title:"List Commands"},i.React.createElement(m,{label:"Always Send Detailed Plugin List",subLabel:"Always use detailed mode when listing plugins",value:s.storage.listSettings?.pluginListAlwaysDetailed??!1,onValueChange:function(a){s.storage.listSettings.pluginListAlwaysDetailed=a,n()}}),i.React.createElement(m,{label:"Always Send Detailed Theme List",subLabel:"Always use detailed mode when listing themes",value:s.storage.listSettings?.themeListAlwaysDetailed??!1,onValueChange:function(a){s.storage.listSettings.themeListAlwaysDetailed=a,n()}}),i.React.createElement(m,{label:"/plugin-list",subLabel:"List all installed plugins",value:s.storage.enabledCommands?.pluginList??!0,onValueChange:function(a){return t("pluginList",a)}}),i.React.createElement(m,{label:"/theme-list",subLabel:"List all installed themes",value:s.storage.enabledCommands?.themeList??!0,onValueChange:function(a){return t("themeList",a)}})),i.React.createElement(b,{title:"Image Commands"},i.React.createElement(m,{label:"/petpet",subLabel:"Create pet-pet GIF of a user",value:s.storage.enabledCommands?.petpet??!0,onValueChange:function(a){return t("petpet",a)}})),i.React.createElement(b,{title:"KonoChan Commands"},i.React.createElement(m,{label:"/konoself",subLabel:"Get random image from KonoChan (private)",value:s.storage.enabledCommands?.konoself??!0,onValueChange:function(a){return t("konoself",a)}}),i.React.createElement(m,{label:"/konosend",subLabel:"Send random image from KonoChan to channel",value:s.storage.enabledCommands?.konosend??!0,onValueChange:function(a){return t("konosend",a)}})),i.React.createElement(b,{title:"Message Commands"},i.React.createElement(m,{label:"/firstmessage",subLabel:"Get the first message in a channel",value:s.storage.enabledCommands?.firstmessage??!0,onValueChange:function(a){return t("firstmessage",a)}})),i.React.createElement(b,{title:"System Commands"},i.React.createElement(m,{label:"/sysinfo",subLabel:"Display system information",value:s.storage.enabledCommands?.sysinfo??!0,onValueChange:function(a){return t("sysinfo",a)}})),i.React.createElement(b,{title:"Credits"},i.React.createElement(w,{label:"Facts Commands",subLabel:"by jdev082"}),i.React.createElement(w,{label:"List Commands",subLabel:"by Kitomanari"}),i.React.createElement(w,{label:"PetPet Command",subLabel:"by wolfieeee"}),i.React.createElement(w,{label:"KonoChan Commands",subLabel:"by btmc727 & Rico040"}),i.React.createElement(w,{label:"FirstMessage Command",subLabel:"by sapphire"}),i.React.createElement(w,{label:"Sysinfo Command",subLabel:"by mugman"})),i.React.createElement(b,{title:"About"},i.React.createElement(w,{label:"Commands",subLabel:"A collection of commands"})))))}s.storage.factSettings||(s.storage.factSettings={sendAsReply:!0,includeCitation:!1}),s.storage.listSettings||(s.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1}),s.storage.enabledCommands||(s.storage.enabledCommands={catfact:!0,dogfact:!0,useless:!0,petpet:!0,pluginList:!0,themeList:!0,konoself:!0,konosend:!0,firstmessage:!0,sysinfo:!0});const xe={catfact:de,dogfact:ue,useless:fe,petpet:Se,pluginList:be,themeList:we,konoself:De,konosend:ve,firstmessage:Ae,sysinfo:Ue};let O=[];var Fe={onLoad:function(){console.log("[All-In-One Commands] Loading plugin...");for(const[e,n]of Object.entries(xe))s.storage.enabledCommands[e]&&O.push(ne.registerCommand(n));console.log("[All-In-One Commands] Plugin loaded successfully!")},onUnload:function(){console.log("[All-In-One Commands] Unloading plugin..."),O.forEach(function(e){return e()}),O=[],console.log("[All-In-One Commands] Plugin unloaded successfully!")},settings:je};return I.default=Fe,Object.defineProperty(I,"__esModule",{value:!0}),I})({},vendetta.commands,vendetta.plugin,vendetta.metro,vendetta.themes,vendetta.plugins,vendetta.ui,vendetta.metro.common,vendetta.debug,vendetta.storage,vendetta.metro.common.ReactNative);
|