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