vd-plugins/all-in-one/index.js
2025-09-27 20:04:21 +02:00

4 lines
9.9 KiB
JavaScript

(function(C,c,s,A,B,T,u,I,O,k,l,$){"use strict";const W=A.findByProps("sendMessage"),o=async function(e,t,a,n){if(!t)return{type:4};const i={content:t,...a&&n?.factSettings?.sendAsReply?{messageReference:{messageId:a}}:{}};return await W.sendMessage(e,i,void 0,{nonce:(Date.now()*4194304).toString()}),{type:4}},m=function(e){B.showToast(e,A.findByProps("Alerts").Alerts.ERROR)},U=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}},K=async function(){return{text:(await(await fetch("https://dogapi.dog/api/v2/facts?limit=1")).json()).data[0].attributes.body}},V=async function(){const e=await(await fetch("https://catfact.ninja/fact")).json();return{text:e.fact,length:e.length}},q=async function(e){return await(await fetch(`https://api.obamabot.me/v2/image/petpet?image=${e.replace("webp","png")}`)).json()},L=function(e){let t=e.text;return s.storage.factSettings?.includeCitation&&e.source&&(t+=`
Source: ${e.source}`),t},Y={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,t){const a=await V();return o(t.channel.id,L(a),t.message?.id,s.storage)}},z={name:"dogfact",displayName:"dogfact",description:"Sends a dog fact.",displayDescription:"Sends a dog fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,t){const a=await K();return o(t.channel.id,L(a),t.message?.id,s.storage)}},H={name:"useless",displayName:"useless",description:"Sends a useless fact.",displayDescription:"Sends a useless fact.",applicationId:"-1",inputType:1,type:1,execute:async function(e,t){const a=await U();return o(t.channel.id,L(a),t.message?.id,s.storage)}},R="https://vd-plugins.github.io/proxy/actuallythesun.github.io/vendetta-plugins/SplitLargeMessages/",r={ENABLED:"\u{1F7E2}",DISABLED:"\u{1F534}",SELECTED:"\u{1F536}",NOT_SELECTED:"\u{1F537}"},p=function(e){return e.map(function(t){return t.name}).join(", ")},d=function(e){return e.join(`
`).trimEnd()},F=function(e){return d(e).length},M=function(){return Object.keys(u.plugins).includes(R)},x=function(){return Object.values(u.plugins).find(function(e){return e.id===R})?.enabled??!1};async function G(e,t){const a=s.storage.listSettings?.pluginListAlwaysDetailed??!1,n=[`**My Plugin List | ${Object.keys(u.plugins).length} Plugins**`,""];for(const i of Object.values(u.plugins)){const{enabled:h,manifest:S,id:v}=i,{name:w,description:D,authors:E}=S;e||a?n.push(`> **Name**: ${w}`,`> **Status**: ${h?r.ENABLED:r.DISABLED}`,`> **Description**: ${D}`,`> **Authors**: ${p(E)}`,`> **[Install!](${v})**`,""):n.push(`> ${h?r.ENABLED:r.DISABLED} **${w}** by ${p(E)}`)}return F(n)>2e3?M()?x()?I.alerts.showConfirmationAlert({content:"Your list is over 2000 characters. Send anyway?",confirmText:"Yes",cancelText:"No",onConfirm:function(){return sendMessage(t.channel.id,d(n))}}):(m("Enable Split Large Messages plugin to send long lists!"),{type:4}):(m("List too long! Install Split Large Messages plugin"),{type:4}):sendMessage(t.channel.id,d(n))}async function J(e,t){const a=s.storage.themeListAlwaysDetailed??!1,n=[`**My Theme List | ${Object.keys(T.themes).length} Themes**`,""],i=Object.values(T.themes);if(i.length)for(const h of i){const{selected:S,data:v,id:w}=h,{name:D,description:E,authors:_}=v;e||a?n.push(`> **Name**: ${D}`,`> **Selected**: ${S?r.SELECTED:r.NOT_SELECTED}`,`> **Description**: ${E}`,`> **Authors**: ${p(_)}`,`> **[Install!](${w})**`,""):n.push(`> ${S?r.SELECTED:r.NOT_SELECTED} **${D}** by ${p(_)}`)}else n.push("Nothing to see here, huh...");return F(n)>2e3?M()?x()?I.alerts.showConfirmationAlert({content:"Your list is over 2000 characters. Send anyway?",confirmText:"Yes",cancelText:"No",onConfirm:function(){return sendMessage(t.channel.id,d(n))}}):(m("Enable Split Large Messages plugin to send long lists!"),{type:4}):(m("List too long! Install Split Large Messages plugin"),{type:4}):sendMessage(t.channel.id,d(n))}const Q={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:async function(e,t){const a=e.find(function(n){return n.name==="detailed"})?.value??!1;return G(a,t)},applicationId:"-1",inputType:1,type:1},X={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:async function(e,t){const a=e.find(function(n){return n.name==="detailed"})?.value??!1;return J(a,t)},applicationId:"-1",inputType:1,type:1},Z=A.findByStoreName("UserStore"),ee={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,t){const a=(await Z.getUser(e[0].value)).getAvatarURL(512),n=await q(a);return o(t.channel.id,n.url,t.message?.id)},applicationId:"-1",inputType:1,type:1},P=async function(e){const t="https://konachan.com/post.json",a=e?"rating:explicit":"rating:safe",n=Math.floor(Math.random()*100);try{const i=await(await fetch(`${t}?tags=${a}&limit=1&page=${n}`)).json();return!Array.isArray(i)||i.length===0?null:i[0].file_url}catch(i){return console.error("[KonoChan Randomizer] Error fetching image:",i),null}},j={name:"nsfw",description:"Include NSFW content?",type:5,required:!1,displayName:"nsfw",displayDescription:"Include NSFW content?"},te={name:"konoself",displayName:"konoself",description:"Fetch a random image from KonoChan for yourself.",displayDescription:"Fetch a random image from KonoChan for yourself.",options:[j],execute:async function(e,t){const a=new Map(e.map(function(i){return[i.name,i]})).get("nsfw")?.value||!1,n=await P(a);return n?o(t.channel.id,`Here's your random image: ${n}`):o(t.channel.id,"No image found. Try again later.")},applicationId:"-1",inputType:1,type:1},ne={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:[j],execute:async function(e,t){const a=new Map(e.map(function(i){return[i.name,i]})).get("nsfw")?.value||!1;if(a&&!t.channel.nsfw)return o(t.channel.id,"This channel is not marked as NSFW. Use an NSFW channel instead.");const n=await P(a);return n?o(t.channel.id,n):o(t.channel.id,"No image found. Try again later.")},applicationId:"-1",inputType:1,type:1},{FormSwitchRow:g,FormIcon:y,FormSection:b,FormDivider:ae}=$.Forms,f={List:l.getAssetIDByName("ic_list"),Message:l.getAssetIDByName("ic_message"),Copy:l.getAssetIDByName("ic_copy_message_link"),Info:l.getAssetIDByName("ic_info"),Theme:l.getAssetIDByName("ic_theme"),Plugin:l.getAssetIDByName("ic_plugins")};function se(){return k.useProxy(s.storage),s.storage.factSettings||(s.storage.factSettings={sendAsReply:!0,includeCitation:!1}),s.storage.listSettings||(s.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1}),React.createElement($.ErrorBoundary,null,React.createElement(O.ReactNative.ScrollView,{style:{flex:1}},React.createElement(b,{title:"Fact Commands",titleStyleType:"no_border"},React.createElement(g,{label:"Send as Reply",subLabel:"Send facts as a reply to the command message",leading:React.createElement(y,{source:f.Message}),onValueChange:function(e){s.storage.factSettings.sendAsReply=e},value:s.storage.factSettings.sendAsReply}),React.createElement(ae,null),React.createElement(g,{label:"Include Source Citation",subLabel:"Include the source of facts when available",leading:React.createElement(y,{source:f.Info}),onValueChange:function(e){s.storage.factSettings.includeCitation=e},value:s.storage.factSettings.includeCitation})),React.createElement(b,{title:"Plugin List",titleStyleType:"no_border"},React.createElement(g,{label:"Always Send Detailed List",subLabel:"Always use detailed mode when listing plugins",leading:React.createElement(y,{source:f.Plugin}),onValueChange:function(e){s.storage.listSettings.pluginListAlwaysDetailed=e},value:s.storage.listSettings.pluginListAlwaysDetailed})),React.createElement(b,{title:"Theme List",titleStyleType:"no_border"},React.createElement(g,{label:"Always Send Detailed List",subLabel:"Always use detailed mode when listing themes",leading:React.createElement(y,{source:f.Theme}),onValueChange:function(e){s.storage.listSettings.themeListAlwaysDetailed=e},value:s.storage.listSettings.themeListAlwaysDetailed}))))}s.storage.factSettings||(s.storage.factSettings={sendAsReply:!0,includeCitation:!1}),s.storage.listSettings||(s.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1});let N=[];var ie={onLoad:function(){console.log("[All-In-One Commands] Loading plugin..."),N=[c.registerCommand(Y),c.registerCommand(z),c.registerCommand(H),c.registerCommand(ee),c.registerCommand(Q),c.registerCommand(X),c.registerCommand(te),c.registerCommand(ne)],console.log("[All-In-One Commands] Plugin loaded successfully!")},onUnload:function(){console.log("[All-In-One Commands] Unloading plugin..."),N.forEach(function(e){return e()}),N=[],console.log("[All-In-One Commands] Plugin unloaded successfully!")},settings:se};return C.default=ie,Object.defineProperty(C,"__esModule",{value:!0}),C})({},vendetta.commands,vendetta.plugin,vendetta.metro,vendetta.ui.toasts,vendetta.themes,vendetta.plugins,vendetta.ui,vendetta.metro.common,vendetta.storage,vendetta.ui.assets,vendetta.ui.components);