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

4 lines
14 KiB
JavaScript

(function(E,j,a,h,re,v,m,u,i,M,l,V){"use strict";const W=h.findByProps("sendMessage"),r=async function(t,n,s,e){if(!n)return{type:4};const o={content:n,...s&&e?.factSettings?.sendAsReply?{messageReference:{messageId:s}}:{}};return await W.sendMessage(t,o,void 0,{nonce:(Date.now()*4194304).toString()}),{type:4}},K=async function(){const t=await(await fetch("https://uselessfacts.jsph.pl/api/v2/facts/random")).json();return{text:t.text,source:t.source,language:t.language}},G=async function(){return{text:(await(await fetch("https://dogapi.dog/api/v2/facts?limit=1")).json()).data[0].attributes.body}},q=async function(){const t=await(await fetch("https://catfact.ninja/fact")).json();return{text:t.fact,length:t.length}},U=async function(t){return await(await fetch(`https://api.obamabot.me/v2/image/petpet?image=${t.replace("webp","png")}`)).json()},T=function(t){let n=t.text;return a.storage.factSettings?.includeCitation&&t.source&&(n+=`
Source: ${t.source}`),n},H={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(t,n){const s=await q();return r(n.channel.id,T(s),n.message?.id,a.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(t,n){const s=await G();return r(n.channel.id,T(s),n.message?.id,a.storage)}},J={name:"useless",displayName:"useless",description:"Sends a useless fact.",displayDescription:"Sends a useless fact.",applicationId:"-1",inputType:1,type:1,execute:async function(t,n){const s=await K();return r(n.channel.id,T(s),n.message?.id,a.storage)}},y="https://vd-plugins.github.io/proxy/actuallythesun.github.io/vendetta-plugins/SplitLargeMessages/",d={ENABLED:"\u{1F7E2}",DISABLED:"\u{1F534}",SELECTED:"\u{1F536}",NOT_SELECTED:"\u{1F537}"},b=function(t){return t.map(function(n){return n.name}).join(", ")},f=function(t){return t.join(`
`).trimEnd()},I=function(t){return f(t).length},$=function(){return Object.keys(m.plugins).includes(y)},x=function(){return Object.values(m.plugins).find(function(t){return t.id===y})?.enabled??!1},k=function(){return u.alerts.showConfirmationAlert({title:"Large Message Warning",content:"This list is too long to send! Would you like to install the Split Large Messages plugin?",confirmText:"Install Plugin",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){i.openURL(y)}})},B=function(){return u.alerts.showConfirmationAlert({title:"Plugin Disabled",content:"The Split Large Messages plugin is installed but disabled. Would you like to enable it now?",confirmText:"Enable Plugin",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){const t=Object.values(m.plugins).find(function(n){return n.id===y});t&&(t.enabled=!0)}})};async function Q(t,n){const s=a.storage.listSettings?.pluginListAlwaysDetailed??!1,e=[`**My Plugin List | ${Object.keys(m.plugins).length} Plugins**`,""];for(const o of Object.values(m.plugins)){const{enabled:S,manifest:w,id:N}=o,{name:L,description:A,authors:D}=w;t||s?e.push(`> **Name**: ${L}`,`> **Status**: ${S?d.ENABLED:d.DISABLED}`,`> **Description**: ${A}`,`> **Authors**: ${b(D)}`,`> **[Install!](${N})**`,""):e.push(`> ${S?d.ENABLED:d.DISABLED} **${L}** by ${b(D)}`)}return I(e)>2e3?$()?x()?u.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return r(n.channel.id,f(e))}}):B():k():r(n.channel.id,f(e))}async function X(t,n){const s=a.storage.themeListAlwaysDetailed??!1,e=[`**My Theme List | ${Object.keys(v.themes).length} Themes**`,""],o=Object.values(v.themes);if(o.length)for(const S of o){const{selected:w,data:N,id:L}=S,{name:A,description:D,authors:O}=N;t||s?e.push(`> **Name**: ${A}`,`> **Selected**: ${w?d.SELECTED:d.NOT_SELECTED}`,`> **Description**: ${D}`,`> **Authors**: ${b(O)}`,`> **[Install!](${L})**`,""):e.push(`> ${w?d.SELECTED:d.NOT_SELECTED} **${A}** by ${b(O)}`)}else e.push("Nothing to see here, huh...");return I(e)>2e3?$()?x()?u.alerts.showConfirmationAlert({title:"Large Message",content:"This list is over 2000 characters. Send anyway?",confirmText:"Send",cancelText:"Cancel",onConfirm:function(){return r(n.channel.id,f(e))}}):B():k():r(n.channel.id,f(e))}const Y={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(t,n){const s=t.find(function(e){return e.name==="detailed"})?.value??!1;return Q(s,n)},applicationId:"-1",inputType:1,type:1},Z={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(t,n){const s=t.find(function(e){return e.name==="detailed"})?.value??!1;return X(s,n)},applicationId:"-1",inputType:1,type:1},ee=h.findByStoreName("UserStore"),te={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(t,n){const s=(await ee.getUser(t[0].value)).getAvatarURL(512),e=await U(s);return r(n.channel.id,e.url,n.message?.id)},applicationId:"-1",inputType:1,type:1},P=async function(t){const n="https://konachan.com/post.json",s=t?"rating:explicit":"rating:safe",e=Math.floor(Math.random()*100);try{const o=await(await fetch(`${n}?tags=${s}&limit=1&page=${e}`)).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}},_={name:"nsfw",description:"Include NSFW content?",type:5,required:!1,displayName:"nsfw",displayDescription:"Include NSFW content?"},F=function(){return u.alerts.showConfirmationAlert({title:"NSFW Content Warning",content:"NSFW content can only be sent in NSFW channels!",confirmText:"Okay",cancelText:null,confirmColor:"brand",isDismissable:!0})},ne={name:"konoself",displayName:"konoself",description:"Fetch a random image from KonoChan for yourself.",displayDescription:"Fetch a random image from KonoChan for yourself.",options:[_],execute:async function(t,n){const s=new Map(t.map(function(o){return[o.name,o]})).get("nsfw")?.value||!1;if(s&&!n.channel.nsfw)return F(),{type:4};const e=await P(s);return e?{type:4,data:{content:`Here's your random image: ${e}`,flags:64}}:{type:4,data:{content:"No image found. Try again later.",flags:64}}},applicationId:"-1",inputType:1,type:1},ae={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:[_],execute:async function(t,n){const s=new Map(t.map(function(o){return[o.name,o]})).get("nsfw")?.value||!1;if(s&&!n.channel.nsfw)return F(),{type:4};const e=await P(s);return e?r(n.channel.id,e):r(n.channel.id,"No image found. Try again later.")},applicationId:"-1",inputType:1,type:1},{ScrollView:se}=h.findByProps("ScrollView"),{TableRowGroup:g,TableSwitchRow:c,Stack:ie,TableRow:p}=h.findByProps("TableSwitchRow","TableRowGroup","Stack","TableRow");a.storage.factSettings||(a.storage.factSettings={sendAsReply:!0,includeCitation:!1}),a.storage.listSettings||(a.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1}),a.storage.enabledCommands||(a.storage.enabledCommands={catfact:!0,dogfact:!0,useless:!0,petpet:!0,pluginList:!0,themeList:!0,konoself:!0,konosend:!0}),a.storage.pendingRestart||(a.storage.pendingRestart=!1);const C={PETPET:"wolfieeee",FACTS:"jdev082",LISTS:"Kitomanari",KONOCHAN:["btmc727","Rico040"]};function oe(){M.useProxy(a.storage);const[t,n]=i.React.useReducer(function(e){return e+1},0);i.React.useEffect(function(){return function(){a.storage.pendingRestart&&u.alerts.showConfirmationAlert({title:"Restart Required",content:"Command changes require Discord to restart. Would you like to restart now?",confirmText:"Restart",cancelText:"Later",confirmColor:"brand",onConfirm:function(){window.enmity.plugins.reload("vendetta")}})}},[]);const s=function(e,o){a.storage.enabledCommands[e]=o,a.storage.pendingRestart=!0,n()};return i.React.createElement(V.View,{style:{flex:1}},i.React.createElement(se,{style:{flex:1}},i.React.createElement(ie,{spacing:8},i.React.createElement(g,{title:"Facts Commands"},i.React.createElement(c,{label:"Send as Reply",subLabel:"Send facts as a reply to the command message",icon:l.getAssetIDByName("ic_reply_24px"),value:a.storage.factSettings.sendAsReply,onValueChange:function(e){a.storage.factSettings.sendAsReply=e,n()}}),i.React.createElement(c,{label:"Include Source Citation",subLabel:"Include the source of facts when available",icon:l.getAssetIDByName("ic_info"),value:a.storage.factSettings.includeCitation,onValueChange:function(e){a.storage.factSettings.includeCitation=e,n()}}),i.React.createElement(p,{label:"Credits",subLabel:`Facts commands by ${C.FACTS}`,icon:l.getAssetIDByName("ic_info")}),i.React.createElement(c,{label:"/catfact",subLabel:"Get random cat facts",icon:l.getAssetIDByName("ic_info"),value:a.storage.enabledCommands.catfact,onValueChange:function(e){return s("catfact",e)}}),i.React.createElement(c,{label:"/dogfact",subLabel:"Get random dog facts",icon:l.getAssetIDByName("ic_info"),value:a.storage.enabledCommands.dogfact,onValueChange:function(e){return s("dogfact",e)}}),i.React.createElement(c,{label:"/useless",subLabel:"Get random useless facts",icon:l.getAssetIDByName("ic_info"),value:a.storage.enabledCommands.useless,onValueChange:function(e){return s("useless",e)}})),i.React.createElement(g,{title:"List Commands"},i.React.createElement(c,{label:"Always Send Detailed Plugin List",subLabel:"Always use detailed mode when listing plugins",icon:l.getAssetIDByName("ic_message_copy"),value:a.storage.listSettings.pluginListAlwaysDetailed,onValueChange:function(e){a.storage.listSettings.pluginListAlwaysDetailed=e,n()}}),i.React.createElement(c,{label:"Always Send Detailed Theme List",subLabel:"Always use detailed mode when listing themes",icon:l.getAssetIDByName("ic_theme"),value:a.storage.listSettings.themeListAlwaysDetailed,onValueChange:function(e){a.storage.listSettings.themeListAlwaysDetailed=e,n()}}),i.React.createElement(p,{label:"Credits",subLabel:`List commands by ${C.LISTS}`,icon:l.getAssetIDByName("ic_info")}),i.React.createElement(c,{label:"/plugin-list",subLabel:"List all installed plugins",icon:l.getAssetIDByName("ic_plugins"),value:a.storage.enabledCommands.pluginList,onValueChange:function(e){return s("pluginList",e)}}),i.React.createElement(c,{label:"/theme-list",subLabel:"List all installed themes",icon:l.getAssetIDByName("ic_theme"),value:a.storage.enabledCommands.themeList,onValueChange:function(e){return s("themeList",e)}})),i.React.createElement(g,{title:"Image Commands"},i.React.createElement(p,{label:"Credits",subLabel:`PetPet command by ${C.PETPET}`,icon:l.getAssetIDByName("ic_info")}),i.React.createElement(c,{label:"/petpet",subLabel:"Create pet-pet GIF of a user",icon:l.getAssetIDByName("ic_image"),value:a.storage.enabledCommands.petpet,onValueChange:function(e){return s("petpet",e)}})),i.React.createElement(g,{title:"KonoChan Commands"},i.React.createElement(p,{label:"Credits",subLabel:`KonoChan commands by ${C.KONOCHAN.join(" & ")}`,icon:l.getAssetIDByName("ic_info")}),i.React.createElement(c,{label:"/konoself",subLabel:"Get random image from KonoChan (private)",icon:l.getAssetIDByName("ic_image"),value:a.storage.enabledCommands.konoself,onValueChange:function(e){return s("konoself",e)}}),i.React.createElement(c,{label:"/konosend",subLabel:"Send random image from KonoChan to channel",icon:l.getAssetIDByName("ic_image"),value:a.storage.enabledCommands.konosend,onValueChange:function(e){return s("konosend",e)}})),i.React.createElement(g,{title:"About"},i.React.createElement(p,{label:"All-In-One Commands",subLabel:"A collection of useful commands",icon:l.getAssetIDByName("ic_badge_staff")})))))}a.storage.factSettings||(a.storage.factSettings={sendAsReply:!0,includeCitation:!1}),a.storage.listSettings||(a.storage.listSettings={pluginListAlwaysDetailed:!1,themeListAlwaysDetailed:!1}),a.storage.enabledCommands||(a.storage.enabledCommands={catfact:!0,dogfact:!0,useless:!0,petpet:!0,pluginList:!0,themeList:!0,konoself:!0,konosend:!0});const le={catfact:H,dogfact:z,useless:J,petpet:te,pluginList:Y,themeList:Z,konoself:ne,konosend:ae};let R=[];var ce={onLoad:function(){console.log("[All-In-One Commands] Loading plugin...");for(const[t,n]of Object.entries(le))a.storage.enabledCommands[t]&&R.push(j.registerCommand(n));console.log("[All-In-One Commands] Plugin loaded successfully!")},onUnload:function(){console.log("[All-In-One Commands] Unloading plugin..."),R.forEach(function(t){return t()}),R=[],console.log("[All-In-One Commands] Plugin unloaded successfully!")},settings:oe};return E.default=ce,Object.defineProperty(E,"__esModule",{value:!0}),E})({},vendetta.commands,vendetta.plugin,vendetta.metro,vendetta.ui.toasts,vendetta.themes,vendetta.plugins,vendetta.ui,vendetta.metro.common,vendetta.storage,vendetta.ui.assets,vendetta.metro.common.ReactNative);